require("Base/BasePanel") CompoundPanel = Inherit(BasePanel) local this = CompoundPanel local TabBox = require("Modules/Common/TabBox") local _TabData={ [1] = { default = "UI_hz_gonghui_31", lock = "UI_hz_gonghui_31",select = "UI_hz_gonghui_31", name = Language[10385] , funcType = FUNCTION_OPEN_TYPE.COMPOUND}, --[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "宝器锻造" }, [2] = { default = "UI_hz_gonghui_32", lock = "UI_hz_gonghui_32",select = "UI_hz_gonghui_32", name = Language[10387] , funcType = FUNCTION_OPEN_TYPE.hunyin}, [3] = { default = "UI_hz_gonghui_33", lock = "UI_hz_gonghui_33",select = "UI_hz_gonghui_33", name = Language[10386], funcType = FUNCTION_OPEN_TYPE.Treasure }, [4] = { default = "UI_hz_gonghui_34", lock = "UI_hz_gonghui_34",select = "UI_hz_gonghui_34", name = "将礼合成", funcType = FUNCTION_OPEN_TYPE.Gift,redpoint=RedPointType.HeroGiftCompound }, [5] = { default = "UI_hz_gonghui_31", lock = "UI_hz_gonghui_31",select = "UI_hz_gonghui_31", name = "主礼合成", funcType = FUNCTION_OPEN_TYPE.Gift,redpoint=RedPointType.PlayerGiftCompound }, } local _TabFontColor = { default = Color.New(255 / 255, 255 / 255, 255 / 255, 1), select = Color.New(255 / 255, 255 / 255, 255 / 255, 1), lock = UIColor.GRAY, } local curIndex = 1 this.contents = { [1] = {view = require("Modules/Compound/view/CompoundPanel_Equip"), panelName = "CompoundPanel_Equip"}, --[2] = {view = require("Modules/Compound/view/CompoundPanel_Talisman"), panelName = "CompoundPanel_Talisman"}, [2] = {view = require("Modules/Compound/view/CompoundPanel_SoulPrint"), panelName = "CompoundPanel_SoulPrint"}, [3] = {view = require("Modules/Compound/view/CompoundPanel_Treasure"), panelName = "CompoundPanel_Treasure"}, [4] = {view = require("Modules/Compound/view/CompoundPanel_Gift"), panelName = "CompoundPanel_Gift"}, [5] = {view = require("Modules/Compound/view/CompoundPanel_PlayerGift"), panelName = "CompoundPanel_PlayerGift"}, } local redPointList={} --初始化组件(用于子类重写) function CompoundPanel:InitComponent() this.spLoader = SpriteLoader.New() this.HelpBtn = Util.GetGameObject(self.gameObject,"helpBtn") this.helpPosition=this.HelpBtn:GetComponent("RectTransform").localPosition --子模块脚本 this.tabBox = Util.GetGameObject(self.gameObject, "TabBox") this.upView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft}) this.btnBack = Util.GetGameObject(self.gameObject, "btnBack/btnBack") --预设赋值 this.prefabs = {} for i=1,#this.contents do this.prefabs[i]=Util.GetGameObject(self.gameObject,this.contents[i].panelName) this.contents[i].view:InitComponent(Util.GetGameObject(self.gameObject, "panle")) end end --绑定事件(用于子类重写) function CompoundPanel:BindEvent() Util.AddClick(this.btnBack, function() self:ClosePanel() end) for i = 1, #this.contents do this.contents[i].view:BindEvent() end end function CompoundPanel.RefreshHelpBtn() if curIndex==1 then this.HelpBtn:SetActive(true) Util.AddOnceClick(this.HelpBtn, function() UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.EquipCompose,this.helpPosition.x,this.helpPosition.y) end) elseif curIndex==2 then this.HelpBtn:SetActive(true) Util.AddOnceClick(this.HelpBtn, function() UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.TreasureCompose,this.helpPosition.x,this.helpPosition.y) end) elseif curIndex==3 then this.HelpBtn:SetActive(true) Util.AddOnceClick(this.HelpBtn, function() UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.SoulPrintCommond,this.helpPosition.x,this.helpPosition.y) end) else this.HelpBtn:SetActive(false) end end --添加事件监听(用于子类重写) function CompoundPanel:AddListener() for i = 1, #this.contents do this.contents[i].view:AddListener() end end --移除事件监听(用于子类重写) function CompoundPanel:RemoveListener() for i = 1, #this.contents do this.contents[i].view:RemoveListener() end end --界面打开时调用(用于子类重写) function CompoundPanel:OnOpen(_curIndex) curIndex = _curIndex and _curIndex or 1 end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function CompoundPanel:OnShow() this.TabCtrl = TabBox.New() this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.SwitchView) this.TabCtrl:SetTabIsLockCheck(this.IsTabLock) this.TabCtrl:Init(this.tabBox, _TabData, curIndex) end function CompoundPanel:OnSortingOrderChange() this.sortingOrder = self.sortingOrder for i = 1, #this.contents do this.contents[i].view:OnSortingOrderChange(self.sortingOrder) end end function this.IsTabLock(index) if _TabData[index].funcType and _TabData[index].funcType > 0 then if ActTimeCtrlManager.SingleFuncState(_TabData[index].funcType) then return false else return true, "【".._TabData[index].name.."】"..ActTimeCtrlManager.SystemOpenTip(_TabData[index].funcType) end else return false end end -- tab节点显示自定义 function this.TabAdapter(tab, index, status) local tabLab = Util.GetGameObject(tab, "text") Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status]) tabLab:GetComponent("Text").text = _TabData[index].name tabLab:GetComponent("Text").color = _TabFontColor[status] local redPoint=Util.GetGameObject(tab,"Redpot") if _TabData[index].redpoint then BindRedPointObject( _TabData[index].redpoint,redPoint) redPointList[_TabData[index].redpoint]=redPoint end Util.GetGameObject(tab,"LockImage"):SetActive(status == "lock") Util.GetGameObject(tab,"select"):SetActive(status == "select" ) this.SetBottomBarIsActive(tab, index) end --特殊的开启条件 function this.SetBottomBarIsActive(tab, index) local ConfigData = ConfigManager.GetConfig(ConfigName.SpecialConfig) if index == 2 then local string = ConfigData[89].Value tab:SetActive(PlayerManager.level >= tonumber(string)) end if index == 3 then local string = ConfigData[40].Value local num = string.split(string.split(string,"|")[1],"#")[2] tab:SetActive(PlayerManager.level >= tonumber(num)) end end --切换视图 function this.SwitchView(index) --先执行上一面板关闭逻辑 local oldSelect oldSelect, curIndex = curIndex, index for i = 1, #this.contents do if oldSelect~=0 then this.contents[oldSelect].view:OnClose() break end end --切换预设显隐 for i = 1, #this.prefabs do this.prefabs[i].gameObject:SetActive(i == index)--切换子模块预设显隐 end --区分显示 if index==1 then this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.Compound_equip}) elseif index==2 then this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main}) elseif index==3 or index==4 or index==5 then this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main}) end this.RefreshHelpBtn() --执行子模块初始化 this.contents[index].view:OnShow(this) end --刷新魂印合成的方法 function this.UpdateCompoundPanel_SoulPrint(equipSign,index) this.contents[curIndex].view.ShowTitleEquipData(nil,equipSign,index) end --界面关闭时调用(用于子类重写) function CompoundPanel:OnClose() for i = 1, #this.contents do this.contents[i].view:OnClose() end end --界面销毁时调用(用于子类重写) function CompoundPanel:OnDestroy() SubUIManager.Close(this.upView) for i = 1, #this.contents do this.contents[i].view:OnDestroy() this.spLoader:Destroy() end for k, v in pairs(redPointList) do ClearRedPointObject(k,v) end end return CompoundPanel