split code a lil better
This commit is contained in:
parent
3ceba9bafc
commit
e8cb599dde
3
main.xml
3
main.xml
|
@ -83,6 +83,9 @@
|
|||
|
||||
require 'uranium.main'
|
||||
|
||||
-- Needed by StepMania, in order to not kill lua mods early
|
||||
self:sleep(9e9)
|
||||
|
||||
-- NotITG and OpenITG have a long standing bug where the InitCommand on an actor can run twice in certain cases.
|
||||
-- By removing the command after it's done, it can only ever run once
|
||||
self:removecommand('Init')
|
||||
|
|
|
@ -579,4 +579,23 @@ function M._transformQueueToTree()
|
|||
M._actorTree = tree
|
||||
end
|
||||
|
||||
function M.prepareForActors()
|
||||
M._actorsInitializing = true
|
||||
M._transformQueueToTree()
|
||||
--Trace(fullDump(M._actorTree))
|
||||
M._currentPath = M._actorTree
|
||||
end
|
||||
|
||||
function M.finalize()
|
||||
oat._actor = nil
|
||||
|
||||
M._actorQueue = nil
|
||||
M._actorAssociationQueue = nil
|
||||
|
||||
M._actorTree = nil
|
||||
M._currentPath = nil
|
||||
M._pastPaths = nil
|
||||
M._currentActor = nil
|
||||
end
|
||||
|
||||
return M
|
|
@ -0,0 +1,33 @@
|
|||
-- indexing things on _G is slower than
|
||||
-- having access to them in a local `oat` table
|
||||
-- that already acts as _G, so we move commonly
|
||||
-- use values over
|
||||
|
||||
local function copy(src)
|
||||
local dest = {}
|
||||
for k, v in pairs(src) do
|
||||
dest[k] = v
|
||||
end
|
||||
return dest
|
||||
end
|
||||
|
||||
oat = _G.oat
|
||||
type = _G.type
|
||||
print = _G.print
|
||||
pairs = _G.pairs
|
||||
ipairs = _G.ipairs
|
||||
unpack = _G.unpack
|
||||
tonumber = _G.tonumber
|
||||
tostring = _G.tostring
|
||||
math = copy(_G.math)
|
||||
table = copy(_G.table)
|
||||
string = copy(_G.string)
|
||||
|
||||
-- convinience shortcuts employed by most templates
|
||||
|
||||
scx = SCREEN_CENTER_X
|
||||
scy = SCREEN_CENTER_Y
|
||||
sw = SCREEN_WIDTH
|
||||
sh = SCREEN_HEIGHT
|
||||
dw = DISPLAY:GetDisplayWidth()
|
||||
dh = DISPLAY:GetDisplayHeight()
|
|
@ -1,35 +1,10 @@
|
|||
local function copy(src)
|
||||
local dest = {}
|
||||
for k, v in pairs(src) do
|
||||
dest[k] = v
|
||||
end
|
||||
return dest
|
||||
end
|
||||
|
||||
oat = _G.oat
|
||||
type = _G.type
|
||||
print = _G.print
|
||||
pairs = _G.pairs
|
||||
ipairs = _G.ipairs
|
||||
unpack = _G.unpack
|
||||
tonumber = _G.tonumber
|
||||
tostring = _G.tostring
|
||||
math = copy(_G.math)
|
||||
table = copy(_G.table)
|
||||
string = copy(_G.string)
|
||||
|
||||
scx = SCREEN_CENTER_X
|
||||
scy = SCREEN_CENTER_Y
|
||||
sw = SCREEN_WIDTH
|
||||
sh = SCREEN_HEIGHT
|
||||
dw = DISPLAY:GetDisplayWidth()
|
||||
dh = DISPLAY:GetDisplayHeight()
|
||||
require 'uranium.constants'
|
||||
require 'uranium.events'
|
||||
local actors = require 'uranium.actors'
|
||||
|
||||
local resetOnFrameStartCfg = false
|
||||
local resetOnFrameStartActors = {}
|
||||
|
||||
require 'uranium.events'
|
||||
|
||||
local hasExited = false
|
||||
local function exit()
|
||||
if hasExited then return end
|
||||
|
@ -56,8 +31,8 @@ function backToSongWheel(message)
|
|||
end
|
||||
|
||||
local function onCommand(self)
|
||||
uranium.actors._actorsInitialized = true
|
||||
uranium.actors._actorsInitializing = false
|
||||
actors._actorsInitialized = true
|
||||
actors._actorsInitializing = false
|
||||
local resetOnFrameStartActors_ = {}
|
||||
for k,v in pairs(resetOnFrameStartActors) do
|
||||
resetOnFrameStartActors_[k.__raw] = v
|
||||
|
@ -100,23 +75,13 @@ function resetActorOnFrameStart(actor, bool)
|
|||
resetOnFrameStartActors[actor.__raw or actor] = bool
|
||||
end
|
||||
|
||||
uranium.actors = require 'uranium.actors'
|
||||
|
||||
local lastt = GAMESTATE:GetSongTime()
|
||||
local function screenReadyCommand(self)
|
||||
actors.finalize()
|
||||
|
||||
hideThemeActors()
|
||||
self:hidden(0)
|
||||
|
||||
oat._actor = nil
|
||||
|
||||
uranium.actors._actorQueue = nil
|
||||
uranium.actors._actorAssociationQueue = nil
|
||||
|
||||
uranium.actors._actorTree = nil
|
||||
uranium.actors._currentPath = nil
|
||||
uranium.actors._pastPaths = nil
|
||||
uranium.actors._currentActor = nil
|
||||
|
||||
collectgarbage()
|
||||
|
||||
local errored = false
|
||||
|
@ -150,7 +115,7 @@ local function screenReadyCommand(self)
|
|||
|
||||
drawfunctionArguments = {}
|
||||
|
||||
for _, q in ipairs(uranium.actors._globalQueue) do
|
||||
for _, q in ipairs(actors._globalQueue) do
|
||||
local enabled = resetOnFrameStartCfg
|
||||
|
||||
local actor = q[1]
|
||||
|
@ -202,10 +167,7 @@ end)
|
|||
if success then
|
||||
print('---')
|
||||
|
||||
uranium.actors._actorsInitializing = true
|
||||
uranium.actors._transformQueueToTree()
|
||||
--Trace(fullDump(uranium.actors._actorTree))
|
||||
uranium.actors._currentPath = uranium.actors._actorTree
|
||||
actors.prepareForActors()
|
||||
|
||||
_main:addcommand('On', onCommand)
|
||||
_main:addcommand('Ready', screenReadyCommand)
|
||||
|
|
Loading…
Reference in New Issue