ShenShouCuiTiOBJ = {} ShenShouCuiTiOBJ.__cname = "ShenShouCuiTiOBJ" -- 配置文件 ShenShouCuiTiOBJ.cfg = {} function ShenShouCuiTiOBJ:main(arg1, arg2, arg3, data) local parent = GUI:Win_Create(self.__cname, 0, 0, 0, 0, false, false, true, false) if data and data.npcid then GUI:Win_BindNPC(parent, data.npcid) end GUI:LoadExport(parent, "game/A/ShenShouCuiTiUI") self._parent = parent self.ui = GUI:ui_delegate(parent) --- 窗口初始化居中与动作 ssrUIManager:OpenAlgin(self) --背景图关闭 GUI:addOnClickEvent(self.ui.bg_close, function() GUI:Win_Close(self._parent) end) --关闭按钮背景板关闭 GUI:addOnClickEvent(self.ui.btn_close, function() GUI:Win_Close(self._parent) end) ---* 绑定事件 self:EventBind() if data and data.cfg then self.cfg = data.cfg end self:updata() end function ShenShouCuiTiOBJ:updata(num) num = num and num or 1 self.id = num for i, v in ipairs(self.cfg.att) do local btn = string.format("list_btn_%d", i) self.ui[btn] = GUI:Button_Create(self.ui.ListView, btn, 0.00, 0.00, string.format("res/custom/05/btn/%s.png", num == i and tostring(i) or i .. "a")) GUI:Button_loadTexturePressed(self.ui[btn], string.format("res/custom/05/btn/%s.png", num == i and tostring(i .. "a") or tostring(i))) GUI:addOnClickEvent(self.ui[btn], function() GUI:Button_loadTextureNormal(self.ui[string.format("list_btn_%d", self.id)], string.format("res/custom/05/btn/%s.png", self.id .. "a")) GUI:Button_loadTexturePressed(self.ui[string.format("list_btn_%d", self.id)], string.format("res/custom/05/btn/%s.png", tostring(self.id))) GUI:Button_loadTextureNormal(self.ui[btn], string.format("res/custom/05/btn/%s.png", tostring(i))) GUI:Button_loadTexturePressed(self.ui[btn], string.format("res/custom/05/btn/%s.png", tostring(i) .. "a")) self.id = i self:show(i) end) end self:show(num) end function ShenShouCuiTiOBJ:show(num) if not num then return end local level = hk.getkeycount("HUMAN(STR_神兽淬体)", num) or 0 local cfg = self.cfg.att[num] ---* 当前等级物品 local _title = string.format("%s淬体Lv.%d", cfg.n, level) local _title_index = SL:Get_ITEM_INDEX_BY_NAME(_title) local _title_data = SL:Get_ITEM_DATA(_title_index) local att_tbl = hk.getequipAttribute(_title_data.Attribute) hk.reloadItemShow(self.ui.d_Item, _title, 1) GUI:Text_setString(self.ui.d_Text, string.format("Lv.%d", level)) if GUI:Win_IsNotNull(self.ui.d_att_str) then GUI:removeFromParent(self.ui.d_att_str) end self.ui.d_att_str = GUI:RichTextFCOLOR_Create(self.ui.img_bg, "d_att_str", 348, 196, att_tbl and table.concat(att_tbl, "\\") or "未激活", 600, 16, "#28EF01", 5) GUI:setAnchorPoint(self.ui.d_att_str, 0.50, 0.50) local _title = string.format("%s淬体Lv.%d", cfg.n, level >= #self.cfg.cl and level or level + 1) local _title_index = SL:Get_ITEM_INDEX_BY_NAME(_title) local _title_data = SL:Get_ITEM_DATA(_title_index) local att_tbl = hk.getequipAttribute(_title_data.Attribute) hk.reloadItemShow(self.ui.x_Item, string.format("%s淬体Lv.%d", cfg.n, level >= #self.cfg.cl and level or level + 1), 1) GUI:Text_setString(self.ui.x_Text, string.format("%s", level >= #self.cfg.cl and "" or "Lv." .. tostring(level + 1))) if GUI:Win_IsNotNull(self.ui.x_att_str) then GUI:removeFromParent(self.ui.x_att_str) end self.ui.x_att_str = GUI:RichTextFCOLOR_Create(self.ui.img_bg, "x_att_str", 592, 196, level >= #self.cfg.cl and "已满级" or table.concat(att_tbl, "\\"), 600, 16, level >= #self.cfg.cl and "#ff0000" or "#ff0000", 5) GUI:setAnchorPoint(self.ui.x_att_str, 0.50, 0.50) GUI:Text_setString(self.ui.ps_text, cfg.str) GUI:removeAllChildren(self.ui.x_Layout) local xh = SL:CopyData(self.cfg.xh) table.insert(xh, { cfg.x, level < #self.cfg.cl and self.cfg.cl[level + 1] or self.cfg.cl[level], 0 }) hk.SettingXhShow(self.ui, self.ui.x_Layout, xh, nil, nil, nil, 0, nil, 30, nil, true) GUI:addOnClickEvent(self.ui.Button, function() ssrMessage:SubLink("ShenShouCuiTiOBJ_up", num) end) -- ---* 初始化红点 -- self:reddot() end function ShenShouCuiTiOBJ:reddot() end ------------------------网络消息------------------------ function ShenShouCuiTiOBJ:ZSResponse() if GUI:Win_IsNotNull(self._parent) then self:updata() end end ---* 注册事件 function ShenShouCuiTiOBJ:EventBind() local function ShenShouCuiTiOBJ_REINLEVELCHANGE(data) if GUI:Win_IsNotNull(self._parent) then if data.key == "HUMAN(STR_神兽淬体)" then self:show(self.id) end end end SL:RegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname, ShenShouCuiTiOBJ_REINLEVELCHANGE) --关闭窗口 SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname, function(widgetName) self:OnClose(widgetName) end) end --关闭窗口 function ShenShouCuiTiOBJ:OnClose(widgetName) if widgetName == self.__cname then self:UnRegisterEvent() end end function ShenShouCuiTiOBJ:UnRegisterEvent() SL:UnRegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname) SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname) end return ShenShouCuiTiOBJ