local UIGuildCreate = UIViewClass() function UIGuildCreate:OnOpened(context) self:RegistSystemEvent(EventID.UI_Guild_GuildCheckContent,self.SetContent) self:RegistSystemEvent(EventID.UI_RefreshCurrency, self.RefreshInfo) local cost = DataSheetManager.GuildCreate:GetDataByID(1) local coinData = DataSheetManager.ItemData:GetDataByID(cost.CreateCostType) UTL.Item.SetAtlasSprite(self.icon_Cost, "UI_Common", coinData.Icon) self:RefreshInfo() for i,v in DataSheetManager.GuildEmblem:GetEnumerator() do self.uint_Scroll:AddData(v,0) end self.uint_Scroll:SelectIndex(0) local count = MDL.Currency.GetMoneyCount(cost.CreateCostType) local hours = DataSheetManager.ConstData:GetDataByID("GuildEvaluationTime").IntValue / UTL.Time.TotalSecondsOneMinute local num = DataSheetManager.ConstData:GetDataByID("GuildEvaluationMemberNum").IntValue self.txt_Info2.text = string.FormatByIdsId(Const_IDS.IDS_GuildCreate_Label3,hours,num,num) self.obj_InputField.characterLimit = 0 end function UIGuildCreate:RefreshInfo() local cost = DataSheetManager.GuildCreate:GetDataByID(1) local count = MDL.Currency.GetMoneyCount(cost.CreateCostType) if count < cost.CreateCostNum then self.txt_Cost.text = UTL.Color.FormatRedColor(cost.CreateCostNum) else self.txt_Cost.text = cost.CreateCostNum end self.isEnough = (count >= cost.CreateCostNum) self.costName = UTL.Item.GetItemDataSpliceByType(cost.CreateCostType).Name end function UIGuildCreate:OnClosed() end function UIGuildCreate:SetContent(msg) if msg.type == MDL.Guild.GuildUpdateType.RecruitTagline then self.obj_InputField5.text = msg.content end end function UIGuildCreate:LimitInputText(inputText,length) inputText.text = UTL.String.CutStrByLength(inputText.text, length) end function UIGuildCreate:OnEndEdit(comp, value) if comp == self.obj_InputField4 then if string.len(self.obj_InputField4.text) > 0 then local length = DataSheetManager.ConstData:GetDataByID("GuildNameCharNumlimit").IntValue self:LimitInputText(self.obj_InputField4, length) MDL.Guild.GuildSetupCheckReq(MDL.Guild.GuildUpdateType.Name,self.obj_InputField4.text) end elseif comp == self.obj_InputField5 then if string.len(self.obj_InputField5.text) > 0 then local length = DataSheetManager.ConstData:GetDataByID("GuildAnncCharNumlimit").IntValue self:LimitInputText(self.obj_InputField5, length) MDL.Guild.GuildSetupCheckReq(MDL.Guild.GuildUpdateType.RecruitTagline,self.obj_InputField5.text) end elseif comp == self.obj_InputField then if string.len(self.obj_InputField.text) > 0 then self:LimitInputText(self.obj_InputField, 2) self.txt_TitleGuildName.text = self.obj_InputField.text MDL.Guild.GuildSetupCheckReq(MDL.Guild.GuildUpdateType.EmblemContent,self.txt_TitleGuildName.text) end end end function UIGuildCreate:OnButtonClicked(comp) if comp == self.btn_Create then if self:CheckStringEmpty() then local context = {name = self.obj_InputField4.text, emblemContend = self.txt_TitleGuildName.text, emblemFrame = self.curSelectImage, recruitTagline = self.obj_InputField5.text, isAutoApprove = self.toggle_AutoAccept.isOn, createType = 1} if MDL.Guild.GetMyGuildInfo().maxCreateType > 1 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildCreateLevelPanel,context) else local str = string.FormatByIdsId(Const_IDS.IDS_GuildCreateConfirm_Text,self.obj_InputField4.text) UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_GuildCreate_PageTitle, str, function () MDL.Guild.GuildCreateReq(context) end,nil) end end end end function UIGuildCreate:CheckStringEmpty() if string.isNilOrEmpty(self.obj_InputField.text)then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildCreate_Fail5) return false end if string.isNilOrEmpty(self.obj_InputField4.text)then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildCreate_Fail3) return false end if string.isNilOrEmpty(self.obj_InputField5.text)then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildAnnounce_EmptyText) return false end if not self.curSelectUnlock then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildCreate_Fail7) return false end if not self.isEnough then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail1,self.costName) return false end return true end function UIGuildCreate:OnCellSelect(scrollRect, index, cellTable, data) UTL.Item.SetAtlasSprite(self.ico_GuildBg, "UI_Guild", data.Image) self.curSelectImage = data.ID UIUtils.SetLabelText(self.txt_title2,Const_IDS[data.Name]) UIUtils.SetLabelText(self.txt_Info,Const_IDS[data.DescText]) self.curSelectUnlock = (data.UnlockConditionParam == 0) if not self.curSelectUnlock then CTL.Sound.PlayGameSound("UI_invalid") end end function UIGuildCreate:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetAtlasSprite(cellTable.ico_GuildBg, "UI_Guild", data.Image) if data.UnlockConditionParam == 0 then cellTable.group_Lock.gameObject:SetActive(false) else cellTable.group_Lock.gameObject:SetActive(true) end end return UIGuildCreate