mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
experimental inclusion of extensions
This commit is contained in:
parent
3c1724d9fb
commit
7731c11c70
14
src/pop/extensions/streamlined_get_set.moon
Normal file
14
src/pop/extensions/streamlined_get_set.moon
Normal 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!
|
@ -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\""
|
||||
|
Loading…
Reference in New Issue
Block a user