local UIGuildNoticePanel = UIViewClass() local MAIL_MAX_COUNT = DataSheetManager.ConstData:GetDataByID("GuildMailDailyNum").IntValue local CHAT_MAX_COUNT = DataSheetManager.ConstData:GetDataByID("GuildMessageDailyNum").IntValue function UIGuildNoticePanel:OnOpened(context) self.toggle_TopGroup:SelectIndex(0) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title,Const_IDS.IDS_GuildMail_Title) end function UIGuildNoticePanel:OnValueChanged(comp, value) if comp == self.obj_InputTitle then local length = DataSheetManager.ConstData:GetDataByID("GuildMailTitleCharLimit").IntValue self.obj_InputTitle.text = UTL.String.CutStrByLength(self.obj_InputTitle.text, length) elseif comp == self.obj_InputField then local length = DataSheetManager.ConstData:GetDataByID("GuildMailCharLimit").IntValue self.obj_InputField.text = UTL.String.CutStrByLength(self.obj_InputField.text, length) elseif comp == self.obj_InputFieldPrivate then local length = DataSheetManager.ConstData:GetDataByID("GuildMessageCharLimit").IntValue self.obj_InputFieldPrivate.text = UTL.String.CutStrByLength(self.obj_InputFieldPrivate.text, length) elseif comp == self.toggle_TopGroup then self.curPageIndex = value self:OnSwitchPage(value) end end function UIGuildNoticePanel:OnSwitchPage(value) UIUtils.SetActive(self.group_Mail, value == 0) UIUtils.SetActive(self.group_Private, value ~= 0) local usedCount = value == 0 and MAIL_MAX_COUNT - self.context.mailCount or CHAT_MAX_COUNT - self.context.privateChatCount if usedCount <= 0 then self.btn_1:SetGray(true) UIUtils.SetLabel(self.txt_NoticeNum, string.FormatByIdsId(Const_IDS.IDS_Guild_DailyNum,UTL.Color.FormatRedColor(0))) else self.btn_1:SetGray(false) UIUtils.SetLabel(self.txt_NoticeNum, string.FormatByIdsId(Const_IDS.IDS_Guild_DailyNum,UTL.Color.FormatGreenColor(usedCount))) end end function UIGuildNoticePanel:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIGuildNoticePanel:OnButtonClicked(comp) if comp == self.btn_1 then if self.curPageIndex == 0 then if string.isNilOrEmpty(self.obj_InputTitle.text) or string.isNilOrEmpty(self.obj_InputField.text) then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildMail_EmptyText) return end MDL.Guild.GuildNotificationReq(self.obj_InputTitle.text,self.obj_InputField.text) self:CloseView() elseif self.curPageIndex == 1 then if string.isNilOrEmpty(self.obj_InputFieldPrivate.text) then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildMail_EmptyText) return end MDL.ChannelChat.SendGuildPrivateNotificationMsg(self.obj_InputFieldPrivate.text) self:CloseView() end elseif comp == self.UICommonPopUp.btn_Close then self:CloseView() end end return UIGuildNoticePanel