chore: upgrade ts2lua-unreal to v0.3.1 with lowercase lib/module.lua & lib/class.lua and commit framework refactor

This commit is contained in:
szy73711 committed 2026-11-30 03:43:42 +08:00
1 parent 783dccf53d
commit 3572f2da43
206 files changed
+14442 -13186

No files matched your search

+202
View File
@@ -0,0 +1,202 @@
local ____lualib = require("lualib_bundle")
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local ____exports = __module.env
local M__share_base_logger = __MODULE__.Import("share.base.logger", __module)
local Logger = M__share_base_logger.Logger
local M__share_base_scoped_object = __MODULE__.Import("share.base.scoped_object", __module)
local ScopedObject = M__share_base_scoped_object.ScopedObject
local M__share_base_traceback = __MODULE__.Import("share.base.traceback", __module)
local tbpcall = M__share_base_traceback.tbpcall
local logger = Logger("UIWindow")
____exports.UIWindow = __TS__DefineClass("UIWindow", __module)
local UIWindow = ____exports.UIWindow
UIWindow.name = "UIWindow"
__TS__ClassExtends(UIWindow, ScopedObject)
function UIWindow.prototype.____constructor(self, ...)
ScopedObject.prototype.____constructor(self, ...)
self.widget = nil
self.isLoading = false
self.isLoaded = false
self.isVisible = false
self.isClosing = false
self.isCached = false
self.buttonBindings = {}
end
function UIWindow.prototype.InitContextInternal(self, ctx, uiManager, config, widgetAdapter)
self.ctx = ctx
self.uiManager = uiManager
self.config = config
self.widgetAdapter = widgetAdapter
end
function UIWindow.prototype.GetWidget(self)
return self.widget
end
function UIWindow.prototype.IsLoading(self)
return self.isLoading
end
function UIWindow.prototype.IsLoaded(self)
return self.isLoaded
end
function UIWindow.prototype.IsVisible(self)
return self.isVisible
end
function UIWindow.prototype.IsClosing(self)
return self.isClosing
end
function UIWindow.prototype.IsCached(self)
return self.isCached
end
function UIWindow.prototype.SetLoadingStateInternal(self, loading, handle)
self.isLoading = loading
self.classLoadHandle = handle
end
function UIWindow.prototype.AttachWidgetInternal(self, widget)
self.widget = widget
self.isLoading = false
self.isLoaded = true
self.isCached = false
self:OnBindWidgets()
end
function UIWindow.prototype.RequireWidget(self, widgetName)
assert(
self.widget ~= nil,
string.format("[%s] Widget root is not attached", self.config.name)
)
local child = self.widgetAdapter:FindChild(self.widget, widgetName)
assert(
child ~= nil,
string.format("[%s] Required child widget '%s' not found in Widget Blueprint", self.config.name, widgetName)
)
return child
end
function UIWindow.prototype.BindButtonClick(self, button, callback)
local bridge = self.ctx:GetService("uiDelegateBridge")
if bridge == nil then
logger:Warn("UIDelegateBridge not registered on context", {window = self.config.name})
return nil
end
local handle = bridge:BindButtonClick(button, callback, self)
self.buttonBindings[#self.buttonBindings + 1] = handle
return handle
end
function UIWindow.prototype.UnbindAllButtons(self)
do
local i = 0
while i < #self.buttonBindings do
self.buttonBindings[i + 1]:Dispose()
i = i + 1
end
end
self.buttonBindings = {}
end
function UIWindow.prototype.ShowInternal(self, zOrder, args)
if self:IsDisposed() or self.isClosing then
return
end
tbpcall(function()
self:OnPreShow(args)
end)
if self.widget ~= nil then
self.widgetAdapter:AddToViewport(self.widget, zOrder)
self.widgetAdapter:SetVisible(self.widget, true)
end
self.isVisible = true
tbpcall(function()
self:OnShow()
end)
end
function UIWindow.prototype.ReuseInternal(self, zOrder, args)
if self:IsDisposed() then
return
end
self.isCached = false
self.isClosing = false
self:EnableAllEventListeners()
self:OnBindWidgets()
tbpcall(function()
self:OnReuseUI(args)
end)
self:ShowInternal(zOrder, args)
end
function UIWindow.prototype.Hide(self)
if not self.isVisible then
return
end
self.isVisible = false
if self.widget ~= nil and self.widgetAdapter:IsWidgetValid(self.widget) then
self.widgetAdapter:SetVisible(self.widget, false)
end
tbpcall(function()
self:OnHide()
end)
end
function UIWindow.prototype.Close(self, onClosed)
if self:IsDisposed() or self.isCached or self.isClosing then
return
end
self.isClosing = true
if self.isLoading and self.classLoadHandle ~= nil then
self.classLoadHandle:Cancel()
self.classLoadHandle = nil
self.isLoading = false
end
local canCache = self.config.cacheTag == "cache" and self.isLoaded and self.widget ~= nil and self.widgetAdapter:IsWidgetValid(self.widget) and not self.ctx:IsShuttingDown()
if canCache then
self.isVisible = false
self.isCached = true
self.isClosing = false
self:UnbindAllButtons()
self:DisableAllEventListeners()
self.widgetAdapter:RemoveFromParent(self.widget)
tbpcall(function()
self:OnClose()
end)
self.uiManager:HandleWindowCachedInternal(self)
if onClosed ~= nil then
tbpcall(onClosed)
end
return
end
if self.isLoaded then
tbpcall(function()
self:OnClose()
end)
end
self.isVisible = false
self:UnbindAllButtons()
if self.widget ~= nil and self.widgetAdapter:IsWidgetValid(self.widget) then
self.widgetAdapter:RemoveFromParent(self.widget)
end
self.widget = nil
self.uiManager:HandleWindowClosedInternal(self)
self:Dispose()
if onClosed ~= nil then
tbpcall(onClosed)
end
end
function UIWindow.prototype.ForceDisposeFromCacheInternal(self)
self.isCached = false
self:UnbindAllButtons()
if self.widget ~= nil and self.widgetAdapter:IsWidgetValid(self.widget) then
self.widgetAdapter:RemoveFromParent(self.widget)
end
self.widget = nil
self:Dispose()
end
function UIWindow.prototype.OnBindWidgets(self)
end
function UIWindow.prototype.OnPreShow(self, _args)
end
function UIWindow.prototype.OnShow(self)
end
function UIWindow.prototype.OnReuseUI(self, _args)
end
function UIWindow.prototype.OnHide(self)
end
function UIWindow.prototype.OnClose(self)
end
function __module.UpdateImports()
Logger = M__share_base_logger.Logger
ScopedObject = M__share_base_scoped_object.ScopedObject
tbpcall = M__share_base_traceback.tbpcall
end