---@class KLUISystemTopPanel:UIKmlLuaPanelBase ---@field view KLUISystemTopPanelView local KLUISystemTopPanel = class(UIKmlLuaPanelBase) local this = KLUISystemTopPanel local ESystemType = { NoShow = enum(0), ShowRight = enum(1), ShowTop = enum(2), } local ETopSystemType = { None = enum(0), Show = enum(1), } ---创建时调用一次 function this:Init() self.systemTemplateList = {} self.systemType = ESystemType.ShowTop self.topSystemType = ETopSystemType.None end ---创建或者刷新界面数据时调用 function this:Refresh() self:Clear() self:RefreshSystemMenu() end function this:RefreshSystemMenu() self:Clear() local tbl = SL:GetConfigTable("cfg_MainPanelUI") local isShowBoss = false ---@param v cfg_MainPanelUI_column for i, v in pairs(tbl) do if v.systemId == "挑战首领" and SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, v.systemId) then isShowBoss = true GUI:setPosition(self.view.bossBtn, v.positionOffset[1] or 285, v.positionOffset[2] or -21) GUI:Button_loadTextureNormal(self.view.bossBtn, v.BtnImage, "Atlas/UIMainPanel.spriteatlas") else if v.displayLocation == self.systemType and (self.topSystemType == ETopSystemType.None or (self.topSystemType == ETopSystemType.Show and v.shrink == ETopSystemType.Show)) then ---@type KLUISystemItem local systemTopTemplatePanelItem = GUI:UIPanel_Open("dev/ui/MainUI/Item/KLUISystem/KLUISystemItem", self.view.systemMenu, self, v, true) GUI:SetID(systemTopTemplatePanelItem.view.root, v.btnName) local isMeet = SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, v.systemId) if v.systemId == "雷刃炎狼兽" then isMeet = InfoManager.mountPreferenceInfo:IsShowBtn() local endTime = (InfoManager.mountPreferenceInfo.endTime - Time.GetServerTime()) // 1000 if endTime > 0 then local TimeText = systemTopTemplatePanelItem.view.TimeText local BtnPanel = systemTopTemplatePanelItem.view.root GUI:setVisible(TimeText, true) self.mountPreTimer = SL:Schedule(self.mountPreTimer, 0, 1, endTime + 1, function() local timeText = InfoManager.mountPreferenceInfo.endTime - Time.GetServerTime() GUI:Text_setString(TimeText, GUIUtil.FormatTimeHMS(timeText // 1000)) if timeText <= 0 then GUI:setVisible(BtnPanel, false) GUI:setVisible(TimeText, false) return end end) end end if v.systemId == "运营活动" then --运营活动入口显隐由后端和system_switch表配置决定 isMeet = InfoManager.mainOperateActivityInfo.isOperateActivityMainBtnShow and isMeet local TimeText = systemTopTemplatePanelItem.view.TimeText if isMeet then local endTime = (InfoManager.mainOperateActivityInfo.operateActivityTypeCloseTime - Time.GetServerTime()) // 1000 if endTime > 0 then GUI:setVisible(TimeText, true) self.MainOperateTimer = SL:Schedule(self.MainOperateTimer, 0, 1, endTime+1, function() local timeText = (InfoManager.mainOperateActivityInfo.operateActivityTypeCloseTime - Time.GetServerTime()) // 1000 GUI:Text_setString(TimeText, GUIUtil.FormatTimeHMS(timeText)) if timeText <= 0 then GUI:setVisible(TimeText, false) return end end) else GUI:setVisible(TimeText, false) end else GUI:setVisible(TimeText, false) end end if v.systemId == "特惠礼包" then isMeet = InfoManager.rechargePushInfo:IsShowBtn() local endTime = (InfoManager.rechargePushInfo.endTime - Time.GetServerTime()) // 1000 if endTime > 0 then local TimeText = systemTopTemplatePanelItem.view.TimeText local BtnPanel = systemTopTemplatePanelItem.view.root GUI:setVisible(TimeText, true) self.PushGiftTimer = SL:Schedule(self.PushGiftTimer, 0, 1, endTime + 1, function() local timeText = InfoManager.rechargePushInfo.endTime - Time.GetServerTime() GUI:Text_setString(TimeText, GUIUtil.FormatTimeHMS(timeText // 1000)) if timeText <= 0 then GUI:setVisible(BtnPanel, false) GUI:setVisible(TimeText, false) return end end) end end if v.systemId == "首充" then isMeet = InfoManager.uiFirstChargeInfo:IsShowBtn() --if isMeet then -- local RoleId = SL:GetMetaValue(EMetaVarGetKey.MAIN_ACTOR_ID) -- local IsShow = PlayerPrefs.GetString("FirstChargeAdComplete" .. RoleId, "false") -- if IsShow then -- local reTime = PlayerPrefs.GetString("FirstChargeAdTime" .. RoleId, "0") -- if tonumber(reTime) > 0 then -- local careerId = PlayerPrefs.GetString("FirstChargeAdPopUpsPictureCareerID" ..RoleId, "") -- local Icon = PlayerPrefs.GetString("FirstChargeAdPopUpsPictureIcon" ..RoleId, "") -- GUI:UIPanel_Open("dev/outui/FirstCharge/Panel/KLFirstChargeAD/KLFirstChargeADPanel", nil, nil, { count = tonumber(reTime),popUpsPicture={careerId,Icon} }) -- end -- end --end end if v.systemId == "限时礼包" then isMeet = InfoManager.rechargeActivityInfo:IsShowTimeLimitGiftBtn() if isMeet then local TimeText = systemTopTemplatePanelItem.view.TimeText local BtnPanel = systemTopTemplatePanelItem.view.root local msgEndTime = InfoManager.rechargeActivityInfo:GetTimeLimitGiftEndTime() if msgEndTime then local endTime = (msgEndTime - Time.GetServerTime()) // 1000 if endTime > 0 then GUI:setVisible(TimeText, true) local maxTime = InfoManager.rechargeActivityInfo:GetMaxTimeLimitGiftEndTime() self.TimeLimitGiftTimer = SL:Schedule(self.TimeLimitGiftTimer, 0, 1, maxTime+1, function() local endTime1,TimeLimitGiftNextEndGroup = InfoManager.rechargeActivityInfo:GetTimeLimitGiftEndTime() local maxTime1 = InfoManager.rechargeActivityInfo:GetMaxTimeLimitGiftEndTime() if not endTime1 then --SL:LogError("全买光或过期或没有") GUI:setVisible(BtnPanel, false) GUI:setVisible(TimeText, false) local panel = GUI:GetUI("dev/outui/Recharge/Panel/KLRechargeActivity/KLRechargeActivityPanel") if panel then GUI:UIPanel_Close("dev/outui/Recharge/Panel/KLRechargeActivity/KLRechargeActivityPanel") SL.ShowMainPanel() end return end local timeText = endTime1 - Time.GetServerTime() GUI:Text_setString(TimeText, GUIUtil.FormatTimeHMS(timeText // 1000)) if not self.TimeLimitGiftNextEndGroup or TimeLimitGiftNextEndGroup ~= self.TimeLimitGiftNextEndGroup then --SL:LogError("转到下一个礼包()") self.TimeLimitGiftNextEndGroup = TimeLimitGiftNextEndGroup local panel = GUI:GetUI("dev/outui/Recharge/Panel/KLRechargeActivity/KLRechargeActivityPanel") if panel then panel:Refresh() end end --SL:LogError("endTime1"..(timeText // 1000).." maxTime1"..maxTime1) if timeText < 1000 then if timeText // 1000 == maxTime1 then --SL:LogError("倒计时结束") GUI:setVisible(BtnPanel, false) GUI:setVisible(TimeText, false) local panel = GUI:GetUI("dev/outui/Recharge/Panel/KLRechargeActivity/KLRechargeActivityPanel") if panel then GUI:UIPanel_Close("dev/outui/Recharge/Panel/KLRechargeActivity/KLRechargeActivityPanel") SL.ShowMainPanel() end return else --SL:LogError("转到下一个礼包2") local panel = GUI:GetUI("dev/outui/Recharge/Panel/KLRechargeActivity/KLRechargeActivityPanel") if panel then panel:Refresh() end end end end) else GUI:setVisible(BtnPanel, false) GUI:setVisible(TimeText, false) end else GUI:setVisible(BtnPanel, false) GUI:setVisible(TimeText, false) end end end GUI:setVisible(systemTopTemplatePanelItem.view.root, isMeet) table.insert(self.systemTemplateList, systemTopTemplatePanelItem) if v.systemId == "月卡" then if self.cur_monthCard_effect then GUI:SetParent(self.cur_monthCard_effect, systemTopTemplatePanelItem) else ---@type cfg_model_effect_column local effect_tbl = SL:GetConfig("cfg_model_effect", 20001, "id") self.cur_monthCard_effect = GUI:Model_Create(systemTopTemplatePanelItem.view.root, { id = "cur_monthCard_effect", mscale = "1,1,1", mrotate = "0,200,0", zindex = "0", x = "0", y = "2", z = "0", a = "00", src = effect_tbl.path }) end end end end end GUI:setVisible(self.view.bossBtn, isShowBoss) if isShowBoss then GUI:setPositionX(self.view.systemMenu, -75) else GUI:setPositionX(self.view.systemMenu, 0) end SL:RefreshPanelALLRedPoint("KLUISystemTopPanel") end ---注册UI事件和服务器消息 function this:RegistEvents() GUI:AddOnClickEvent(self.view.sysExpand, self, self.OnClicksysExpandBtn) GUI:AddOnClickEvent(self.view.sysExpandClickBg, self, self.OnClicksysExpandBtn) GUI:AddOnClickEvent(self.view.sysFold, self, self.OnClicksysFoldBtn) GUI:AddOnClickEvent(self.view.sysFoldClickBg, self, self.OnClicksysFoldBtn) GUI:AddOnClickEvent(self.view.bossBtn, self, self.OnClickBossBtn) SL:RegisterLUAEvent(LUA_EVENT_HIDE_RIGHT_BTN_VIEW, self.OnClicksysFoldBtn, self) SL:RegisterLUAEvent(LUA_EVENT_LEVELCHANGE, self.RefreshBossBtn, self) SL:RegisterLUAEvent(LUA_EVENT_OPEN_SERVER_DAY_CHANGE, self.RefreshBossBtn, self) SL:RegisterLUAEvent(LUA_EVENT_CHANGESCENE, self.LUA_EVENT_CHANGESCENE, self) SL:RegisterLUAEvent(LUA_EVENT_ENTRY_MAP_LOADING_PANEL_CLOSE, self.LUA_EVENT_ENTRY_MAP_LOADING_PANEL_CLOSE, self) SL:RegisterLUAEvent(LUA_EVENT_RES_FIRST_CHARGE_GIFT_INFO, self.RES_FirstChargeGift_Info, self) SL:RegisterLUAEvent(LUA_EVENT_MAINOPERATEACTIVITY_CHANGE, self.RefreshSystemMenu, self) SL:RegisterLUAEvent(LUA_EVENT_LEVELCHANGE, self.RefreshSystemMenu, self) end function this:RES_FirstChargeGift_Info(_, message) local count = 0 for rewardId, state in pairs(message.data.rewards) do if state == 2 then count = count + 1 end end if count == 3 then for i, systemItem in pairs(self.systemTemplateList) do if systemItem.args.id == 203 then GUI:SetActive(systemItem.view.root, false) end end end end function this:OnClicksysExpandBtn() if self.topSystemType ~= ETopSystemType.None then GUI:setVisible(self.view.sysExpand, false) GUI:setVisible(self.view.sysFold, true) self.topSystemType = ETopSystemType.None GUI:setContentSize(self.view.systemMenu,470,115) self:RefreshSystemMenu() --隐藏boss血条 SL:onLUAEvent(LUA_EVENT_HIDE_BOSS_HP) end end function this:OnClicksysFoldBtn() if self.topSystemType ~= ETopSystemType.Show then GUI:setVisible(self.view.sysExpand, true) GUI:setVisible(self.view.sysFold, false) self.topSystemType = ETopSystemType.Show GUI:setContentSize(self.view.systemMenu,170,115) self:RefreshSystemMenu() --取消隐藏boss血条 SL:onLUAEvent(LUA_EVENT_CANCEL_HIDE_BOSS_HP) end end function this:OnClickBossBtn() ---@type cfg_MainPanelUI_column local tbl = SL:GetConfig("cfg_MainPanelUI", 215, "id") --EventManager.Dispatch(LUA_EVENT_OPENMAINSYSTEMFUNCTION, tbl and tbl.systemId or "挑战首领") SL:LUA_EVENT_OPENMAINSYSTEMFUNCTION(tbl and tbl.systemId or "挑战首领") end function this:RefreshBossBtn() local isShowBoss = SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, "挑战首领") GUI:setVisible(self.view.bossBtn, isShowBoss) if isShowBoss then GUI:setPositionX(self.view.systemMenu, -75) else GUI:setPositionX(self.view.systemMenu, 0) end end function this:LUA_EVENT_CHANGESCENE(_, data) ---@type cfg_map_info_column local tbl = SL:GetConfig("cfg_map_info", data.cfgId) if tbl and tbl.type == EMapType.CopyMap then self:OnClicksysFoldBtn() end end function this:LUA_EVENT_ENTRY_MAP_LOADING_PANEL_CLOSE(_, data) local mapId = SL:GetMetaValue(EMetaVarGetKey.MAP_ID) ---@type cfg_map_info_column local tbl = SL:GetConfig("cfg_map_info", mapId) if tbl and tbl.type == EMapType.CopyMap then self:OnClicksysFoldBtn() end end ---清除数据 function this:Clear() --if GUI:GetUI("dev/outui/FirstCharge/Panel/KLFirstChargeAD/KLFirstChargeADPanel") then -- GUI:UIPanel_Close("dev/outui/FirstCharge/Panel/KLFirstChargeAD/KLFirstChargeADPanel") --end ---@param systemItem KLUISystemItem for i, systemItem in pairs(self.systemTemplateList) do GUI:UIPanel_Close(nil, systemItem) end self.systemTemplateList = {} self.cur_monthCard_effect = nil if self.PushGiftTimer then SL:UnSchedule(self.PushGiftTimer) self.PushGiftTimer = nil end if self.mountPreTimer then SL:UnSchedule(self.mountPreTimer) self.mountPreTimer = nil end self.TimeLimitGiftNextEndGroup = nil if self.TimeLimitGiftTimer then SL:UnSchedule(self.TimeLimitGiftTimer) self.TimeLimitGiftTimer = nil end if self.MainOperateTimer then SL:UnSchedule(self.MainOperateTimer) self.MainOperateTimer = nil end end function this:Close() if self.PushGiftTimer then SL:UnSchedule(self.PushGiftTimer) self.PushGiftTimer = nil end if self.mountPreTimer then SL:UnSchedule(self.mountPreTimer) self.mountPreTimer = nil end self.TimeLimitGiftNextEndGroup = nil if self.TimeLimitGiftTimer then SL:UnSchedule(self.TimeLimitGiftTimer) self.TimeLimitGiftTimer = nil end self.cur_monthCard_effect = nil self.systemTemplateList = {} if self.MainOperateTimer then SL:UnSchedule(self.MainOperateTimer) self.MainOperateTimer = nil end end return this