local UIGuildApply = UIViewClass() function UIGuildApply:OnOpened(context) self:RegistSystemEvent(EventID.UI_Guild_GuildListRefresh,self.RefreshList) self:RegistSystemEvent(EventID.UI_Guild_SelfInfoRefresh, self.SetApplyCount) MDL.Guild.GetGuildListReq() UIUtils.SetActive(self.btn_CloseInput, false) end function UIGuildApply:RefreshList(list) if list and #list> 0 then self.group_Empty01.gameObject:SetActive(false) self.group_Empty02.gameObject:SetActive(false) self.guild_Info.gameObject:SetActive(true) self.listEmpty = false else self.group_Empty01.gameObject:SetActive(true) self.group_Empty02.gameObject:SetActive(true) self.guild_Info.gameObject:SetActive(false) self.listEmpty = true end if self.LoopScroll_Properties.Count == 0 then if list and #list> 0 then local index = 0 for i,v in ipairs(list) do if self.context and v.id == self.context.id then index = i - 1 self.context = nil end self.LoopScroll_Properties:AddData(v, 0) end self.LoopScroll_Properties:SelectIndex(index, true) end 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.guildList = list self:SetApplyCount(true) end function UIGuildApply:OnClosed() end function UIGuildApply:SetApplyCount(isReload) local maxValue = DataSheetManager.ConstData:GetDataByID("PlayerApplicationListLimit").IntValue if maxValue == #MDL.Guild.GetMyGuildInfo().applayGuildId then self.btn_Quickapply:SetGray(true,true) self.lab_Times.text = UTL.Color.FormatRedColor(maxValue).."/"..maxValue else self.btn_Quickapply:SetGray(false) self.lab_Times.text = #MDL.Guild.GetMyGuildInfo().applayGuildId.."/"..maxValue end if self.curSelectData and MDL.Guild.IsApplay(self.curSelectData.id) then UIUtils.SetActive(self.btn_Apply, false) UIUtils.SetActive(self.btn_Cancel, true) else UIUtils.SetActive(self.btn_Apply, true) UIUtils.SetActive(self.btn_Cancel, false) end if not isReload then self.LoopScroll_Properties:RefreshCells() end end function UIGuildApply: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 UIGuildApply:OnButtonClicked(comp) if comp == self.btn_Apply then if not self:JoinCheck(MDL.Guild.GuildJoinReq,{self.curSelectData and self.curSelectData.id}) then MDL.Guild.GuildJoinReq({self.curSelectData.id},nil) end elseif comp == self.btn_Quickapply then if not self:JoinCheck(MDL.Guild.GuildOneKeyJoinReq,nil) then MDL.Guild.GuildOneKeyJoinReq() end elseif comp == self.event_InDeclaration then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildApplyManifestoPanel) elseif 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.btn_Cancel then MDL.Guild.CancelApplayJoinGuildReq(self.curSelectData.id) end end function UIGuildApply: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 UIGuildApply:JoinCheck(cbFunc,params) if self.listEmpty then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildApply_Fail5) return true end if string.isNilOrEmpty(MDL.Guild.GetMyGuildInfo().approveTagline) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildApplyManifestoPanel,{func = cbFunc,params = params}) return true end end function UIGuildApply:OnCellSelect(scrollRect, index, cellTable, data) self.txt_TitleGuildName.text = data.emblemContent self.txt_MainGuildName.text = data.name self.txt_JobPlayerName.text = data.leader.name 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 CTL.Player.OperateGenderImage(self.leader_Gender, data.leader.sex) 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 self.neishi_Rank.text = nil end CTL.Player.OperateGenderImage(self.neishi_Gender, data.diplomat.sex) UIUtils.SetActive(self.neishi_Gender,true) UIUtils.SetActive(self.neishi_Empty,false) UIUtils.SetActive(self.neishi_Chat,true) else UIUtils.SetLabelText(self.neishi_Empty,Const_IDS.IDS_GuildApply_Label7) self.txt_NeishiName.text = nil self.neishi_Rank.text = nil UIUtils.SetActive(self.neishi_Empty,true) UIUtils.SetActive(self.neishi_Chat,false) UIUtils.SetActive(self.neishi_Gender,false) end self.group_info2.text = data.recruitTagline -- self.txt_CombatNum.text = data.limit.gs -- self.level_Limit.text = data.limit.level 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 self:SetLimit(data.limit.level, data.limit.gs) if MDL.Guild.IsApplay(data.id) then UIUtils.SetActive(self.btn_Apply, false) UIUtils.SetActive(self.btn_Cancel, true) else UIUtils.SetActive(self.btn_Apply, true) UIUtils.SetActive(self.btn_Cancel, false) end self.curSelectData = data UTL.Item.SetAtlasSprite(self.ico_GuildBg, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(data.emblemFrame).Image) end function UIGuildApply: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 UIGuildApply: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 return UIGuildApply