local UICountryPublicNotice = UIViewClass() function UICountryPublicNotice:OnOpened(context) self.obj_InputField.text = context.text if context.isNotice then self:SetNoticeInfo() else self:SetRecruitInfo() end end function UICountryPublicNotice:OnValueChanged(comp, value) if comp == self.obj_InputField then local length = DataSheetManager.ConstData:GetDataByID("GuildNoticeCharNumlimit").IntValue self.obj_InputField.text = UTL.String.CutStrByLength(self.obj_InputField.text, length) end end function UICountryPublicNotice:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UICountryPublicNotice:OnButtonClicked(comp) if comp == self.btn_1 then if string.isNilOrEmpty(self.obj_InputField.text) then CTL.Sound.PlayGameSound("UI_invalid") self:ShowEmptyTips() else self:GuildSetupReq() self:CloseView() end elseif comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UICountryPublicNotice:SetNoticeInfo() UIUtils.SetLabelText(self.lab_NoticePrompt, Const_IDS.IDS_CountrySetting_CountryNoticeIntro) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_CountrySetting_CountryNotice) if self.obj_InputField.text == "" then local data = MDL.Country.GetMyCountryInfo() self.obj_InputField.text = MDL.Country.GetCountryNotice(data.notice, data.countryID) --self.obj_InputField.text = MDL.Country.GetCountryNotice(nil, MDL.Country.GetMyCountryId()) end end function UICountryPublicNotice:SetRecruitInfo() UIUtils.SetLabelText(self.lab_NoticePrompt, Const_IDS.IDS_CountrySetting_CountryAnnouceIntro) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_Country_Announcement) if self.obj_InputField.text == "" then local data = MDL.Country.GetMyCountryInfo() self.obj_InputField.text = MDL.Country.GetCountryAnnouncement(data.declaration, data.countryID) end end function UICountryPublicNotice:ShowEmptyTips() if self.context.isNotice then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildNotice_EmptyText) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildAnnounce_EmptyText) end end function UICountryPublicNotice:GuildSetupReq() if self.context.isNotice then MDL.Country.CountrySetNoticeReq(self.obj_InputField.text) else MDL.Country.CountrySetDeclarationReq(self.obj_InputField.text) end end return UICountryPublicNotice