TeJieBoxOBJ = Up_BaseClassOBJ:new() TeJieBoxOBJ.__cname = "TeJieBoxOBJ" -- 配置文件 TeJieBoxOBJ.cfg = {} TeJieBoxOBJ.UIfile = "game/B/player_tejie_box_UI" TeJieBoxOBJ.pos = { [1] = { 192, 266 }, [2] = { 110, 186 }, [3] = { 276, 186 }, [4] = { 192, 106 }, } function TeJieBoxOBJ:updata() --界面拖拽 GUI:Win_SetDrag(self._parent, self.ui.img_bg) local whereOpen = hk.getkeytbl("HUMAN(STR_特戒盒子)") GUI:removeAllChildren(self.ui.item_Layout) for i = 1, 4, 1 do local open = whereOpen[i] and true or false if not open then local btn = "btn_jieshuo_" .. i self.ui[btn] = GUI:Button_Create(self.ui.item_Layout, btn, self.pos[i][1]-30, self.pos[i][2]-30, "res/custom/36/2.png") GUI:setAnchorPoint(self.ui[btn], 0.50, 0.50) GUI:addOnClickEvent(self.ui[btn], function() ssrMessage:SubLink(self.__cname .. "_boxjiesuo", { id = i }) end) else local EquipShow = "EquipShow_" .. (78 + i) self.ui[EquipShow] = GUI:EquipShow_Create(self.ui.item_Layout, EquipShow, self.pos[i][1]-30, self.pos[i][2]-30, (78 + i), false, { bgVisible = false, doubleTakeOff = true, look = true, movable = true, starLv = true, lookPlayer = false, showModelEffect = true }) GUI:setAnchorPoint(self.ui[EquipShow], 0.50, 0.50) end end end ---* 注册事件 function TeJieBoxOBJ:EventBind() local function TeJieBoxOBJ_Var_Change(data) if GUI:Win_IsNotNull(self._parent) then if data.key == "HUMAN(STR_特戒盒子)" then self:updata() end end end SL:RegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname, TeJieBoxOBJ_Var_Change) local function reloaditem() self:updata() end SL:RegisterLUAEvent(LUA_EVENT_TAKE_ON_EQUIP, self.__cname, reloaditem) SL:RegisterLUAEvent(LUA_EVENT_TAKE_OFF_EQUIP, self.__cname, reloaditem) --关闭窗口 SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname, function(widgetName) self:OnClose(widgetName) end) end --关闭窗口 function TeJieBoxOBJ:OnClose(widgetName) if widgetName == self.__cname then self:UnRegisterEvent() end end function TeJieBoxOBJ:UnRegisterEvent() SL:UnRegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname) SL:UnRegisterLUAEvent(LUA_EVENT_TAKE_ON_EQUIP, self.__cname) SL:UnRegisterLUAEvent(LUA_EVENT_TAKE_OFF_EQUIP, self.__cname) SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname) end return TeJieBoxOBJ