some stuff actually works :D
This commit is contained in:
parent
3bd423243e
commit
02cd8eba19
@ -12,7 +12,7 @@ local type,pcall = type,pcall
|
|||||||
setmetatable(element, {
|
setmetatable(element, {
|
||||||
__call = function(cls, ...)
|
__call = function(cls, ...)
|
||||||
local self
|
local self
|
||||||
local func, loader, w, h, param = ...
|
local func, loader, param = ...
|
||||||
|
|
||||||
self = setmetatable({}, element)
|
self = setmetatable({}, element)
|
||||||
self.parentFunc = func
|
self.parentFunc = func
|
||||||
@ -24,7 +24,7 @@ setmetatable(element, {
|
|||||||
loader(f)
|
loader(f)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:new(w, h, param)
|
self:new(param)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,72 +0,0 @@
|
|||||||
--Internal event/zone/perf-log system
|
|
||||||
local signals = {}
|
|
||||||
signals.__index = signals
|
|
||||||
|
|
||||||
function signals.newController()
|
|
||||||
return setmetatable({
|
|
||||||
stack = {},
|
|
||||||
|
|
||||||
eventSubs = {},
|
|
||||||
zoneSubs = {},
|
|
||||||
|
|
||||||
startTime = 0,
|
|
||||||
totalTime = 0
|
|
||||||
}, signals)
|
|
||||||
end
|
|
||||||
|
|
||||||
function signals:push(name)
|
|
||||||
self.stack[#self.stack+1] = {name = name}
|
|
||||||
|
|
||||||
self.startTime = love.timer.getTime()
|
|
||||||
|
|
||||||
if self.zoneSubs[name] then
|
|
||||||
for i, e in ipairs(self.zoneSubs[name]) do
|
|
||||||
if e.on and e.func() then
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function signals:pop()
|
|
||||||
local name = self.stack[#self.stack].name
|
|
||||||
|
|
||||||
if self.zoneSubs[name] then
|
|
||||||
for i, e in ipairs(self.zoneSubs[name]) do
|
|
||||||
if not e.on and e.func() then
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.totalTime = love.timer.getTime() - self.startTime
|
|
||||||
self.stack[#self.stack] = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function signals:emitEvent(name, content)
|
|
||||||
if self.eventSubs[name] then
|
|
||||||
for i,e in ipairs(self.eventSubs[name]) do
|
|
||||||
e.func(content)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function signals:onEvent(func, event)
|
|
||||||
if not self.eventSubs[event] then
|
|
||||||
self.eventSubs[event] = {}
|
|
||||||
end
|
|
||||||
self.eventSubs[event][#self.eventSubs[event]+1] = {func = func}
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--on - true when new zone is pushed
|
|
||||||
-- false when zone is popped
|
|
||||||
function signals:onSignal(func, name, on)
|
|
||||||
if not self.zoneSubs[name] then
|
|
||||||
self.zoneSubs[name] = {}
|
|
||||||
end
|
|
||||||
self.zoneSubs[name][#self.zoneSubs[name]+1] = {func = func, on = on}
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
return signals
|
|
||||||
11
init.lua
11
init.lua
@ -14,14 +14,13 @@ helium.elementBuffer = {}
|
|||||||
helium.__index = helium
|
helium.__index = helium
|
||||||
|
|
||||||
setmetatable(helium, {__call = function(s, chunk)
|
setmetatable(helium, {__call = function(s, chunk)
|
||||||
return {
|
return setmetatable({
|
||||||
__call = function(s, param, w, h)
|
|
||||||
return helium.element(chunk, nil, w, h, param)
|
|
||||||
end,
|
|
||||||
draw = function (param, x, y, w, h)
|
draw = function (param, x, y, w, h)
|
||||||
return helium.element.immediate(param, chunk, x, y, w, h)
|
return helium.element.immediate(param, chunk, x, y, w, h)
|
||||||
end
|
end
|
||||||
}
|
},{__call = function(s, param)
|
||||||
|
return helium.element(chunk, nil, param)
|
||||||
|
end,})
|
||||||
end})
|
end})
|
||||||
|
|
||||||
function helium.render()
|
function helium.render()
|
||||||
@ -112,7 +111,7 @@ if helium.conf.AUTO_RUN then
|
|||||||
|
|
||||||
love.graphics.present()
|
love.graphics.present()
|
||||||
end
|
end
|
||||||
|
|
||||||
if love.timer then love.timer.sleep(0.001) end
|
if love.timer then love.timer.sleep(0.001) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user