Refresh top icons and fix delay module loading

This commit is contained in:
Admin 2026-06-22 21:08:34 +08:00
parent 61f5decc15
commit e7fbb8b7bb
5 changed files with 157 additions and 67 deletions

View file

@ -463,6 +463,10 @@ ConstCfg = {
num = 1, num = 1,
where = 13, where = 13,
}, },
[16] = {
name = "łŹÇż˝đ´´ŇŠ",
num = 999,
},
}, },
newhuman_level = 1, --新人的等级 newhuman_level = 1, --新人的等级
newhuman_map = { "3", 330, 330 }, --新人的地图 newhuman_map = { "3", 330, 330 }, --新人的地图

View file

@ -0,0 +1,103 @@
CreateTopIconOBJ = {}
CreateTopIconOBJ._name = "CreateTopIconOBJ"
CreateTopIconOBJ.allowFunc = { "refresh" }
CreateTopIconOBJ.cfg = {
{
icon = "a1",
wnd = "Box996",
name = "Box996",
},
{
icon = "a9",
wnd = "TradingBank",
name = "TradingBank",
},
{
icon = "a2",
wnd = "StoreRecharge",
name = "StoreRecharge",
},
{
icon = "a3",
open = "FuLiDaTingOBJ_main",
name = "FuLi",
},
{
icon = "6",
open = "ShouChongOBJ_main",
name = "ShouChong",
},
{
icon = "a6",
name = "Strategy",
client_open = "StrategyOBJ",
},
{
icon = "a7",
name = "Service",
},
{
icon = "a10",
open = "XianShiChongBangOBJ_main",
name = "XianShiChongBang",
},
{
icon = "a5",
open = "HuodongzhongxinOBJ_main",
name = "HuoDong",
},
{
path = "res/custom/46/icon_top.png",
name = "YueKa",
open = "YueKaOBJ_main",
},
}
function CreateTopIconOBJ:checkShow(actor, cfg)
if cfg.show == false then
return false
end
local check = cfg.check or cfg.checkcontion
if not check then
return true
end
return Func.checkcontion(actor, check, false, false)
end
function CreateTopIconOBJ:getCfg(actor)
local list = {}
for _, cfg in ipairs(self.cfg or {}) do
if self:checkShow(actor, cfg) then
local viewCfg = table.Copy(cfg)
viewCfg.show = nil
viewCfg.check = nil
viewCfg.checkcontion = nil
table.insert(list, viewCfg)
end
end
return list
end
function CreateTopIconOBJ:refresh(actor)
if not isnotnull(actor) then
return
end
Message:SubLink(actor, self._name .. "_refresh", self:getCfg(actor))
end
local function refreshTopIcon(actor)
CreateTopIconOBJ:refresh(actor)
end
GameEvent.add(EventCfg.onLoginEnd, refreshTopIcon, CreateTopIconOBJ)
GameEvent.add(EventCfg.onqfloadend, refreshTopIcon, CreateTopIconOBJ)
return CreateTopIconOBJ

View file

