源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

64 lines
2.0 KiB

--个性化聊天界面
ChatCustomTextView = ChatCustomTextView or BaseClass(BaseView)
function ChatCustomTextView:__init()
self.base_file = "chat"
self.layout_file = "chatCustomTextView"
self.layer_name = "UI"
self.destroy_imm = true
self.use_background = true
self.click_bg_toClose = true
self.change_scene_close = true
self.background_alpha = 0
self.model = ChatModel:getInstance()
self.load_callback = function ()
self:LoadSuccess()
self:InitEvent()
end
self.open_callback = function ()
self.titleText.text = ""
self.contentText.text = ""
end
self.close_callback = function ()
end
self.destroy_callback = function ()
end
end
function ChatCustomTextView:LoadSuccess()
self.titleInput = self:GetChild("titleInput")
self.contentInput = self:GetChild("contentInput")
self.titleText = self:GetChild("titleInput"):GetComponent("InputField")
self.contentText = self:GetChild("contentInput"):GetComponent("InputField")
self.sureBtn = self:GetChild("sureBtn").gameObject
self.cancelBtn = self:GetChild("cancelBtn").gameObject
self.titleText.characterLimit = 4
self.contentText.characterLimit = 25
end
function ChatCustomTextView:Open(index)
self.index = index
BaseView.Open(self)
end
function ChatCustomTextView:InitEvent()
local function onBtnClickHandler(target)
if target == self.sureBtn then
local cookie = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.CHAT_CUSTOM_TEXT)
cookie = cookie or {}
cookie[self.index] = cookie[self.index] or {}
cookie[self.index].desc = string.gsub(self.titleText.text,'(["])',"")
cookie[self.index].one = string.gsub(self.contentText.text,'(["])',"")
CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.CHAT_CUSTOM_TEXT, cookie)
Message.show("添加成功")
self.model:Fire(ChatModel.UPDATE_INDIVID_VIEW)
self:Close()
elseif target == self.cancelBtn then
self:Close()
end
end
AddClickEvent(self.sureBtn,onBtnClickHandler)
AddClickEvent(self.cancelBtn,onBtnClickHandler)
end