local UICountryPopupMemberList = UIViewClass() function UICountryPopupMemberList:OnOpened(context) MDL.Country.CountryGetOfficialPanelInfoReq() self:RegistSystemEvent(EventID.Country_OnSearchOfficial, self.OnSearchPlayer) self:RegistSystemEvent(EventID.Country_OnGetNationalList, self.AddPlayerInfo) self:RegistSystemEvent(EventID.Country_OnSearchGuild, self.OnSearchGuild) self:RegistSystemEvent(EventID.Country_OnGetGuildInfo, self.AddGuildInfo) self:RegistSystemEvent(EventID.Country_OnCountrySetOfficial, self.OnCountrySetOfficial) self:RegistSystemEvent(EventID.Country_OnMemberListRefreshList, self.RefreshMemberList) UIUtils.SetActive(self.group_NationalList.btn_Cancel, false) self.toggle_Group:SelectIndex(0) end function UICountryPopupMemberList:RefreshMemberList() self:OnValueChanged(self.toggle_Group, 0) end function UICountryPopupMemberList:OnCountrySetOfficial(info) self.curChangeInfo = info self.group_NationalList.scroll_Details:RefreshCells(false) self.curChangeInfo = nil end function UICountryPopupMemberList:OnSearchPlayer(list) self.group_NationalList.scroll_Details:ClearCells() for i, v in ipairs(list) do self.group_NationalList.scroll_Details:AddData(v, 0) end self.curPage = 0 self.totalLength = 0 if self.isAppoint and self.scroll_Details.Count > 0 then self.group_NationalList.scroll_Details:SelectIndex(0) end self.curSelectPlayer = nil end function UICountryPopupMemberList:OnValueChanged(comp, index) if self.toggle_Group == comp then if index == 0 then self.curPage = 0 self.totalLength = 0 self.curAddCount = 0 self.state_Group:SetState(1) self.group_NationalList.scroll_Details:ClearCells() MDL.Country.CountryGetNationalListReq(self.curPage + 1, MDL.Country.NationalRankType.National) elseif index == 1 then self.curPage = 0 self.totalLength = 0 self.curAddCount = 0 self.state_Group:SetState(0) self.group_GuildList.scroll_Details:ClearCells() MDL.Country.CountryGetGuildInfoReq(self.curPage + 1, false) end elseif comp == self.group_NationalList.obj_InputField then local length = DataSheetManager.ConstData:GetDataByID("GuildNameCharNumlimit").IntValue self.group_NationalList.obj_InputField.text = UTL.String.CutStrByLength(self.group_NationalList.obj_InputField.text, length) end end function UICountryPopupMemberList:SearchPlayer() if string.isNilOrEmpty(self.group_NationalList.obj_InputField.text) then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Chat_CantBlank) return end UIUtils.SetActive(self.group_NationalList.btn_Cancel, true) MDL.Country.CountrySearchNationalReq(self.group_NationalList.obj_InputField.text) end function UICountryPopupMemberList:AddPlayerInfo(list, totalLength, onlineNum) self.totalLength = totalLength for i, v in ipairs(list) do self.group_NationalList.scroll_Details:AddData(v, 0) end self.curPage = self.curPage + 1 if self.isAppoint and self.curSelectPlayer == nil then self.group_NationalList.scroll_Details:SelectIndex(0) end self.curAddCount = self.group_NationalList.scroll_Details.Count self.group_NationalList.txt_GuildNum.text = string.FormatByIdsId(Const_IDS.IDS_Country_CountryMemberNum, onlineNum, totalLength) end function UICountryPopupMemberList:OnButtonClicked(comp) if comp == self.group_NationalList.btn_Cancel then self.group_NationalList.obj_InputField.text = nil UIUtils.SetActive(self.group_NationalList.btn_Cancel, false) self.curPage = 0 self.curAddCount = 0 self.group_NationalList.scroll_Details:ClearCells() MDL.Country.CountryGetNationalListReq(self.curPage + 1, MDL.Country.NationalRankType.National) elseif comp == self.group_NationalList.btn_Search then self:SearchPlayer() elseif comp == self.group_GuildList.btn_Cancel then self.group_GuildList.obj_InputField.text = nil UIUtils.SetActive(self.group_GuildList.btn_Cancel, false) self.curPage = 0 self.curAddCount = 0 self.group_GuildList.scroll_Details:ClearCells() MDL.Country.CountryGetGuildInfoReq(self.curPage + 1, false) elseif comp == self.group_GuildList.btn_Search then self:SearchGuild() elseif comp == self.group_NationalList.btn_Info then local length = DataSheetManager.ConstData:GetDataByID("CountryMemberShowTimeLimit").IntValue local str = string.FormatByIdsId(Const_IDS.IDS_Country_CountryMemberIntro, length) UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = self.group_NationalList.btn_Info, posType = LuaConst.DescriptionPanelType.Center, text = str }) elseif comp == self.btn_QuitGuild then if MDL.Guild.CheckLeader(1) then local length = DataSheetManager.ConstData:GetDataByID("CountryQuitPunishTime").IntValue local timeStr = string.FormatByIdsId(Const_IDS.IDS_Item_Time_Hour, length / UTL.Time.TotalSecondsOneHour) local str = string.FormatByIdsId(Const_IDS.IDS_Country_QuitCountryConfirm2, MDL.Guild.GetMyGuildInfo().guildName, timeStr) UTL.MessageBox.ShowOKCancelBox("", str, function() MDL.Country.CountryGuildLeaveReq() end ) else CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Guild_OnlyLead) end elseif comp == self.group_NationalList.btn_Arrow_CE then self:ClickSortMember(MDL.Country.NationalRankType.Gs, 3) elseif comp == self.group_NationalList.btn_Arrow_LV then self:ClickSortMember(MDL.Country.NationalRankType.Lvl, 2) elseif comp == self.group_NationalList.btn_Arrow_Official then self:ClickSortMember(MDL.Country.NationalRankType.Official, 1) end end function UICountryPopupMemberList:ClickSortMember(rankType, arrowIndex) self.totalLength = 0 self.curAddCount = 0 self.curPage = 0 self.state_Group:SetState(1) self.group_NationalList.scroll_Details:ClearCells() if self.curRankType == rankType then self:SetArrow(arrowIndex, true) self.curReverse = not self.curReverse else self.curRankType = rankType self.curReverse = false self:SetArrow(arrowIndex, false) end MDL.Country.CountryGetNationalListReq(self.curPage + 1, rankType, self.curReverse) end function UICountryPopupMemberList:SetArrow(index, reverse) local arrows = self.group_NationalList.arrows if reverse then local x, y, z = arrows[index].transform:GetLocalScale() arrows[index].transform:SetLocalScale(x, -y, z) else arrows[index].transform:SetLocalScale(1, 1, 1) end for i, v in ipairs(arrows) do if i == index then arrows[i].gameObject:SetActive(true) else arrows[i].gameObject:SetActive(false) end end end function UICountryPopupMemberList:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.group_NationalList.scroll_Details then self:InitPlayerCell(index, cellTable, data) else self:InitGuildCell(index, cellTable, data) end end function UICountryPopupMemberList:InitPlayerCell(index, cellTable, data) if self.curAddCount == index + 1 and index < self.totalLength - 1 then MDL.Country.CountryGetNationalListReq(self.curPage + 1, MDL.Country.NationalRankType.National) end if self.curChangeInfo and self.curChangeInfo.showInfo.acid == data.showInfo.acid then data.position = self.curChangeInfo.position end UTL.Item.SetAtlasSprite(cellTable.img_Emblem, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(data.showInfo.EmblemFrame).Image) cellTable.txt_PlayerName.text = data.showInfo.name cellTable.txt_BR_Num.text = data.showInfo.gsSum cellTable.txt_Name.text = data.showInfo.guildName cellTable.txt_Server.text = CTL.CrossServer.GetServerShowStr(data.showInfo.ShowServerId) cellTable.txt_Emblem.text = data.showInfo.EmblemContent cellTable.txt_Class.text = MDL.Country.GetJobColorName(data.position) cellTable.state_Bg:SetState(index % 2) UIUtils.SetLabel(cellTable.txt_Lv, UTL.Item.GetNobilityByTeamLevel(data.showInfo.level)) if data.showInfo.isOnline then cellTable.txt_State.text = UTL.Color.FormatGreenColor(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Friend_Online)) else local timeOffset = UTL.Time.GetServerTimestamp() - data.showInfo.logoutTime cellTable.txt_State.text = UTL.Color.FormatWhiteColor(UTL.Time.GetBeyondTime(timeOffset)) end UIUtils.SetActive(cellTable.img_SelfBg, data.showInfo.acid == BattleDataGetter.GetAcID()) CTL.Character.SetPortraitAndFrame(cellTable.HeroHead, data.showInfo.PortraitId, data.showInfo.FrameId) end function UICountryPopupMemberList:InitGuildCell(index, cellTable, data) if self.curAddCount == index + 1 then MDL.Country.CountryGetGuildInfoReq(self.curPage + 1, false) end UTL.Item.SetAtlasSprite(cellTable.img_Emblem, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(data.guildEmblemFrame).Image) cellTable.txt_Emblem.text = data.guildEmblemContent cellTable.txt_Name.text = data.guildName cellTable.txt_Server.text = CTL.CrossServer.GetServerShowStr(data.serverId) cellTable.txt_PeopleNum.text = data.guildNum cellTable.txt_PlayerName.text = data.guildLeadName cellTable.txt_BR_Num.text = data.guildGs cellTable.txt_Class.text = MDL.Country.GetGuildTitleColorName(data.levelInCountry) cellTable.state_Bg:SetState(index % 2) UIUtils.SetActive(cellTable.img_SelfBg, data.guildId == MDL.Guild.GetMyGuildInfo().guildId) end function UICountryPopupMemberList:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.group_NationalList.scroll_Details then CTL.PlayerInteract.OpenFriendInteractView(data.showInfo.acid, MDL.PlayerInteract.OccasionType.CountryMember) else MDL.Country.CountryGetTargetGuildInfoReq(data.guildId) end end function UICountryPopupMemberList:AddGuildInfo(list, totalLength) self.totalLength = totalLength for i, v in ipairs(list) do self.group_GuildList.scroll_Details:AddData(v, 0) end self.curPage = self.curPage + 1 if self.curSelectGuild == nil and self.isAppoint then self.group_GuildList.scroll_Details:SelectIndex(0) end self.group_GuildList.txt_GuildNum.text = string.FormatByIdsId(Const_IDS.IDS_Country_CountryGuildNum, totalLength) self.curAddCount = self.group_GuildList.scroll_Details.Count end function UICountryPopupMemberList:OnSearchGuild(list) self.group_GuildList.scroll_Details:ClearCells() for i, v in ipairs(list) do self.group_GuildList.scroll_Details:AddData(v, 0) end self.curPage = 0 self.totalLength = 0 if self.isAppoint and self.group_GuildList.scroll_Details.Count > 0 then self.group_GuildList.scroll_Details:SelectIndex(0) end self.curSelectGuild = nil end function UICountryPopupMemberList:SearchGuild() if string.isNilOrEmpty(self.group_GuildList.obj_InputField.text) then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Chat_CantBlank) return end MDL.Country.CountrySearchGuildReq(self.group_GuildList.obj_InputField.text) UIUtils.SetActive(self.group_GuildList.btn_Cancel, true) end return UICountryPopupMemberList