local UIGVGFightWarTasks = UIViewClass() -------------------- function UIGVGFightWarTasks:OnCreated() self.clickItemDict = {} end function UIGVGFightWarTasks:OnOpened(context) self:RegistSystemEvent(EventID.GVGFight_RefreshSeasonTaskPanel, self.RefreshSeasonTaskPanel) MDL.GVGFight.GVGSeasonTaskPanelReq() end function UIGVGFightWarTasks:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGVGFightWarTasks:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() end end function UIGVGFightWarTasks:OnCellInit(scrollRect, index, cellTable, data) local taskData = DataSheetManager.GVGFightTask:GetDataByTaskID(data.taskId) local triggerData = DataSheetManager.TriggerID:GetDataByID(taskData.TriggerID) local info = data UIUtils.SetLabelText(cellTable.txt_Task, Const_IDS[taskData.TaskTitle]) local reachStr = "" if info.state == MDL.GVGFight.GVGSeasonMedalTaskState.NoReach then UIUtils.SetActive(cellTable.btn_Go, true) UIUtils.SetActive(cellTable.btn_Receive, false) UIUtils.SetActive(cellTable.img_Received, false) reachStr = UTL.Color.FormatTextByColor(UTL.Color.yellow, data.reachNum) UIUtils.SetLabelText(cellTable.lab_CurrentState, Const_IDS.IDS_GVGFight_SeasonTask_State2) elseif info.state == MDL.GVGFight.GVGSeasonMedalTaskState.ReachNoGet then UIUtils.SetActive(cellTable.btn_Receive, true) cellTable.btn_Receive:SetRedPoint(true) UIUtils.SetActive(cellTable.btn_Go, false) UIUtils.SetActive(cellTable.img_Received, false) reachStr = UTL.Color.FormatTextByColor(UTL.Color.Green, data.reachNum) cellTable.lab_CurrentState.text = nil elseif info.state == MDL.GVGFight.GVGSeasonMedalTaskState.Got then UIUtils.SetActive(cellTable.img_Received, true) UIUtils.SetActive(cellTable.btn_Go, false) UIUtils.SetActive(cellTable.btn_Receive, false) reachStr = UTL.Color.FormatTextByColor(UTL.Color.yellow, data.reachNum) cellTable.lab_CurrentState.text = nil end cellTable.txt_TaskNum.text = reachStr .. "/"..triggerData.Unlock_Table[1].UnlockConditionParamA local rewards = DataSheetManager.GVGFightRewardRepeat:GetDataByID(taskData.RewardID) for i, item in ipairs(rewards.Item_Table) do local obj = cellTable.Content[i] if obj == nil then obj = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.itemTemplate.gameObject) UIUtils.SetActive(obj.gameObject, true) end UIUtils.SetActive(obj.gameObject, true) if GameAppInfo.IsVersionGreaterThan16000() then self:InitCellUITemplate(cellTable.cell.gameObject, obj.item, cellTable.Content) end self.clickItemDict[obj.item.event_Click] = item.ItemID UTL.Item.SetItemCell(obj.item, item.ItemID, item.ItemNum) UIUtils.SetActive(obj.mask_ItemReceived, info.state == MDL.GVGFight.GVGSeasonMedalTaskState.Got) end for i = #rewards.Item_Table + 1, #cellTable.Content do local obj = cellTable.Content[i] UIUtils.SetActive(obj.gameObject, false) end end function UIGVGFightWarTasks:OnCellClicked(scrollRect, index, cellTable, target, data) if self.clickItemDict[target] then UTL.ItemTips.ShowCommonTipsById(self.clickItemDict[target]) elseif cellTable.btn_Receive == target then MDL.GVGFight.GVGGetSeasonTaskReq(data.taskId) end end -------------------- function UIGVGFightWarTasks:RefreshSeasonTaskPanel() self.Loop_WarTasks:ClearCells() for _, v in MDL.GVGFight.GetSeasonTaskInfoIterator() do self.Loop_WarTasks:AddData(v, 0) end end return UIGVGFightWarTasks