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:
1 parent
783dccf53d
commit
3572f2da43
206 files changed
+14442
-13186
No files matched your search
@@ -0,0 +1,130 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
||||
local __TS__New = ____lualib.__TS__New
|
||||
local ____exports = __module.env
|
||||
local M__share_base_scoped_object = __MODULE__.Import("share.base.scoped_object", __module)
|
||||
local ScopedObject = M__share_base_scoped_object.ScopedObject
|
||||
____exports.MgrDataBase = __TS__DefineClass("MgrDataBase", __module)
|
||||
local MgrDataBase = ____exports.MgrDataBase
|
||||
MgrDataBase.name = "MgrDataBase"
|
||||
function MgrDataBase.prototype.____constructor(self)
|
||||
end
|
||||
function MgrDataBase.prototype.OnEnterGame(self)
|
||||
end
|
||||
function MgrDataBase.prototype.OnExitGame(self)
|
||||
end
|
||||
____exports.ControllerBase = __TS__DefineClass("ControllerBase", __module)
|
||||
local ControllerBase = ____exports.ControllerBase
|
||||
ControllerBase.name = "ControllerBase"
|
||||
__TS__ClassExtends(ControllerBase, ScopedObject)
|
||||
function ControllerBase.prototype.____constructor(self, mgr)
|
||||
ScopedObject.prototype.____constructor(self)
|
||||
self.mgr = mgr
|
||||
end
|
||||
function ControllerBase.prototype.OnEnter(self)
|
||||
end
|
||||
function ControllerBase.prototype.OnBindEvents(self)
|
||||
end
|
||||
function ControllerBase.prototype.OnActive(self)
|
||||
end
|
||||
function ControllerBase.prototype.OnExit(self)
|
||||
end
|
||||
____exports.MgrBase = __TS__DefineClass("MgrBase", __module)
|
||||
local MgrBase = ____exports.MgrBase
|
||||
MgrBase.name = "MgrBase"
|
||||
__TS__ClassExtends(MgrBase, ScopedObject)
|
||||
function MgrBase.prototype.____constructor(self, ...)
|
||||
ScopedObject.prototype.____constructor(self, ...)
|
||||
self.controllers = {}
|
||||
self.isActive = true
|
||||
end
|
||||
function MgrBase.prototype.Initialization(self)
|
||||
self:OnCreate()
|
||||
self:OnBindControllers()
|
||||
self:OnBindEvents()
|
||||
end
|
||||
function MgrBase.prototype.OnBindControllers(self)
|
||||
end
|
||||
function MgrBase.prototype.OnBindEvents(self)
|
||||
end
|
||||
function MgrBase.prototype.OnEnterGame(self)
|
||||
end
|
||||
function MgrBase.prototype.OnExitGame(self)
|
||||
end
|
||||
function MgrBase.prototype.OnClean(self)
|
||||
end
|
||||
function MgrBase.prototype.SetActive(self, active)
|
||||
self.isActive = active
|
||||
if active then
|
||||
self:EnableControllers()
|
||||
self:EnableAllEventListeners()
|
||||
else
|
||||
self:DisableControllers()
|
||||
self:DisableAllEventListeners()
|
||||
end
|
||||
end
|
||||
function MgrBase.prototype.AddController(self, ctor)
|
||||
local existing = self.controllers[ctor]
|
||||
assert(existing == nil, "MgrBase.AddController: controller already added")
|
||||
local ctrl = __TS__New(ctor, self)
|
||||
self.controllers[ctor] = ctrl
|
||||
ctrl:OnEnter()
|
||||
ctrl:OnBindEvents()
|
||||
ctrl:OnActive()
|
||||
return ctrl
|
||||
end
|
||||
function MgrBase.prototype.GetController(self, ctor)
|
||||
return self.controllers[ctor]
|
||||
end
|
||||
function MgrBase.prototype.DelController(self, ctor)
|
||||
local ctrl = self.controllers[ctor]
|
||||
if ctrl == nil then
|
||||
return
|
||||
end
|
||||
self.controllers[ctor] = nil
|
||||
ctrl:OnExit()
|
||||
ctrl:Dispose()
|
||||
end
|
||||
function MgrBase.prototype.DelAllControllers(self)
|
||||
local list = {}
|
||||
for ctorKey, ctrl in pairs(self.controllers) do
|
||||
if ctrl ~= nil then
|
||||
self.controllers[ctorKey] = nil
|
||||
list[#list + 1] = ctrl
|
||||
end
|
||||
end
|
||||
do
|
||||
local i = 0
|
||||
while i < #list do
|
||||
list[i + 1]:OnExit()
|
||||
list[i + 1]:Dispose()
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
function MgrBase.prototype.EnableControllers(self)
|
||||
for _, ctrl in pairs(self.controllers) do
|
||||
if ctrl ~= nil then
|
||||
ctrl:EnableAllEventListeners()
|
||||
ctrl:OnActive()
|
||||
end
|
||||
end
|
||||
end
|
||||
function MgrBase.prototype.DisableControllers(self)
|
||||
for _, ctrl in pairs(self.controllers) do
|
||||
if ctrl ~= nil then
|
||||
ctrl:DisableAllEventListeners()
|
||||
end
|
||||
end
|
||||
end
|
||||
function MgrBase.prototype.Dispose(self)
|
||||
if self:IsDisposed() then
|
||||
return
|
||||
end
|
||||
self:DelAllControllers()
|
||||
self:OnClean()
|
||||
ScopedObject.prototype.Dispose(self)
|
||||
end
|
||||
function __module.UpdateImports()
|
||||
ScopedObject = M__share_base_scoped_object.ScopedObject
|
||||
end
|
||||
@@ -0,0 +1,124 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__New = ____lualib.__TS__New
|
||||
local ____exports = __module.env
|
||||
---
|
||||
-- @noSelf
|
||||
local function ResolveClassName(ctor, explicitName)
|
||||
if explicitName ~= nil and explicitName ~= "" then
|
||||
return explicitName
|
||||
end
|
||||
local rawName = ctor.name
|
||||
if rawName ~= nil and type(rawName) == "string" and rawName ~= "" then
|
||||
return rawName
|
||||
end
|
||||
return tostring(ctor)
|
||||
end
|
||||
____exports.MgrRegistry = __TS__DefineClass("MgrRegistry", __module)
|
||||
local MgrRegistry = ____exports.MgrRegistry
|
||||
MgrRegistry.name = "MgrRegistry"
|
||||
function MgrRegistry.prototype.____constructor(self)
|
||||
self.mgrByCtor = {}
|
||||
self.mgrNameByCtor = {}
|
||||
self.mgrByName = {}
|
||||
self.dataByCtor = {}
|
||||
self.disposed = false
|
||||
end
|
||||
function MgrRegistry.prototype.CreateMgrData(self, ctor)
|
||||
local existing = self.dataByCtor[ctor]
|
||||
if existing ~= nil then
|
||||
return existing
|
||||
end
|
||||
local data = __TS__New(ctor)
|
||||
self.dataByCtor[ctor] = data
|
||||
return data
|
||||
end
|
||||
function MgrRegistry.prototype.GetMgrData(self, ctor)
|
||||
return self.dataByCtor[ctor]
|
||||
end
|
||||
function MgrRegistry.prototype.DelMgrData(self, ctor)
|
||||
local data = self.dataByCtor[ctor]
|
||||
if data == nil then
|
||||
return
|
||||
end
|
||||
self.dataByCtor[ctor] = nil
|
||||
data:Dispose()
|
||||
end
|
||||
function MgrRegistry.prototype.CreateMgr(self, ctor, explicitName)
|
||||
local existing = self.mgrByCtor[ctor]
|
||||
if existing ~= nil then
|
||||
return existing
|
||||
end
|
||||
local mgr = __TS__New(ctor)
|
||||
local name = ResolveClassName(ctor, explicitName)
|
||||
self.mgrByCtor[ctor] = mgr
|
||||
self.mgrNameByCtor[ctor] = name
|
||||
self.mgrByName[name] = mgr
|
||||
mgr:Initialization()
|
||||
return mgr
|
||||
end
|
||||
function MgrRegistry.prototype.GetMgr(self, ctor)
|
||||
return self.mgrByCtor[ctor]
|
||||
end
|
||||
function MgrRegistry.prototype.GetMgrByName(self, name)
|
||||
return self.mgrByName[name]
|
||||
end
|
||||
function MgrRegistry.prototype.DelMgr(self, ctor)
|
||||
local mgr = self.mgrByCtor[ctor]
|
||||
if mgr == nil then
|
||||
return
|
||||
end
|
||||
local name = self.mgrNameByCtor[ctor]
|
||||
self.mgrByCtor[ctor] = nil
|
||||
self.mgrNameByCtor[ctor] = nil
|
||||
if name ~= nil and self.mgrByName[name] == mgr then
|
||||
self.mgrByName[name] = nil
|
||||
end
|
||||
mgr:Dispose()
|
||||
end
|
||||
function MgrRegistry.prototype.GetMgrCount(self)
|
||||
local count = 0
|
||||
for _, mgr in pairs(self.mgrByCtor) do
|
||||
if mgr ~= nil then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
return count
|
||||
end
|
||||
function MgrRegistry.prototype.Dispose(self)
|
||||
if self.disposed then
|
||||
return
|
||||
end
|
||||
self.disposed = true
|
||||
local mgrList = {}
|
||||
for key, mgr in pairs(self.mgrByCtor) do
|
||||
if mgr ~= nil then
|
||||
self.mgrByCtor[key] = nil
|
||||
mgrList[#mgrList + 1] = mgr
|
||||
end
|
||||
end
|
||||
self.mgrNameByCtor = {}
|
||||
self.mgrByName = {}
|
||||
do
|
||||
local i = 0
|
||||
while i < #mgrList do
|
||||
mgrList[i + 1]:Dispose()
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
local dataList = {}
|
||||
for key, data in pairs(self.dataByCtor) do
|
||||
if data ~= nil then
|
||||
self.dataByCtor[key] = nil
|
||||
dataList[#dataList + 1] = data
|
||||
end
|
||||
end
|
||||
do
|
||||
local i = 0
|
||||
while i < #dataList do
|
||||
dataList[i + 1]:Dispose()
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
function __module.UpdateImports()
|
||||
end
|
||||
Reference in new issue
Block a user