sk-client/Assets/ManagedResources/~Lua/Modules/Operating/OperatingTokensPanel.lua

208 lines
5.8 KiB
Lua

---@class OperatingPanel
OperatingTokensPanel = Inherit(BasePanel)
local this = OperatingTokensPanel
local OperatingTokenGiftPackPage = require("Modules/Operating/OperatingTokenGiftPackPage")
local btnString={GetLanguageStrById(34010400),GetLanguageStrById(34010401),GetLanguageStrById(34010402),GetLanguageStrById(34010403),GetLanguageStrById(34010404)}
--显示类型 type 面板类型 body 显示页签索引
local ShowType = {
Welfare = {
type = 1,
body = {
1, 2, 5, 9, 3, 10, 11, 13, 21
}
},--福利
MonthFund = {
type = 2,
body = {
7, 8, 12, 14, 15, 16, 17, 18, 19, 20
}
}--激励计划
}
--tab 对应 page
local TabToContent = {
[1] = 1,
[2] = 1,
[3] = 1,
[4] = 1,
[5] = 1,
}
local kMaxTab = #TabToContent
local curIndex = 0
local showType
function OperatingTokensPanel:InitComponent()
self.btnBack = Util.GetGameObject(self.gameObject, "bg/btnBack")
self.tabsContent = Util.GetGameObject(self.gameObject, "bg/tabList/viewPort/tabsContent"):GetComponent("RectTransform")
self.operateTabs = {}
self.selectTabs = {}
for i = 1, kMaxTab do
self.operateTabs[i] = Util.GetGameObject(self.tabsContent.transform, "tabs_" .. i)
Util.GetGameObject(self.operateTabs[i], "Image"):GetComponent("Text").text=btnString[i]
self.selectTabs[i] = Util.GetGameObject(self.operateTabs[i], "selected")
Util.GetGameObject(self.selectTabs[i], "Image"):GetComponent("Text").text=btnString[i]
end
self.selectTabIndex = -1
self.operatingContents = {
[1] = OperatingTokenGiftPackPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_1")),
}
table.walk(self.operatingContents, function(content)
content:OnHide()
end)
self.HeadFrameView = SubUIManager.Open(SubUIConfig.PlayerHeadFrameView, self.gameObject.transform)
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform, { showType = UpViewOpenType.ShowRight, UpViewConfigId = 2 })
end
function OperatingTokensPanel:BindEvent()
Util.AddClick(self.btnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
for i = 1, kMaxTab do
Util.AddClick(self.operateTabs[i], function()
curIndex = i
this:OnTabChanged()
end)
end
this:BindRedPoint()
end
function OperatingTokensPanel:OnOpen(data)
for i = 1, #self.operatingContents do
self.operatingContents[i]:OnHide()
end
data = data and data or {}
showType = data.showType or 1
curIndex=1
this:RefreshTabStatus()
if data and data.tabIndex then
--curIndex = data.tabIndex
else
this:GetPriorityIndex()
end
end
function OperatingTokensPanel:OnShow()
self.HeadFrameView:OnShow()
self.UpView:OnOpen({showType = UpViewOpenType.ShowRight, UpViewConfigId = 2 })
SoundManager.PlayMusic(SoundConfig.BGM_Main)
this:CheckRedPoint()
this:RefreshTabStatus()
if not curIndex then
this:GetPriorityIndex()
end
this:OnTabChanged()
end
function OperatingTokensPanel:OnSortingOrderChange()
end
--添加事件监听(用于子类重写)
function OperatingTokensPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.MonthCard.OnMonthCardUpdate, this.RefreshActivity)
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityOpenOrClose, this.RefreshActivity)
Game.GlobalEvent:AddEvent(GameEvent.WarOrder.UnLock, this.RefreshActivity)
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnFuncStateChange, this.RefreshActivity)
end
--移除事件监听(用于子类重写)
function OperatingTokensPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.MonthCard.OnMonthCardUpdate, this.RefreshActivity)
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnActivityOpenOrClose, this.RefreshActivity)
Game.GlobalEvent:RemoveEvent(GameEvent.WarOrder.UnLock, this.RefreshActivity)
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.OnFuncStateChange, this.RefreshActivity)
end
function OperatingTokensPanel:OnClose()
end
function OperatingTokensPanel:OnDestroy()
SubUIManager.Close(self.HeadFrameView)
SubUIManager.Close(self.UpView)
--界面摧毁的时候再清理
this:ClearRedPoint()
end
--切换面板
function this:OnTabChanged()
--LogError("curIndex======================"..curIndex)
for i, select in ipairs(self.selectTabs) do
select:SetActive(i == curIndex)
end
for i = 1, #self.operatingContents do
self.operatingContents[i]:OnHide()
end
self.operatingContents[TabToContent[curIndex]]:OnShow(self.sortingOrder,curIndex)
end
--刷新活动
function this:RefreshActivity()
this:CheckRedPoint()
this:RefreshTabStatus()
if this.operateTabs[curIndex].gameObject.activeSelf then
this:OnTabChanged()
else
this:GetPriorityIndex()
this:OnTabChanged()
end
end
--刷新活动
function this:RefreshTabStatus()
-- for n = 1, #self.operateTabs do
-- self.operateTabs[n]:SetActive(false)
-- end
end
--获取活动
function this:GetPriorityIndex()
if showType == 1 then
for i = 1, #ShowType.Welfare.body do
if this.operateTabs[ShowType.Welfare.body[i]].gameObject.activeSelf then
curIndex = ShowType.Welfare.body[i]
return
end
end
elseif showType == 2 then
for i = 1, #ShowType.MonthFund.body do
if this.operateTabs[ShowType.MonthFund.body[i]].gameObject.activeSelf then
curIndex = ShowType.MonthFund.body[i]
return
end
end
end
end
function this:BindRedPoint()
end
function this:ClearRedPoint()
end
function this:CheckRedPoint()
end
return OperatingTokensPanel