experimental inclusion of extensions

This commit is contained in:
Paul Liverman 2016-04-01 14:14:24 -07:00
parent 3c1724d9fb
commit 7731c11c70
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,14 @@
-- adds methods to elements using a single function for get and set operations
-- ex: instead of getWidth() and setWidth(val), use width() and width(val)
import graphics from love
import sub, len from string
path = sub ..., 1, len(...) - len "/extensions/streamlined_get_set"
element = require "#{path}/elements/element"
element.__base.position = (x, y) =>
if x or y
return @setPosition x, y
else
return @getPosition!

View File

@ -47,6 +47,16 @@ pop.load = ->
print "skin loaded: \"#{name}\""
-- load extensions by just running them via require
extensions = filesystem.getDirectoryItems "#{path}/extensions"
for i = 1, #extensions
unless extensions[i]\sub(-4) == ".lua"
continue
name = extensions[i]\sub 1, -5
require "#{path}/extensions/#{name}"
-- main window (called screen because there will be a window element class)
pop.screen = pop.create("element", false)\setSize(graphics.getWidth!, graphics.getHeight!)
print "created \"pop.screen\""