PGRData/Script/matrix/xui/xuidormtemplate/XUiPanelEncoding.lua
2024-09-01 22:49:41 +02:00

69 lines
No EOL
2.1 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local XUiPanelEncoding = XClass(nil, "XUiPanelEncoding")
function XUiPanelEncoding:Ctor(ui, rootUi)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self.RootUi = rootUi
XTool.InitUiObject(self)
self:AddListener()
end
function XUiPanelEncoding:RegisterClickEvent(uiNode, func)
if func == nil then
XLog.Error("XUiPanelEncoding:RegisterClickEvent函数参数错误参数func不能为空")
return
end
if type(func) ~= "function" then
XLog.Error("XUiPanelEncoding:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func))
end
local listener = function(...)
func(self, ...)
end
CsXUiHelper.RegisterClickEvent(uiNode, listener)
end
function XUiPanelEncoding:AddListener()
self:RegisterClickEvent(self.BtnAllClose, self.OnBtnCloseClick)
self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick)
self:RegisterClickEvent(self.BtnCancel, self.OnBtnCloseClick)
self:RegisterClickEvent(self.BtnSure, self.OnBtnSureClick)
end
function XUiPanelEncoding:OnBtnCloseClick()
self:Close()
end
function XUiPanelEncoding:OnBtnSureClick()
local shareId = string.gsub(self.InFSigm.text, "^%s*(.-)%s*$", "%1")
if string.len(shareId) < 0 then
XUiManager.TipError(CS.XTextManager.GetText("DormTemplateEncondeNoneID"))
return
end
local titletext = CS.XTextManager.GetText("TipTitle")
local contenttext = CS.XTextManager.GetText("DormTemplateEncondeTip")
XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function()
XDataCenter.DormManager.DormGetPlayerLayoutReq(shareId, function()
local fromRoomId = self.RootUi.FromRoomId
self:Close()
self.RootUi:Close()
XDataCenter.DormManager.EnterTemplateDormitory(shareId, XDormConfig.DormDataType.Provisional, fromRoomId)
end)
end)
end
function XUiPanelEncoding:Close()
self.GameObject:SetActiveEx(false)
end
function XUiPanelEncoding:Open()
self.InFSigm.text = ""
self.GameObject:SetActiveEx(true)
end
return XUiPanelEncoding