This commit is contained in:
Paul Liverman III 2017-08-13 03:52:45 -07:00
parent a0e5fdb465
commit c9df709c80
6 changed files with 9 additions and 66 deletions

View File

@ -6,7 +6,7 @@ do
floor, max = _obj_0.floor, _obj_0.max floor, max = _obj_0.floor, _obj_0.max
end end
local inheritsFromElement local inheritsFromElement
inheritsFromElement = require(tostring((...):sub(1, -18)) .. "/util").inheritsFromElement inheritsFromElement = require(tostring((...):sub(1, -19)) .. "/util").inheritsFromElement
local element local element
do do
local _class_0 local _class_0

View File

@ -5,7 +5,7 @@
import graphics from love import graphics from love
import floor, max from math import floor, max from math
import inheritsFromElement from require "#{(...)\sub 1, -18}/util" import inheritsFromElement from require "#{(...)\sub 1, -19}/util"
class element class element
--- Constructor expects nothing, or a data table describing it. --- Constructor expects nothing, or a data table describing it.

View File

@ -5,24 +5,7 @@ local scrollbox
do do
local _class_0 local _class_0
local _parent_0 = element local _parent_0 = element
local _base_0 = { 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
}
_base_0.__index = _base_0 _base_0.__index = _base_0
setmetatable(_base_0, _parent_0.__base) setmetatable(_base_0, _parent_0.__base)
_class_0 = setmetatable({ _class_0 = setmetatable({
@ -35,12 +18,6 @@ do
if self.data.type == "element" then if self.data.type == "element" then
self.data.type = "scrollbox" self.data.type = "scrollbox"
end end
self.data.color = {
0,
0,
0,
255
}
end, end,
__base = _base_0, __base = _base_0,
__name = "scrollbox", __name = "scrollbox",

View File

@ -1,43 +1,9 @@
local pop
import graphics from love import graphics from love
element = require "#{(...)\sub 1, -10}/element" element = require "#{(...)\sub 1, -10}/element"
class scrollbox extends element class scrollbox extends element
load: (pop_lib) -> new: (@parent, @data={}) =>
pop = pop_lib super @parent, @data
new: (@parent, @data={}) => @data.type = "scrollbox" if @data.type == "element"
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 @

View File

@ -159,7 +159,7 @@ love.load = function()
}) })
}) })
end end
return new_method() return old_method()
end end
love.update = function(dt) love.update = function(dt)
return pop.update(dt) return pop.update(dt)

View File

@ -51,8 +51,8 @@ love.load = ->
}) })
}) })
--old_method! old_method!
new_method! --new_method!
love.update = (dt) -> love.update = (dt) ->
pop.update dt pop.update dt