@ -17,67 +17,15 @@ CreateTopIconOBJ.PCpos = {
[3] = -600, [3] = -600,
} }
CreateTopIconOBJ.cfg = { CreateTopIconOBJ.cfg = {}
CreateTopIconOBJ._redKeys = {}
[1] = {
icon = "a1",
wnd = ssrConstCfg.Box996,
name = "Box996",
}, -- 996盒子
[2] = {
icon = "a9",
wnd = ssrConstCfg.TradingBank,
name = "TradingBank",
}, -- 交易行
[3] = {
icon = "a2",
wnd = ssrConstCfg.StoreRecharge,
name = "StoreRecharge",
}, -- 充值中心
[4] = {
icon = "a4",
open = "KuangBaoOBJ_main",
name = "KuangBao",
}, -- 狂暴之力
[5] = {
icon = "a3",
open = "FuLiDaTingOBJ_main",
name = "FuLi",
}, -- 福利中心
[6] = {
icon = "6",
open = "ShouChongOBJ_main",
name = "ShouChong",
}, -- 首充
[7] = {
icon = "a6",
name = "Strategy",
client_open = "StrategyOBJ",
}, -- 游戏攻略
[8] = {
icon = "a7",
name = "Service",
}, -- 联系客服
[9] = {
icon = "a10",
open = "XianShiChongBangOBJ_main",
name = "XianShiChongBang",
}, -- 限时冲榜
[10] = {
icon = "a5",
open = "HuodongzhongxinOBJ_main",
name = "HuoDong",
}, -- 活动中心
[11] = {
path = "res/custom/46/icon_top.png",
name = "YueKa",
open = "YueKaOBJ_main",
}, -- 月卡
CreateTopIconOBJ.wndMap = {
Box996 = ssrConstCfg.Box996,
TradingBank = ssrConstCfg.TradingBank,
StoreRecharge = ssrConstCfg.StoreRecharge,
} }
function CreateTopIconOBJ:main() function CreateTopIconOBJ:main()
if MainMiniMap._ui then if MainMiniMap._ui then
@ -93,10 +41,15 @@ function CreateTopIconOBJ:main()
GUI:setAnchorPoint(self.ui.Top_Node, 1.00, 0) GUI:setAnchorPoint(self.ui.Top_Node, 1.00, 0)
GUI:setPosition(self.ui.Top_Node, self.posX, self.posY) GUI:setPosition(self.ui.Top_Node, self.posX, self.posY)
GUI:addOnClickEvent(self.ui.top_btn, function()
local Visible_bool = GUI:getVisible(self.ui.btn_switch)
self:setShowCopyBtn(not Visible_bool)
end)
---* 绑定事件 ---* 绑定事件
self:EventBind() self:EventBind()
self:createIcon() self:createIcon()
ssrMessage:SubLink(self.__cname .. "_refresh")
end end
end end
end end
@ -104,9 +57,12 @@ end
--* 创建图标 --* 创建图标
function CreateTopIconOBJ:createIcon() function CreateTopIconOBJ:createIcon()
if GUI:Win_IsNull(self.ui.btn_switch) then if not self.ui or GUI:Win_IsNull(self.ui.btn_switch) then
return return
end end
self:clearIcon()
for i, v in ipairs(self.cfg) do for i, v in ipairs(self.cfg) do
local icon = string.format("icon_%s", i) local icon = string.format("icon_%s", i)
if v.icon then if v.icon then
@ -124,7 +80,10 @@ function CreateTopIconOBJ:createIcon()
GUI:addOnClickEvent(self.ui[icon], function() GUI:addOnClickEvent(self.ui[icon], function()
if v.wnd then if v.wnd then
ssrUIManager:OPEN(v.wnd, { redKey = redKey }) local wnd = type(v.wnd) == "string" and self.wndMap[v.wnd] or v.wnd
if wnd then
ssrUIManager:OPEN(wnd, { redKey = redKey })
end
elseif v.open then elseif v.open then
Npc_dispatchex(nil, nil, nil, nil, SL:JsonEncode({ Npc_dispatchex(nil, nil, nil, nil, SL:JsonEncode({
sync_obj = v.open, sync_obj = v.open,
@ -140,14 +99,18 @@ function CreateTopIconOBJ:createIcon()
end) end)
GUI:setOpacity(self.ui[icon], 0) GUI:setOpacity(self.ui[icon], 0)
local iconNode = self.ui[icon]
SL:ScheduleOnce(function() SL:ScheduleOnce(function()
self:Action(self.ui[icon]) if iconNode and GUI:Win_IsNotNull(iconNode) then
self:Action(iconNode)
end
end, 0.1) end, 0.1)
--注册到全局红点系统:作为聚合点,由子模块 register(parent=redKey) 决定亮灭 --注册到全局红点系统:作为聚合点,由子模块 register(parent=redKey) 决定亮灭
--偏移可在 cfg 中通过 redOffset = { x = ?, y = ? } 自定义;不设则取默认 {15,15} --偏移可在 cfg 中通过 redOffset = { x = ?, y = ? } 自定义;不设则取默认 {15,15}
if RedDotMgr and RedDotMgr.register then if RedDotMgr and RedDotMgr.register then
local iconKey = icon local iconKey = icon
table.insert(self._redKeys, redKey)
RedDotMgr:register(redKey, { RedDotMgr:register(redKey, {
target = function() target = function()
return CreateTopIconOBJ.ui and CreateTopIconOBJ.ui[iconKey] return CreateTopIconOBJ.ui and CreateTopIconOBJ.ui[iconKey]
@ -173,11 +136,31 @@ function CreateTopIconOBJ:createIcon()
local btn_pos = GUI:getContentSize(self.ui.top_btn) local btn_pos = GUI:getContentSize(self.ui.top_btn)
GUI:setPosition(self.ui.btn_switch, btn_pos.width - 40, btn_pos.height + 30) GUI:setPosition(self.ui.btn_switch, btn_pos.width - 40, btn_pos.height + 30)
end
GUI:addOnClickEvent(self.ui.top_btn, function() function CreateTopIconOBJ:clearIcon()
local Visible_bool = GUI:getVisible(self.ui.btn_switch) if RedDotMgr and RedDotMgr.unregister then
self:setShowCopyBtn(not Visible_bool) for _, redKey in ipairs(self._redKeys or {}) do
end) RedDotMgr:unregister(redKey)
end
end
self._redKeys = {}
if self.ui and GUI:Win_IsNotNull(self.ui.btn_switch) then
GUI:removeAllChildren(self.ui.btn_switch)
end
end
function CreateTopIconOBJ:refresh(arg1, arg2, arg3, data)
self.cfg = data or {}
if self.ui and GUI:Win_IsNotNull(self.ui.btn_switch) then
self:createIcon()
if RedDotMgr and RedDotMgr.refreshAll then
RedDotMgr:refreshAll()
end
end
end end
-- 设置顶部功能按钮的显示状态 -- 设置顶部功能按钮的显示状态

View file

@ -15,7 +15,7 @@ TaskShowOBJ.UIfile = getUifile()
TaskShowOBJ.mainLineData = nil TaskShowOBJ.mainLineData = nil
local function canRouteMainLine(data) local function canRouteMainLine(data)
return data and tonumber(data.status or 0) == 0 and not data.finish return data ~= nil and tonumber(data.status or 0) == 0 and not data.finish
end end
local function getShortDesc(data) local function getShortDesc(data)

View file

@ -31,7 +31,7 @@ SL:ScheduleOnce(function()
for i, v in ipairs(SL:GetFilesByPath("GUILayout/delay") or {}) do for i, v in ipairs(SL:GetFilesByPath("GUILayout/delay") or {}) do
local game_file = string.format("GUILayout/delay/%s", v) local game_file = string.format("GUILayout/delay/%s", v)
local file_name = SL:Split(game_file, ".")[1] local file_name = SL:Split(game_file, ".")[1]
local obj_name = SL:Split(game_file, "/")[3] local obj_name = SL:Split(v, ".")[1]
dispatch_handler[obj_name] = SL:Require(file_name, true) dispatch_handler[obj_name] = SL:Require(file_name, true)
local target = dispatch_handler[obj_name] local target = dispatch_handler[obj_name]
if target and target["main"] then if target and target["main"] then