-- 势力名门展示界面 local UIGuildManagementRewardsPop = UIViewClass() local Const_Minutes = 5 local Const_Tab_SLG = { [1100] = true, [1200] = true, } local function SortBySortId(a, b) return a.SortId < b.SortId end function UIGuildManagementRewardsPop:OnOpened(context) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.CheckIfClose) self:RegistSystemEvent(EventID.UI_Guild_GuildInfoRefresh, self.CheckIfClose) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_GuildLeaderInspire_LotReward) self:RegistSystemEvent(EventID.UI_Guild_LeaderTaskInfoUpdate, self.UpdateInfo) CTL.Guild.RemoveLeaderTaskRed() UIUtils.SetActive(self.img_notice, MDL.Guild.GetMyFamousInfo().hasFirstBalance == false) end function UIGuildManagementRewardsPop:CheckIfClose() if CTL.Guild.CheckGuildManagementEntry() == false then self:CloseView() end end function UIGuildManagementRewardsPop:UpdateTimerFunc() self:StopRepeatFunc(self.UpdateTimerFunc) local times = MDL.Guild.GetHasBalanceNums() if times <= 1 then local customStr, customType, refreshInterval = CTL.Guild.GetPeakParam(Const_IDS.IDS_GuildLeaderInspire_TimeTips2) self.txt_time:SetCustomString(customStr, 1, customType) local _, leftTime = MDL.Guild.GetGuildBalanceTime() self.txt_time:ResetAndBeginTimer(false, leftTime) if refreshInterval > 0 then self:StartRepeatFunc(self.UpdateTimerFunc, refreshInterval + 1, 1) end UIUtils.SetLabelText(self.txt_time_lab1, Const_IDS.IDS_GuildLeaderInspire_TimeTips5) UIUtils.SetLabelText(self.txt_time_lab2, Const_IDS.IDS_GuildLeaderInspire_TimeTips5) else self.txt_time:EndTimer() self.txt_time_lab1.text = nil self.txt_time_lab2.text = nil local param1, param2 = UTL.Time.GetDateDescAndTime({[1] = DataSheetManager.ConstData:GetDataByID("GuildLeaderInspireRankTime").IntValue}) local content = string.FormatByIdsId(Const_IDS.IDS_GuildLeaderInspire_TimeTips7, string.Concat(param1, param2)) self.txt_time:SetCDLabel(content) end local _, offset = MDL.Guild.GetGuildBalanceTime() --到结算时间前5分钟要强行关闭界面,服务器这个期间要结算 self:StartRepeatFunc(self.OnTimeToClose, offset - Const_Minutes * UTL.Time.TotalSecondsOneMinute, 1) end function UIGuildManagementRewardsPop:InitData() self:UpdateTimerFunc() self.tabInfoDic = {} self.tabList = {} for i, v in MDL.Guild.IpairsLeaderTaskInfo() do local cfg = DataSheetManager.GuildLeaderInspire:GetDataByID(v.taskId) if (Const_Tab_SLG[cfg.Enum] and MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.End and MDL.Guild.GetLeaderTaskState(v.taskId) ~= CTL.Guild.GuildLeaderTaskRewardState_CanGet) or (cfg.FunctionID ~= 0 and not MDL.Unlock.IsUnlock(cfg.FunctionID)) then --不显示 else if self.tabInfoDic[cfg.Classification] == nil then self.tabInfoDic[cfg.Classification] = {} table.insert(self.tabList, cfg.Classification) end table.insert(self.tabInfoDic[cfg.Classification], cfg) end end table.sort(self.tabList) --从小到大排序 for i, v in pairs(self.tabInfoDic) do table.sort(v, SortBySortId) end end function UIGuildManagementRewardsPop:UpdateInfo(isResp) if CTL.Guild.CheckGuildManagementEntry() == false then self:CloseView() return end if isResp == false then MDL.Guild.GetGuildLeaderTaskInfoReq() else self:InitData() self.loop_BtnTab:ReloadAll(self.tabList) if self.selectType == nil or table.containValue(self.tabList, self.selectType) == false then self.loop_BtnTab:SelectIndex(0) else self.loop_Info:RefreshCells() end local totalCount = 0 for i, v in MDL.Guild.IpairsLeaderTaskInfo() do local cfg = DataSheetManager.GuildLeaderInspire:GetDataByID(v.taskId) if (Const_Tab_SLG[cfg.Enum] and MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.End and MDL.Guild.GetLeaderTaskState(v.taskId) ~= CTL.Guild.GuildLeaderTaskRewardState_CanGet) or (cfg.FunctionID ~= 0 and not MDL.Unlock.IsUnlock(cfg.FunctionID)) then else totalCount = totalCount + self:GetRewardCount(cfg) end end self.txt_All.text = math.min(MDL.Guild.GetLeaderHasGetCount(), totalCount) .. "/" .. totalCount self.get_All_Button:SetRedPoint(self:CheckIfReward()) end end function UIGuildManagementRewardsPop:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_BtnTab then local typeDesc = self.tabInfoDic[data][1].ClassificationDes UIUtils.SetLabelText(cellTable.txt_Name_Nomal, Const_IDS[typeDesc]) UIUtils.SetLabelText(cellTable.txt_Name_Selected, Const_IDS[typeDesc]) if self.selectType == data then cellTable.state_btnState:SetState(1) else cellTable.state_btnState:SetState(0) end UIUtils.SetActive(cellTable.img_RedDot, CTL.Guild.CheckManagementRewardRed(data)) else UIUtils.SetLabelText(cellTable.txt_Name, Const_IDS[data.TitleDes]) cellTable.txt_stage.text = string.FormatByIdsId(Const_IDS.IDS_GuildLeaderInspire_Stage, data.Star) for i, v in ipairs(cellTable.group_star) do if data.Star >= i then UIUtils.SetActive(v, true) else UIUtils.SetActive(v, false) end end --奖励 local num = self:GetRewardCount(data) cellTable.txt_num.text = num cellTable.Button:SetRedPoint(false) local curProgress, totalProgress = MDL.Guild.GetLeaderTaskProgress(data) local state = MDL.Guild.GetLeaderTaskState(data.ID) local progressContent = "" if state == CTL.Guild.GuildLeaderTaskRewardState_UnFinished then cellTable.group_GetState:SetState(2) --该状态可能是进度完成,但是未结算,因此字色需要修改 if curProgress >= totalProgress then progressContent = UTL.Color.FormatGreenColor(curProgress) .. "/" .. totalProgress else progressContent = UTL.Color.FormatRedColor(curProgress) .. "/" .. totalProgress end if data.WaitEnd == 1 then UIUtils.SetLabelText(cellTable.lab_Get, Const_IDS.IDS_GuildLeaderInspire_Settlement) else UIUtils.SetLabelText(cellTable.lab_Get, Const_IDS.IDS_Achievement_NotReached) end elseif state == CTL.Guild.GuildLeaderTaskRewardState_CanGet then cellTable.group_GetState:SetState(0) progressContent = UTL.Color.FormatGreenColor(curProgress) .. "/" .. totalProgress cellTable.Button:SetRedPoint(true) else cellTable.group_GetState:SetState(1) progressContent = UTL.Color.FormatGreenColor(curProgress) .. "/" .. totalProgress end cellTable.txt_Detail.text = string.FormatByIdsId(Const_IDS[data.TaskDes], progressContent) end end function UIGuildManagementRewardsPop:GetRewardCount(cfg) local times = MDL.Guild.GetHasBalanceNums() local rewardId = 0 if times == 0 then if MDL.Guild.CheckLeader(1) then rewardId = cfg.FirstRankRewardIDForLeader else rewardId = cfg.FirstRankRewardID end else if MDL.Guild.CheckLeader(1) then rewardId = cfg.NormalRankRewardIDForLeader else rewardId = cfg.NormalRankRewardID end end local _, reward = DataSheetManager.GuildLeaderInspireRewardRepeat:TryGetDataByAttrRepeatID(rewardId) if reward then return reward.Item_Table[1].ItemNum end return 0 end function UIGuildManagementRewardsPop:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_BtnTab then if self.selectCell then self.selectCell.state_btnState:SetState(0) end self.selectType = data self.selectCell = cellTable cellTable.state_btnState:SetState(1) local list = self.tabInfoDic[data] self.loop_Info:ReloadAll(list) else if target == cellTable.Button then MDL.Guild.RewardGuildLeaderTaskReq(data.ID, false) end end end function UIGuildManagementRewardsPop:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildManagementRewardsPop:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.get_All_Button then if self:CheckIfReward() == false then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ClimbTower_NoRewardTip) else MDL.Guild.RewardGuildLeaderTaskReq(0, true) end end end function UIGuildManagementRewardsPop:CheckIfReward() local canGet = false for i, v in MDL.Guild.IpairsLeaderTaskInfo() do if v.rewardState == CTL.Guild.GuildLeaderTaskRewardState_CanGet then canGet = true break end end return canGet end function UIGuildManagementRewardsPop:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end function UIGuildManagementRewardsPop:OnTimeToClose() CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_41707_InfoCode_GuildLeaderInspire_TaskSettle) self:CloseView() end return UIGuildManagementRewardsPop