71 lines
1.7 KiB
Lua
71 lines
1.7 KiB
Lua
local Bag_Btn = {}
|
|
|
|
Bag_Btn._isWin32 = SL:GetValue("IS_PC_OPER_MODE")
|
|
|
|
|
|
function Bag_Btn:main(parent)
|
|
if GUI:Win_IsNull(parent) then
|
|
return
|
|
end
|
|
|
|
GUI:LoadExport(parent, not Bag_Btn._isWin32 and "bag/Bag_Btn" or "bag/Bag_Btn_Win32")
|
|
self.ui = GUI:ui_delegate(parent)
|
|
|
|
|
|
self:init()
|
|
self:RegisterEvent()
|
|
end
|
|
|
|
function Bag_Btn:init()
|
|
-- GUI:Text_setString(self.ui.money_Text_1, SL:Get_MONEY(1))
|
|
|
|
for i = 1, 4, 1 do
|
|
GUI:Text_setString(self.ui["money_Text_" .. i], SL:Get_MONEY(i))
|
|
end
|
|
|
|
|
|
--* 背包整理
|
|
GUI:addOnClickEvent(self.ui.RefreshBag, function()
|
|
SL:RequestRefreshBagPos()
|
|
end)
|
|
|
|
---* 打开仓库
|
|
GUI:addOnClickEvent(self.ui.CangKu, function()
|
|
ssrMessage:SubLink("SysBtnOBJ_opencangku")
|
|
end)
|
|
|
|
---* 打开回收
|
|
GUI:addOnClickEvent(self.ui.HuiShou, function()
|
|
HuiShouOBJ:main()
|
|
end)
|
|
end
|
|
|
|
---* 货币改变时触发
|
|
function Bag_Btn.MoneyChange(data)
|
|
if GUI:Win_IsNotNull(Bag_Btn.ui["money_Text_" .. data.id]) then
|
|
GUI:Text_setString(Bag_Btn.ui["money_Text_" .. data.id], SL:Get_MONEY(data.id))
|
|
end
|
|
end
|
|
|
|
function Bag_Btn:RegisterEvent()
|
|
SL:RegisterLUAEvent(LUA_EVENT_MONEY_CHANGE, "Bag_Btn", Bag_Btn.MoneyChange) --关闭界面
|
|
--关闭窗口
|
|
SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, "Bag_Btn", function(widgetName)
|
|
self:OnClose(widgetName)
|
|
end)
|
|
end
|
|
|
|
--关闭窗口
|
|
function Bag_Btn:OnClose(widgetName)
|
|
if widgetName == "BagLayerGUI" then
|
|
self:OnCloseLayer()
|
|
end
|
|
end
|
|
|
|
-- 关闭监听
|
|
function Bag_Btn:OnCloseLayer(id)
|
|
SL:UnRegisterLUAEvent(LUA_EVENT_MONEY_CHANGE, "Bag_Btn")
|
|
SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, "Bag_Btn")
|
|
end
|
|
|
|
return Bag_Btn
|