summaryrefslogtreecommitdiffhomepage
path: root/config/menus/select.lua
diff options
context:
space:
mode:
Diffstat (limited to 'config/menus/select.lua')
-rw-r--r--config/menus/select.lua76
1 files changed, 52 insertions, 24 deletions
diff --git a/config/menus/select.lua b/config/menus/select.lua
index 23f9374..1e57960 100644
--- a/config/menus/select.lua
+++ b/config/menus/select.lua
@@ -3,46 +3,75 @@ local menu, background = ...
local Button = require "not.Button"
local Selector = require "not.Selector"
local Element = require "not.Element"
+local Group = require "not.Group"
local width, height = love.graphics.getWidth()/getScale(), love.graphics.getHeight()/getScale()
local bx = width/2-29
-local naut_Selector = Selector(menu)
local start_Button = Button(menu)
-require "iconsList"
-local nautsIcons, nautsList = getNautsIconsList()
-
if background == nil or not background:is(require "not.MenuBackground") then
background = require "not.MenuBackground"(menu)
end
+-- TODO: Temporary group for naut selectors. This isn't production code at any means!
+local group, get
+do
+ local atlas = love.graphics.newImage("assets/portraits.png")
+ local nauts = require("config.nauts")
+ local icons = {}
+ for i=0,#nauts-1 do
+ table.insert(icons, love.graphics.newQuad(i*28, 0, 28, 27, 1008, 27))
+ end
+
+ group = Group(menu)
+
+ local
+ function attack (self)
+ if not self.lock then
+ if self.index == 1 then
+ return
+ end
+ if self.index == 2 then
+ self.index = self:rollRandom({1, 2})
+ end
+ if self:isUnique() then
+ self.lock = true
+ end
+ end
+ end
+
+ for i,_ in pairs(Controller.getSets()) do
+ group:addChild(Selector(nauts, group, menu))
+ :set("icons_atlas", atlas)
+ :set("icons_quads", icons)
+ :set("attack", attack)
+ end
+
+ group:set("margin", 16)
+ local gw, gh = group:getSize()
+ group:setPosition((width - gw)/2, 55)
+
+ function get ()
+ local selection = group:callEach("getLocked")
+ for i,naut in ipairs(selection) do
+ selection[i] = {naut, Controller.getSets()[i]}
+ end
+ return selection
+ end
+end
+
return {
background,
- naut_Selector
- :setPosition(width/2,60)
- :setMargin(8)
- :setSize(32, 32)
- :set("list", nautsList)
- :set("global", false)
- :set("icons_i", love.graphics.newImage("assets/portraits.png"))
- :set("icons_q", nautsIcons)
- :init()
- ,
+ group,
start_Button
:setText("Force start")
:setPosition(bx,134)
:set("isEnabled", function ()
- if #naut_Selector:getFullSelection(false) > 1 then
- return true
- end
- return false
+ return #get() > 1
end)
:set("active", function (self)
- local nauts = naut_Selector:getFullSelection(false)
- if #nauts > 1 then
- sceneManager:changeScene(World(MAP, nauts))
- end
+ sceneManager:changeScene(World(MAP, get()))
end)
,
Button(menu)
@@ -67,8 +96,7 @@ return {
end
end)
:set("update", function (self, dt)
- local total = #naut_Selector:getFullSelection(false)
- if total > 1 then
+ if #get() > 1 then
self.the_final_countdown = self.the_final_countdown - dt
else
self.the_final_countdown = 9