### Create GUI Layout Panels with Lua Source: https://context7.com/shengfeiyue/996m2_client_open_dev/llms.txt This snippet demonstrates how to create container panels and add UI elements like images and text to them using the GUI library. It supports touch events and anchor points for flexible positioning and nesting. ```lua local ui = {} function ui.init(parent) -- Create touch-enabled full-screen panel local Panel_touch = GUI:Layout_Create(parent, "Panel_touch", 0.00, 0.00, 1136.00, 640.00, false) GUI:setTouchEnabled(Panel_touch, true) GUI:setTag(Panel_touch, -1) -- Create centered background panel local Panel_bg = GUI:Layout_Create(parent, "Panel_bg", 568.00, 320.00, 1136.00, 640.00, false) GUI:setAnchorPoint(Panel_bg, 0.50, 0.50) GUI:setTouchEnabled(Panel_bg, true) -- Add background image to panel local Image_bg = GUI:Image_Create(Panel_bg, "Image_bg", 568.00, 640.00, "res/private/login/bg_cjzy_05.png") GUI:setAnchorPoint(Image_bg, 0.50, 1.00) return parent end return ui ``` -------------------------------- ### Build Character Role Selection Interface with Lua Source: https://context7.com/shengfeiyue/996m2_client_open_dev/llms.txt This snippet illustrates the creation of a character selection interface. It includes setting up panels for character information, displaying text for name and level, and creating buttons for selection and game actions. ```lua -- Character slot panel with info display local Panel_role_1 = GUI:Layout_Create(Panel_bg, "Panel_role_1", 568.00, 595.00, 350.00, 400.00, false) GUI:setAnchorPoint(Panel_role_1, 1.00, 1.00) GUI:setTouchEnabled(Panel_role_1, true) -- Character info panel local Panel_info_1 = GUI:Layout_Create(Panel_bg, "Panel_info_1", 284.00, 0.00, 210.00, 200.00, false) -- Add character name display local Text_name_1 = GUI:Text_Create(Panel_info_1, "Text_name_1", 70.00, 106.00, 16, "#ffffff", "传奇经典") GUI:Text_enableOutline(Text_name_1, "#000000", 1) -- Add level display local Text_level_1 = GUI:Text_Create(Panel_info_1, "Text_level_1", 70.00, 77.00, 16, "#ffffff", "9级") -- Add selection button local Button_select_1 = GUI:Button_Create(Panel_info_1, "Button_select_1", 140.00, 140.00, "res/private/login/btn_cjzy_01.png") GUI:Button_loadTexturePressed(Button_select_1, "res/private/login/btn_cjzy_01_1.png") GUI:Button_setTitleText(Button_select_1, "选 择") GUI:Button_setTitleColor(Button_select_1, "#b0977a") GUI:Button_setTitleFontSize(Button_select_1, 16) GUI:setTouchEnabled(Button_select_1, true) -- Action panel with start, create, delete buttons local Panel_act = GUI:Layout_Create(Panel_bg, "Panel_act", 568.00, 0.00, 350.00, 200.00, false) local Button_start = GUI:Button_Create(Panel_act, "Button_start", 175.00, 144.00, "res/private/login/btn_kqyx_01.png") GUI:Button_setTitleText(Button_start, "开 始") ``` -------------------------------- ### Initialize and Manage Inventory Bag UI (Lua) Source: https://context7.com/shengfeiyue/996m2_client_open_dev/llms.txt Initializes the inventory bag UI, including grid configuration, scrollable item view, page navigation, and action buttons. It registers event listeners for item changes and item movement, and includes functions for creating and displaying individual items within the grid. ```lua Bag = {} function Bag.Init() -- Grid configuration Bag._ScrollHeight = GUIShare.BagGridSet.ScrollHeight Bag._IWidth = GUIShare.BagGridSet.ItemWidth Bag._IHeight = GUIShare.BagGridSet.ItemWHeight Bag._Row = GUIShare.BagGridSet.Row Bag._Col = GUIShare.BagGridSet.Col Bag._PerPageNum = GUIShare.BagGridSet.PerPageNum Bag._MaxPage = GUIShare.BagGridSet.MaxPage Bag._selPage = 0 Bag._openNum = SL:GetMetaValue("MAX_BAG") end function Bag.main(page) local parent = GUI:Attach_Parent() Bag.Init() -- Create scrollable container for items local ScrollView = GUI:ScrollView_Create(parent, "ScrollView", 22.5, 392, Bag._PWidth, Bag._PHeight, 1) GUI:setTouchEnabled(ScrollView, true) GUI:ScrollView_setInnerContainerSize(ScrollView, Bag._PWidth, Bag._ScrollHeight) -- Create page buttons local Page1 = GUI:Button_Create(parent, "Page1", 5, 315, "res/public/1900000641.png") GUI:addOnClickEvent(Page1, function() Bag.PageTo(1) end) -- Create action buttons local Button_reset = GUI:Button_Create(parent, "Button_reset", 300, 50, "res/public/1900000652.png") GUI:Button_setTitleText(Button_reset, "整理") GUI:addOnClickEvent(Button_reset, function() SL:ResetBagPos() end) -- Initialize grid and items Bag.InitGird() Bag.RefreshItemList() -- Register events SL:RegisterLUAEvent(LUA_EVENT_BAG_ITEM_CHANGE, "Bag", Bag.BagItemChange) SL:RegisterLUAEvent(LUA_EVENT_ITEM_MOVING, "Bag", Bag.OnItemMoving) end function Bag.CreateItem(data, pos) local YPos = math.floor((pos - (Bag._selPage-1) * Bag._PerPageNum -1) / Bag._Col) local XPos = (pos-1) % Bag._Col local posX = XPos * Bag._IWidth + Bag._IWidth/2 local posY = Bag._ScrollHeight - Bag._IHeight/2 - Bag._IHeight * YPos local ItemShow = GUI:ItemShow_Create(Bag._UI_ScrollView, tostring(data.MakeIndex), posX, posY, { itemData = data, index = data.Index, movable = true, from = SL:GetItemForm().BAG, checkPower = true, starLv = true }) -- Add double-click use event GUI:ItemShow_addDoubleEvent(ItemShow, function() SL:UseItem(SL:GetItemDataByMakeIndex(data.MakeIndex)) end) return ItemShow end ``` -------------------------------- ### Handle Mouse and Touch Input Events in Lua Source: https://context7.com/shengfeiyue/996m2_client_open_dev/llms.txt This Lua code demonstrates platform-conditional input handling for mouse and touch events. It enables mouse support on Windows platforms, registering events for double-click, right-click, and mouse wheel. On mobile platforms, it configures double-tap events. The code utilizes the SL and GUI libraries for game logic and UI interactions. ```lua -- Check platform mode if SL:IsWinMode() then -- Desktop mode with mouse support GUI:setMouseEnabled(PMainUI, true) -- Register mouse button events GUI:addMouseButtonEvent(ItemShow, { onLeftDoubleFunc = function() SL:UseItem(SL:GetItemDataByMakeIndex(data.MakeIndex)) return -1 end, onRightDownFunc = function() SL:UseItem(SL:GetItemDataByMakeIndex(data.MakeIndex)) return -1 end }) -- Register mouse wheel event for scrolling SL:RegisterWndEvent(ItemShow, "Bag", WND_EVENT_MOUSE_WHEEL, function(data) if ItemTips and ItemTips.OnMouseScroll then ItemTips.OnMouseScroll(data) end end) -- Shift key modifier support if SL:GetMetaValue("IS_PRESS_SHIFT") then -- Batch operations when shift pressed SL:OpenCommonTipsPop({ str = "请输入要拆分的数量:", callback = callback, showEdit = true }) end else -- Mobile touch mode GUI:ItemShow_addDoubleEvent(ItemShow, function() SL:CloseItemTips() local status = SL:GetNpcStorageStatus() if status > 0 then SL:SaveItemToNpcStorage(data) else SL:UseItem(SL:GetItemDataByMakeIndex(data.MakeIndex)) end end) end ``` -------------------------------- ### Create Reusable Item Display Component UI (Lua) Source: https://context7.com/shengfeiyue/996m2_client_open_dev/llms.txt Creates a standardized UI element for displaying game items. This component includes a background panel, item icon, count display, star level indicator, selection tag, and a power indicator. It supports touch interaction and is designed for reusability within the game's UI. ```lua function ui.init(parent) local Node = GUI:Node_Create(parent, "Node", 568.00, 320.00) -- Background panel for item local Panel_bg = GUI:Layout_Create(Node, "Panel_bg", 0.00, 0.00, 60.00, 60.00, false) GUI:setAnchorPoint(Panel_bg, 0.50, 0.50) GUI:setTouchEnabled(Panel_bg, true) GUI:setTag(Panel_bg, 21) -- Item background image local Image_bg = GUI:Image_Create(Panel_bg, "Image_bg", 30.00, 30.00, "res/public/1900000651.png") GUI:setAnchorPoint(Image_bg, 0.50, 0.50) -- Visual effect nodes (under and over item) local Node_sfx_under = GUI:Node_Create(Panel_bg, "Node_sfx_under", 30.00, 30.00) GUI:setTag(Node_sfx_under, 11) -- Item icon button local Button_icon = GUI:Button_Create(Panel_bg, "Button_icon", 30.00, 30.00, "res/private/gui_edit//Button_Normal.png") GUI:setContentSize(Button_icon, 50, 50) GUI:setTouchEnabled(Button_icon, false) -- Item count text local Text_count = GUI:Text_Create(Panel_bg, "Text_count", 57.00, 11.00, 15, "#ffffff", "1000") GUI:setAnchorPoint(Text_count, 1.00, 0.50) GUI:Text_enableOutline(Text_count, "#000000", 2) -- Star level indicator local Text_star_lv = GUI:Text_Create(Panel_bg, "Text_star_lv", 4.00, 58.00, 18, "#efad21", "0") GUI:Text_enableOutline(Text_star_lv, "#111111", 1) -- Selection indicator local Image_choosTag = GUI:Image_Create(Panel_bg, "Image_choosTag", 30.00, 30.00, "res/public/1900000678_2.png") GUI:setVisible(Image_choosTag, false) -- Power indicator local Image_power = GUI:Image_Create(Panel_bg, "Image_power", 57.00, 34.00, "res/public/btn_szjm_01_3.png") return Node end ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.