summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--config/menumain.lua12
-rw-r--r--config/menuselect.lua16
-rw-r--r--selector.lua28
3 files changed, 45 insertions, 11 deletions
diff --git a/config/menumain.lua b/config/menumain.lua
index 2d92817..cb53714 100644
--- a/config/menumain.lua
+++ b/config/menumain.lua
@@ -5,31 +5,31 @@ local header = require "header"
local element = require "element"
local width, height = love.graphics.getWidth()/getRealScale(), love.graphics.getHeight()/getRealScale()
-local button_x = width/2-29
+local bx = width/2-29
return {
button:new(menu)
:setText("Start")
- :setPosition(button_x, 80)
+ :setPosition(bx, 80)
:set("active", function (self)
self.parent:load("menuselect")
end)
,
button:new(menu)
:setText("Join")
- :setPosition(button_x, 96)
+ :setPosition(bx, 96)
,
button:new(menu)
:setText("Settings")
- :setPosition(button_x, 112)
+ :setPosition(bx, 112)
,
button:new(menu)
:setText("Credits")
- :setPosition(button_x, 128)
+ :setPosition(bx, 128)
,
button:new(menu)
:setText("Exit")
- :setPosition(button_x, 144)
+ :setPosition(bx, 144)
:set("active", love.event.quit)
,
element:new(menu)
diff --git a/config/menuselect.lua b/config/menuselect.lua
index ffdda7f..8d646ba 100644
--- a/config/menuselect.lua
+++ b/config/menuselect.lua
@@ -4,10 +4,13 @@ local button = require "button"
local selector = require "selector"
local width, height = love.graphics.getWidth()/getRealScale(), love.graphics.getHeight()/getRealScale()
+local bx = width/2-29
+
+local naut_selector = selector:new(menu)
return {
- selector:new(menu)
- :setPosition(width/2,10)
+ naut_selector
+ :setPosition(width/2,60)
:setMargin(8)
:setSize(32, 32)
:set("list", require "nautslist")
@@ -17,8 +20,15 @@ return {
:init()
,
button:new(menu)
+ :setText("Force start")
+ :setPosition(bx,101)
+ :set("active", function (self)
+ changeScene(World:new(nil,naut_selector:getFullSelection(false)))
+ end)
+ ,
+ button:new(menu)
:setText("Go back")
- :setPosition(10,height-25)
+ :setPosition(bx,117)
:set("active", function (self)
self.parent:load("menumain")
end)
diff --git a/selector.lua b/selector.lua
index 043a08b..0b3fe8a 100644
--- a/selector.lua
+++ b/selector.lua
@@ -4,8 +4,8 @@
How to use `Selector` in `Menu` config file?
selector:new(menu)
:setPosition(x, y)
- :setMargin(8)
- :setSize(32, 32)
+ :setMargin(8) -- each block has marigin on both sides; they do stack
+ :setSize(32, 32) -- size of single graphics frame
:set("list", require "nautslist")
:set("sprite", love.graphics.newImage("assets/portraits.png"))
:set("quads", require "portraits")
@@ -142,6 +142,20 @@ function Selector:getListValue(i)
return self.list[i]
end
+-- Get list of selections, checks if not locked are allowed.
+function Selector:getFullSelection(allowed)
+ local allowed = allowed or false
+ local t = {}
+ for n,v in ipairs(self.selections) do
+ local name = self:getListValue(self:getSelection(n))
+ local locked = self:isLocked(n)
+ if not (not locked and not allow) then
+ table.insert(t, {name, self.sets[n], self:isLocked(n)})
+ end
+ end
+ return t
+end
+
-- Draw single block of Selector
function Selector:drawBlock(n, x, y, scale)
local x, y = x or 0, y or 0
@@ -198,6 +212,16 @@ function Selector:controlpressed(set, action, key)
local locked = self:isLocked(n)
if action == "left" and not locked then self:previous(n) end
if action == "right" and not locked then self:next(n) end
+ if action == "attack" then
+ if self:getSelection(n) ~= 1 then
+ self.locks[n] = true
+ end
+ end
+ if action == "jump" then
+ if locked then
+ self.locks[n] = false
+ end
+ end
end
end
function Selector:controlreleased(set, action, key) end