changhong_newclient/lua_probject/base_project/Game/View/Common/MsgWindow.lua

81 lines
2.0 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

--通用消息弹出框View
--author--
MsgWindow = {}
MsgWindow.MsgMode = {
OkAndCancel = 1,
OnlyOk = 2
}
MsgWindow.RES_LIST = {
"MessageBox",
"MessageBox1"
}
local M = MsgWindow
function MsgWindow.new(blur_view, tip, mode, url, showCheck, data)
setmetatable(M, { __index = BaseWindow })
local self = setmetatable({}, { __index = M })
self.class = "MsgWindow"
self._blur_view = blur_view
self._close_destroy = true
self._tip = tip
self._mode = mode
self.onOk = event("onOk", true)
self.onCancel = event("onCancel", true)
self.showCheck = showCheck
self.data = data
local self_url = url and url or "ui://Common/" .. MsgWindow.RES_LIST[self._mode]
self:init(self_url)
return self
end
function M:init(url)
BaseWindow.init(self, url)
self._close_destroy = true
if not self.data or not self.data.closeZone then
self._close_zone = false
end
local view = self._view
local btn_ok = view:GetChild("btn_ok")
btn_ok.onClick:Add(function()
self.onOk()
self:Destroy()
end)
local tex_message = view:GetChild("tex_message")
if (self._tip) then tex_message.text = self._tip end
local btn_close = view:GetChild('btn_close1')
if not self.data or not self.data.openClose then
btn_close.visible = false
end
if (btn_close ~= nil) then
btn_close.onClick:Add(
function()
self:CloseEvent()
end
--self:Destroy()
)
end
self.btnCheck = view:GetChild("btnCheck")
if self.btnCheck then
self.btnCheck.visible = false
if self.showCheck then
self.btnCheck.selected = true
self.btnCheck.visible = true
end
end
if self.data and self.data.titleUrl then
view:GetChild('n18').icon = self.data.titleUrl
end
end
function M:Close()
BaseWindow.Close(self)
if (self._mode == MsgWindow.MsgMode.OkAndCancel) then
self.onCancel()
end
end