diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-04 23:50:25 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-04 23:50:25 +0200 |
commit | 0e79f3ecbb0dca43aad166a718f58484afabe712 (patch) | |
tree | 9f13aea97704beadb2dce5a9f4b27ea54eeb9712 /config/menus/select.lua | |
parent | 168123c5a499d2d103d55bbf403b3a49bc3c28ec (diff) | |
download | roflnauts-0e79f3ecbb0dca43aad166a718f58484afabe712.zip roflnauts-0e79f3ecbb0dca43aad166a718f58484afabe712.tar.gz roflnauts-0e79f3ecbb0dca43aad166a718f58484afabe712.tar.bz2 |
Naut selection kinda works with new Group+Selector combo
Diffstat (limited to 'config/menus/select.lua')
-rw-r--r-- | config/menus/select.lua | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/config/menus/select.lua b/config/menus/select.lua index 23f9374..937bfd8 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -3,46 +3,49 @@ 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 = Group(menu) +local +function add (element) + table.insert(group.children, element) + return element +end + +for i,_ in pairs(Controller.getSets()) do + add(Selector(require("config.nauts"), group, menu)):setPosition(10+48*(i-1), 10) +end + +local +function get () + local selection = group:callEach("getSelected") + for i,naut in ipairs(selection) do + selection[i] = {naut, Controller.getSets()[i]} + end + return selection +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 true 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,7 +70,7 @@ return { end end) :set("update", function (self, dt) - local total = #naut_Selector:getFullSelection(false) + local total = 0 if total > 1 then self.the_final_countdown = self.the_final_countdown - dt else |