98 lines
3.2 KiB
Lua
98 lines
3.2 KiB
Lua
require("Base/BasePanel")
|
|
MsgPanel = Inherit(BasePanel)
|
|
|
|
local str1 = Language[10555]
|
|
local str2 = Language[11308]
|
|
local str3 = Language[11309]
|
|
--初始化组件(用于子类重写)
|
|
function MsgPanel:InitComponent()
|
|
|
|
MsgPanel.btn_Left = Util.GetGameObject (self.transform, "buttom/op/btnLeft")
|
|
MsgPanel.txt_BtnLeft = Util.GetGameObject (MsgPanel.btn_Left, "Text"):GetComponent("Text")
|
|
|
|
MsgPanel.btn_Right = Util.GetGameObject (self.transform, "buttom/op/btnRight")
|
|
MsgPanel.txt_BtnRight = Util.GetGameObject (MsgPanel.btn_Right, "Text"):GetComponent("Text")
|
|
|
|
MsgPanel.title = Util.GetGameObject (self.transform, "buttom/title"):GetComponent("Text")
|
|
MsgPanel.tipLabel = Util.GetGameObject (self.transform, "buttom/content"):GetComponent("Text")
|
|
MsgPanel._toggle= Util.GetGameObject (self.transform, "buttom/Toggle"):GetComponent("Toggle")
|
|
MsgPanel._toggleText= Util.GetGameObject (self.transform, "buttom/Toggle/Text"):GetComponent("Text")
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function MsgPanel:BindEvent()
|
|
|
|
Util.AddClick(MsgPanel.btn_Left, MsgPanel.OnLeftBtnClick)
|
|
Util.AddClick(MsgPanel.btn_Right, MsgPanel.OnRightBtnClick)
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function MsgPanel:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function MsgPanel:OnDestroy()
|
|
|
|
end
|
|
|
|
--左边按钮点击事件
|
|
function MsgPanel.OnLeftBtnClick()
|
|
MsgPanel.Hide()
|
|
if MsgPanel.leftAction then
|
|
MsgPanel.leftAction()
|
|
--MsgPanel.leftAction = nil
|
|
end
|
|
end
|
|
|
|
--右边按钮点击事件
|
|
function MsgPanel.OnRightBtnClick()
|
|
MsgPanel.Hide()
|
|
if MsgPanel.rightAction then
|
|
MsgPanel.rightAction(MsgPanel._toggle.isOn)
|
|
--MsgPanel.rightAction = nil
|
|
end
|
|
end
|
|
|
|
--展示一个按钮
|
|
function MsgPanel.ShowOne(msg, action, text, title)
|
|
UIManager.OpenPanel(UIName.MsgPanel)
|
|
MsgPanel.leftAction = action
|
|
MsgPanel.txt_BtnLeft.text = text and text or str1
|
|
MsgPanel.tipLabel.text = msg
|
|
MsgPanel.title.text = title and title or str3
|
|
MsgPanel.btn_Left.gameObject:SetActive(true)
|
|
MsgPanel.btn_Right.gameObject:SetActive(false)
|
|
MsgPanel._toggle.gameObject:SetActive(false)
|
|
ForceRebuildLayout(MsgPanel._toggle.transform)
|
|
end
|
|
|
|
--展示两个按钮
|
|
function MsgPanel.ShowTwo(msg, leftAction, rightAction, leftText, rightText, title,isShowToggle,toggleText)
|
|
UIManager.OpenPanel(UIName.MsgPanel)
|
|
MsgPanel.leftAction = leftAction
|
|
MsgPanel.rightAction = rightAction
|
|
MsgPanel.txt_BtnLeft.text = leftText and leftText or str2
|
|
MsgPanel.txt_BtnRight.text = rightText and rightText or str1
|
|
MsgPanel.title.text = title and title or str3
|
|
MsgPanel.tipLabel.text = msg;
|
|
MsgPanel.btn_Left.gameObject:SetActive(true)
|
|
MsgPanel.btn_Right.gameObject:SetActive(true)
|
|
if(isShowToggle) then
|
|
MsgPanel._toggle.gameObject:SetActive(true)
|
|
if(toggleText) then
|
|
MsgPanel._toggleText.text=toggleText
|
|
else
|
|
MsgPanel._toggleText.text=Language[11310]
|
|
end
|
|
else
|
|
MsgPanel._toggle.gameObject:SetActive(false)
|
|
end
|
|
ForceRebuildLayout(MsgPanel._toggle.transform)
|
|
end
|
|
|
|
function MsgPanel.Hide()
|
|
MsgPanel:ClosePanel()
|
|
end
|
|
|
|
return MsgPanel |