bayuMIR/client/dev/GUILayout/game/B/zhiBaoBoxOBJ.lua
2026-06-12 02:32:15 +08:00

84 lines
2.6 KiB
Lua

ZhiBaoBoxOBJ = Up_BaseClassOBJ:new()
ZhiBaoBoxOBJ.__cname = "ZhiBaoBoxOBJ"
-- 配置文件
ZhiBaoBoxOBJ.cfg = {}
ZhiBaoBoxOBJ.UIfile = "game/B/player_zhibao_box_UI"
ZhiBaoBoxOBJ.pos = {
[1] = { 248, 304 },
[2] = { 158, 214 },
[3] = { 335, 214 },
[4] = { 247, 123 },
}
function ZhiBaoBoxOBJ: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], self.pos[i][2], "res/private/player_zhibao_box_UI/7.png")
GUI:setAnchorPoint(self.ui[btn], 0.50, 0.50)
GUI:addOnClickEvent(self.ui[btn], function()
ssrMessage:SubLink("ZhiBaoLaoRenOBJ_boxjiesuo", { id = i })
end)
else
local EquipShow = "EquipShow_" .. (70 + i)
self.ui[EquipShow] = GUI:EquipShow_Create(self.ui.item_Layout, EquipShow, self.pos[i][1], self.pos[i][2], (70 + 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 ZhiBaoBoxOBJ:EventBind()
local function ZhiBaoBoxOBJ_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, ZhiBaoBoxOBJ_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 ZhiBaoBoxOBJ:OnClose(widgetName)
if widgetName == self.__cname then
self:UnRegisterEvent()
end
end
function ZhiBaoBoxOBJ: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 ZhiBaoBoxOBJ