local UISceneQuizMain = UIViewClass() local SceneQuizData = DataSheetManager.SceneQuizData:GetDataByModeTypeID(1) local PreliminaryTime = DataSheetManager.TimeRefresh:GetDataByID(SceneQuizData.PreliminaryTime).HMS local FinalTime = DataSheetManager.TimeRefresh:GetDataByID(SceneQuizData.FinalTime).HMS function UISceneQuizMain:OnOpened(context) self.activityId = MDL.SceneQuiz.CurActivityID self:RegistSystemEvent(EventID.UI_SceneQuiz_QuizModuleInfoRefresh, self.RefreshStageInfo) self:RegistSystemEvent(EventID.UI_SceneQuiz_MyInfoRefresh, self.RefreshStageInfo) self:RegistSystemEvent(EventID.UI_SceneQuiz_StageChange, self.RequestInfo) local _, preliminaryTime = UTL.Time.GetDateDescAndTime({ SceneQuizData.PreliminaryTime }) local _, finalTime = UTL.Time.GetDateDescAndTime({ SceneQuizData.FinalTime }) self.txt_PreliminaryTime.text = preliminaryTime self.txt_FinalTime.text = finalTime self.txt_TimeInfo:SetDHMSStr( string.FormatByIdsKey("IDS_SceneQuiz_MainHint_1", UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow)), string.FormatByIdsKey("IDS_SceneQuiz_MainHint_1", "{0}:{1}:{2}"), string.FormatByIdsKey("IDS_SceneQuiz_MainHint_1", "{0}:{1}"), string.FormatByIdsKey("IDS_SceneQuiz_MainHint_1", "{0}:{1}") ) self.txt_BtnHint:SetDHMSStr( string.FormatByIdsKey("IDS_SceneQuiz_MainHint_8", UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow)), string.FormatByIdsKey("IDS_SceneQuiz_MainHint_8", "{0}:{1}:{2}"), string.FormatByIdsKey("IDS_SceneQuiz_MainHint_8", "{0}:{1}"), string.FormatByIdsKey("IDS_SceneQuiz_MainHint_8", "{0}:{1}") ) self.isInit = true MDL.SceneQuiz.SceneQuizGetInfoReq() end function UISceneQuizMain:RequestInfo() MDL.SceneQuiz.SceneQuizGetInfoReq() end function UISceneQuizMain:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UISceneQuizMain:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.btn_Reward then CTL.SceneQuiz.OpenRewardPanel(self.activityId, {activityId = self.activityId}) elseif comp == self.btn_Join then --进入初赛 CTL.SceneQuiz.OpenPreliminaryView(self.activityId, {activityId = self.activityId}) elseif comp == self.btn_Watch then --观战 CTL.SceneQuiz.EnterSceneQuizFinals() elseif comp == self.btn_Enter then --进入决赛 CTL.SceneQuiz.EnterSceneQuizFinals() elseif comp == self.btn_Bet then CTL.SceneQuiz.OpenBetView(self.activityId, {activityId = self.activityId}) elseif comp == self.btn_Rank then CTL.SceneQuiz.OpenRankView(self.activityId, {activityId = self.activityId, rankType = false}) elseif comp == self.btn_Info or comp == self.btn_InfoLoc then -- 玩法说明 UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.SceneQuiz}) end end function UISceneQuizMain:RefreshStageInfo() local curStage = MDL.SceneQuiz.GetCurStage() local nextStageTime = MDL.SceneQuiz.GetTempStageEndTime() self.isFinal = MDL.SceneQuiz.GetIsFinal() if curStage == MDL.SceneQuiz.ScheduleStage.PreCompetition then --赛前准备阶段 self.state_Progress:SetState(0) self.state_Bottom:SetState(0) self.txt_NextTime:SetDHMSStr( UIUtils.GetLocalizedTxt(Const_IDS.IDS_SceneQuiz_MainHint_4) .. UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow), UIUtils.GetLocalizedTxt(Const_IDS.IDS_SceneQuiz_MainHint_4) .. "{0}:{1}:{2}", UIUtils.GetLocalizedTxt(Const_IDS.IDS_SceneQuiz_MainHint_4) .. "{0}:{1}", UIUtils.GetLocalizedTxt(Const_IDS.IDS_SceneQuiz_MainHint_4) .. "{0}:{1}" ) self.txt_NextTime:ResetAndBeginCustomTimer(false, nextStageTime - UTL.Time.GetServerTimestamp(), 0, nil) local _, time = UTL.Time.GetDateDescAndTime({ SceneQuizData.PreliminaryTime }) self.txt_Info.text = string.FormatByIdsKey("IDS_SceneQuiz_MainHint_3", time, SceneQuizData.PreliminaryNum) elseif curStage == MDL.SceneQuiz.ScheduleStage.Preliminary then --初赛阶段,如果处在主界面默认打开答题界面 self.state_Progress:SetState(1) self.state_Bottom:SetState(1) self.btn_Join:SetRedPoint(true) if self.isFocus and not self.isInit then CTL.SceneQuiz.OpenPreliminaryView(self.activityId, {activityId = self.activityId}) end elseif curStage == MDL.SceneQuiz.ScheduleStage.Bet then --押注阶段 self.state_Progress:SetState(2) self.state_Bottom:SetState(2) if self.isFinal then UIUtils.SetLabelText(self.txt_Info, Const_IDS.IDS_SceneQuiz_PreliminaryHint_2) else UIUtils.SetLabelText(self.txt_Info, Const_IDS.IDS_SceneQuiz_PreliminaryHint_3) end self.txt_NextTime:SetDHMSStr( UIUtils.GetLocalizedTxt(Const_IDS.IDS_SceneQuiz_MainHint_5) .. UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow), UIUtils.GetLocalizedTxt(Const_IDS.IDS_SceneQuiz_MainHint_5) .. "{0}:{1}:{2}", UIUtils.GetLocalizedTxt(Const_IDS.IDS_SceneQuiz_MainHint_5) .. "{0}:{1}", UIUtils.GetLocalizedTxt(Const_IDS.IDS_SceneQuiz_MainHint_5) .. "{0}:{1}" ) self.txt_NextTime:ResetAndBeginCustomTimer(false, UTL.Time.GetServerIntervalTimeByTimeId(SceneQuizData.FinalTime), 0, nil) self.btn_Bet:SetRedPoint(CTL.SceneQuiz.GetBetNum() < SceneQuizData.BetMaxNum) elseif curStage == MDL.SceneQuiz.ScheduleStage.Finals then --决赛阶段 local stageState = MDL.SceneQuiz.GetStageState() self.state_Progress:SetState(3) self.state_Bottom:SetState(3) if stageState == MDL.SceneQuiz.StageState.Prepare then --可以进入决赛 self.txt_BtnHint:ResetAndBeginCustomTimer(false, SceneQuizData.FinalJoinTime + UTL.Time.GetServerIntervalTimeByTimeId(SceneQuizData.FinalTime), 0, nil) UIUtils.SetActive(self.btn_Watch, not self.isFinal) self.btn_Watch:SetRedPoint(not self.isFinal) UIUtils.SetActive(self.btn_Enter, self.isFinal) self.btn_Enter:SetRedPoint(self.isFinal) elseif stageState == MDL.SceneQuiz.StageState.Doing then --决赛进入时间已过,不可进入决赛 self.txt_BtnHint:EndTimer() UIUtils.SetActive(self.btn_Watch, true) self.btn_Watch:SetRedPoint(true) UIUtils.SetActive(self.btn_Enter, false) self.btn_Enter:SetRedPoint(false) end elseif curStage == MDL.SceneQuiz.ScheduleStage.AfterCompetition then --赛后阶段 self.state_Progress:SetState(4) self.state_Bottom:SetState(4) self.txt_NextTime:SetDHMSStr( string.FormatByIdsKey("IDS_SceneQuiz_MainHint_1", UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow)), string.FormatByIdsKey("IDS_SceneQuiz_MainHint_1", "{0}:{1}:{2}"), string.FormatByIdsKey("IDS_SceneQuiz_MainHint_1", "{0}:{1}"), string.FormatByIdsKey("IDS_SceneQuiz_MainHint_1", "{0}:{1}") ) if nextStageTime and nextStageTime > 0 then --nextStageTime此时是到达下一次比赛开始的当天早上5点,所以需要加上决赛的时间再减去过天5点的时间 local time = nextStageTime - UTL.Time.GetServerTimestamp() + PreliminaryTime - DataSheetManager.TimeRefresh:GetDataByID(1).HMS self.txt_NextTime:ResetAndBeginCustomTimer(false, time, 0, nil) UIUtils.SetLabelText(self.txt_Info, Const_IDS.IDS_SceneQuiz_MainHint_9) else self.txt_NextTime:EndTimer() UIUtils.SetLabelText(self.txt_Info, Const_IDS.IDS_SceneQuiz_MainHint_12) end elseif curStage == MDL.SceneQuiz.ScheduleStage.None then --后续没有比赛了 self.state_Progress:SetState(5) self.state_Bottom:SetState(5) if nextStageTime and nextStageTime > 0 then self.txt_TimeInfo:ResetAndBeginCustomTimer(false, nextStageTime - UTL.Time.GetServerTimestamp(), 0, nil) else self.txt_TimeInfo:EndTimer() UIUtils.SetActive(self.txt_Info, true) UIUtils.SetLabelText(self.txt_Info, Const_IDS.IDS_SceneQuiz_MainHint_12) end end self.isInit = false end function UISceneQuizMain:OnFocusChanged(value) self.isFocus = value end return UISceneQuizMain