summaryrefslogtreecommitdiffhomepage
path: root/not/Element.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-04-09 22:07:04 +0200
committerAki <nthirtyone@gmail.com>2017-04-09 22:07:04 +0200
commit0dd01913fe0eefc7ba4bc0797877f40fdedf9315 (patch)
tree8d270eb07f589d2487b3ce66d4865e5a4718042a /not/Element.lua
parent55b0cf1a22e4a7e41fe00aa693445d6c4bd0652d (diff)
parenta03c1125f10fbbad253a0efc4727072fcbd55345 (diff)
downloadroflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.zip
roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.gz
roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.bz2
Merge branch 'com'
Diffstat (limited to 'not/Element.lua')
-rw-r--r--not/Element.lua50
1 files changed, 50 insertions, 0 deletions
diff --git a/not/Element.lua b/not/Element.lua
new file mode 100644
index 0000000..e6d91da
--- /dev/null
+++ b/not/Element.lua
@@ -0,0 +1,50 @@
+--- `Element`
+-- Empty element used inside `Menu`.
+Element = {
+ parent = --[[not.Menu]]nil,
+ x = 0,
+ y = 0
+}
+
+Element.__index = Element
+
+function Element:new (parent)
+ local o = setmetatable({}, self)
+ o.parent = parent
+ return o
+end
+
+function Element:delete () end -- deletes Element
+
+function Element:getPosition ()
+ return self.x, self.y
+end
+function Element:setPosition (x, y)
+ self.x = x or 0
+ self.y = y or 0
+ return self
+end
+
+function Element:set (name, func)
+ if type(name) == "string" and func ~= nil then
+ self[name] = func
+ end
+ return self
+end
+
+-- Called when menu tries to focus on this element.
+-- If it will return false then menu will skip element and go to next in list.
+function Element:focus ()
+ return false
+end
+function Element:blur () end -- Called when Element loses focus.
+
+-- LÖVE2D callbacks
+function Element:draw (scale) end
+function Element:update (dt) end
+
+-- Controller callbacks
+function Element:controlpressed (set, action, key) end
+function Element:controlreleased (set, action, key) end
+
+return Element