89 lines
2.8 KiB
Lua
89 lines
2.8 KiB
Lua
|
|
---聊天View对象
|
|
local ChatView = {}
|
|
|
|
local M = ChatView
|
|
|
|
function ChatView.new(main_view)
|
|
UIPackage.AddPackage("base/chat/ui/Chat")
|
|
setmetatable(M, {__index = BaseWindow})
|
|
local self = setmetatable({}, {__index = M})
|
|
self.class = "ChatView"
|
|
self._main_view = main_view
|
|
self._blur_view = main_view._root_view
|
|
|
|
self:init("ui://Chat/Main")
|
|
return self
|
|
end
|
|
|
|
function M:init(url)
|
|
BaseWindow.init(self,url)
|
|
local lit_biaoqing1 = self._view:GetChild("lit_biaoqing1")
|
|
lit_biaoqing1.onClickItem:Set(function (context)
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|
_gamectr:SendInteraction(DataManager.SelfUser.account_id, 1, context.data.name )
|
|
self:Close()
|
|
end)
|
|
|
|
|
|
-- local lit_biaoqing2 = self._view:GetChild("lit_biaoqing2")
|
|
-- lit_biaoqing2.onClickItem:Set(function (context)
|
|
-- local _gamectr = ControllerManager.GetController(GameController)
|
|
-- _gamectr:SendInteraction(DataManager.SelfUser.account_id, 1, context.data.name )
|
|
-- self:Close()
|
|
-- end)
|
|
|
|
|
|
-- local lit_biaoqing3 = self._view:GetChild("lit_biaoqing3")
|
|
-- lit_biaoqing3.onClickItem:Set(function (context)
|
|
-- local _gamectr = ControllerManager.GetController(GameController)
|
|
-- _gamectr:SendInteraction(DataManager.SelfUser.account_id, 1, context.data.name )
|
|
-- self:Close()
|
|
-- end)
|
|
-- lit_biaoqing3:RemoveChildrenToPool()
|
|
|
|
self:FillChatMsg()
|
|
|
|
local tex_chat = self._view:GetChild("tex_chat")
|
|
local btn_send = self._view:GetChild("btn_send")
|
|
btn_send.onClick:Set(function( ... )
|
|
local chat_text = tex_chat.text
|
|
if string.utf8len(chat_text) >0 then
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|
_gamectr:SendInteraction(DataManager.SelfUser.account_id, 4,chat_text)
|
|
self:Close()
|
|
end
|
|
end)
|
|
|
|
end
|
|
|
|
function M:FillChatMsg()
|
|
local chat_msg
|
|
local language = self._main_view:GetLanguage()
|
|
if language == 1 then
|
|
chat_msg = self._main_view.Fix_Msg_Chat2
|
|
else
|
|
chat_msg = self._main_view.Fix_Msg_Chat
|
|
end
|
|
local lit_yuyin = self._view:GetChild("lit_yuyin")
|
|
lit_yuyin:RemoveChildrenToPool()
|
|
for i = 1 , #chat_msg do
|
|
local btn = lit_yuyin:AddItemFromPool()
|
|
btn.data = tostring(i)
|
|
btn.text = chat_msg[i]
|
|
btn.onClick:Set(function(context)
|
|
local g = context.sender
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|
local msg = g.data + language * 100
|
|
_gamectr:SendInteraction(DataManager.SelfUser.account_id, 2, msg)
|
|
self:Close()
|
|
end)
|
|
end
|
|
end
|
|
|
|
function M:HideInputField()
|
|
self._view:GetController("sdk").selectedIndex = 1
|
|
end
|
|
|
|
return M
|