local UISubjectMonthMain = UIViewClass() function UISubjectMonthMain:OnOpened(context) if not CTL.SubjectMonth.IsOpen() then self:CloseView() return end self:RegistSystemEvent(EventID.UI_SubjectMonth_UpdateSubjectMonthPreviewInfo, self.RefreshActivityPreview) self:RegistSystemEvent(EventID.UI_SubjectMonth_UpdateSubjectMonthInfo, self.RefreshSubActivityEntry) self:RegistSystemEvent(EventID.UI_SubjectMonth_UpdateBossChallengeInfo, self.RefreshSubActivityEntry) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.FairPlay_KingChallenge, self.RefreshKingChallengeEntryRedPoint) self.activityId = MDL.SubjectMonth.GetActivityId() local prefabData = CTL.SubjectMonth.GetVersionsPrefabData() UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[prefabData.ActivityName]) UIUtils.SetLabel(self.txt_Info, MDL.OperationActivity.GetTimePeriodDesc(MDL.OperationActivity.ActivityType.SubjectMonth, self.activityId)) MDL.SubjectMonth.OpenSubjectMonthPanelReq() self:RefreshSubActivityEntry() self:RefreshActivityPreview() self:RefreshKingChallengeEntryRedPoint() self:RefreshKingChallengeIcon() end function UISubjectMonthMain:RefreshSubActivityEntry() self.btn_SignIn:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.SubjectMonth_SignIn)) self.btn_BattlePass:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.SubjectMonth_HonorOrder)) if CTL.SubjectMonth.IsSubActivityOpen(MDL.SubjectMonth.SubActivityType.BossChallenge) then UIUtils.SetActive(self.btn_Challenge, true) self.btn_Challenge:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.SubjectMonth_BossChallenge) or CTL.MonthBossChallenge.IsShowNewBossTip()) else UIUtils.SetActive(self.btn_Challenge, false) end if CTL.Rogue.IsOpen() then UIUtils.SetActive(self.btn_Rogue, true) self.btn_Rogue:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.SubjectMonth_Rogue) or CTL.Rogue.IsShowNewLevelTip()) else UIUtils.SetActive(self.btn_Rogue, false) end end function UISubjectMonthMain:RefreshKingChallengeEntryRedPoint() self.btn_KingChallenge:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.FairPlay_KingChallenge)) end function UISubjectMonthMain:RefreshKingChallengeIcon() local bigSeasonCfg = DataSheetManager.KingChallengeSeason:GetDataByID(MDL.KingChallenge.GetCurBigSeasonId()) UIUtils.SetImageByAssetBundle(self.kingchallenge_icon, bigSeasonCfg.SeasonPic) if self.Loc_tittle.CurState == 1 then self.Loc_tittle:SetText(0, UIUtils.GetLocalizedTxt(Const_IDS[bigSeasonCfg.SeasonName])) else self.Loc_tittle:SetImage(0, bigSeasonCfg.SeasonArtName, true) end end function UISubjectMonthMain:RefreshActivityPreview() self.SortCompetitionData = CTL.SubjectMonth.GetSortCompetitionData() for i, v in ipairs(self.SortCompetitionData) do local id = v.id local cell = self.group_Preview[i] if not cell then cell = self:InstantiateCollection(self.group_Preview, self.cell_ActivityPreview.gameObject) end UIUtils.SetActive(cell.gameObject, true) local activityData = DataSheetManager.ActivityData:GetDataByID(id) UIUtils.SetImageByAssetBundle(cell.img_Icon, activityData.ActivityPicture) UIUtils.SetLabelText(cell.txt_Name, Const_IDS[activityData.Activity]) local previewInfo = MDL.SubjectMonth.GetActivityPreviewInfo(id) cell.effect_Reward:StopUIEffect() local isNotNil = IsProtoDataNotNil(previewInfo) if isNotNil and previewInfo.isForceEnd then UIUtils.SetLabel(cell.txt_Time, UTL.Color.FormatRedColor(UIUtils.GetLocalizedTxt(Const_IDS["IDS_WarZoneAuction_9"]))) elseif isNotNil and previewInfo.isReadSpecialIds then UIUtils.SetLabel(cell.txt_Time, UTL.Color.FormatGreenColor(UIUtils.GetLocalizedTxt(Const_IDS["IDS_BossChallenge_AboutToOpen"]))) elseif not isNotNil or previewInfo.isReadIds then UIUtils.SetLabel(cell.txt_Time, UTL.Color.FormatTextByColor("FFF596", Localization.GetOperationActivityLabel(v.competitionTimeText))) else local curTime = UTL.Time.GetServerTimestamp() if curTime < previewInfo.startTime then UIUtils.SetLabel(cell.txt_Time, UTL.Color.FormatGreenColor(os.date(UTL.Time.FormatDateEnum.YMD, previewInfo.startTime))) elseif curTime > previewInfo.endTime then UIUtils.SetLabel(cell.txt_Time, UTL.Color.FormatRedColor(UIUtils.GetLocalizedTxt(Const_IDS["IDS_WarZoneAuction_9"]))) else UIUtils.SetLabel(cell.txt_Time, UTL.Color.FormatGreenColor(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Activity_BalanceBattle_Ongoing"]))) cell.effect_Reward:PlayUIEffect() end end end for i = #self.SortCompetitionData + 1, #self.group_Preview do UIUtils.SetActive(self.group_Preview[i].gameObject, false) end end function UISubjectMonthMain:OnButtonClicked(comp) if comp == self.btn_SignIn then UIManager.OpenView(Const_UI_Lua.UIEnum.UISubjectMonthSignIn) elseif comp == self.btn_BattlePass then UIManager.OpenView(Const_UI_Lua.UIEnum.UISubjectMonthHonorOrderMain) elseif comp == self.btn_Challenge then CTL.MonthBossChallenge.SaveNewBossTipRecord() UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISubjectMonthChallenge) elseif comp == self.btn_Rogue then CTL.Rogue.SaveNewLevelTipRecord() UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISubjectMonthRogueMain) elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.SubjectMonth }) elseif comp == self.btn_KingChallenge then if not CTL.KingChallenge.IsShowKingChallengeEntry() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_168_WarnCode_Funtion_Not_Unlock) return end UIManager.OpenView(Const_UI_Lua.UIEnum.UIKingChallengeMainPanel) else for i, v in ipairs(self.group_Preview) do if comp == v.event_Click then CTL.SubjectMonth.GoActivity(self.SortCompetitionData[i].id) break end end end end function UISubjectMonthMain:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end return UISubjectMonthMain