From 65e2f701a6c0cfbf53506678771839f7f6d12cbf Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 24 Aug 2016 22:14:10 +0200 Subject: map selection --- assets/placeholder-map-icon.png | Bin 0 -> 1220 bytes config/menuhost.lua | 13 +++++++++++++ config/menuselect.lua | 2 +- selector.lua | 5 ++++- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 assets/placeholder-map-icon.png diff --git a/assets/placeholder-map-icon.png b/assets/placeholder-map-icon.png new file mode 100644 index 0000000..cab79f1 Binary files /dev/null and b/assets/placeholder-map-icon.png differ diff --git a/config/menuhost.lua b/config/menuhost.lua index 3ad10db..53972b3 100644 --- a/config/menuhost.lua +++ b/config/menuhost.lua @@ -6,11 +6,24 @@ local selector = require "selector" local width, height = love.graphics.getWidth()/getRealScale(), love.graphics.getHeight()/getRealScale() local bx = width/2-29 +local map_selector = selector:new(menu) + return { + map_selector + :setPosition(width/2, 10) + :setSize(80, 42) + :setMargin(0) + :set("global", true) + :set("list", require "maplist") + :set("sprite", love.graphics.newImage("assets/placeholder-map-icon.png")) + :set("quads", require "mapicons") + :init() + , button:new(menu) :setText("Select") :setPosition(bx,101) :set("active", function (self) + MAP = map_selector:getFullSelection(true)[1][1] self.parent:load("menuselect") end) , diff --git a/config/menuselect.lua b/config/menuselect.lua index af71b5f..20ea607 100644 --- a/config/menuselect.lua +++ b/config/menuselect.lua @@ -27,7 +27,7 @@ return { :set("active", function (self) local nauts = naut_selector:getFullSelection(false) if #nauts > 1 then - changeScene(World:new(nil, nauts)) + changeScene(World:new(MAP, nauts)) else self:blink() end diff --git a/selector.lua b/selector.lua index a0e19f8..f2d7b16 100644 --- a/selector.lua +++ b/selector.lua @@ -82,6 +82,7 @@ function Selector:init() end -- Initialize global Selector if self.global then + self.sets = {} self.locks = {false} self.selections = {1} -- Initialize Selector for Controllers @@ -162,7 +163,9 @@ function Selector:getFullSelection(allowed) local name = self:getListValue(self:getSelection(n)) local locked = self:isLocked(n) if locked or allowed then - table.insert(t, {name, self.sets[n]}) + local a = {name} + if self.sets[n] then table.insert(a, self.sets[n]) end + table.insert(t, a) end end return t -- cgit v1.1