---@class KLEfficiencyNewPanel:UIKmlLuaPanelBase ---@field view KLEfficiencyNewPanelView ---@field showTbls table}> ---@field nowData {group:number,name:string,bgImg:string,ids:table} ---@field nowRewardCfgData cfg_efficiency_level_column local KLEfficiencyNewPanel = class(UIKmlLuaPanelBase) local this =KLEfficiencyNewPanel function this:AsyncLoadUI() end ---创建时调用一次 function this:Init() self.isFirstOpenUI = false ---当前选中的数据 self.nowData = nil ---所有页签的红点 self.toggleRedPointList = {} self.toggleLevelList = {} SL.HideMainPanel() local tbl = SL:GetConfigTable("cfg_efficiency") self.showTbls = {} self.togIndex = nil local myLv = SL:GetMetaValue("LEVEL") local tempList = {} ---@param v cfg_efficiency_column for _, v in pairs(tbl) do if not tempList[v.group] then tempList[v.group] = { group = v.group, name = v.name, bgImg = v.backgroundImg, lv = v.level, ids = {v.id} } table.insert(self.showTbls, tempList[v.group]) else table.insert(tempList[v.group].ids, v.id) end table.insert(self.toggleLevelList,v.level) end --跳转到指定页签 if self.args and tempList[self.args] and myLv >= tempList[self.args].lv then self.isFirstOpenUI = true self.togIndex = self.args end GUI:DataListInitData(self.view.datalist, function() return table.count(self.showTbls) end,function() end,function() end,function(realIndex) local info = self.showTbls[realIndex+1] local rootCtrl = GUI:GetChildControl(self.view.datalist,realIndex,'root') GUI:SetActive(rootCtrl,myLv >= info.lv) local nameCtrl = GUI:GetChildControl(self.view.datalist,realIndex,'text_name') local togCtrl = GUI:GetChildControl(self.view.datalist,realIndex,'toggle') local togRed = GUI:GetChildControl(self.view.datalist,realIndex,'toggle_red') if not self.toggleRedPointList[info.group] then self.toggleRedPointList[info.group] = {info=info,image=togRed} end if self.togIndex and self.togIndex == info.group then self.nowData = info end GUI:Text_setString(nameCtrl, info.name) GUI:SetToggleGroup(togCtrl, self.view.togglegroup8) GUI:SetToggleOnValueChange(togCtrl, self, self.OnPageChange, info) if realIndex == 0 and not self.isFirstOpenUI then--第一次打开界面时默认选中第一个页签 GUI:Toggle_setIsOn(togCtrl,true) self.isFirstOpenUI = true else if self.nowData and self.nowData.group == info.group then GUI:Toggle_setIsOn(togCtrl,true) end end end) GUI:DataListUpdateData(self.view.datalist) self:UpdateReward() end function this:OnPageChange(control, eventData, callBack) if callBack[1] then self.nowData = eventData ---是否需要点击发送保存红点消息给服务器 local isReqSaveRed = InfoManager.uiEfficiencyNewInfo:GetToggleIsEfficiencyRedDot(self.nowData.group) if isReqSaveRed then SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_SAVE_EFFECIENCY_RED_DOT,{type=1,group = self.nowData.group}) end SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_CHECK_EFFECIENCY_ACTIVE,self.nowData.ids) if eventData.group == 1 then GUI:setVisible(self.view.Multiplier, true) GUI:setVisible(self.view.Single, false) ---@type cfg_efficiency_column local left = SL:GetConfig("cfg_efficiency", eventData.ids[1]) GUI:AddOnClickEvent(self.view.btn_left, self, function() GUI:UIPanel_Close(self.filePath) self:JumpUIPanel(left) end) if left.item[1] and left.item[1][1] then GUI:setVisible(self.view.model_left,true) GUI:Item_setItemId(self.view.model_left, left.item[1][1]) GUI:Item_Scale(self.view.model_left,left.Scale) else GUI:setVisible(self.view.model_left,false) end GUI:Text_setString(self.view.text_left_num,left.text.."%") ---@type cfg_efficiency_column local up = SL:GetConfig("cfg_efficiency", eventData.ids[2]) GUI:AddOnClickEvent(self.view.btn_up, self, function() GUI:UIPanel_Close(self.filePath) self:JumpUIPanel(up) end) if up.item[1] and up.item[1][1] then GUI:setVisible(self.view.model_up,true) GUI:Item_setItemId(self.view.model_up, up.item[1][1]) GUI:Item_Scale(self.view.model_up,up.Scale) else GUI:setVisible(self.view.model_up,false) end GUI:Text_setString(self.view.text_up_num,up.text.."%") ---@type cfg_efficiency_column --[[local down = SL:GetConfig("cfg_efficiency", eventData.ids[3]) GUI:AddOnClickEvent(self.view.btn_down, self, function() GUI:UIPanel_Close(self.filePath) self:JumpUIPanel(down) end) GUI:Item_UpdataData(self.view.model_down, { mfixsize = tostring(down.Scale)..","..tostring(down.Scale), itemid = down.item[1][1] }) GUI:Text_setString(self.view.text_down_num,down.text.."%")--]] else GUI:setVisible(self.view.Multiplier, false) GUI:setVisible(self.view.Single, true) ---@type cfg_efficiency_column local tbl = SL:GetConfig("cfg_efficiency", eventData.ids[1]) GUI:Image_loadTexture(self.view.img_info,"Texture/"..tbl.backgroundImg..".png","") end end end ---注册UI事件和服务器消息 function this:RegistEvents() GUI:AddOnClickEvent(self.view.btn_go, self, self.OnGoClick) GUI:AddOnClickEvent(self.view.btn_close, self, self.CLoseSelf) GUI:AddOnClickEvent(self.view.item_reward, self, self.ReceiveReward) SL:RegisterLUAEvent(LUA_EFFICIENCY_RED_DOT_CHANGE, self.RefreshToggleRed, self) SL:RegisterLUAEvent(LUA_EFFICIENCY_TAB_ACTIVE_CHANGE, self.LUA_EFFICIENCY_TAB_ACTIVE_CHANGE, self) SL:RegisterLUAEvent(LUA_EVENT_LEVELCHANGE, self.LUA_EVENT_LEVELCHANGE, self) end function this:OnGoClick() if self.nowData then GUI:UIPanel_Close(self.filePath) ---@type cfg_efficiency_column local tbl = SL:GetConfig("cfg_efficiency", self.nowData.ids[1]) self:JumpUIPanel(tbl) end end ---跳转界面 ---@param tbl cfg_efficiency_column function this:JumpUIPanel(tbl) if not tbl.jumpCondition or tbl.jumpCondition == "" then--未配置的情况下直接跳转第一个配置的界面即可 shortcutOutMgr.DO(tbl.Jump[1]) SL.HideMainPanel() return end local jumpConditionList = string.split(tbl.jumpCondition,"|") local listCount = table.count(jumpConditionList) for i = 1, listCount do if ConditionManager.Check4D(jumpConditionList[i]) or jumpConditionList[i] == "" then--配置条件满足或者未配置即跳转对应配置的界面 shortcutOutMgr.DO(tbl.Jump[i]) SL.HideMainPanel() return end end if listCount > 0 and tbl.Jump[listCount + 1] then--前置条件都未满足且下一个条件未配置跳下个界面(例如配置的是:"103#100" 然后Jump配了2个跳转) shortcutOutMgr.DO(tbl.Jump[listCount + 1]) SL.HideMainPanel() end end function this:CLoseSelf() GUI:UIPanel_Close(self.filePath) SL.ShowMainPanel() end function this:ReceiveReward() if not self.nowRewardCfgData then return end local myLv = SL:GetMetaValue("LEVEL") if self.nowRewardCfgData.level > myLv then SL:TipMessage( SL:GetConfig('cfg_string',249).text, 1, NoticeType.NoticeMid )--"等级不足", return end --TODO: 领取奖励协议 SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_GET_EFFECIENCY_REWARD,{id=self.nowRewardCfgData.id,type=2}) end function this:UpdateReward() self.nowRewardCfgData = nil local nowId = InfoManager.uiEfficiencyNewInfo:GetNowRewardCfgId() --有服务器数据的时候直接拿服务器id获取表数据 if nowId and SL:HasConfig("cfg_efficiency_level",nowId) then self.nowRewardCfgData = SL:GetConfig("cfg_efficiency_level",nowId) end self:ShowRewardInfo() end ---显示奖励信息 function this:ShowRewardInfo() if not self.nowRewardCfgData then GUI:setVisible(self.view.item_reward, false) return end local myLv = SL:GetMetaValue("LEVEL") local myCareer = SL:GetMetaValue(EMetaVarGetKey.JOB) local v = self.nowRewardCfgData GUI:setVisible(self.view.item_reward, true) GUI:Text_setString(self.view.text_limit, string.format("达到%d级可领", v.level)) GUI:Text_setTextColor(self.view.text_limit,v.level <= myLv and EColor[EGradColor.green] or EColor[EGradColor.red]) GUI:SetActive(self.view.item_reward_red,v.level <= myLv) for _, d in pairs(v.item) do if d[1] == myCareer then GUI:Item_UpdataData(self.view.item_reward, {itemid = d[2], itemcount=d[3]}) break end end end ---刷新页签红点 function this:RefreshToggleRed() for i, v in ipairs(self.toggleRedPointList) do local isShow = InfoManager.uiEfficiencyNewInfo:GetToggleIsEfficiencyRedDot(v.info.group) GUI:SetActive(v.image,isShow) end self:UpdateReward() end ---激活信息刷新 function this:LUA_EFFICIENCY_TAB_ACTIVE_CHANGE(_,message) if self.nowData then self:RefreshTabActiveInfo() end end ---刷新激活信息页面 function this:RefreshTabActiveInfo() local list = InfoManager.uiEfficiencyNewInfo:GetEfficiencyTabActiveInfo() if self.nowData.group == 1 then local leftIsActive = table.contains(list,self.nowData.ids[1]) GUI:SetActive(self.view.btn_left,not leftIsActive) GUI:SetActive(self.view.img_state_left,leftIsActive) local upIsActive = table.contains(list,self.nowData.ids[2]) GUI:SetActive(self.view.btn_up,not upIsActive) GUI:SetActive(self.view.img_state_up,upIsActive) local downIsActive = table.contains(list,self.nowData.ids[3]) GUI:SetActive(self.view.btn_down,not downIsActive) GUI:SetActive(self.view.img_state_down,downIsActive) else local isActive = table.contains(list,self.nowData.ids[1]) GUI:SetActive(self.view.btn_go,not isActive) GUI:SetActive(self.view.Single_active,isActive) end end ---等级改变 function this:LUA_EVENT_LEVELCHANGE(id,level) GUI:DataListUpdateData(self.view.datalist) end ---界面显示时调用一次 function this:Show() end ---创建或者刷新界面数据时调用 function this:Refresh() self:RefreshToggleRed() end function this:Close() end return this