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

72 lines
1.7 KiB
Lua
Raw Permalink 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)
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
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
self._close_zone = false
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 (btn_close~=nil) then
btn_close.onClick:Add(
function()
self:CloseEvent()
end
)
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
end
function M:Close()
BaseWindow.Close(self)
if(self._mode == MsgWindow.MsgMode.OkAndCancel) then
self.onCancel()
end
end