160 lines
5.9 KiB
Lua
160 lines
5.9 KiB
Lua
require("Base/BasePanel")
|
|
ChongBangPanel = Inherit(BasePanel)
|
|
local this = ChongBangPanel
|
|
local AcitvityShowTheme = ConfigManager.GetConfig(ConfigName.AcitvityShowTheme)
|
|
this.contents = {
|
|
[1] = {view = require("Modules/ChongBang/RankPanel"), panelName = "ChongBang"},
|
|
}
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local tabs = {}
|
|
local curRank = 1
|
|
local tabList = {
|
|
[1] = {default = "", select = "", activeType = 300, NetIndex = RANK_TYPE.ACTIVITY_MAIN_LEVEL_RANK},
|
|
[2] = {default = "", select = "", activeType = 306, NetIndex = RANK_TYPE.ACTIVITY_DIAMOND_CONSUME_RANK},
|
|
[3] = {default = "", select = "", activeType = 305, NetIndex = RANK_TYPE.ACTIVITY_ARENA_RANK},
|
|
[4] = {default = "", select = "", activeType = 303, NetIndex = RANK_TYPE.ACTIVITY_VIRTUAL_BATTLE_RANK},
|
|
[5] = {default = "", select = "", activeType = 308, NetIndex = RANK_TYPE.ACTIVITY_GENERAL_PROGRESS_RANK},
|
|
[6] = {default = "", select = "", activeType = 304, NetIndex = RANK_TYPE.ACTIVITY_DEF_TRAINING_RANK},
|
|
[7] = {default = "", select = "", activeType = 307, NetIndex = RANK_TYPE.ACTIVITY_SUPPORT_PROGRESS_RANK},
|
|
[8] = {default = "", select = "", activeType = 309, NetIndex = RANK_TYPE.ACTIVITY_ADJUTANT_PROGRESS_RANK},
|
|
[9] = {default = "", select = "", activeType = 302, NetIndex = RANK_TYPE.ACTIVITY_HERO_FORCE_RANK},
|
|
[10] = {default = "", select = "", activeType = 301, NetIndex = RANK_TYPE.ACTIVITY_FORCE_RANK},
|
|
}
|
|
function this:InitComponent()
|
|
this.HeadFrameView = SubUIManager.Open(SubUIConfig.PlayerHeadFrameView, this.gameObject.transform)
|
|
this.UpView = SubUIManager.Open(SubUIConfig.UpView, this.transform, { showType = UpViewOpenType.ShowRight })
|
|
this.btnBack = Util.GetGameObject(this.gameObject, "btnBack")
|
|
this.GetTabInfo()
|
|
this.tabbox = Util.GetGameObject(this.gameObject, "tabs/viewPort")
|
|
this.PageTabCtrl = TabBox.New()
|
|
this.PageTabCtrl:SetTabAdapter(this.PageTabAdapter)
|
|
this.PageTabCtrl:SetTabIsLockCheck(this.PageTabIsLockCheck)
|
|
this.PageTabCtrl:SetChangeTabCallBack(this.OnPageTabChange)
|
|
this.time = Util.GetGameObject(this.gameObject, "layout/ChongBang/time/Text"):GetComponent("Text")
|
|
this.prefabs = {}
|
|
for i = 1,#this.contents do
|
|
this.prefabs[i] = Util.GetGameObject(this.gameObject, this.contents[i].panelName)
|
|
this.contents[i].view:InitComponent(Util.GetGameObject(this.gameObject, this.contents[i].panelName))
|
|
end
|
|
end
|
|
|
|
function this:BindEvent()
|
|
Util.AddClick(this.btnBack, function()
|
|
this:ClosePanel()
|
|
end)
|
|
for i = 1, #this.contents do
|
|
this.contents[i].view:BindEvent()
|
|
end
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function this:AddListener()
|
|
for i = 1, #this.contents do
|
|
this.contents[i].view:AddListener()
|
|
end
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function this:RemoveListener()
|
|
for i = 1, #this.contents do
|
|
this.contents[i].view:RemoveListener()
|
|
end
|
|
end
|
|
|
|
-- 打开时调用
|
|
function this:OnOpen(index)
|
|
curRank = index and index or 1
|
|
this.PageTabCtrl:Init(this.tabbox, tabList, curRank)
|
|
end
|
|
|
|
function this:OnShow()
|
|
this.PageTabCtrl:ChangeTab(curRank)
|
|
this.contents[1].view:OnShow(this, tabList[curRank].activeType, tabList[curRank].NetIndex)
|
|
local curType = tabList[curRank].activeType
|
|
this:OnShowData(curType)
|
|
this:SetTime()
|
|
end
|
|
local endtime = 0
|
|
function this:SetTime()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
local timeDown = endtime
|
|
this.time.text = GetLanguageStrById(12321)..TimeToDHMS(timeDown)
|
|
self.timer = Timer.New(function()
|
|
timeDown = timeDown - 1
|
|
if timeDown < 1 then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
this.time.text = GetLanguageStrById(12321)..TimeToDHMS(0)
|
|
return
|
|
end
|
|
this.time.text = GetLanguageStrById(12321)..TimeToDHMS(timeDown)
|
|
end, 1, -1, true)
|
|
self.timer:Start()
|
|
end
|
|
local allData = {}
|
|
function this:OnShowData(curType)
|
|
allData = OperatingManager.InitLeiJiChongZhiData(curType)
|
|
if allData then
|
|
endtime = ActivityGiftManager.GetTaskEndTime(curType) - GetTimeStamp()
|
|
end
|
|
-- CheckRedPointStatus(RedPointType.DynamicActRecharge)
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function this:OnClose()
|
|
for i = 1, #this.contents do
|
|
this.contents[i].view:OnClose()
|
|
end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function this:OnDestroy()
|
|
SubUIManager.Close(this.HeadFrameView)
|
|
SubUIManager.Close(this.UpView)
|
|
for i = 1, #this.contents do
|
|
this.contents[i].view:OnDestroy()
|
|
end
|
|
end
|
|
|
|
-- tab按钮自定义显示设置
|
|
function this.PageTabAdapter(tab, index, status)
|
|
Util.GetGameObject(tab, "icon"):GetComponent("Image").sprite = Util.LoadSprite(tabList[index].default)
|
|
Util.GetGameObject(tab, "selected/icon"):GetComponent("Image").sprite = Util.LoadSprite(tabList[index].select)
|
|
Util.GetGameObject(tab, "selected"):SetActive(status == "select")
|
|
-- local redpoint = Util.GetGameObject(tab, "redPoint")
|
|
|
|
tab:SetActive(ActivityGiftManager.GetActivityIdByType(tabList[index].activeType) > 0)
|
|
end
|
|
|
|
-- tab可用性检测
|
|
function this.PageTabIsLockCheck(index)
|
|
return false
|
|
end
|
|
|
|
-- tab改变事件
|
|
function this.OnPageTabChange(index)
|
|
curRank = index
|
|
-- for i = 1, #this.prefabs do
|
|
-- this.prefabs[i].gameObject:SetActive(i == index)
|
|
-- end
|
|
-- this.contents[index].view:OnShow()
|
|
this.HeadFrameView:OnShow()
|
|
this.contents[1].view:OnShow(this, tabList[curRank].activeType, tabList[curRank].NetIndex)
|
|
end
|
|
|
|
function this.GetTabInfo()
|
|
for i = 1, #tabList do
|
|
local data = AcitvityShowTheme[tabList[i].activeType]
|
|
if not data then
|
|
LogError("AcitvityShowTheme请配置"..tabList[i].activeType)
|
|
else
|
|
tabList[i].default = GetPictureFont(data.TabDefault)
|
|
tabList[i].select = GetPictureFont(data.TabSelect)
|
|
end
|
|
end
|
|
end
|
|
|
|
return ChongBangPanel |