local UISlgGvEOfficialMain = UIViewClass() function UISlgGvEOfficialMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_SlgGvE_Official_Update_Info, self.RefreshOfficialInfo) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_SlgGve_Official_Title) UIUtils.SetActive(self.isUpLvImgMask, false) self:RefreshOfficialInfo() end function UISlgGvEOfficialMain:RefreshOfficialInfo() self:RefreshCurOfficialData() self:RefreshLeftOfficialInfo() self:RefreshOfficialTaskList() end function UISlgGvEOfficialMain:RefreshCurOfficialData() self.curOfficialLv = MDL.SlgGvE.GetCurOfficalLv() self.curSelectOfficialLv = self.curOfficialLv self.maxOfficiallv = CTL.SlgGvE.GetMaxOfficalLv() self.isMaxOfficiallv = self.curOfficialLv == self.maxOfficiallv self.isFinishedAllTask = CTL.SlgGvE.IsFinishedAllTask(self.curOfficialLv) end function UISlgGvEOfficialMain:RefreshLeftOfficialInfo() local curSelectOfficialCfg = DataSheetManager.SlgGvEOfficialLevel:GetDataByOfficialTitleLevel(self.curSelectOfficialLv) UIUtils.SetActive(self.btn_PageLeft, self.curSelectOfficialLv > 1) UIUtils.SetActive(self.btn_PageRight, self.curSelectOfficialLv < self.curOfficialLv + 1 and self.curSelectOfficialLv < self.maxOfficiallv) self.txt_Page.text = self.curSelectOfficialLv.."/"..self.maxOfficiallv UIUtils.SetImageByAssetBundle(self.img_Icon, curSelectOfficialCfg.OfficialTitleIcon) self.txt_OfficialRank.text = UIUtils.GetLocalizedTxt(Const_IDS[curSelectOfficialCfg.OfficialTitleName]) local reward = curSelectOfficialCfg.Reward_Table self.loop_Item:ReloadAll(reward) local isReceived = MDL.SlgGvE.IsCurOfficalLvRewardReceived(self.curSelectOfficialLv) if isReceived then self.officialState:SetState(1) else if self.curSelectOfficialLv > self.curOfficialLv then self.officialState:SetState(2) else self.officialState:SetState(0) self.event_Collect:SetRedPoint(self.isFinishedAllTask) if self.curSelectOfficialLv == self.maxOfficiallv then UIUtils.SetLabelText(self.labLocal_Collect, Const_IDS.IDS_Gift_Receive) else UIUtils.SetLabelText(self.labLocal_Collect, Const_IDS.IDS_SlgGve_Official_Hint_2) end end end end function UISlgGvEOfficialMain:RefreshOfficialTaskList() --大于等于当前官爵,任务列表从服务器读;小于读配置 if self.curSelectOfficialLv >= self.curOfficialLv then local tasksData = MDL.SlgGvE.GetOfficalTasksDataList(self.curSelectOfficialLv) self.loopScroll_Mission:ReloadAll(tasksData) else local cfgList = CTL.SlgGvE.GetOfficialLvTaskCfgList(self.curSelectOfficialLv) self.loopScroll_Mission:ReloadAll(cfgList) end end function UISlgGvEOfficialMain:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UISlgGvEOfficialMain:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.event_Collect then self:OnClickUpLvRewardBtn() elseif comp == self.btn_PageLeft then self.curSelectOfficialLv = self.curSelectOfficialLv - 1 self:RefreshLeftOfficialInfo() self:RefreshOfficialTaskList() elseif comp == self.btn_PageRight then self.curSelectOfficialLv = self.curSelectOfficialLv + 1 self:RefreshLeftOfficialInfo() self:RefreshOfficialTaskList() end end function UISlgGvEOfficialMain:OnClickUpLvRewardBtn() if MDL.SlgGvE.GetSeasonState() ~= MDL.SlgGvE.SeasonState.Playing then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SlgGve_Season_Hint_4"]) return end if self.isFinishedAllTask then MDL.SlgGvE.GVEOfficialLevelUpReq() return end CTL.Tips.AddTipsMsg(Const_IDS["IDS_SlgGve_Official_Hint_1"]) end function UISlgGvEOfficialMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Item then if target == cellTable.item.event_Click then UTL.ItemTips.ShowCommonTipsById(data.Item) end elseif scrollRect == self.loopScroll_Mission then if target == cellTable.event_Collect then MDL.SlgGvE.GVEOfficialTaskRewardReq(data.taskId) else local taskCfg if self.curSelectOfficialLv >= self.curOfficialLv then taskCfg = DataSheetManager.SlgGvEOfficialTask:GetDataByOfficialQuestID(data.taskId) else taskCfg = data end self:OnClickRewardItem(target, cellTable, taskCfg.Reward_Table) end end end function UISlgGvEOfficialMain:OnClickRewardItem(target, cellTable, rewardData) for i = 1, #cellTable.Content do if cellTable.Content[i].item.event_Click == target then UTL.ItemTips.ShowCommonTipsById(rewardData[i].Item) end end end function UISlgGvEOfficialMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Item then UTL.Item.SetItemCell(cellTable.item, data.Item, data.ItemNum) local isReceived = MDL.SlgGvE.IsCurOfficalLvRewardReceived(self.curSelectOfficialLv) UIUtils.SetActive(cellTable.mask_Received, isReceived) if self.isFinishedAllTask and not isReceived then cellTable.effect_AvailableItem:PlayUIEffect() else cellTable.effect_AvailableItem:StopUIEffect() end elseif scrollRect == self.loopScroll_Mission then if self.curSelectOfficialLv >= self.curOfficialLv then self:RefreshTaskInfoByServerData(cellTable, data) else self:RefreshTaskInfoByCfgData(cellTable, data) end end end function UISlgGvEOfficialMain:RefreshTaskInfoByCfgData(cellTable, data) local triggerData = DataSheetManager.TriggerID:GetDataByID(data.TriggerID) cellTable.txt_Title.text = UIUtils.GetLocalizedTxt(Const_IDS[data.TaskTitleIDS]) local process = CTL.SlgGvE.GetTriggerTaskTotalProgress(triggerData.Unlock_Table[1]) cellTable.txt_ProgressNum.text = process .."/".. process cellTable.Fill.fillAmount = 1 UIUtils.SetLabel(cellTable.txt_Des, MDL.Unlock.GetDesByTriggerID(triggerData.Unlock_Table[1], true)) self:SetCellRewards(cellTable, data.Reward_Table, MDL.SlgGvE.OfficialTaskState.Received) cellTable.State:SetState(2) end function UISlgGvEOfficialMain:RefreshTaskInfoByServerData(cellTable, data) local taskInfo = MDL.SlgGvE.GetOfficalTaskData(self.curSelectOfficialLv, data.taskId) local triggerData = DataSheetManager.TriggerID:GetDataByID(taskInfo.taskCfg.TriggerID) cellTable.txt_Title.text = UIUtils.GetLocalizedTxt(Const_IDS[taskInfo.taskCfg.TaskTitleIDS]) local process = CTL.SlgGvE.GetTriggerTaskTotalProgress(triggerData.Unlock_Table[1]) cellTable.txt_ProgressNum.text = taskInfo.curProgresss .."/".. process cellTable.Fill.fillAmount = taskInfo.curProgresss / process UIUtils.SetLabel(cellTable.txt_Des, MDL.Unlock.GetDesByTriggerID(triggerData.Unlock_Table[1], taskInfo.curProgresss / process >= 1)) self:SetCellRewards(cellTable, taskInfo.taskCfg.Reward_Table, taskInfo.taskState) if self.curSelectOfficialLv == self.curOfficialLv + 1 then --预览下一级隐藏按钮 cellTable.State:SetState(3) else if taskInfo.taskState == MDL.SlgGvE.OfficialTaskState.UnFinished then --前往 cellTable.State:SetState(0) elseif taskInfo.taskState == MDL.SlgGvE.OfficialTaskState.Finished then --已完成可领取 cellTable.State:SetState(1) else --已领取 cellTable.State:SetState(2) end end cellTable.event_Collect:SetRedPoint(taskInfo.taskState == MDL.SlgGvE.OfficialTaskState.Finished) end function UISlgGvEOfficialMain:SetCellRewards(cellTable, rewardData, taskState) for i, reward in ipairs(rewardData) do local item = cellTable.Content[i] if not item then item = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.cell_Reward.gameObject) end UTL.Item.SetItemCell(item.item, reward.Item, reward.ItemNum) UIUtils.SetActive(item.gameObject, true) UIUtils.SetActive(item.mask_Received, taskState == MDL.SlgGvE.OfficialTaskState.Received) --已领取 if taskState == MDL.SlgGvE.OfficialTaskState.Finished and self.curOfficialLv == self.curSelectOfficialLv then --可领取 item.effect_AvailableItem:PlayUIEffect() else item.effect_AvailableItem:StopUIEffect() end end for i = #rewardData + 1, #cellTable.Content do UIUtils.SetActive(cellTable.Content[i].gameObject, false) end end return UISlgGvEOfficialMain