added element load call (yay\!)

This commit is contained in:
Paul Liverman III 2016-04-03 00:27:15 -07:00
parent d38a398cbc
commit cdf3f99705
6 changed files with 22 additions and 16 deletions

View File

@ -25,17 +25,14 @@ do
print(" assuming LÖVE version > 0.10.1 (there may be bugs)") print(" assuming LÖVE version > 0.10.1 (there may be bugs)")
end end
end end
local pop_ref = nil local pop_ref = false
local window local window
do do
local _class_0 local _class_0
local _parent_0 = element local _parent_0 = element
local _base_0 = { local _base_0 = {
wrap = function(pop) load = function(pop)
pop_ref = pop pop_ref = pop
return function(...)
return pop.create("window", ...)
end
end, end,
debugDraw = function(self) debugDraw = function(self)
graphics.setLineWidth(0.5) graphics.setLineWidth(0.5)

View File

@ -28,6 +28,9 @@ pop.load = function()
end end
local name = elements[i]:sub(1, -5) local name = elements[i]:sub(1, -5)
pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name)) pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name))
if pop.elements[name].load then
pop.elements[name].load(pop)
end
print("element loaded: \"" .. tostring(name) .. "\"") print("element loaded: \"" .. tostring(name) .. "\"")
if not (pop[name]) then if not (pop[name]) then
if pop.elements[name].wrap then if pop.elements[name].wrap then

View File

@ -25,17 +25,14 @@ do
print(" assuming LÖVE version > 0.10.1 (there may be bugs)") print(" assuming LÖVE version > 0.10.1 (there may be bugs)")
end end
end end
local pop_ref = nil local pop_ref = false
local window local window
do do
local _class_0 local _class_0
local _parent_0 = element local _parent_0 = element
local _base_0 = { local _base_0 = {
wrap = function(pop) load = function(pop)
pop_ref = pop pop_ref = pop
return function(...)
return pop.create("window", ...)
end
end, end,
debugDraw = function(self) debugDraw = function(self)
graphics.setLineWidth(0.5) graphics.setLineWidth(0.5)

View File

@ -28,6 +28,9 @@ pop.load = function()
end end
local name = elements[i]:sub(1, -5) local name = elements[i]:sub(1, -5)
pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name)) pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name))
if pop.elements[name].load then
pop.elements[name].load(pop)
end
print("element loaded: \"" .. tostring(name) .. "\"") print("element loaded: \"" .. tostring(name) .. "\"")
if not (pop[name]) then if not (pop[name]) then
if pop.elements[name].wrap then if pop.elements[name].wrap then

View File

@ -22,14 +22,16 @@ do
print "elements/window: unrecognized LÖVE version: #{major}.#{minor}.#{revision}" print "elements/window: unrecognized LÖVE version: #{major}.#{minor}.#{revision}"
print " assuming LÖVE version > 0.10.1 (there may be bugs)" print " assuming LÖVE version > 0.10.1 (there may be bugs)"
-- a reference to pop is needed for windows, this is obtained using the wrap function when it is loaded pop_ref = false -- reference to pop, loaded by pop.load!
pop_ref = nil -- yes, this is convoluted and probably needs a re-design
class window extends element class window extends element
wrap: (pop) -> load: (pop) ->
pop_ref = pop -- set our reference to pop (needed for mouse handling) pop_ref = pop
return (...) -> -- standard wrapper, nothing special needed
return pop.create("window", ...) --wrap: (pop) ->
-- pop_ref = pop -- set our reference to pop (needed for mouse handling)
-- return (...) -> -- standard wrapper, nothing special needed
-- return pop.create("window", ...)
new: (parent, title="window", tBackground={25, 180, 230, 255}, tColor={255, 255, 255, 255}, wBackground={200, 200, 210, 255}) => new: (parent, title="window", tBackground={25, 180, 230, 255}, tColor={255, 255, 255, 255}, wBackground={200, 200, 210, 255}) =>
super parent super parent

View File

@ -28,6 +28,10 @@ pop.load = ->
-- load into pop.elements table -- load into pop.elements table
name = elements[i]\sub 1, -5 name = elements[i]\sub 1, -5
pop.elements[name] = require "#{path}/elements/#{name}" pop.elements[name] = require "#{path}/elements/#{name}"
if pop.elements[name].load
pop.elements[name].load pop
print "element loaded: \"#{name}\"" print "element loaded: \"#{name}\""
-- create pop.element() wrapper if possible -- create pop.element() wrapper if possible