134 lines
4.9 KiB
Lua
134 lines
4.9 KiB
Lua
|
local next = next
|
||
|
local XUiActivityBase = XLuaUiManager.Register(XLuaUi, "UiActivityBase")
|
||
|
|
||
|
XUiActivityBase.BtnTabIndex = {
|
||
|
Activity = 1,
|
||
|
Notice = 2,
|
||
|
ActivityNotice = 3,
|
||
|
ActivityLink = 4,
|
||
|
}
|
||
|
|
||
|
XUiActivityBase.GameNoticeType = {
|
||
|
ActivityNotice = 0,
|
||
|
Notice = 1,
|
||
|
}
|
||
|
|
||
|
function XUiActivityBase:OnAwake()
|
||
|
self:InitAutoScript()
|
||
|
|
||
|
local tabGroup = {
|
||
|
self.BtnActivity,
|
||
|
self.BtnGameNotice,
|
||
|
self.BtnActivityNotice,
|
||
|
self.BtnLink,
|
||
|
}
|
||
|
self.PanelType:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end)
|
||
|
self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin)
|
||
|
|
||
|
XRedPointManager.AddRedPointEvent(self.BtnActivity, self.OnCheckNewActivities, self, { XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_ACTIVITIES })
|
||
|
XRedPointManager.AddRedPointEvent(self.BtnGameNotice, self.OnCheckNewGameNotices, self, { XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_NOTICES })
|
||
|
XRedPointManager.AddRedPointEvent(self.BtnActivityNotice, self.OnCheckNewActivityNotices, self, { XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_ACTIVITY_NOTICES })
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:OnGetEvents()
|
||
|
return { XEventId.EVENT_UIDIALOG_VIEW_ENABLE }
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:OnNotify(evt)
|
||
|
if evt == XEventId.EVENT_UIDIALOG_VIEW_ENABLE then
|
||
|
self:Close()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:OnCheckNewGameNotices(count)
|
||
|
self.BtnGameNotice:ShowReddot(count >= 0)
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:OnCheckNewActivities(count)
|
||
|
self.BtnActivity:ShowReddot(count >= 0)
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:OnCheckNewActivityNotices(count)
|
||
|
self.BtnActivityNotice:ShowReddot(count >= 0)
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:OnStart(skipIndex, subSkipIndex, subSkipId)
|
||
|
local defaultSelectIndex = skipIndex
|
||
|
self.SubSkipIndex = subSkipIndex
|
||
|
self.SubSkipId = subSkipId
|
||
|
self.ActivityGroupInfos = XDataCenter.ActivityManager.GetActivityGroupInfos()
|
||
|
|
||
|
local HaveGameNotice = XDataCenter.NoticeManager.CheckHaveNotice(XUiActivityBase.GameNoticeType.Notice)
|
||
|
local HaveActivityNotice = XDataCenter.NoticeManager.CheckHaveNotice(XUiActivityBase.GameNoticeType.ActivityNotice)
|
||
|
local HaveActivity = next(self.ActivityGroupInfos)
|
||
|
|
||
|
if HaveActivity then
|
||
|
defaultSelectIndex = defaultSelectIndex or XUiActivityBase.BtnTabIndex.Activity
|
||
|
elseif HaveActivityNotice then
|
||
|
defaultSelectIndex = defaultSelectIndex or XUiActivityBase.BtnTabIndex.ActivityNotice
|
||
|
else
|
||
|
defaultSelectIndex = defaultSelectIndex or XUiActivityBase.BtnTabIndex.Activity
|
||
|
end
|
||
|
|
||
|
self.BtnGameNotice:SetDisable(not HaveGameNotice)
|
||
|
self.BtnActivityNotice:SetDisable(not HaveActivityNotice)
|
||
|
|
||
|
if defaultSelectIndex then
|
||
|
self.PanelType:SelectIndex(defaultSelectIndex)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:InitAutoScript()
|
||
|
self:AutoAddListener()
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:AutoAddListener()
|
||
|
self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick)
|
||
|
self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick)
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:OnBtnBackClick()
|
||
|
self:Close()
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:OnBtnMainUiClick()
|
||
|
XLuaUiManager.RunMain()
|
||
|
end
|
||
|
|
||
|
function XUiActivityBase:OnClickTabCallBack(tabIndex)
|
||
|
if self.SelectedIndex and self.SelectedIndex == tabIndex then
|
||
|
return
|
||
|
end
|
||
|
|
||
|
if tabIndex == XUiActivityBase.BtnTabIndex.Activity then
|
||
|
self:OpenOneChildUi("UiActivityBaseChild", self.ActivityGroupInfos, self.SubSkipIndex, self.SubSkipId)
|
||
|
elseif tabIndex == XUiActivityBase.BtnTabIndex.Notice then
|
||
|
if not XDataCenter.NoticeManager.CheckHaveNotice(XUiActivityBase.GameNoticeType.Notice) then
|
||
|
XUiManager.TipText("NoInGameNotice")
|
||
|
return
|
||
|
end
|
||
|
|
||
|
if not XLuaUiManager.IsUiShow("UiGameNotice") then
|
||
|
self:OpenOneChildUi("UiGameNotice", self, self.SubSkipIndex, self.SubSkipId, XUiActivityBase.GameNoticeType.Notice)
|
||
|
else
|
||
|
CsXGameEventManager.Instance:Notify(XEventId.EVENT_NOTICE_TYPE_CHANAGE, XUiActivityBase.GameNoticeType.Notice)
|
||
|
end
|
||
|
elseif tabIndex == XUiActivityBase.BtnTabIndex.ActivityNotice then
|
||
|
if not XDataCenter.NoticeManager.CheckHaveNotice(XUiActivityBase.GameNoticeType.ActivityNotice) then
|
||
|
XUiManager.TipText("NoActivities")
|
||
|
return
|
||
|
end
|
||
|
|
||
|
if not XLuaUiManager.IsUiShow("UiGameNotice") then
|
||
|
self:OpenOneChildUi("UiGameNotice", self, self.SubSkipIndex, self.SubSkipId, XUiActivityBase.GameNoticeType.ActivityNotice)
|
||
|
else
|
||
|
CsXGameEventManager.Instance:Notify(XEventId.EVENT_NOTICE_TYPE_CHANAGE, XUiActivityBase.GameNoticeType.ActivityNotice)
|
||
|
end
|
||
|
elseif tabIndex == XUiActivityBase.BtnTabIndex.ActivityLink then
|
||
|
self:OpenOneChildUi("UiActivityBaseLink")
|
||
|
end
|
||
|
self.SubSkipIndex = nil
|
||
|
self.SubSkipId = nil
|
||
|
|
||
|
self.SelectedIndex = tabIndex
|
||
|
end
|