miduo_client/Assets/ManagedResources/~Lua/Modules/Message/SysPanel.lua

98 lines
3.1 KiB
Lua

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