121 lines
3.9 KiB
Lua
121 lines
3.9 KiB
Lua
FuLiDaTingOBJ = Up_BaseClassOBJ:new()
|
||
|
||
FuLiDaTingOBJ.__cname = "FuLiDaTingOBJ"
|
||
|
||
-- 配置文件
|
||
FuLiDaTingOBJ.cfg = {}
|
||
|
||
FuLiDaTingOBJ.UIfile = "game/A/FuLiDaTingUI"
|
||
|
||
FuLiDaTingOBJ.branch = {
|
||
[1] = function(parent, data)
|
||
WangZheTeQuanOBJ:main(parent, data)
|
||
end,
|
||
[2] = function(parent, data)
|
||
MeiRiChongZhiOBJ:main(parent, data)
|
||
end,
|
||
[3] = function(parent, data)
|
||
MeiriXianGouOBJ:main(parent, data)
|
||
end,
|
||
[4] = function(parent, data)
|
||
ZBHuiShouOBJ:main(parent, data)
|
||
end,
|
||
[5] = function(parent, data)
|
||
ZBShouBaoOBJ:main(parent, data)
|
||
end,
|
||
[6] = function(parent, data)
|
||
BOSSshouShaOBJ:main(parent, data)
|
||
end,
|
||
[7] = function(parent, data)
|
||
ChengZhangJiJinOBJ:main(parent, data)
|
||
end,
|
||
[8] = function(parent, data)
|
||
LeiChongJiangLiOBJ:main(parent, data)
|
||
end,
|
||
}
|
||
|
||
|
||
function FuLiDaTingOBJ:updata()
|
||
self.id = self.id or 1
|
||
GUI:ListView_removeAllItems(self.ui.btn_ListView)
|
||
for i, v in ipairs(self.cfg or {}) do
|
||
local function addbtn()
|
||
local class_btn = string.format("class_btn_%d", i)
|
||
self.ui[class_btn] = GUI:Button_Create(self.ui.btn_ListView, class_btn, 0.00, 0.00,
|
||
string.format("res/custom/01/btn/%s.png", self.id == i and tostring(i) or i .. "a"))
|
||
GUI:addOnClickEvent(self.ui[class_btn], function()
|
||
GUI:Button_loadTextureNormal(self.ui["class_btn_" .. self.id],
|
||
string.format("res/custom/01/btn/%s.png", self.id .. "a"))
|
||
GUI:Button_loadTextureNormal(self.ui[class_btn], string.format("res/custom/01/btn/%d.png", i))
|
||
self.id = i
|
||
self:addpage()
|
||
end)
|
||
end
|
||
addbtn()
|
||
end
|
||
|
||
self:addpage()
|
||
--左侧按钮重建后通知红点系统重新挂点
|
||
if RedDotMgr and RedDotMgr.refreshChildren then
|
||
RedDotMgr:refreshChildren("TopIcon_FuLi")
|
||
end
|
||
end
|
||
|
||
function FuLiDaTingOBJ:addpage()
|
||
if not self.id then
|
||
return
|
||
end
|
||
if self.branch[self.id] then
|
||
local func = self.branch[self.id]
|
||
if func then
|
||
GUI:removeAllChildren(self.ui.Content_Node)
|
||
func(self.ui.Content_Node, self.cfg[self.id] and self.cfg[self.id] or nil)
|
||
end
|
||
end
|
||
end
|
||
|
||
--红点逻辑已统一迁移到 RedDotMgr:
|
||
-- * 顶部福利图标(TopIcon_FuLi)作为聚合点,由 CreateTopIconOBJ 自动注册
|
||
-- * 各子页面在自己的文件末尾通过 RedDotMgr:register("FuLi_xxx", {...}) 注册条件
|
||
-- * 子页面状态变化会自动向上传播让顶部图标亮/灭
|
||
|
||
------------------------注册事件------------------------
|
||
function FuLiDaTingOBJ:EventBind()
|
||
local function FuLiDaTingOBJ_titleReload(data)
|
||
if data.oper == 2 then
|
||
if GUI:Win_IsNotNull(self._parent) then
|
||
self:updata()
|
||
end
|
||
end
|
||
end
|
||
SL:RegisterLUAEvent(LUA_EVENT_TITLE_REFRESH, self.__cname, FuLiDaTingOBJ_titleReload)
|
||
|
||
|
||
|
||
--关闭窗口
|
||
SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname, function(widgetName)
|
||
self:OnClose(widgetName)
|
||
end)
|
||
end
|
||
|
||
--关闭窗口
|
||
function FuLiDaTingOBJ:OnClose(widgetName)
|
||
if widgetName == self.__cname then
|
||
self:UnRegisterEvent()
|
||
end
|
||
end
|
||
|
||
function FuLiDaTingOBJ:UnRegisterEvent()
|
||
SL:UnRegisterLUAEvent(LUA_EVENT_TITLE_REFRESH, self.__cname)
|
||
SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname)
|
||
end
|
||
|
||
--热重载残留清理:旧版本曾用 "fulidating" 这个 key 注册过 3 个全局事件,闭包里仍引用已删除的 redVar/reddot
|
||
--不清理会在服务器变量变化/等级变化时报 attempt to index field 'redVar'
|
||
if SL and SL.UnRegisterLUAEvent then
|
||
SL:UnRegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, "fulidating")
|
||
SL:UnRegisterLUAEvent(LUA_EVENT_LEVEL_CHANGE, "fulidating")
|
||
SL:UnRegisterLUAEvent(LUA_EVENT_REINLEVEL_CHANGE, "fulidating")
|
||
end
|
||
|
||
return FuLiDaTingOBJ
|