local UIGuildChangeNamePanel = UIViewClass() function UIGuildChangeNamePanel:OnOpened(context) UIUtils.SetLabelText(self.txt_Tips, Const_IDS.IDS_GuildChangeName_Label1) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_GuildChangeName_Title) UIUtils.SetLabelText(self.Placeholder, Const_IDS.IDS_GuildChangeNameCharRules) local costType = DataSheetManager.ConstData:GetDataByID("GuildNameChangeCostType").IntValue local costCount = DataSheetManager.ConstData:GetDataByID("GuildNameChangeCostNum").IntValue local coinData = DataSheetManager.ItemData:GetDataByID(costType) UTL.Item.SetAtlasSprite(self.img_Icon, "UI_Common", coinData.Icon) local count = MDL.Currency.GetMoneyCount(costType) if count < costCount then self.txt_Count.text = UTL.Color.FormatRedColor(costCount) else self.txt_Count.text = costCount self.isEnough = true end self.changeNameCDTime = DataSheetManager.ConstData:GetDataByID("GuildNameChangeCD").IntValue * UTL.Time.TotalSecondsOneHour self:SetChangeNamePanel() self.event_Random.gameObject:SetActive(false) self.group_Gender.gameObject:SetActive(false) end function UIGuildChangeNamePanel:SetChangeNamePanel() local lastTime = MDL.Guild.GetMyGuildInfo().preUpdateNameTime if lastTime and lastTime > 0 then local cdTime = os.difftime(lastTime + self.changeNameCDTime, UTL.Time.GetServerTimestamp()) self.isInCD = cdTime > 0 if not self.isInCD then self.txt_CDTips:ActiveComponents(false) self:StopRepeatFunc(self.OnUpdateFun) else self.txt_CDTips:ResetAndBeginCustomTimer(false, cdTime, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_PlayName_ChangeNameCDTime"]), 1) self:StartRepeatFunc(self.OnUpdateFun, cdTime) end end UIUtils.SetActive(self.group_NameChange.gameObject, true) if MDL.Guild.GetNamedFreeNums() > 0 then UIUtils.SetActive(self.group_Cost, false) -- 合服后给玩家赠送新的改名机会 UIUtils.SetLabelText(self.txt_LevelHint, Const_IDS.IDS_GamexMerge_Rename) UIUtils.SetActive(self.txt_LevelHint, true) else UIUtils.SetActive(self.group_Cost, true) UIUtils.SetActive(self.txt_LevelHint, false) end end function UIGuildChangeNamePanel:OnValueChanged(comp, value) if comp == self.obj_input then local length = DataSheetManager.ConstData:GetDataByID("GuildNameCharNumlimit").IntValue self.obj_input.text = UTL.String.CutStrByLength(self.obj_input.text, length) end end function UIGuildChangeNamePanel:OnUpdateFun(deltaTime, timeSinceUpdate) self:SetChangeNamePanel() end function UIGuildChangeNamePanel:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIGuildChangeNamePanel:OnButtonClicked(comp) if comp == self.btn_Sure then if string.isNilOrEmpty(self.obj_input.text)then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildCreate_Fail3) return end if self.isInCD then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildChangeName_Fail1) return end if self.obj_input.text == MDL.Guild.GetGuildMemberInfo().listInfo.name then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildRepeatedName) end if self.isEnough then local content = string.FormatByIdsId(Const_IDS.IDS_GuildChangeNameConfirm_Label, self.obj_input.text) UTL.MessageBox.ShowOKCancelBox(nil, content, function() MDL.Guild.GuildSetupReq(MDL.Guild.GuildUpdateType.Name, self.obj_input.text) self:CloseView() end) else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail5) end elseif comp == self.UICommonPopUp.btn_Close then self:CloseView() end end return UIGuildChangeNamePanel