local UICountryPopupNationalAppoint = UIViewClass() function UICountryPopupNationalAppoint:OnOpened(context) self:RegistSystemEvent(EventID.Country_OnSearchOfficial, self.OnSearchGuild) self:RegistSystemEvent(EventID.Country_OnGetNationalList, self.AddGuildInfo) UIUtils.SetActive(self.btn_Cancel, false) self.curPage = 0 self:Init(context) end function UICountryPopupNationalAppoint:Init(context) MDL.Country.CountryGetNationalListReq(self.curPage + 1, MDL.Country.NationalRankType.Appointment) self.curJobId = context.jobId self.curIndex = context.index self.isAppoint = true self.UICommonPopUp.txt_Title.text = string.FormatByIdsId(Const_IDS.IDS_Country_OfficerAppointIntro, MDL.Country.GetJobColorName(self.curJobId)) end function UICountryPopupNationalAppoint:AddGuildInfo(list, totalLength, onlineNum) self.totalLength = totalLength for i, v in ipairs(list) do self.scroll_Details:AddData(v, 0) end self.curPage = self.curPage + 1 if self.isAppoint and self.curSelectPlayer == nil then self.scroll_Details:SelectIndex(0) end self.curAddCount = self.scroll_Details.Count if self.txt_GuildNum then self.txt_GuildNum.text = string.FormatByIdsId(Const_IDS.IDS_Country_CountryMemberNum, onlineNum, totalLength) end end function UICountryPopupNationalAppoint:OnSearchGuild(list) self.scroll_Details:ClearCells() for i, v in ipairs(list) do self.scroll_Details:AddData(v, 0) end self.curPage = 0 self.totalLength = 0 self.curSelectPlayer = nil if self.isAppoint and self.scroll_Details.Count > 0 then self.scroll_Details:SelectIndex(0) end end function UICountryPopupNationalAppoint:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Cancel then self.obj_InputField.text = nil UIUtils.SetActive(self.btn_Cancel, false) self.curPage = 0 self.scroll_Details:ClearCells() MDL.Country.CountryGetNationalListReq(self.curPage + 1, MDL.Country.NationalRankType.Appointment) elseif comp == self.btn_Appoint then if self:CheckSetOfficial() then self:ClickAppoint() end elseif comp == self.btn_Search then self:SearchGuild() elseif comp == self.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.btn_Info, posType = LuaConst.DescriptionPanelType.RightLower, text = str}) end end function UICountryPopupNationalAppoint:CheckSetOfficial() if self.curSelectPlayer.position == MDL.Country.CountryJob.CountryPopulace then return true else CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_Country_GuildAlreadyAppointedTip) return false end end function UICountryPopupNationalAppoint:OnValueChanged(comp, value) if comp == self.obj_InputField then local length = DataSheetManager.ConstData:GetDataByID("GuildNameCharNumlimit").IntValue self.obj_InputField.text = UTL.String.CutStrByLength(self.obj_InputField.text, length) end end function UICountryPopupNationalAppoint:SearchGuild() if string.isNilOrEmpty(self.obj_InputField.text) then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Chat_CantBlank) return end UIUtils.SetActive(self.btn_Cancel, true) MDL.Country.CountrySearchNationalReq(self.obj_InputField.text) end function UICountryPopupNationalAppoint:OnCellInit(scrollRect, index, cellTable, data) if index == self.totalLength - 1 then elseif self.curAddCount == index + 1 then MDL.Country.CountryGetNationalListReq(self.curPage + 1, MDL.Country.NationalRankType.Appointment) 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) end function UICountryPopupNationalAppoint:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Player then CTL.PlayerInteract.OpenFriendInteractView(data.showInfo.acid) end end function UICountryPopupNationalAppoint:OnCellSelect(scrollRect, index, cellTable, data) self.curSelectPlayer = data if self.curSelectPlayer.position == MDL.Country.CountryJob.CountryPopulace then self.btn_Appoint:SetGray(false) else self.btn_Appoint:SetGray(true, true) end end function UICountryPopupNationalAppoint:ClickAppoint() local roleInfo = self.curSelectPlayer.showInfo local jobName = MDL.Country.GetJobColorName(self.curJobId) local str = string.FormatByIdsId(Const_IDS.IDS_Country_AppointOfficerConfirm, CTL.CrossServer.GetServerShowStr(roleInfo.ShowServerId), roleInfo.name, jobName) UTL.MessageBox.ShowOKCancelBox("", str, function() MDL.Country.CountrySetOfficialReq(roleInfo.acid, self.curJobId, self.curIndex) end ) end return UICountryPopupNationalAppoint