local UISubjectMonthHonorOrderMain = UIViewClass() local EventSystem = require('Event/EventSystem') local Tab = { Reward = 1, Task = 2, } function UISubjectMonthHonorOrderMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_SubjectMonth_UpdateHonorOrderInfo, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:RegistSystemEvent(EventID.UI_SubjectMonth_UpdateHonorOrderInfo, self.RefreshPanel) self.battlePassID = CTL.MonthHonorOrder.GetBattlePassId() self.battlePassCfg = DataSheetManager.VersionsBattlePassData:GetDataByBattlePassID(self.battlePassID) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_VersionsActivity_ChildName2) UIUtils.SetLabelText(self.txt_Title, Const_IDS[self.battlePassCfg.TitleText]) UTL.Item.SetLocalizationImage(self.loc_Title, self.img_Title, self.battlePassCfg.TitlePicture) self.activityId = MDL.SubjectMonth.GetActivityId() self:RefreshPanel() self:OnButtonClicked(self.btn_Reward) end function UISubjectMonthHonorOrderMain:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UISubjectMonthHonorOrderMain:RefreshPanel() if MDL.MonthHonorOrder.IsPlayNewLevelEffect() then self.effect:PlayUIEffect() end UIUtils.SetLabel(self.txt_lv, MDL.MonthHonorOrder.GetLevel()) local score = MDL.MonthHonorOrder.GetScore() local eachLevelScore = self.battlePassCfg.EachLevelExp if CTL.MonthHonorOrder.IsMaxLevel() then UIUtils.SetLabel(self.txt_Num, "") self.slider_Score.value = 1 else UIUtils.SetLabel(self.txt_Num, string.format("%s/%s", score, eachLevelScore)) self.slider_Score.value = score / eachLevelScore end self.renderModel:ShowWeapon(UTL.UIRender.LoadShowWeaponDataWithAppearance(self.battlePassCfg.GrandValue1, self.battlePassCfg.GrandValue2)) UIUtils.SetLabelText(self.txt_Name, Const_IDS[self.battlePassCfg.GrandText]) self:RefreshBtn() self:RefreshLeftTime() self:RefreshRedPoint() end function UISubjectMonthHonorOrderMain:CloseSubView() self.subView:CloseAll() end function UISubjectMonthHonorOrderMain:RefreshBtn() if self.tab == Tab.Reward then UIUtils.SetActive(self.btn_Upgrade, not CTL.MonthHonorOrder.IsAllGradeUnlock()) UIUtils.SetActive(self.btn_Receive, CTL.MonthHonorOrder.CanReceiveAnyLevelReward()) elseif self.tab == Tab.Task then UIUtils.SetActive(self.btn_Upgrade, false) UIUtils.SetActive(self.btn_Receive, CTL.MonthHonorOrder.CanReceiveAnyTaskReward()) end end function UISubjectMonthHonorOrderMain:RefreshLeftTime() local activityType = MDL.OperationActivity.ActivityType.SubjectMonth local activityInfo = MDL.OperationActivity.GetOperationActivityInfo(activityType, self.activityId) local leftTime = activityInfo.endTime - UTL.Time.GetServerTimestamp() local dayStr = string.FormatByIdsId(Const_IDS.IDS_KingChallenge_Hint3, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_1)) local hourStr = string.FormatByIdsId(Const_IDS.IDS_KingChallenge_Hint3, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_2)) local minStr = string.FormatByIdsId(Const_IDS.IDS_KingChallenge_Hint3, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_3)) local secStr = string.FormatByIdsId(Const_IDS.IDS_KingChallenge_Hint3, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_4)) self.txt_CountDown:SetDHMSStr(dayStr, hourStr, minStr, secStr) self.txt_CountDown:ResetAndBeginCustomTimer(false, leftTime, 0, nil) end function UISubjectMonthHonorOrderMain:RefreshRedPoint() self.btn_Reward:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.SubjectMonth_HonorOrder_Reward)) self.btn_Task:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.SubjectMonth_HonorOrder_Task)) end function UISubjectMonthHonorOrderMain:OnButtonClicked(comp) if 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.MonthHonorOrder }) elseif comp == self.btn_Reward then self:CloseSubView() self.tab = Tab.Reward self.state_btn:SetState(1) self.state_btn:SetState(2) self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISubjectMonthHonorOrderReward)) self:RefreshBtn() elseif comp == self.btn_Task then self:CloseSubView() self.tab = Tab.Task self.state_btn:SetState(0) self.state_btn:SetState(3) self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISubjectMonthHonorOrderTask)) self:RefreshBtn() elseif comp == self.btn_Receive then if self.tab == Tab.Reward then if CTL.MonthHonorOrder.CanReceiveAnyLevelReward() then MDL.MonthHonorOrder.GetSubjectMonthBattlePassLevelRewardReq(0, 0, true) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_ClimbTower_NoRewardTip) end elseif self.tab == Tab.Task then if CTL.MonthHonorOrder.CanReceiveAnyTaskReward() then MDL.MonthHonorOrder.GetSubjectMonthBattlePassTaskRewardReq(0, 0, true) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_ClimbTower_NoRewardTip) end end elseif comp == self.btn_Upgrade then UIManager.OpenView(Const_UI_Lua.UIEnum.UISubjectMonthHonorOrderBuy) end end return UISubjectMonthHonorOrderMain