help
This commit is contained in:
parent
17d8f49151
commit
441ca0facc
|
@ -0,0 +1,6 @@
|
||||||
|
<ActorFrame Condition="%function(self) print('actorframe condition'); return true end" InitCommand="%function(self) print('actorframe initcommand') end">
|
||||||
|
<children>
|
||||||
|
<Layer Condition="%function(self) print('sprite condition'); return true end" InitCommand="%function(self) print('sprite initcommand') end"/>
|
||||||
|
<Layer Condition="%function(self) print('file condition'); recursionc = (recursionc or 0) + 1; return recursionc < 4 end" InitCommand="%function(self) print('file initcommand') end" File="actors.xml" />
|
||||||
|
</children>
|
||||||
|
</ActorFrame>
|
115
main.xml
115
main.xml
|
@ -288,8 +288,29 @@
|
||||||
-- actors
|
-- actors
|
||||||
|
|
||||||
local actorQueue = {}
|
local actorQueue = {}
|
||||||
|
local actorAssociationQueue = {}
|
||||||
|
|
||||||
|
local actorTree = {}
|
||||||
|
local currentPath
|
||||||
|
local pastPaths = {}
|
||||||
local currentActor = nil
|
local currentActor = nil
|
||||||
|
|
||||||
|
local function findFirstActor(path)
|
||||||
|
for i, v in ipairs(path) do
|
||||||
|
if v.type or v.file then
|
||||||
|
return v, i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function findFirstActorFrame(path)
|
||||||
|
for i, v in ipairs(path) do
|
||||||
|
if not v.type and not v.file then
|
||||||
|
return v, i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
oat._actor = {}
|
oat._actor = {}
|
||||||
|
|
||||||
function oat._actor.next()
|
function oat._actor.next()
|
||||||
|
@ -337,14 +358,17 @@
|
||||||
|
|
||||||
function oat._actor.init(self)
|
function oat._actor.init(self)
|
||||||
currentActor.init(self)
|
currentActor.init(self)
|
||||||
|
currentActor = nil -- shouldn't be needed from now on
|
||||||
end
|
end
|
||||||
|
|
||||||
function oat._actor.initFrame(self)
|
function oat._actor.initFrame(self)
|
||||||
local nextChild = self(2)
|
print('initiating an actorframe')
|
||||||
|
--local nextChild = self(2)
|
||||||
self:SetDrawFunction(function()
|
self:SetDrawFunction(function()
|
||||||
if nextChild then
|
--if nextChild then
|
||||||
nextChild:Draw()
|
-- nextChild:Draw()
|
||||||
end
|
--end
|
||||||
|
-- TODO
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -352,6 +376,7 @@
|
||||||
local queue = {}
|
local queue = {}
|
||||||
local initCommands = {}
|
local initCommands = {}
|
||||||
local lockedActor
|
local lockedActor
|
||||||
|
local queueRepresentation
|
||||||
|
|
||||||
return setmetatable({}, {
|
return setmetatable({}, {
|
||||||
__index = function(self, key)
|
__index = function(self, key)
|
||||||
|
@ -365,8 +390,17 @@
|
||||||
end
|
end
|
||||||
return val
|
return val
|
||||||
end
|
end
|
||||||
|
if key == '__queue' then
|
||||||
|
return queueRepresentation
|
||||||
|
end
|
||||||
|
if key == '__queueRepresentation' then
|
||||||
|
return function(q)
|
||||||
|
queueRepresentation = q
|
||||||
|
end
|
||||||
|
end
|
||||||
if key == '__lock' then
|
if key == '__lock' then
|
||||||
return function(actor)
|
return function(actor)
|
||||||
|
if lockedActor then return end
|
||||||
for _, v in ipairs(queue) do
|
for _, v in ipairs(queue) do
|
||||||
local func = actor[v[1]]
|
local func = actor[v[1]]
|
||||||
if not func then
|
if not func then
|
||||||
|
@ -406,6 +440,7 @@
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
initCommands = {}
|
initCommands = {}
|
||||||
|
queueRepresentation = nil -- to make mr. Garbage Collector's job easier
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return function(...)
|
return function(...)
|
||||||
|
@ -420,7 +455,7 @@
|
||||||
__newindex = function()
|
__newindex = function()
|
||||||
error('uranium: cannot set properties on actors!', 2)
|
error('uranium: cannot set properties on actors!', 2)
|
||||||
end,
|
end,
|
||||||
__tostring = function() return name end,
|
__tostring = function() return 'Proxy of ' .. name end,
|
||||||
__name = name
|
__name = name
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -431,11 +466,11 @@
|
||||||
local actor = createProxyActor(type)
|
local actor = createProxyActor(type)
|
||||||
table.insert(actorQueue, {
|
table.insert(actorQueue, {
|
||||||
type = type,
|
type = type,
|
||||||
file = nil,
|
|
||||||
init = function(a)
|
init = function(a)
|
||||||
actor.__lock(a)
|
actor.__lock(a)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
actor.__queueRepresentation(actorQueue[#actorQueue])
|
||||||
return actor
|
return actor
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -458,6 +493,20 @@
|
||||||
actor.__lock(a)
|
actor.__lock(a)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
actor.__queueRepresentation(actorQueue[#actorQueue])
|
||||||
|
return actor
|
||||||
|
end
|
||||||
|
|
||||||
|
function ActorFrame()
|
||||||
|
if actorsInitialized then error('uranium: cannot create an actor during runtime!!', 2) end
|
||||||
|
local actor = createProxyActor('ActorFrame')
|
||||||
|
table.insert(actorQueue, {
|
||||||
|
type = 'ActorFrame',
|
||||||
|
init = function(a)
|
||||||
|
actor.__lock(a)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
actor.__queueRepresentation(actorQueue[#actorQueue])
|
||||||
return actor
|
return actor
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -496,6 +545,7 @@
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
actor.__queueRepresentation(actorQueue[#actorQueue])
|
||||||
return actor
|
return actor
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -510,6 +560,7 @@
|
||||||
actor.__lock(a)
|
actor.__lock(a)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
actor.__queueRepresentation(actorQueue[#actorQueue])
|
||||||
return actor
|
return actor
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -524,6 +575,7 @@
|
||||||
actor.__lock(a)
|
actor.__lock(a)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
actor.__queueRepresentation(actorQueue[#actorQueue])
|
||||||
return actor
|
return actor
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -538,16 +590,62 @@
|
||||||
actor.__lock(a)
|
actor.__lock(a)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
actor.__queueRepresentation(actorQueue[#actorQueue])
|
||||||
return actor
|
return actor
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function addChild(frame, actor)
|
||||||
|
actorAssociationQueue[actor.__queue] = frame.__queue
|
||||||
|
end
|
||||||
|
|
||||||
|
local function transformQueueToTree()
|
||||||
|
local tree = {}
|
||||||
|
local paths = {}
|
||||||
|
local iter = 0
|
||||||
|
while #actorQueue > 0 do
|
||||||
|
iter = iter + 1
|
||||||
|
if iter > 999999 then
|
||||||
|
error('uranium: failed to transform queue to tree: reached maximum iteration limit! is there an actor with an invalid actorframe?')
|
||||||
|
end
|
||||||
|
for i = #actorQueue, 1, -1 do
|
||||||
|
v = actorQueue[i]
|
||||||
|
local insertInto
|
||||||
|
if not actorAssociationQueue[v] then
|
||||||
|
insertInto = tree
|
||||||
|
else
|
||||||
|
if paths[actorAssociationQueue[v]] then
|
||||||
|
insertInto = paths[actorAssociationQueue[v]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if insertInto then
|
||||||
|
if v.type == 'ActorFrame' then
|
||||||
|
table.insert(insertInto, {init = v.init})
|
||||||
|
table.remove(actorQueue, i)
|
||||||
|
paths[v] = insertInto[#insertInto]
|
||||||
|
else
|
||||||
|
table.insert(insertInto, v)
|
||||||
|
table.remove(actorQueue, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
actorTree = tree
|
||||||
|
end
|
||||||
|
|
||||||
local success, result = pcall(function()
|
local success, result = pcall(function()
|
||||||
require('main')
|
--require('main')
|
||||||
|
--require('stdlib.util')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if success then
|
if success then
|
||||||
luaobj = result
|
luaobj = result
|
||||||
|
|
||||||
|
--local queue = actorQueue
|
||||||
|
--actorQueue = deepcopy(actorQueue)
|
||||||
|
--transformQueueToTree()
|
||||||
|
--Trace(fullDump(actorTree))
|
||||||
|
--currentPath = actorTree
|
||||||
|
|
||||||
self:addcommand('On', onCommand)
|
self:addcommand('On', onCommand)
|
||||||
self:addcommand('Ready', screen_ready_command)
|
self:addcommand('Ready', screen_ready_command)
|
||||||
self:addcommand('Off', exit)
|
self:addcommand('Off', exit)
|
||||||
|
@ -570,6 +668,7 @@
|
||||||
-- By removing the command after it's done, it can only ever run once
|
-- By removing the command after it's done, it can only ever run once
|
||||||
self:removecommand('Init')
|
self:removecommand('Init')
|
||||||
end"><children>
|
end"><children>
|
||||||
<Layer Condition="oat._actor.next()" File="actors.xml"/>
|
<!--<Layer Condition="oat._actor.next()" File="actors.xml" />-->
|
||||||
|
<Layer File="actorsTest.xml" />
|
||||||
<Layer Type="Quad" InitCommand="xywh,SCREEN_CENTER_X,SCREEN_CENTER_Y,SCREEN_WIDTH,SCREEN_HEIGHT;diffuse,#000000;sleep,9e9"/>
|
<Layer Type="Quad" InitCommand="xywh,SCREEN_CENTER_X,SCREEN_CENTER_Y,SCREEN_WIDTH,SCREEN_HEIGHT;diffuse,#000000;sleep,9e9"/>
|
||||||
</children></Layer>
|
</children></Layer>
|
Loading…
Reference in New Issue