-- 势力名门展示界面 local UIGuildFamousPop = UIViewClass() function UIGuildFamousPop:OnOpened(context) self:RegistSystemEvent(EventID.UI_Guild_FamousInfoRefresh, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_Guild_RankInfo, self.UpdateRankInfo) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_GuildLeaderInspire_Rank3Guild) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) MDL.Guild.GetMaxReptGuildInfoReq() self.guildIDs = {} end function UIGuildFamousPop:RefreshPanel() self.myGuildInfo = MDL.Guild.GetMyFamousInfo() local isFirstBalance = self.myGuildInfo.hasFirstBalance local famousGuildList = MDL.Guild.GetTopFamousGuildInfo() -- 势力排行 table.clearArray(self.guildIDs) for i, v in ipairs(self.group_Guild_Arr) do -- 第一期不显示加入势力 local info = famousGuildList[i] if IsProtoDataNotNil(info) then info = famousGuildList[i].guildInfo UIUtils.SetLabel(v.txt_GuildName, info.guildName) UIUtils.SetLabel(v.txt_PlayerName, info.guildLeaderName) -- 设置徽记 self:SetGuildReputation(v.txt_Fame, v.txt_FameVal, info.param1, info.param2) -- 设置名望 self:SetGuildFameNum(v, info.emblemContent, info.emblemFrame) v.obj_state:SetState(0) table.insert(self.guildIDs, info.guildID) UIUtils.SetActive(v.btn_Apply, info.guildID ~= MDL.Guild.GetMyGuildId() and isFirstBalance == true) else v.obj_state:SetState(1) end end self:UpdateCountDownTimer() end function UIGuildFamousPop:UpdateCountDownTimer() self:StopRepeatFunc(self.UpdateCountDownTimer) local _, leftTime = MDL.Guild.GetGuildBalanceTime() local times = MDL.Guild.GetHasBalanceNums() if times <= 1 then local customStr, customType, refreshInterval = CTL.Guild.GetPeakParam(Const_IDS.IDS_GuildLeaderInspire_TimeTips1) self.txt_CountDown:SetCustomString(customStr, 1, customType) self.txt_CountDown:ResetAndBeginTimer(false, leftTime) if refreshInterval > 0 then self:StartRepeatFunc(self.UpdateCountDownTimer, refreshInterval + 1, 1) end else self.txt_CountDown:EndTimer() local param1, param2 = UTL.Time.GetDateDescAndTime({[1] = DataSheetManager.ConstData:GetDataByID("GuildLeaderInspireRankTime").IntValue}) self.txt_CountDown:SetCDLabel(string.FormatByIdsId(Const_IDS.IDS_GuildLeaderInspire_TimeTips3, string.Concat(param1, param2))) end end function UIGuildFamousPop:OnBackButtonPressed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildFamousPop:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.btn_go then CTL.Guild.OpenGuildMain({ selectIndex = 2 }) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_go02 then CTL.Guild.OpenGuildMain({ selectIndex = 4 }) elseif comp == self.btn_1 then CTL.Activities.OpenActivityWindowByID(LuaConst.ActivityType.GuildSalary) elseif comp == self.btn_2 then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGuildAuctionBase) elseif comp == self.btn_3 then CTL.Guild.OpenLeaderManagement() else for i, v in ipairs(self.group_Guild_Arr) do if comp == v.btn_Apply then if self.lastBtnClickTimestamp and UTL.Time.GetServerTimestamp() - self.lastBtnClickTimestamp <= 60 then return end self.lastBtnClickTimestamp = UTL.Time.GetServerTimestamp() if string.isNilOrEmpty(MDL.Guild.GetMyGuildId()) then -- 没有势力直接进入 MDL.Guild.GuildJoinReq({self.guildIDs[i]}) else -- 自己有势力发送私聊 MDL.Guild.SendFamousGuildNotification(MDL.Guild.GetTopFamousGuildInfo()[i].leaderacid) CTL.Tips.AddTipsMsg(Const_IDS["IDS_Guild_PrestigiousGuildApplyTip"]) end end end end end function UIGuildFamousPop:SetGuildReputation(txt_Fame, txt_Info, fameLevel, fameValue) local fameStr, total = self:GetGuildReputationParam(fameLevel, fameValue) UIUtils.SetLabel(txt_Fame, fameStr) UIUtils.SetLabel(txt_Info, total) end -- 通用设置军团标记 function UIGuildFamousPop:SetGuildFameNum(collection, emblemContent, emblemFrame) if not string.isNilOrEmpty(emblemContent) then UIUtils.SetLabel(collection.lab_GuildName, emblemContent) UIUtils.SetActive(collection.img_GuildIcon, true) local guildEmblemCfg = DataSheetManager.GuildEmblem:GetDataByID(emblemFrame) if guildEmblemCfg then UTL.Item.SetAtlasSprite(collection.img_GuildIcon, "UI_Guild", guildEmblemCfg.Image) end end end function UIGuildFamousPop:UpdateRankInfo(guildRankInfo) self.LoopScroll_Properties:ReloadAll(guildRankInfo.guildInfo) if self.LoopScroll_Properties.Count == 0 then UIUtils.SetActive(self.obj_Rank, true) else UIUtils.SetActive(self.obj_Rank, false) end if guildRankInfo.myGuildInfo.index == 0 then UIUtils.SetActive(self.group_Own.group_Info, false) UIUtils.SetActive(self.group_Own.group_Empty, true) else UIUtils.SetActive(self.group_Own.group_Info, true) UIUtils.SetActive(self.group_Own.group_Empty, false) self:SetRankInfoItem(self.group_Own, guildRankInfo.myGuildInfo, false) end end function UIGuildFamousPop:OnCellInit(scrollRect, index, cellTable, data) cellTable.UIState2:SetState(index % 2) self:SetRankInfoItem(cellTable, data, true) end function UIGuildFamousPop:OnCellClicked(scrollRect, index, cellTable, target, data) MDL.Country.CountryGetTargetGuildInfoReq(data.guildID) end function UIGuildFamousPop:SetRankInfoItem(comp, data, isCell) UIUtils.SetLabel(comp.group_2.txt_Name, data.guildName) -- 设置排名 UIUtils.SetLabel(comp.group_1.txt_Rank, data.index) if self.myGuildInfo.hasFirstBalance == false then if data.index <= 3 then comp.group_1.UIState:SetState(data.index - 1) else comp.group_1.UIState:SetState(3) end else if data.famousGuild and isCell then comp.group_1.UIState:SetState(4) else if data.index <= 3 then comp.group_1.UIState:SetState(data.index - 1) else comp.group_1.UIState:SetState(3) end end end CTL.Guild.SetGuildEmblem(comp.group_2.img_Guild, comp.group_2.txt_Guild, data.emblemFrame, data.emblemContent) self:SetGuildReputation(comp.group_4.txt_Fame, comp.group_4.txt_Info, data.param1, data.param2) UIUtils.SetLabel(comp.group_3.txt_Info, data.guildLeaderName) end function UIGuildFamousPop:GetGuildReputationParam(fameLevel, fameValue) local totalValue = 0 local lastGuildReputationData = nil for i = 1, fameLevel do lastGuildReputationData = DataSheetManager.GuildReputation:GetDataByID(i) totalValue = totalValue + lastGuildReputationData.Value end local fameStr = CTL.Guild.GetGuildReputationInfo(fameLevel) return fameStr, totalValue + fameValue end return UIGuildFamousPop