local UIGuildWarSingUpView = UIViewClass() local Stages = MDL.GuildWar.Stages local MAXPAGECOUNT = 3 local ONEPAGECOUNT = 10 local HALFPAGECOUNT = ONEPAGECOUNT/2 local ONEGROUPCOUNT = 4 local RANKPATH = ConstAssetPathConfig.RANKPATH function UIGuildWarSingUpView:OnOpened(context) self.pageCount = 1 self.list = context.signUpInfo if self.list == nil or #self.list == 0 then self.btn_Before.gameObject:SetActive(false) self.btn_Next.gameObject:SetActive(false) self.group_SignedGuild.gameObject:SetActive(false) self.group_LevelList.gameObject:SetActive(false) self.groupEmpty.gameObject:SetActive(true) UIUtils.SetLabelText(self.localLab_SignedGuild,Const_IDS.IDS_GuildWar_SignInfo) if context.issue > 1 then self:SetMyRankInfo() else self:SetFirstMyRankInfo() end return end self.groupEmpty.gameObject:SetActive(false) if context.issue == 1 then self.group_SignedGuild.gameObject:SetActive(true) self.group_LevelList.gameObject:SetActive(false) self.isFirst = true UIUtils.SetLabelText(self.localLab_SignedGuild,Const_IDS.IDS_GuildWar_SignInfo) self.maxPageCount = math.ceil(#self.list/10) self:ShowFirstLoop(1) if self.maxPageCount == 1 then self.btn_Before.gameObject:SetActive(false) self.btn_Next.gameObject:SetActive(false) else self.btn_Before.gameObject:SetActive(false) self.btn_Next.gameObject:SetActive(true) end self:SetFirstMyRankInfo() else self.isFirst = false self.group_SignedGuild.gameObject:SetActive(false) self.group_LevelList.gameObject:SetActive(true) UIUtils.SetLabelText(self.localLab_SignedGuild,Const_IDS.IDS_GuildWar_SignedGuild) self.maxPageCount = MAXPAGECOUNT self:ShowSelfRank() end end function UIGuildWarSingUpView:ShowSelfRank() local rank = self:SetMyRankInfo() or 1 self:ShowTrailing(rank) self.pageCount = rank if self.pageCount == 1 then self.btn_Before.gameObject:SetActive(false) else self.btn_Before.gameObject:SetActive(true) end if self.pageCount == self.maxPageCount then self.btn_Next.gameObject:SetActive(false) else self.btn_Next.gameObject:SetActive(true) end end function UIGuildWarSingUpView:ShowFirstLoop(page) local startIndex = (page -1) * ONEPAGECOUNT + 1 local endIndex = startIndex + ONEPAGECOUNT - 1 if #self.list < endIndex then endIndex = #self.list end if endIndex%HALFPAGECOUNT <= HALFPAGECOUNT and endIndex%HALFPAGECOUNT>0 and startIndex > HALFPAGECOUNT then startIndex = startIndex - HALFPAGECOUNT end self.LoopLeft_SignedGuild:ClearCells() self.LoopRight_SignedGuild:ClearCells() for i = startIndex, endIndex do if self.list[i] then if i - startIndex < HALFPAGECOUNT then self.LoopLeft_SignedGuild:AddData({i,self.list[i]},0) else self.LoopRight_SignedGuild:AddData({i,self.list[i]},0) end end end end function UIGuildWarSingUpView:SetFirstMyRankInfo() local myGuildRank = nil local index = 1 for i,v in ipairs(self.list) do if v.guildId == MDL.Guild.GetMyGuildInfo().guildId then myGuildRank = v index = i break end end self.group_Signed.gameObject:SetActive(true) self.group_Level.gameObject:SetActive(false) if myGuildRank then self.group_Signed.txt_MyGuild.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_MyGuildName).. myGuildRank.guildName self.group_Signed.txt_RankNum.text = index self.group_Signed.txt_FameNum.text = myGuildRank.fameValue else self.group_Signed.txt_MyGuild.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_MyGuildName).. MDL.Guild.GetMyGuildInfo().guildName UIUtils.SetLabelText(self.group_Signed.txt_RankNum,Const_IDS.IDS_GuildWar_NotSigned) if not next(MDL.Guild.GetGuildMemberInfo()) then MDL.Guild.GetGuildInfoReq() self:RegistSystemEvent(EventID.UI_Guild_GuildInfoRefresh, self.UpdateGuildInfo) else self.group_Signed.txt_FameNum.text = MDL.Guild.GetGuildMemberInfo().listInfo.fameValue end end end function UIGuildWarSingUpView:UpdateGuildInfo() self.group_Signed.txt_FameNum.text = MDL.Guild.GetGuildMemberInfo().listInfo.fameValue end function UIGuildWarSingUpView:SetMyRankInfo( ... ) local index = 0 for i,v in ipairs(self.list) do if v.guildId == MDL.Guild.GetMyGuildInfo().guildId then index = i break end end local rank = math.ceil(index / ONEGROUPCOUNT) self.group_Signed.gameObject:SetActive(false) self.group_Level.gameObject:SetActive(true) self.group_Level.txt_MyGuild.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_MyGuildName) .. MDL.Guild.GetMyGuildInfo().guildName if rank > 0 then if rank >= 6 then rank = 5 end local excelData = DataSheetManager.GuildWarGroup:GetDataByID(rank) UIUtils.SetLabelText(self.group_Level.txt_MatchTxt,Const_IDS[excelData.GroupName]) return math.ceil(rank/2) else UIUtils.SetLabelText(self.group_Level.txt_MatchTxt,Const_IDS.IDS_GuildWar_NotSigned) end end function UIGuildWarSingUpView:ShowBeforePage() self.pageCount = self.pageCount -1 if self.pageCount == 1 then self.btn_Before.gameObject:SetActive(false) else self.btn_Before.gameObject:SetActive(true) end self.btn_Next.gameObject:SetActive(true) if self.isFirst then self:ShowFirstLoop(self.pageCount) else self:ShowTrailing(self.pageCount) end end function UIGuildWarSingUpView:ShowNextPage() self.pageCount = self.pageCount + 1 if self.pageCount == self.maxPageCount then self.btn_Next.gameObject:SetActive(false) else self.btn_Next.gameObject:SetActive(true) end self.btn_Before.gameObject:SetActive(true) if self.isFirst then self:ShowFirstLoop(self.pageCount) else self:ShowTrailing(self.pageCount) end end function UIGuildWarSingUpView:ShowTrailing(page) if page == 1 then self:SetGroupInfo(self.cell_LevelList1,1) self:SetGroupInfo(self.cell_LevelList2,2) elseif page == 2 then self:SetGroupInfo(self.cell_LevelList1,3) self:SetGroupInfo(self.cell_LevelList2,4) elseif page == 3 then self:SetGroupInfo(self.cell_LevelList1,4) self:SetGroupInfo(self.cell_LevelList2,5) end end function UIGuildWarSingUpView:SetGroupInfo(groupObj , groupId) groupObj.LoopScroll_RankList:ClearCells() local start = (groupId-1)*ONEGROUPCOUNT+1 local endIndex = start + ONEGROUPCOUNT if groupId == 5 then endIndex = #self.list end for i = start, endIndex do local v = self.list[i] if v then groupObj.LoopScroll_RankList:AddData(self.list[i],0) end end if groupObj.LoopScroll_RankList.Count <= HALFPAGECOUNT then groupObj.LoopScroll_RankList:SetMovementType(LuaConst.MovementType.UnDrag) groupObj.arrow.gameObject:SetActive(false) else groupObj.LoopScroll_RankList:SetMovementType(LuaConst.MovementType.Elastic) groupObj.arrow.gameObject:SetActive(true) end local excelData = DataSheetManager.GuildWarGroup:GetDataByID(groupId) UTL.Item.SetAtlasSprite(groupObj.ico_Level, "UI_GuildWar", excelData.GroupImage) groupObj.localLab_Level.text = UTL.Color.FormatTextByColor(excelData.Color,UIUtils.GetLocalizedTxt(Const_IDS[excelData.GroupName])) end function UIGuildWarSingUpView:OnButtonClicked(comp) if comp == self.btn_Before then self:ShowBeforePage() elseif comp == self.btn_Next then self:ShowNextPage() end end function UIGuildWarSingUpView:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopLeft_SignedGuild or scrollRect == self.LoopRight_SignedGuild then if data[1] <= 3 then local rank = string.format(RANKPATH,data[1]) UIUtils.SetImageByAssetBundle(cellTable.img_Rank, rank) cellTable.txt_Rank.text = nil cellTable.img_Rank.gameObject:SetActive(true) else cellTable.img_Rank.gameObject:SetActive(false) cellTable.txt_Rank.text = data[1] end UIUtils.SetActive(cellTable.img_Dark, index % 2 == 1) cellTable.txt_Name.text = data[2].guildName cellTable.txt_Fame.text = data[2].fameValue if CTL.GuildWar.IsShowCrossServerUI() then UIUtils.SetLabel(cellTable.txt_Name, data[2].guildName..string.FormatByIdsId(Const_IDS["IDS_CrossSever_SeverSuffixText1"], CTL.CrossServer.GetServerIDAndServerNameByServerID(data[2].zoneInfo.serverId))) end elseif scrollRect == self.cell_LevelList1.LoopScroll_RankList or scrollRect == self.cell_LevelList2.LoopScroll_RankList then cellTable.txt_Name.text = data.guildName cellTable.txt_Fame.text = data.fameValue UIUtils.SetActive(cellTable.img_Dark, index % 2 == 1) cellTable.img_Champion.gameObject:SetActive(data.isChampion) if CTL.GuildWar.IsShowCrossServerUI() then UIUtils.SetLabel(cellTable.txt_Name, data.guildName..string.FormatByIdsId(Const_IDS["IDS_CrossSever_SeverSuffixText1"], CTL.CrossServer.GetServerIDAndServerNameByServerID(data.zoneInfo.serverId))) end end end return UIGuildWarSingUpView