summaryrefslogtreecommitdiffhomepage
path: root/not
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-06-27 09:02:03 +0200
committerAki <nthirtyone@gmail.com>2017-06-27 09:02:03 +0200
commitbaf04a055dbc66b80c29a406907a0a595ac55f00 (patch)
tree49559118c1c6246cf7f954e9f706bae6f29e5057 /not
parent2c458f0c756ebe577083a7cc972a07e870cb0ba9 (diff)
downloadroflnauts-baf04a055dbc66b80c29a406907a0a595ac55f00.zip
roflnauts-baf04a055dbc66b80c29a406907a0a595ac55f00.tar.gz
roflnauts-baf04a055dbc66b80c29a406907a0a595ac55f00.tar.bz2
Moved ui elements to use new oop lib
Diffstat (limited to 'not')
-rw-r--r--not/Button.lua29
-rw-r--r--not/Element.lua16
-rw-r--r--not/Header.lua20
-rw-r--r--not/Selector.lua50
4 files changed, 44 insertions, 71 deletions
diff --git a/not/Button.lua b/not/Button.lua
index 91aca45..a2f7a19 100644
--- a/not/Button.lua
+++ b/not/Button.lua
@@ -1,27 +1,18 @@
+require "not.Element"
+
--- `Button`
-- Menu element that can be activated by user.
-Button = {
- parent = --[[not.Menu]]nil,
- x = 0,
- y = 0,
- text = "",
- focused = false,
- sprite,
- quads,
- delay = 2,
- parent,
-}
+Button = Element:extends()
--- `Button` is a child of `Element`.
-require "not.Element"
-Button.__index = Button
-setmetatable(Button, Element)
+Button.text = ""
+Button.focused = false
+Button.sprite = --[[]]nil
+Button.quads = --[[]]nil
+Button.delay = 2
function Button:new (parent)
- local o = setmetatable({}, self)
- o.parent = parent
- o.sprite, o.quads = parent:getSheet()
- return o
+ Button.__super.new(self, parent)
+ self.sprite, self.quads = parent:getSheet()
end
function Button:setText (text)
diff --git a/not/Element.lua b/not/Element.lua
index e6d91da..24576e6 100644
--- a/not/Element.lua
+++ b/not/Element.lua
@@ -1,17 +1,15 @@
+require "not.Object"
+
--- `Element`
-- Empty element used inside `Menu`.
-Element = {
- parent = --[[not.Menu]]nil,
- x = 0,
- y = 0
-}
+Element = Object:extends()
-Element.__index = Element
+Element.parent = --[[not.Menu]]nil
+Element.x = 0
+Element.y = 0
function Element:new (parent)
- local o = setmetatable({}, self)
- o.parent = parent
- return o
+ self.parent = parent
end
function Element:delete () end -- deletes Element
diff --git a/not/Header.lua b/not/Header.lua
index a563ab2..8b2ec0d 100644
--- a/not/Header.lua
+++ b/not/Header.lua
@@ -1,22 +1,14 @@
+require "not.Element"
+
--- `Header`
-- Swinging title.
-Header = {
- parent = --[[not.Menu]]nil,
- x = 0,
- y = 0,
- text = "",
- bounce = 2,
-}
+Header = Element:extends()
--- `Header` is a child of `Element`.
-require "not.Element"
-Header.__index = Header
-setmetatable(Header, Element)
+Header.text = ""
+Header.bounce = 2
function Header:new (parent)
- local o = setmetatable({}, self)
- o.parent = parent
- return o
+ Header.__super.new(self, parent)
end
function Header:setText (text)
diff --git a/not/Selector.lua b/not/Selector.lua
index 8e03457..ef78778 100644
--- a/not/Selector.lua
+++ b/not/Selector.lua
@@ -1,3 +1,5 @@
+require "not.Element"
+
--- `Selector`
-- Used in Menu for selecting various things from list. Works for each Controller set or globally.
--[[
@@ -12,39 +14,29 @@ selector:new(menu)
:set("global", false) -- true: single selector; false: selector for each controller set present
:init()
]]
-Selector = {
- parent = --[[not.Menu]]nil,
- x = 0,
- y = 0,
- width = 0,
- height = 0,
- margin = 0,
- focused = false,
- global = false,
- delay = 2,
- first = false,
- list,
- sets,
- locks,
- selections,
- shape = "portrait",
- sprite,
- quads,
- icons_i,
- icons_q
-}
+Selector = Element:extends()
--- `Selector` is a child of `Element`.
-require "not.Element"
-Selector.__index = Selector
-setmetatable(Selector, Element)
+Selector.width = 0
+Selector.height = 0
+Selector.margin = 0
+Selector.focused = false
+Selector.global = false
+Selector.delay = 2
+Selector.first = false
+Selector.list = --[[]]nil
+Selector.sets = --[[]]nil
+Selector.locks = --[[]]nil
+Selector.selections = --[[]]nil
+Selector.shape = "portrait"
+Selector.sprite = --[[]]nil
+Selector.quads = --[[]]nil
+Selector.icons_i = --[[]]nil
+Selector.icons_q = --[[]]nil
-- Constructor
function Selector:new (parent)
- local o = setmetatable({}, self)
- o.parent = parent
- o.sprite, o.quads = parent:getSheet()
- return o
+ Selector.__super.new(self, parent)
+ self.sprite, self.quads = parent:getSheet()
end
-- Size of single block