local UIChangAnSiegeMain = UIViewClass() local CellType = { WEI = Const_IDS.IDS_SiegeCity_MBFTab_1, SHU = Const_IDS.IDS_SiegeCity_MBFTab_2, WU = Const_IDS.IDS_SiegeCity_MBFTab_3, QUN = Const_IDS.IDS_SiegeCity_MBFTab_4, OTHER = Const_IDS.IDS_SiegeCity_ABFTab_1, Main = Const_IDS.IDS_SiegeCity_MBFTab, Assistant = Const_IDS.IDS_SiegeCity_ABFTab, } local CountryIDS = { Const_IDS.IDS_DrawCard_PageTitle_WEI, Const_IDS.IDS_DrawCard_PageTitle_SHU, Const_IDS.IDS_DrawCard_PageTitle_WU, Const_IDS.IDS_DrawCard_PageTitle_QUN } local CellTypeToCountryId = { [CellType.WEI] = MDL.Country.CountryType.Wei, [CellType.SHU] = MDL.Country.CountryType.Shu, [CellType.WU] = MDL.Country.CountryType.Wu, [CellType.QUN] = MDL.Country.CountryType.Qun, [CellType.OTHER] = MDL.Country.CountryType.Han, } local CountryIconName = { [LuaConst.EHeroKingdomType.WEI] = "gb_msz_wei.png", [LuaConst.EHeroKingdomType.SHU] = "gb_msz_shu.png", [LuaConst.EHeroKingdomType.WU] = "gb_msz_wu.png", [LuaConst.EHeroKingdomType.QUN] = "gb_msz_qun.png", } local SiegeCityBuildPeople = DataSheetManager.ConstData:GetDataByID("SiegeCityBuildPeople").IntValue local OccupyIDS = {Const_IDS.IDS_SiegeCity_Tips3, Const_IDS.IDS_SiegeCity_Tips4, Const_IDS.IDS_SiegeCity_Tips5, Const_IDS.IDS_SiegeCity_Tips6} function UIChangAnSiegeMain:OnOpened(context) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_SiegeCity_Name) self:RegistSystemEvent(EventID.UI_ChangAnSiege_MainPanel, self.UpdateMainPanel) self:RegistSystemEvent(EventID.UI_ChangePlayerSeat, self.ChangePlayerSeat) self:RegistSystemEvent(EventID.UI_ChangeSighUpSiegeCity, self.ChangeSighUpSiegeCity) self:RegistSystemEvent(EventID.ChangAnSiege_StageChanged, self.OnStageChanged) self:RegistSystemEvent(EventID.UI_ChangAnSiege_RefreshRevenueStatus, self.RefreshTaxationRedPoint) MDL.ChangAnSiege.SiegeCityEnterMainPanelReq() UIUtils.SetActive(self.btn_Setting, MDL.ChangAnSiege.CanEditMembers()) self.lastRepTime = UTL.Time.GetServerTimestamp() MDL.ChangAnSiege.InitMainCityMemberCount() self.numberMax = MDL.ChangAnSiege.GetMainCityMemberCount() self:RefreshActivityRedPoint() UTL.UIRender.AdaptiveImageSizeFit(self.bottom) end function UIChangAnSiegeMain:RefreshActivityRedPoint() if MDL.Activities.GetRedPointByID(LuaConst.ActivityType.SyncCityWar) then MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.SyncCityWar, 1, true, LuaConst.ActivityType.SyncCityWar) end self.btn_Array:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.ChangAnSiegeLineUp)) end function UIChangAnSiegeMain:OnStageChanged() if MDL.ChangAnSiege.GetCurStage() == MDL.ChangAnSiege.SiegeCitySeasonStage.None then CTL.ChangAnSiege.CloseChangAnSiegeView() else MDL.ChangAnSiege.SiegeCityEnterMainPanelReq() end end function UIChangAnSiegeMain:RefreshMemberInfo() if self.lastRepTime == nil or UTL.Time.GetServerTimestamp() - self.lastRepTime > 2 then MDL.ChangAnSiege.RefreshSighUpPlayersReq() self.lastRepTime = UTL.Time.GetServerTimestamp() end end function UIChangAnSiegeMain:UpdateMainPanel(info) --由于proto数据不能直接赋值 这里做一个拷贝 self.mainPanelInfo = {} self.mainPanelInfo.registerNums = info.registerNums self.mainPanelInfo.defendSituation = info.defendSituation self.mainPanelInfo.members = info.members self.mainPanelInfo.fought = info.fought self.mainPanelInfo.showStageInfo = info.showStageInfo self.mainPanelInfo.maxContinuousOccupy = info.maxContinuousOccupy self.mainPanelInfo.ContinuousOccupy = info.ContinuousOccupy self.mainPanelInfo.contribution = info.contribution self.mainPanelInfo.rank = info.rank self.mainPanelInfo.countrySeasonEndTime = info.countrySeasonEndTime self.isDefence = info.defendSituation.countryId == MDL.Country.GetMyCountryId() self:InitTab() self.fold = {} self.loop_Tab:SelectIndex(1) self:InitCountryInfo() self.loop_CASCountry:ReloadAll(MDL.ChangAnSiege.GetLineUpCountryLimits()) self:InitBuffInfo() self:RefreshStageInfo() self:RefreshTaxationRedPoint() end function UIChangAnSiegeMain:ChangePlayerSeat(members) self.mainPanelInfo.members = members self.loop_Tab:RefreshCells() end function UIChangAnSiegeMain:ChangeSighUpSiegeCity(members) for i, v in ipairs(self.mainPanelInfo.members) do for _, newMembers in ipairs(members) do if v.countryId == newMembers.countryId then self.mainPanelInfo.members[i] = newMembers end end end self.loop_Tab:RefreshCells() end function UIChangAnSiegeMain:InitBuffInfo() self.txt_ContinuousOccupation.text = string.FormatByIdsKey("IDS_HorseActivity_RewardHint_7", self.mainPanelInfo.defendSituation.ContinuousOccupy) if self.mainPanelInfo.defendSituation.ContinuousOccupy >= 3 then UIUtils.SetLabelText(self.txt_BattlefieldFatigue, OccupyIDS[4]) else UIUtils.SetLabelText(self.txt_BattlefieldFatigue, OccupyIDS[self.mainPanelInfo.defendSituation.ContinuousOccupy+1]) end end function UIChangAnSiegeMain:ShowPlayerList(index, cellType) local curCountryInfo = self:GetInfoByIndex(index) self.curSelectCountryId = curCountryInfo.countryId self.loop_ParticipatingPersonnel:ClearCells() if curCountryInfo.countryId == 99 then for i, v in ipairs(curCountryInfo.members) do self.loop_ParticipatingPersonnel:AddData(v, 0) end self.loop_ParticipatingPersonnel:AddData(nil, 0) self.txt_DefensiveBattlefield.text = self:GetCountryDesc(cellType) .. self:GetMembersFormatStr(#curCountryInfo.members) else local tempMemberInfos = {} for index, memberInfo in ipairs(curCountryInfo.members) do if index<=SiegeCityBuildPeople then tempMemberInfos[index] = memberInfo elseif CTL.ChangAnSiege.IsLeaderByJobId(memberInfo.officialJob) then table.insert(tempMemberInfos, 4, memberInfo) else table.insert(tempMemberInfos, memberInfo) end end for i = 1, self.numberMax do self.loop_ParticipatingPersonnel:AddData(tempMemberInfos[i], 0) end self.txt_DefensiveBattlefield.text = self:GetCountryDesc(cellType) .. self:GetMembersFormatStr(#curCountryInfo.members, self.numberMax) end self:InitBtn() self:RefreshMemberInfo() end function UIChangAnSiegeMain:GetCountryDesc(cellType) return MDL.ChangAnSiege.GetCountryTabDesc(self:GetCountryId(cellType), self.isDefence) end function UIChangAnSiegeMain:GetInfoByIndex(index) local countryId = nil if index == 1 then if self.isDefence then countryId = self.defenceCountryIds[index] else countryId = MDL.Country.GetMyCountryId() end elseif index == 2 then countryId = self.defenceCountryIds[index] elseif index == 3 then if self.isDefence then countryId = self.defenceCountryIds[index] else countryId = 99 end elseif index == 5 then countryId = 99 end for i, v in ipairs(self.mainPanelInfo.members) do if v.countryId == countryId then return v end end end function UIChangAnSiegeMain:InitTab() if self.loop_Tab.Count > 0 then self.loop_Tab:ClearCells() end self.loop_Tab:AddData(CellType.Main, 0) if self.isDefence then self.defenceCountryIds = {} for i = 1, 4 do if i ~= self.mainPanelInfo.defendSituation.countryId then table.insert(self.defenceCountryIds, i) end end end if self.isDefence then for i, v in ipairs(self.defenceCountryIds) do self.loop_Tab:AddData(self:GetCellTypeByCountryId(v), 1) end else self.loop_Tab:AddData(self:GetCellTypeByCountryId(self.mainPanelInfo.defendSituation.countryId), 1) end self.loop_Tab:AddData(CellType.Assistant, 0) self.loop_Tab:AddData(CellType.OTHER, 1) end function UIChangAnSiegeMain:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.SiegeCity }) elseif comp == self.btn_BattlefieldDescription then UIManager.OpenView(Const_UI_Lua.UIEnum.UIChangAnSiegeBattleGround) elseif comp == self.btn_Array then self.btn_Array:SetRedPoint(false) CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.ChangAnSiegeLineUp) UIManager.OpenView(Const_UI_Lua.UIEnum.UIChangAnSiegeSelectOfficer, { freeLineupFuncType = MDL.FreeLineUp.FuncType.ChangAnSiege, activityType = LuaConst.ActivityType.SyncCityWar }, Const_UI_Lua.UIEnum.UIDemonGodSelectOfficer) elseif comp == self.btn_Shop then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, { TabEnum = CTL.PayMall.ShopMainTabEnum.SiegeCityStore }) elseif comp == self.btn_Reward then UIManager.OpenView(Const_UI_Lua.UIEnum.UIChangAnSiegeReward, self.mainPanelInfo) elseif comp == self.btn_Taxation then UIManager.OpenView(Const_UI_Lua.UIEnum.UIChangAnSiegeTaxation) elseif comp == self.btn_Setting then UIManager.OpenView(Const_UI_Lua.UIEnum.UIChangAnSiegeBattleArray, self.mainPanelInfo) elseif comp == self.btn_RegistrationStatus then if MDL.ChangAnSiege.GetCurStage() == MDL.ChangAnSiege.SiegeCitySeasonStage.Register then self:JoinBattleGround() else if CTL.Team.IsInTeam() then UTL.MessageBox.ShowOKCancelBox("", Const_IDS.IDS_GVGFight_AttackWindow_Tips4, MDL.Team.TeamLeaveReq) else MDL.ChangAnSiege.EnterSiegeCityReq() end end elseif comp == self.btn_KingRight then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryKingRightPopUp) elseif comp == self.btn_Tips then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.SiegeCityLeader }) end end function UIChangAnSiegeMain:GetMembersFormatStr(num, maxNum) return MDL.ChangAnSiege.GetMembersFormatStr(num, maxNum) end function UIChangAnSiegeMain:GetCountryId(cellType) return CellTypeToCountryId[cellType] end function UIChangAnSiegeMain:GetCellTypeByCountryId(countryId) for i, v in pairs(CellTypeToCountryId) do if v == countryId then return i end end end function UIChangAnSiegeMain:InitTabCell(index, cellTable, data) if data == CellType.Main then UIUtils.SetLabelText(cellTable.txt_Name_Selected, data) cellTable.obj_Battlefieldstate:SetState(0) elseif data == CellType.Assistant then UIUtils.SetLabelText(cellTable.txt_Name_Selected, data) cellTable.obj_Battlefieldstate:SetState(1) else cellTable.txt_Name_Selected.text = MDL.ChangAnSiege.GetCountryTabDesc(self:GetCountryId(data), self.isDefence) if MDL.ChangAnSiege.GetCurStage() ~= MDL.ChangAnSiege.SiegeCitySeasonStage.Show then local curCountryInfo = self:GetInfoByIndex(index) if data == CellType.OTHER then cellTable.txt_Num.text = self:GetMembersFormatStr(#curCountryInfo.members) else cellTable.txt_Num.text = self:GetMembersFormatStr(#curCountryInfo.members, self.numberMax) end UIUtils.SetActive(cellTable.img_Coordinate, self:SelfEnterWarCountryId() == curCountryInfo.countryId) else cellTable.txt_Num.text = nil UIUtils.SetActive(cellTable.img_Coordinate, false) end if self.preSelectCellTable ~= cellTable then cellTable.obj_state:SetState(1) end end end function UIChangAnSiegeMain:InitSignUpPlayerCell(index, cellTable, playerInfo) if playerInfo then cellTable.txt_PlayerName.text = playerInfo.name cellTable.txt_PowerNumber.text = playerInfo.gs UIUtils.SetActive(cellTable.img_Empty, false) UIUtils.SetActive(cellTable.player_Group, true) if self.curSelectCountryId ~= 99 then UIUtils.SetActive(cellTable.img_Commander, index < SiegeCityBuildPeople or CTL.ChangAnSiege.IsLeaderByJobId(playerInfo.officialJob)) else UIUtils.SetActive(cellTable.img_Commander, false) end CTL.Character.SetPortraitAndFrame(cellTable.template_PlayerHead, playerInfo.portraitId, playerInfo.frameId) if playerInfo.acid == BattleDataGetter.GetAcID() then cellTable.txt_PlayerName.text = UTL.Color.FormatGreenColor(playerInfo.name) else cellTable.txt_PlayerName.text = UTL.Color.FormatWhiteColor(playerInfo.name) end else cellTable.txt_PlayerName.text = nil cellTable.txt_PowerNumber.text = nil UIUtils.SetActive(cellTable.img_Empty, true) UIUtils.SetActive(cellTable.player_Group, false) end end function UIChangAnSiegeMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Tab then self:InitTabCell(index, cellTable, data) elseif self.loop_CASCountry == scrollRect then local countryData = DataSheetManager.HeroCountry:GetDataByID(data) UTL.Item.SetAtlasSprite(cellTable.img_Country, "UI_Formation", countryData.Uipath) UIUtils.SetLocalizationImage(cellTable.img_CountryName, CountryIconName[data]) elseif scrollRect == self.group_SettlementStage.Loop_CASSettlementRank then if index <= 2 then cellTable.state_Rank:SetState(index) else cellTable.state_Rank:SetState(3) UIUtils.SetLabel(cellTable.txt_Rank, index + 1) end if data.acid == BattleDataGetter.GetAcID() then UIUtils.SetLabel(cellTable.txt_PlayerName, UTL.Color.FormatGreenColor(data.name)) else UIUtils.SetLabel(cellTable.txt_PlayerName, UTL.Color.FormatWhiteColor(data.name)) end UIUtils.SetLabel(cellTable.txt_TotalContribution, data.contribute) CTL.Character.SetPortraitAndFrame(cellTable.template_PlayerHead, data.portraitId, data.frameId) else self:InitSignUpPlayerCell(index, cellTable, data) end end function UIChangAnSiegeMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Tab then if data ~= CellType.Main and data ~= CellType.Assistant then if MDL.ChangAnSiege.GetCurStage() ~= MDL.ChangAnSiege.SiegeCitySeasonStage.Show then self:ShowPlayerList(index, data) end if self.preSelectCellTable ~= cellTable then cellTable.obj_state:SetState(0) if self.preSelectCellTable then self.preSelectCellTable.obj_state:SetState(1) end self.preSelectCellTable = cellTable end end end end function UIChangAnSiegeMain:InitCountryInfo() local defendCountryId = self.mainPanelInfo.defendSituation.countryId local index = 0 local countryId = 1 for i = 1, 4 do index = index + 1 local curIndex = index if i == self.mainPanelInfo.defendSituation.countryId then curIndex = 4 index = index - 1 end countryId = i local jobData = DataSheetManager.CountryJob:GetDataByID(MDL.Country.CountryJob.CountryKing) UIUtils.SetLabelText(self.group_Middle[curIndex].lab_Monarch, Const_IDS[jobData.Title_Table[countryId].JobName]) if countryId == MDL.Country.GetMyCountryId() then self.group_Middle[curIndex].state_Country:SetState(1) else self.group_Middle[curIndex].state_Country:SetState(0) end end end function UIChangAnSiegeMain:SelfEnterWarCountryId() for i, v in ipairs(self.mainPanelInfo.members) do for _, player in ipairs(v.members) do if player.acid == BattleDataGetter.GetAcID() then return v.countryId end end end end function UIChangAnSiegeMain:InitBtn() self.txt_Desc.text = nil if MDL.ChangAnSiege.GetCurStage() == MDL.ChangAnSiege.SiegeCitySeasonStage.Register then local countryId = self:SelfEnterWarCountryId() if countryId then UIUtils.SetActive(self.btn_RegistrationStatus, false) if MDL.ChangAnSiege.IsSecondBattlefield(countryId) then UIUtils.SetLabelText(self.txt_Desc, Const_IDS.IDS_SiegeCity_BattleField_SignUpTips_5) else self.txt_Desc.text = string.FormatByIdsId(Const_IDS.IDS_SiegeCity_BattleField_SignUpTips_4, MDL.ChangAnSiege.GetCountryTabDesc(countryId, self.isDefence)) end else UIUtils.SetActive(self.btn_RegistrationStatus, true) self.btn_RegistrationStatus:SetText(Const_IDS.IDS_SiegeCity_BattleField_SignUp) self.btn_RegistrationStatus:SetRedPoint(true) end local str = UIUtils.GetLocalizedTxt(Const_IDS.IDS_SiegeCity_BattleField_SignUpCountDown) local endTime = MDL.ChangAnSiege.GetStageTime(MDL.ChangAnSiege.SiegeCitySeasonStage.Register).endTime local offset = endTime - UTL.Time.GetServerTimestamp() self.time_RegistrationStatus:SetCustomString(str, 1, 1) self.time_RegistrationStatus:ResetAndBeginTimer(false, offset) elseif MDL.ChangAnSiege.GetCurStage() == MDL.ChangAnSiege.SiegeCitySeasonStage.Preparation then local str = string.FormatByIdsId(Const_IDS.IDS_SiegeCity_BattleField_ReadyTime, "{0}:{1}") local endTime = MDL.ChangAnSiege.GetStageTime(MDL.ChangAnSiege.SiegeCitySeasonStage.Preparation).endTime local offset = endTime - UTL.Time.GetServerTimestamp() self.time_RegistrationStatus:SetCustomString(str, 1, 5) self.time_RegistrationStatus:ResetAndBeginTimer(false, offset) self.btn_RegistrationStatus:SetText(Const_IDS.IDS_SiegeCity_BattleField_Join) UIUtils.SetActive(self.btn_RegistrationStatus, true) self.btn_RegistrationStatus:SetRedPoint(false) elseif MDL.ChangAnSiege.GetCurStage() == MDL.ChangAnSiege.SiegeCitySeasonStage.Fight then local str = string.FormatByIdsId(Const_IDS.IDS_SiegeCity_BattleField_EndTime, "{0}:{1}") local endTime = MDL.ChangAnSiege.GetStageTime(MDL.ChangAnSiege.SiegeCitySeasonStage.Fight).endTime local offset = endTime - UTL.Time.GetServerTimestamp() self.time_RegistrationStatus:SetCustomString(str, 1, 5) self.time_RegistrationStatus:ResetAndBeginTimer(false, offset) self.btn_RegistrationStatus:SetText(Const_IDS.IDS_SiegeCity_BattleField_Join) self.btn_RegistrationStatus:SetRedPoint(false) UIUtils.SetActive(self.btn_RegistrationStatus, not self.mainPanelInfo.fought and not self.mainPanelInfo.isBattleEnd) end end function UIChangAnSiegeMain:JoinBattleGround() if self.curSelectCountryId < MDL.Country.CountryType.Han then local nums = 0 for i, v in ipairs(self.mainPanelInfo.members) do if v.countryId == self.curSelectCountryId then nums = #v.members end end if nums >= self.numberMax then CTL.Tips.AddTipsMsg(Const_IDS.IDS_SiegeCity_BattleField_SignUpTips_2) else MDL.ChangAnSiege.SighUpSiegeCityReq(self.curSelectCountryId) end else MDL.ChangAnSiege.SighUpSiegeCityReq(self.curSelectCountryId) end end function UIChangAnSiegeMain:RefreshStageInfo() if MDL.ChangAnSiege.GetCurStage() == MDL.ChangAnSiege.SiegeCitySeasonStage.Show then UIUtils.SetActive(self.group_RegistrationStage, false) UIUtils.SetActive(self.group_SettlementStage.gameObject, true) self:SetShowInfo() else UIUtils.SetActive(self.group_RegistrationStage, true) UIUtils.SetActive(self.group_SettlementStage.gameObject, false) end end function UIChangAnSiegeMain:SetShowInfo() local occupyCountryId = self.mainPanelInfo.showStageInfo.countryId local countryData = DataSheetManager.CountryBase:GetDataByID(occupyCountryId) UIUtils.SetImageByAssetBundle(self.group_SettlementStage.img_Country, countryData.LogoPath) UIUtils.SetLocalizationImage(self.group_SettlementStage.img_CountryName, countryData.NamePath) --攻占失败和防守成功 表现连续占领 if MDL.Country.GetMyCountryId() == self.mainPanelInfo.showStageInfo.lastCountryId then if self.mainPanelInfo.showStageInfo.isDefendWin then -- 防守成功 UIUtils.SetLabelText(self.group_SettlementStage.txt_Success, Const_IDS.IDS_SiegeCity_ShowStage_Title_3) self:ShowSettlementStageBaseInfo(1, false) else UIUtils.SetLabelText(self.group_SettlementStage.txt_Fail, Const_IDS.IDS_SiegeCity_ShowStage_Title_4) self:ShowSettlementStageBaseInfo(0, true) end else if not self.mainPanelInfo.showStageInfo.isDefendWin then -- 攻占成功 UIUtils.SetLabelText(self.group_SettlementStage.txt_Success, Const_IDS.IDS_SiegeCity_ShowStage_Title_1) self:ShowSettlementStageBaseInfo(1, true) else UIUtils.SetLabelText(self.group_SettlementStage.txt_Fail, Const_IDS.IDS_SiegeCity_ShowStage_Title_2) self:ShowSettlementStageBaseInfo(0, false) end end local tabIndex = MDL.Country.GetMyCountryId() - 1 self.group_SettlementStage.toggle_TopGroup:SelectIndex(tabIndex) local endTime = MDL.ChangAnSiege.GetStageTime(MDL.ChangAnSiege.SiegeCitySeasonStage.Show).endTime local offset = endTime - UTL.Time.GetServerTimestamp() local str if not MDL.ChangAnSiege.IsLastBattle() then str = string.FormatByIdsId(Const_IDS.IDS_SiegeCity_ShowStage_CD_1, "{0}:{1}:{2}") --下一场报名阶段倒计时 self.group_SettlementStage.txt_NextCountdown:SetCustomString(str, 1, 2) else str = UIUtils.GetLocalizedTxt(Const_IDS.IDS_SiegeCity_ShowStage_CD_2) -- 距离下一赛季结束 self.group_SettlementStage.txt_NextCountdown:SetCustomString(str, 1, 1) end self.group_SettlementStage.txt_NextCountdown:ResetAndBeginTimer(false, offset) end local function CountryTotalContributionSort(a, b) return a.countryTotalContribution > b.countryTotalContribution end function UIChangAnSiegeMain:ShowSettlementStageBaseInfo(state, isTotalContribution) self.group_SettlementStage.state_Settlement:SetState(state) UIUtils.SetActive(self.group_SettlementStage.group_SecondCountry, isTotalContribution) UIUtils.SetActive(self.group_SettlementStage.group_ThirdCountry, isTotalContribution) if isTotalContribution then self.attackCountries = {} local index = 1 for i, v in ipairs(self.mainPanelInfo.showStageInfo.countryContributes) do if v.countryId ~= self.mainPanelInfo.showStageInfo.lastCountryId then local attackCountry = {} attackCountry.countryId = v.countryId attackCountry.ranks = v.ranks table.insert(self.attackCountries, attackCountry) self.attackCountries[index].countryTotalContribution = self:CalculateCountryContribute(v) index = index + 1 end end table.sort(self.attackCountries, CountryTotalContributionSort) --第一进攻国 UIUtils.SetLabel(self.group_SettlementStage.txt_TotalContribution, self.attackCountries[1].countryTotalContribution) UIUtils.SetLabelText(self.group_SettlementStage.lab_TotalContribution, Const_IDS.IDS_SiegeCity_ShowStage_OccupyNation_5) --第二进攻国 UIUtils.SetLabel(self.group_SettlementStage.txt_SecondCountryName, CTL.Country.GetCountryNameWithColorAndColon(self.attackCountries[2].countryId)) UIUtils.SetLabel(self.group_SettlementStage.txt_SecondTotalContribution, self.attackCountries[2].countryTotalContribution) --第三进攻国 UIUtils.SetLabel(self.group_SettlementStage.txt_ThirdCountryName, CTL.Country.GetCountryNameWithColorAndColon(self.attackCountries[3].countryId)) UIUtils.SetLabel(self.group_SettlementStage.txt_ThirdTotalContribution, self.attackCountries[3].countryTotalContribution) else local continuousOccupyTimes = string.FormatByIdsId(Const_IDS.IDS_SiegeCity_ShowStage_OccupyNation_7, self.mainPanelInfo.defendSituation.ContinuousOccupy) UIUtils.SetLabel(self.group_SettlementStage.txt_TotalContribution, continuousOccupyTimes) UIUtils.SetLabelText(self.group_SettlementStage.lab_TotalContribution, Const_IDS.IDS_SiegeCity_ShowStage_OccupyNation_6) end UIUtils.SetLabel(self.group_SettlementStage.txt_Monarch, self.mainPanelInfo.showStageInfo.leaderName) UIUtils.SetLabel(self.group_SettlementStage.txt_CountryTitle, MDL.Country.GetCountryTitle(self.mainPanelInfo.showStageInfo.countryName, self.mainPanelInfo.showStageInfo.countryId)) end function UIChangAnSiegeMain:CalculateCountryContribute(countryContributes) local countryContribute = 0 for _, v in ipairs(countryContributes.ranks) do countryContribute = countryContribute + v.contribute end return countryContribute end local function ContributionSort(a, b) if a.contribute == b.contribute then return a.playerId < b.playerId end return a.contribute > b.contribute end function UIChangAnSiegeMain:RefreshSettlementStageRankInfo(index) self.settlementRankData = {} for _, v in ipairs(self.mainPanelInfo.showStageInfo.countryContributes) do if v.countryId == index then self.settlementRankData = v.ranks break end end table.sort(self.settlementRankData, ContributionSort) self.group_SettlementStage.Loop_CASSettlementRank:ReloadAll(self.settlementRankData) if self.settlementRankData and #self.settlementRankData > 0 then self.group_SettlementStage.Loop_CASSettlementRank:MoveIndex(0) end end function UIChangAnSiegeMain:OnValueChanged(comp, index) if comp == self.group_SettlementStage.toggle_TopGroup then self:RefreshSettlementStageRankInfo(index + 1) end end function UIChangAnSiegeMain:RefreshTaxationRedPoint() self.btn_Taxation:SetRedPoint(MDL.ChangAnSiege.GetRevenueStatus() == MDL.ChangAnSiege.RevenueStatus.Can_Receive) end return UIChangAnSiegeMain