diff --git a/elements/element.lua b/elements/element.lua index f4c5971..274e255 100644 --- a/elements/element.lua +++ b/elements/element.lua @@ -6,7 +6,7 @@ do floor, max = _obj_0.floor, _obj_0.max end local inheritsFromElement -inheritsFromElement = require(tostring((...):sub(1, -18)) .. "/util").inheritsFromElement +inheritsFromElement = require(tostring((...):sub(1, -19)) .. "/util").inheritsFromElement local element do local _class_0 diff --git a/elements/element.moon b/elements/element.moon index a98edef..12d11e7 100644 --- a/elements/element.moon +++ b/elements/element.moon @@ -5,7 +5,7 @@ import graphics from love import floor, max from math -import inheritsFromElement from require "#{(...)\sub 1, -18}/util" +import inheritsFromElement from require "#{(...)\sub 1, -19}/util" class element --- Constructor expects nothing, or a data table describing it. diff --git a/elements/scrollbox.lua b/elements/scrollbox.lua index 0d2b844..e9f86d2 100644 --- a/elements/scrollbox.lua +++ b/elements/scrollbox.lua @@ -5,24 +5,7 @@ local scrollbox do local _class_0 local _parent_0 = element - local _base_0 = { - draw = function(self) - graphics.setColor(self.data.color) - graphics.rectangle("fill", self.data.x, self.data.y, self.data.w, self.data.h) - return self - end, - setBackground = function(self, r, g, b, a) - if a == nil then - a = 255 - end - if "table" == type(r) then - self.data.color = r - else - self.data.color = r, g, b, a - end - return self - end - } + local _base_0 = { } _base_0.__index = _base_0 setmetatable(_base_0, _parent_0.__base) _class_0 = setmetatable({ @@ -35,12 +18,6 @@ do if self.data.type == "element" then self.data.type = "scrollbox" end - self.data.color = { - 0, - 0, - 0, - 255 - } end, __base = _base_0, __name = "scrollbox", diff --git a/elements/scrollbox.moon b/elements/scrollbox.moon index 9249f14..428b35e 100644 --- a/elements/scrollbox.moon +++ b/elements/scrollbox.moon @@ -1,43 +1,9 @@ -local pop import graphics from love element = require "#{(...)\sub 1, -10}/element" class scrollbox extends element - load: (pop_lib) -> - pop = pop_lib + new: (@parent, @data={}) => + super @parent, @data - new: (@parent, @data={}) => - super @parent, @data - - @data.type = "scrollbox" if @data.type == "element" - @data.color = {255, 255, 255, 255} - @data.background = {0, 0, 0, 255} - - draw: => - graphics.setColor @data.background - graphics.rectangle "fill", @data.x, @data.y, @data.w, @data.h - - --TODO do stuff to set up for drawing - for i=1, #@data.child - pop.draw @data.child[i] - --TODO undo for regular drawing - --TODO return something to cancel drawing children - - return @ - - setColor: (r, g, b, a=255) => - if "table" == type r - @data.color = r - else - @data.color = r, g, b, a - - return @ - - setBackground: (r, g, b, a=255) => - if "table" == type r - @data.background = r - else - @data.background = r, g, b, a - - return @ + @data.type = "scrollbox" if @data.type == "element" diff --git a/main.lua b/main.lua index 1bcd320..f3d0ab9 100644 --- a/main.lua +++ b/main.lua @@ -159,7 +159,7 @@ love.load = function() }) }) end - return new_method() + return old_method() end love.update = function(dt) return pop.update(dt) diff --git a/main.moon b/main.moon index 13f9ea5..befaece 100644 --- a/main.moon +++ b/main.moon @@ -51,8 +51,8 @@ love.load = -> }) }) - --old_method! - new_method! + old_method! + --new_method! love.update = (dt) -> pop.update dt