local UIGuildGuildListPanel = UIViewClass() function UIGuildGuildListPanel:OnOpened(context) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_Guild_FunctionName"]) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) self:RegistSystemEvent(EventID.UI_Guild_GuildListRefresh,self.RefreshList) MDL.Guild.GetGuildListReq() UIUtils.SetActive(self.btn_CloseInput, false) UTL.Toggle.InitToggleGroupByIDS(self.leftBtn.toggles_Group, "txt",{Const_IDS.IDS_GuildMember_Button2}) self.leftBtn.toggles_Group:SelectIndex(0) end function UIGuildGuildListPanel:RefreshList(list) local selectIndex = 0 if list and #list> 0 then if self.LoopScroll_Properties.Count == 0 then local index = nil for i,v in ipairs(list) do if self.context and v.id == self.context.id then index = i - 1 end self.LoopScroll_Properties:AddData(v, 0) end if index == nil and self.context ~= nil then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1318_InfoCode_Guild_GuildNotExist) end self.context = nil self.LoopScroll_Properties:SelectIndex(index or 0,true) else self.LoopScroll_Properties:ReloadAll(list) local index = 0 for i,v in ipairs(list) do if v.id == self.curSelectData.id then index = i - 1 end end self.LoopScroll_Properties:SelectIndex(index) end self.group_Empty01.gameObject:SetActive(false) self.group_Empty02.gameObject:SetActive(false) else self.group_Empty01.gameObject:SetActive(true) self.group_Empty02.gameObject:SetActive(true) self.listEmpty = true end self.guildList = list end function UIGuildGuildListPanel:OnValueChanged(comp, value) if comp == self.obj_InputField then if string.isNilOrEmpty(self.obj_InputField.text) and #self.guildList > 0 then if self.search then self.search = false self.LoopScroll_Properties:ReloadAll(self.guildList) self.LoopScroll_Properties:SelectIndex(0) end end UIUtils.SetActive(self.btn_CloseInput, not string.isNilOrEmpty(self.obj_InputField.text)) end end function UIGuildGuildListPanel:OnBackButtonPressed() self:OnButtonClicked(self.btn_close) end function UIGuildGuildListPanel:OnButtonClicked(comp) if comp == self.boss_Chat then CTL.Friend.PrivateTalkToAcid(self.curSelectData.leader.acid) elseif comp == self.neishi_Chat then CTL.Friend.PrivateTalkToAcid(self.curSelectData.diplomat.acid) elseif comp == self.btn_Search then self:SearchGuild() elseif comp == self.btn_CloseInput then if self.search then self.search = false self.LoopScroll_Properties:ReloadAll(self.guildList) self.LoopScroll_Properties:SelectIndex(0) end self.obj_InputField.text = nil elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() end end function UIGuildGuildListPanel:OnCellSelect(scrollRect, index, cellTable, data) self.txt_TitleGuildName.text = data.emblemContent self.txt_MainGuildName.text = data.name self.txt_JobPlayerName.text = data.leader.name CTL.Player.OperateGenderImage(self.image_Gender, data.leader.sex) if data.leader.rankIdx > 0 then self.txt_Rank.text = string.FormatByIdsId(Const_IDS.IDS_GuildApply_Label2,data.leader.rankIdx) else UIUtils.SetLabelText(self.txt_Rank, Const_IDS.IDS_GuildBoss_NotInList) end if data.diplomat and not string.isNilOrEmpty(data.diplomat.acid) then self.txt_NeishiName.text = data.diplomat.name if data.diplomat.rankIdx > 0 then self.neishi_Rank.text = string.FormatByIdsId(Const_IDS.IDS_GuildApply_Label2,data.diplomat.rankIdx) else UIUtils.SetLabelText(self.neishi_Rank, Const_IDS.IDS_GuildBoss_NotInList) end UIUtils.SetActive(self.image_NS_Gender,true) UIUtils.SetActive(self.neishi_Empty,false) UIUtils.SetActive(self.neishi_Chat,true) CTL.Player.OperateGenderImage(self.image_NS_Gender, data.diplomat.sex) else UIUtils.SetLabelText(self.neishi_Empty,Const_IDS.IDS_GuildApply_Label7) self.txt_NeishiName.text = nil self.neishi_Rank.text = nil UIUtils.SetActive(self.image_NS_Gender,false) UIUtils.SetActive(self.neishi_Empty,true) UIUtils.SetActive(self.neishi_Chat,false) end self.group_info2.text = data.recruitTagline self:SetLimit(data.limit.level, data.limit.gs) UTL.Item.SetAtlasSprite(self.ico_GuildBg, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(data.emblemFrame).Image) self.curSelectData = data if data.isAutoApprove then UIUtils.SetLabelText(self.auto_txt,Const_IDS.IDS_Guild_AutoApprove ) else UIUtils.SetLabelText(self.auto_txt,Const_IDS.IDS_Guild_ManualApprove ) end end function UIGuildGuildListPanel:SearchGuild() if string.isNilOrEmpty(self.obj_InputField.text) then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Chat_CantBlank) return end local searchRes = {} for i,v in ipairs(self.guildList) do if string.find(v.name ,self.obj_InputField.text,1,true) then table.insert( searchRes, v) end end if #searchRes> 0 then self.search = true self.LoopScroll_Properties:ReloadAll(searchRes) self.LoopScroll_Properties:SelectIndex(0) else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildSearch_Fail1) end end function UIGuildGuildListPanel:SetLimit(level,gs) if level > 0 or gs > 0 then local myLevel = MDL.Player.GetRoleLevel() local myGs = MDL.Player.GetLineUpGs() if myLevel < level then self.level_Limit.text = UTL.Color.FormatRedColor(UTL.Item.GetNobilityByTeamLevel(level, 2)) else self.level_Limit.text = UTL.Item.GetNobilityByTeamLevel(level, 2) end if myGs < gs then self.txt_CombatNum.text = UTL.Color.FormatRedColor(gs) else self.txt_CombatNum.text = gs end self.limit_State:SetState(0) else self.limit_State:SetState(1) end end function UIGuildGuildListPanel:OnCellInit(scrollRect, index, cellTable, data) cellTable.txt_GuildName.text = data.name if data.memberCount >= data.memberCountLimit then cellTable.txt_GuildMemberNum.text = UTL.Color.FormatRedColor(data.memberCount).."/"..data.memberCountLimit else cellTable.txt_GuildMemberNum.text = data.memberCount.."/"..data.memberCountLimit end local activeness = 3 local activenessArray = DataSheetManager.ConstData:GetDataByID("GuildActivityValueRange").IntListValue for i, v in ipairs(activenessArray) do if data.activeness <= v then activeness = i - 1 break end end cellTable.lights:SetState(activeness) cellTable.ico_Apply.gameObject:SetActive(MDL.Guild.IsApplay(data.id)) local fameStr, fameNum = CTL.Guild.GetGuildReputationInfo(data.fameLevel) cellTable.txt_GuildFame.text = fameStr if fameNum > 0 then cellTable.txt_GuileLevel.text = fameNum UIUtils.SetActive(cellTable.img_bg, true) else UIUtils.SetActive(cellTable.img_bg, false) end UIUtils.SetActive(cellTable.sprite_Bg1, index % 2 ~= 0) end function UIGuildGuildListPanel:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end return UIGuildGuildListPanel