summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--config/menus/credits.lua8
-rw-r--r--config/menus/host.lua16
-rw-r--r--config/menus/main.lua20
-rw-r--r--config/menus/select.lua26
-rw-r--r--config/menus/settings.lua18
-rw-r--r--not/Button.lua29
-rw-r--r--not/Element.lua16
-rw-r--r--not/Header.lua20
-rw-r--r--not/Selector.lua50
9 files changed, 88 insertions, 115 deletions
diff --git a/config/menus/credits.lua b/config/menus/credits.lua
index 77cba62..6a2ab50 100644
--- a/config/menus/credits.lua
+++ b/config/menus/credits.lua
@@ -1,20 +1,20 @@
local menu = ...
-local button = require "not.Button"
-local element = require "not.Element"
+local Button = require "not.Button"
+local Element = require "not.Element"
local width, height = love.graphics.getWidth()/getRealScale(), love.graphics.getHeight()/getRealScale()
local bx = width/2-29
return {
- button:new(menu)
+ Button(menu)
:setText("Go back")
:setPosition(bx,144)
:set("active", function (self)
self.parent:open("main")
end)
,
- element:new(menu)
+ Element(menu)
:setPosition(width/2, 30)
:set("draw", function (self, scale)
local x,y = self:getPosition()
diff --git a/config/menus/host.lua b/config/menus/host.lua
index b318a5b..fff683c 100644
--- a/config/menus/host.lua
+++ b/config/menus/host.lua
@@ -1,18 +1,18 @@
local menu = ...
-local button = require "not.Button"
-local selector = require "not.Selector"
+local Button = require "not.Button"
+local Selector = require "not.Selector"
local width, height = love.graphics.getWidth()/getScale(), love.graphics.getHeight()/getScale()
local bx = width/2-29
-local map_selector = selector:new(menu)
+local map_Selector = Selector(menu)
require "iconsList"
local icons, maps = getMapsIconsList()
return {
- map_selector
+ map_Selector
:setPosition(width/2, 40)
:setSize(80, 42)
:setMargin(0)
@@ -24,18 +24,18 @@ return {
:set("shape", "panorama")
:init()
,
- button:new(menu)
+ Button(menu)
:setText("Next")
:setPosition(bx,101)
:set("isEnabled", function ()
- return map_selector:isLocked()
+ return map_Selector:isLocked()
end)
:set("active", function (self)
- MAP = map_selector:getFullSelection(true)[1][1] -- please, don't kill me for this, kek
+ MAP = map_Selector:getFullSelection(true)[1][1] -- please, don't kill me for this, kek
self.parent:open("select")
end)
,
- button:new(menu)
+ Button(menu)
:setText("Go back")
:setPosition(bx,117)
:set("active", function (self)
diff --git a/config/menus/main.lua b/config/menus/main.lua
index 236c011..d65c57d 100644
--- a/config/menus/main.lua
+++ b/config/menus/main.lua
@@ -1,8 +1,8 @@
local menu = ...
-local button = require "not.Button"
-local header = require "not.Header"
-local element = require "not.Element"
+local Button = require "not.Button"
+local Header = require "not.Header"
+local Element = require "not.Element"
local width, height = love.graphics.getWidth()/getScale(), love.graphics.getHeight()/getScale()
local bx = width/2-29
@@ -10,40 +10,40 @@ local bx = width/2-29
local awesometwo = love.graphics.newImage("assets/two.png")
return {
- button:new(menu)
+ Button(menu)
:setText("Start")
:setPosition(bx, 80)
:set("active", function (self)
self.parent:open("host")
end)
,
- button:new(menu)
+ Button(menu)
:setText("Join")
:setPosition(bx, 96)
:set("isEnabled", function (self)
return false
end)
,
- button:new(menu)
+ Button(menu)
:setText("Settings")
:setPosition(bx, 112)
:set("active", function (self)
self.parent:open("settings")
end)
,
- button:new(menu)
+ Button(menu)
:setText("Credits")
:setPosition(bx, 128)
:set("active", function (self)
self.parent:open("credits")
end)
,
- button:new(menu)
+ Button(menu)
:setText("Exit")
:setPosition(bx, 144)
:set("active", love.event.quit)
,
- element:new(menu)
+ Element(menu)
:setPosition(width/2, 15)
:set("draw", function (self, scale)
local x,y = self:getPosition()
@@ -52,7 +52,7 @@ return {
love.graphics.draw(awesometwo, x*scale, y*scale, 0, scale, scale, 35)
end)
,
- header:new(menu)
+ Header(menu)
:setText("Roflnauts")
:setPosition(width/2,40)
,
diff --git a/config/menus/select.lua b/config/menus/select.lua
index fd897d2..431e620 100644
--- a/config/menus/select.lua
+++ b/config/menus/select.lua
@@ -1,20 +1,20 @@
local menu = ...
-local button = require "not.Button"
-local selector = require "not.Selector"
-local element = require "not.Element"
+local Button = require "not.Button"
+local Selector = require "not.Selector"
+local Element = require "not.Element"
local width, height = love.graphics.getWidth()/getScale(), love.graphics.getHeight()/getScale()
local bx = width/2-29
-local naut_selector = selector:new(menu)
-local start_button = button:new(menu)
+local naut_Selector = Selector(menu)
+local start_Button = Button(menu)
require "iconsList"
local nautsIcons, nautsList = getNautsIconsList()
return {
- naut_selector
+ naut_Selector
:setPosition(width/2,60)
:setMargin(8)
:setSize(32, 32)
@@ -24,30 +24,30 @@ return {
:set("icons_q", nautsIcons)
:init()
,
- start_button
+ start_Button
:setText("Force start")
:setPosition(bx,134)
:set("isEnabled", function ()
- if #naut_selector:getFullSelection(false) > 1 then
+ if #naut_Selector:getFullSelection(false) > 1 then
return true
end
return false
end)
:set("active", function (self)
- local nauts = naut_selector:getFullSelection(false)
+ local nauts = naut_Selector:getFullSelection(false)
if #nauts > 1 then
changeScene(World(MAP, nauts))
end
end)
,
- button:new(menu)
+ Button(menu)
:setText("Go back")
:setPosition(bx,150)
:set("active", function (self)
self.parent:open("host")
end)
,
- element:new(menu)
+ Element(menu)
:setPosition(bx, 101)
:set("the_final_countdown", 9)
:set("draw", function (self, scale)
@@ -62,14 +62,14 @@ return {
end
end)
:set("update", function (self, dt)
- local total = #naut_selector:getFullSelection(false)
+ local total = #naut_Selector:getFullSelection(false)
if total > 1 then
self.the_final_countdown = self.the_final_countdown - dt
else
self.the_final_countdown = 9
end
if self.the_final_countdown < 0 then
- start_button:active()
+ start_Button:active()
end
end)
,
diff --git a/config/menus/settings.lua b/config/menus/settings.lua
index ae0403d..a1c6507 100644
--- a/config/menus/settings.lua
+++ b/config/menus/settings.lua
@@ -1,15 +1,15 @@
local menu = ...
-local button = require "not.Button"
-local selector = require "not.Selector"
-local element = require "not.Element"
+local Button = require "not.Button"
+local Selector = require "not.Selector"
+local Element = require "not.Element"
local width, height = love.graphics.getWidth()/getRealScale(), love.graphics.getHeight()/getRealScale()
local bx = width/2-29
local keys = {"Left", "Right", "Up", "Down", "Attack", "Jump"}
-local dimmer = element:new(menu)
+local dimmer = Element(menu)
:setPosition(width/2, 15)
:set("visible", false)
:set("currentControl", "Left") -- it actually means control that is being set CURRENTLY
@@ -65,7 +65,7 @@ local controlreleased = function(self, set, action, key)
end
local a = {
- button:new(menu)
+ Button(menu)
:setText("Keyboard 1")
:setPosition(bx,80)
:set("setNumber", function () return 1 end)
@@ -74,7 +74,7 @@ local a = {
:set("stopChange", stopChange)
:set("active", startChange)
,
- button:new(menu)
+ Button(menu)
:setText("Keyboard 2")
:setPosition(bx,96)
:set("setNumber", function () return 2 end)
@@ -83,7 +83,7 @@ local a = {
:set("stopChange", stopChange)
:set("active", startChange)
,
- button:new(menu)
+ Button(menu)
:setText("Gamepad 1")
:setPosition(bx,112)
:set("setNumber", function () return 3 end)
@@ -92,7 +92,7 @@ local a = {
:set("stopChange", stopChange)
:set("active", startChange)
,
- button:new(menu)
+ Button(menu)
:setText("Gamepad 2")
:setPosition(bx,128)
:set("setNumber", function () return 4 end)
@@ -101,7 +101,7 @@ local a = {
:set("stopChange", stopChange)
:set("active", startChange)
,
- button:new(menu)
+ Button(menu)
:setText("Go back")
:setPosition(bx,144)
:set("active", function (self)
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