summaryrefslogtreecommitdiffhomepage
path: root/config/menus
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-21 21:05:37 +0200
committerAki <nthirtyone@gmail.com>2017-09-21 21:05:37 +0200
commite9a450d65d4fb564691cdf651ef5771dd88303ae (patch)
treef49d29582dd6877f3b3c807c3f7d9d92d368f798 /config/menus
parenteb8302723cd85adca0fbaf505cfb315f1db0299a (diff)
parentb97985def64b8bd8f93a7b391b12333595432e52 (diff)
downloadroflnauts-e9a450d65d4fb564691cdf651ef5771dd88303ae.zip
roflnauts-e9a450d65d4fb564691cdf651ef5771dd88303ae.tar.gz
roflnauts-e9a450d65d4fb564691cdf651ef5771dd88303ae.tar.bz2
Merge branch 'maps'
Diffstat (limited to 'config/menus')
-rw-r--r--config/menus/host.lua48
-rw-r--r--config/menus/select.lua76
2 files changed, 82 insertions, 42 deletions
diff --git a/config/menus/host.lua b/config/menus/host.lua
index a180736..c8ef4d8 100644
--- a/config/menus/host.lua
+++ b/config/menus/host.lua
@@ -6,37 +6,49 @@ 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(menu)
-
-require "iconsList"
-local icons, maps = getMapsIconsList()
-
if background == nil or not background:is(require "not.MenuBackground") then
background = require "not.MenuBackground"(menu)
end
+-- TODO: This is temporary solution for generating available maps list and portraits for them to pass to Selector. See also: `iconsList`.
+local icons, maps = {}, {}
+do
+ local files = love.filesystem.getDirectoryItems("config/maps")
+ for _,filename in pairs(files) do
+ local path = string.format("config/maps/%s", filename)
+ if love.filesystem.isFile(path) and filename ~= "readme.md" then
+ local map = love.filesystem.load(path)()
+ local i, name = map.portrait, map.name
+ map.filename = path
+ if i then
+ table.insert(icons, love.graphics.newQuad((i-1)*76, 0, 76, 37, 608, 37))
+ table.insert(maps, map)
+ end
+ end
+ end
+end
+
+local mapSelector = Selector(maps, nil, menu)
+
return {
background,
- map_Selector
- :setPosition(width/2, 40)
- :setSize(80, 42)
- :setMargin(0)
- :set("global", true)
- :set("first", true)
- :set("list", maps)
- :set("icons_i", love.graphics.newImage("assets/maps.png"))
- :set("icons_q", icons)
- :set("shape", "panorama")
- :init()
+ mapSelector
+ :setPosition(width/2-40, 40)
+ :set("shape", Selector.SHAPE_PANORAMA)
+ :set("icons_quads", icons)
+ :set("icons_atlas", love.graphics.newImage("assets/maps.png"))
+ :set("getText", function (self)
+ return self:getSelected().name
+ end)
,
Button(menu)
:setText("Next")
:setPosition(bx,101)
:set("isEnabled", function ()
- return map_Selector:isLocked()
+ return mapSelector:getLocked()
end)
:set("active", function (self)
- MAP = map_Selector:getFullSelection(true)[1][1] -- please, don't kill me for this, kek
+ MAP = mapSelector:getSelected()
self.parent:open("select")
end)
,
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