166 lines
4.7 KiB
Lua
166 lines
4.7 KiB
Lua
---@class OperatingPanel
|
|
WanYuanPanel = Inherit(BasePanel)
|
|
local this = WanYuanPanel
|
|
|
|
local LoginMoneyPage = require("Modules/WanYuan/LoginMoney")--登录礼金
|
|
local LevelMoneyPage = require("Modules/WanYuan/LevelMoney")--等级礼金
|
|
|
|
--local WarOrder = require("Modules/Operating/WarOrder")--战令
|
|
|
|
--tab 对应 page
|
|
local TabToContent = {
|
|
[1] = 1,
|
|
[2] = 2,
|
|
}
|
|
local Tabtype = {
|
|
[1] = ActivityTypeDef.LoginLiJin,
|
|
[2] = ActivityTypeDef.LevelLiJin,
|
|
}
|
|
|
|
local kMaxTab = #TabToContent
|
|
local curIndex = 0
|
|
local showType
|
|
|
|
function WanYuanPanel: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)
|
|
self.selectTabs[i] = Util.GetGameObject(self.operateTabs[i], "selected")
|
|
end
|
|
self.selectTabIndex = -1
|
|
self.operatingContents = {
|
|
[1] = LoginMoneyPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_1")),
|
|
[2] = LevelMoneyPage.new(self, Util.GetGameObject(self.transform, "bg/pageContent/page_2")),
|
|
}
|
|
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 })
|
|
|
|
|
|
end
|
|
|
|
function WanYuanPanel: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 WanYuanPanel:OnOpen(index)
|
|
for i = 1, #self.operatingContents do
|
|
self.operatingContents[i]:OnHide()
|
|
end
|
|
this:RefreshTabStatus()
|
|
curIndex = index
|
|
|
|
end
|
|
|
|
function WanYuanPanel:OnShow()
|
|
self.HeadFrameView:OnShow()
|
|
self.UpView:OnOpen({showType = UpViewOpenType.ShowRight, panelType = PanelType.Main })
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Main)
|
|
|
|
this:CheckRedPoint()
|
|
this:RefreshTabStatus()
|
|
this:OnTabChanged()
|
|
end
|
|
|
|
function WanYuanPanel:OnSortingOrderChange()
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function WanYuanPanel:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.WanYuan.Refresh, this.RefreshActivity)
|
|
end
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function WanYuanPanel:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.WanYuan.Refresh, this.RefreshActivity)
|
|
end
|
|
|
|
function WanYuanPanel:OnClose()
|
|
|
|
end
|
|
|
|
function WanYuanPanel:OnDestroy()
|
|
SubUIManager.Close(self.HeadFrameView)
|
|
SubUIManager.Close(self.UpView)
|
|
--界面摧毁的时候再清理
|
|
this:ClearRedPoint()
|
|
end
|
|
|
|
--切换面板
|
|
function this:OnTabChanged()
|
|
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()
|
|
|
|
end
|
|
|
|
--刷新活动
|
|
function this.RefreshActivity()
|
|
WanYuanPanel:CheckRedPoint()
|
|
end
|
|
|
|
--刷新活动
|
|
function this:RefreshTabStatus()
|
|
for n = 1, #self.operateTabs do
|
|
self.operateTabs[n]:SetActive(false)
|
|
end
|
|
local id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.LoginLiJin)
|
|
local id2 = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.LevelLiJin)
|
|
-- Log("id 00 "..id)
|
|
if id and id > 0 then --and ActivityGiftManager.IsQualifiled(tabs[index].ActType)
|
|
self.operateTabs[1]:SetActive(true)
|
|
end
|
|
if id2 and id2 > 0 then --and ActivityGiftManager.IsQualifiled(tabs[index].ActType)
|
|
self.operateTabs[2]:SetActive(true)
|
|
end
|
|
end
|
|
|
|
|
|
function this:BindRedPoint()
|
|
-- BindRedPointObject(RedPointType.GiftPage, Util.GetGameObject(self.operateTabs[1], "redPoint"))
|
|
-- BindRedPointObject(RedPointType.NobilityMonthCard, Util.GetGameObject(self.operateTabs[1], "redPoint"))
|
|
|
|
end
|
|
|
|
function this:ClearRedPoint()
|
|
-- ClearRedPointObject(RedPointType.CumulativeSignIn)
|
|
|
|
end
|
|
|
|
function this:CheckRedPoint()
|
|
-- CheckRedPointStatus(RedPointType.NobilityMonthCard)
|
|
for i = 1, kMaxTab do
|
|
local redPoint = Util.GetGameObject(self.operateTabs[i].transform, "redPoint")
|
|
if PrivilegeTurnManager.RefreShWanYuanRedPoint(Tabtype[i]) then
|
|
redPoint:SetActive(true)
|
|
else
|
|
redPoint:SetActive(false)
|
|
end
|
|
end
|
|
end
|
|
return WanYuanPanel |