183 lines
5.9 KiB
Lua
183 lines
5.9 KiB
Lua
require("Base/BasePanel")
|
||
FestivalActivityPanel = Inherit(BasePanel)
|
||
local this = FestivalActivityPanel
|
||
local _CurPageIndex = 1
|
||
local GlobalActConfig = ConfigManager.GetConfig(ConfigName.GlobalActivity)
|
||
local AcitvityShowTheme = ConfigManager.GetConfig(ConfigName.AcitvityShowTheme)
|
||
local TabBox = require("Modules/Common/TabBox")
|
||
local tabs = {}
|
||
this.contents = {
|
||
[1] = {view = require("Modules/FestivalActivity/Festival_Login"), panelName = "page_1"},
|
||
[2] = {view = require("Modules/FestivalActivity/Festival_Task"), panelName = "page_2"},
|
||
[3] = {view = require("Modules/FestivalActivity/Festival_Gift"), panelName = "page_3"},
|
||
[4] = {view = require("Modules/FestivalActivity/Festival_Recharge"), panelName = "page_4"},
|
||
}
|
||
--初始化组件(用于子类重写)
|
||
function FestivalActivityPanel:InitComponent()
|
||
this.close = Util.GetGameObject(self.gameObject,"btnBack")
|
||
this.tabbox = Util.GetGameObject(self.gameObject, "tabbox")
|
||
this.InitTab()
|
||
this.PageTabCtrl = TabBox.New()
|
||
this.PageTabCtrl:SetTabAdapter(this.PageTabAdapter)
|
||
this.PageTabCtrl:SetTabIsLockCheck(this.PageTabIsLockCheck)
|
||
this.PageTabCtrl:SetChangeTabCallBack(this.OnPageTabChange)
|
||
|
||
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, this.contents[i].panelName))
|
||
end
|
||
|
||
this.PlayerHeadFrameView = SubUIManager.Open(SubUIConfig.PlayerHeadFrameView, self.gameObject.transform)
|
||
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform)
|
||
end
|
||
|
||
-- tab按钮自定义显示设置
|
||
function this.PageTabAdapter(tab, index, status)
|
||
local img = Util.GetGameObject(tab, "icon"):GetComponent("Image")
|
||
local selected = Util.GetGameObject(tab, "selected")
|
||
img.sprite = Util.LoadSprite(tabs[index].default)
|
||
Util.GetGameObject(selected, "icon"):GetComponent("Image").sprite = Util.LoadSprite(tabs[index].select)
|
||
selected:SetActive(status == "select")
|
||
|
||
local id = ActivityGiftManager.IsActivityTypeOpen(tabs[index].ActType)
|
||
if id and id > 0 and ActivityGiftManager.IsQualifiled(tabs[index].ActType) then
|
||
tab.gameObject:SetActive(true)
|
||
else
|
||
tab.gameObject:SetActive(false)
|
||
end
|
||
end
|
||
|
||
-- tab可用性检测
|
||
function this.PageTabIsLockCheck(index)
|
||
return false
|
||
end
|
||
|
||
-- tab改变事件
|
||
function this.OnPageTabChange(index)
|
||
_CurPageIndex = index
|
||
|
||
for i = 1, #this.prefabs do
|
||
this.prefabs[i].gameObject:SetActive(i == index)--切换子模块预设显隐
|
||
end
|
||
this.contents[index].view:OnShow(this)
|
||
this.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = tabs[index].panelType })
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function FestivalActivityPanel:BindEvent()
|
||
Util.AddClick(this.close,function ()
|
||
self:ClosePanel()
|
||
end)
|
||
for i = 1, #this.contents do
|
||
this.contents[i].view:BindEvent()
|
||
end
|
||
end
|
||
|
||
--添加事件监听(用于子类重写)
|
||
function FestivalActivityPanel:AddListener()
|
||
for i = 1, #this.contents do
|
||
this.contents[i].view:AddListener()
|
||
end
|
||
end
|
||
|
||
--移除事件监听(用于子类重写)
|
||
function FestivalActivityPanel:RemoveListener()
|
||
for i = 1, #this.contents do
|
||
this.contents[i].view:RemoveListener()
|
||
end
|
||
end
|
||
|
||
--界面打开时调用(用于子类重写)
|
||
function FestivalActivityPanel:OnOpen(index)
|
||
_CurPageIndex = index and index or 1
|
||
|
||
this.PageTabCtrl:Init(this.tabbox, tabs, _CurPageIndex)
|
||
|
||
for i = 1, #tabs do
|
||
local go = Util.GetGameObject(this.tabbox, "box").transform:GetChild(i - 1).gameObject
|
||
BindRedPointObject(tabs[i].rpType, Util.GetGameObject(go, "redPoint"))
|
||
end
|
||
end
|
||
|
||
function FestivalActivityPanel:OnShow()
|
||
this.PageTabCtrl:ChangeTab(_CurPageIndex)
|
||
this.contents[_CurPageIndex].view:OnShow()
|
||
this.PlayerHeadFrameView:OnShow(true)
|
||
end
|
||
|
||
--界面关闭时调用(用于子类重写)
|
||
function FestivalActivityPanel:OnClose()
|
||
for i = 1, #this.contents do
|
||
this.contents[i].view:OnClose()
|
||
end
|
||
|
||
for i = 1, #tabs do
|
||
ClearRedPointObject(tabs[i].rpType)
|
||
end
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function FestivalActivityPanel:OnDestroy()
|
||
SubUIManager.Close(this.PlayerHeadFrameView)
|
||
SubUIManager.Close(this.UpView)
|
||
for i = 1, #this.contents do
|
||
this.contents[i].view:OnDestroy()
|
||
end
|
||
tabs = {}
|
||
end
|
||
|
||
local ActTypes = {
|
||
ActivityTypeDef.Festival_Login,
|
||
ActivityTypeDef.Festival_Task,
|
||
ActivityTypeDef.Festival_Gift,
|
||
ActivityTypeDef.Festival_Recharge
|
||
}
|
||
|
||
local RpType = {
|
||
RedPointType.Festival_rpLogin,
|
||
RedPointType.Festival_rpTask,
|
||
RedPointType.Festival_rpGift,
|
||
RedPointType.Festival_rpRecharge,
|
||
}
|
||
|
||
function this.InitTab()
|
||
for _, type in ipairs(ActTypes) do
|
||
local id, rpType, panelType, showArtId
|
||
local addState = true
|
||
id = ActivityGiftManager.IsActivityTypeOpen(type)
|
||
if id then
|
||
showArtId = GlobalActConfig[id].ShowArt
|
||
else
|
||
addState = false
|
||
end
|
||
rpType = RpType[_]
|
||
|
||
if addState then
|
||
local default, lock, select
|
||
if AcitvityShowTheme[showArtId] then
|
||
default = GetPictureFont(AcitvityShowTheme[showArtId].TabDefault)
|
||
lock = AcitvityShowTheme[showArtId].TabLock
|
||
select = GetPictureFont(AcitvityShowTheme[showArtId].TabSelect)
|
||
else
|
||
default = ""
|
||
lock = ""
|
||
select = ""
|
||
LogRed("AcitvityShowTheme找不到活动:<color=green>"..id.."</color>对应的showArtId")
|
||
end
|
||
table.insert(tabs, {
|
||
Id = id,
|
||
default = default,
|
||
lock = lock,
|
||
select = select,
|
||
rpType = rpType,
|
||
panelType = panelType,
|
||
ActType = type,
|
||
tabIndex = _,
|
||
})
|
||
end
|
||
end
|
||
end
|
||
|
||
return FestivalActivityPanel |