From 2b33497121abec53d1fcbce68c9c0d8224079032 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 2 Sep 2017 21:08:42 +0200 Subject: Map selector no longer use pre-written maps list or iconsList functions --- config/menus/host.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'config/menus') diff --git a/config/menus/host.lua b/config/menus/host.lua index a180736..2166360 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -8,13 +8,27 @@ 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: Temporary fun stuff for maps, will be changed along `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 + if i then + icons[name] = love.graphics.newQuad((i-1)*76, 0, 76, 37, 532, 37) + table.insert(maps, name) + end + end + end +end + return { background, map_Selector -- cgit v1.1 From ddd632254394a8ebfa3151e91978daa5455829a6 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 3 Sep 2017 20:04:44 +0200 Subject: Verbose explanation of TODO about map selector list --- config/menus/host.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/menus') diff --git a/config/menus/host.lua b/config/menus/host.lua index 2166360..38cc463 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -12,7 +12,7 @@ if background == nil or not background:is(require "not.MenuBackground") then background = require "not.MenuBackground"(menu) end --- TODO: Temporary fun stuff for maps, will be changed along `iconsList`. +-- 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") -- cgit v1.1 From 48f8e2e9b19a074306a9db896b84b27b21a2cc99 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 4 Sep 2017 22:23:32 +0200 Subject: Testing new Selector and added update, locked drawing --- config/menus/host.lua | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'config/menus') diff --git a/config/menus/host.lua b/config/menus/host.lua index 38cc463..e7b41c2 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -6,8 +6,6 @@ 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) - if background == nil or not background:is(require "not.MenuBackground") then background = require "not.MenuBackground"(menu) end @@ -23,34 +21,28 @@ do local i, name = map.portrait, map.name if i then icons[name] = love.graphics.newQuad((i-1)*76, 0, 76, 37, 532, 37) - table.insert(maps, name) + table.insert(maps, map) end end end end +local mapSelector = Selector(maps, nil, menu) + return { background, - map_Selector + mapSelector :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() + :set("shape", Selector.SHAPE_PANORAMA) , 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().name -- TODO: It uses map name for compatibility with old code. self.parent:open("select") end) , -- cgit v1.1 From 5da2cf3f8dc86da6b35641b3bf462808bfab913b Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 4 Sep 2017 22:37:24 +0200 Subject: Centered map selector --- config/menus/host.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/menus') diff --git a/config/menus/host.lua b/config/menus/host.lua index e7b41c2..8fca328 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -32,7 +32,7 @@ local mapSelector = Selector(maps, nil, menu) return { background, mapSelector - :setPosition(width/2, 40) + :setPosition(width/2-40, 40) :set("shape", Selector.SHAPE_PANORAMA) , Button(menu) -- cgit v1.1 From 0e79f3ecbb0dca43aad166a718f58484afabe712 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 4 Sep 2017 23:50:25 +0200 Subject: Naut selection kinda works with new Group+Selector combo --- config/menus/select.lua | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'config/menus') 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 -- cgit v1.1 From 0f97a9712bbbb297c83758ecd48e5e51532a426f Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 00:34:42 +0200 Subject: Provide icons for map selector to draw --- config/menus/host.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'config/menus') diff --git a/config/menus/host.lua b/config/menus/host.lua index 8fca328..8054942 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -20,7 +20,7 @@ do local map = love.filesystem.load(path)() local i, name = map.portrait, map.name if i then - icons[name] = love.graphics.newQuad((i-1)*76, 0, 76, 37, 532, 37) + table.insert(icons, love.graphics.newQuad((i-1)*76, 0, 76, 37, 532, 37)) table.insert(maps, map) end end @@ -34,6 +34,8 @@ return { mapSelector :setPosition(width/2-40, 40) :set("shape", Selector.SHAPE_PANORAMA) + :set("icons_quads", icons) + :set("icons_atlas", love.graphics.newImage("assets/maps.png")) , Button(menu) :setText("Next") -- cgit v1.1 From dacc12eb824264e4f71e21ebecac4c76c9ad6382 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 00:58:00 +0200 Subject: Provided icons for nauts selectors --- config/menus/select.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'config/menus') diff --git a/config/menus/select.lua b/config/menus/select.lua index 937bfd8..9ce7201 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -15,6 +15,13 @@ if background == nil or not background:is(require "not.MenuBackground") then end -- TODO: Temporary group for naut selectors. This isn't production code at any means! +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 + local group = Group(menu) local function add (element) @@ -23,7 +30,10 @@ function add (element) end for i,_ in pairs(Controller.getSets()) do - add(Selector(require("config.nauts"), group, menu)):setPosition(10+48*(i-1), 10) + add(Selector(nauts, group, menu)) + :setPosition(10+48*(i-1), 10) + :set("icons_atlas", atlas) + :set("icons_quads", icons) end local -- cgit v1.1 From 9fcdea2e2eb36a2ee0a32cede760b8ec74b1feed Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 00:59:50 +0200 Subject: Separated dev code part from rest --- config/menus/select.lua | 50 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'config/menus') diff --git a/config/menus/select.lua b/config/menus/select.lua index 9ce7201..609c2f6 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -15,34 +15,36 @@ if background == nil or not background:is(require "not.MenuBackground") then end -- TODO: Temporary group for naut selectors. This isn't production code at any means! -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 +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 -local group = Group(menu) -local -function add (element) - table.insert(group.children, element) - return element -end + group = Group(menu) + local + function add (element) + table.insert(group.children, element) + return element + end -for i,_ in pairs(Controller.getSets()) do - add(Selector(nauts, group, menu)) - :setPosition(10+48*(i-1), 10) - :set("icons_atlas", atlas) - :set("icons_quads", icons) -end + for i,_ in pairs(Controller.getSets()) do + add(Selector(nauts, group, menu)) + :setPosition(10+48*(i-1), 10) + :set("icons_atlas", atlas) + :set("icons_quads", icons) + end -local -function get () - local selection = group:callEach("getSelected") - for i,naut in ipairs(selection) do - selection[i] = {naut, Controller.getSets()[i]} + 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 selection end return { -- cgit v1.1 From fc16ad592a45648c7df7cc18c2b6cd153af238e3 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 01:02:52 +0200 Subject: Notes on new naut selector --- config/menus/select.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'config/menus') diff --git a/config/menus/select.lua b/config/menus/select.lua index 609c2f6..a3c379b 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -15,6 +15,9 @@ if background == nil or not background:is(require "not.MenuBackground") then end -- TODO: Temporary group for naut selectors. This isn't production code at any means! +-- TODO: New nauts selector is missing random rolling! +-- TODO: New nauts selector allows empty naut as selection! +-- TODO: New nauts selector allows non-unique selections within groups! local group, get do local atlas = love.graphics.newImage("assets/portraits.png") -- cgit v1.1 From b117c29325698e56a4fbd76426739dd48fa154cb Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 01:24:02 +0200 Subject: Map config table is now passed to World rather than map name --- config/menus/host.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/menus') diff --git a/config/menus/host.lua b/config/menus/host.lua index 8054942..1ac4b0f 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -44,7 +44,7 @@ return { return mapSelector:getLocked() end) :set("active", function (self) - MAP = mapSelector:getSelected().name -- TODO: It uses map name for compatibility with old code. + MAP = mapSelector:getSelected() self.parent:open("select") end) , -- cgit v1.1 From 78654392715768991cb10fc7c1aca60859e58516 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 02:03:35 +0200 Subject: Centered nauts selectors group --- config/menus/select.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'config/menus') diff --git a/config/menus/select.lua b/config/menus/select.lua index a3c379b..c4a9595 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -28,19 +28,17 @@ do end group = Group(menu) - local - function add (element) - table.insert(group.children, element) - return element - end for i,_ in pairs(Controller.getSets()) do - add(Selector(nauts, group, menu)) - :setPosition(10+48*(i-1), 10) + group:addChild(Selector(nauts, group, menu)) :set("icons_atlas", atlas) :set("icons_quads", icons) end + group:set("margin", 16) + local gw, gh = group:getSize() + group:setPosition((width - gw)/2, 10) + function get () local selection = group:callEach("getSelected") for i,naut in ipairs(selection) do -- cgit v1.1 From e8c85303a138e44e1bbe7613c0e6db8d5b7c1fb6 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 02:11:07 +0200 Subject: Force start and countdown; selectors properly placed --- config/menus/select.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'config/menus') diff --git a/config/menus/select.lua b/config/menus/select.lua index c4a9595..2341556 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -37,10 +37,10 @@ do group:set("margin", 16) local gw, gh = group:getSize() - group:setPosition((width - gw)/2, 10) + group:setPosition((width - gw)/2, 55) function get () - local selection = group:callEach("getSelected") + local selection = group:callEach("getLocked") for i,naut in ipairs(selection) do selection[i] = {naut, Controller.getSets()[i]} end @@ -55,7 +55,7 @@ return { :setText("Force start") :setPosition(bx,134) :set("isEnabled", function () - return true + return #get() > 1 end) :set("active", function (self) sceneManager:changeScene(World(MAP, get())) @@ -83,8 +83,7 @@ return { end end) :set("update", function (self, dt) - local total = 0 - if total > 1 then + if #get() > 1 then self.the_final_countdown = self.the_final_countdown - dt else self.the_final_countdown = 9 -- cgit v1.1 From 7f524270713a558c0538c7d728271121928a60ec Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 02:17:01 +0200 Subject: Map config filepath is now added to map config table; used by debug mode --- config/menus/host.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'config/menus') diff --git a/config/menus/host.lua b/config/menus/host.lua index 1ac4b0f..5595f8b 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -19,6 +19,7 @@ do if love.filesystem.isFile(path) and filename ~= "readme.md" then local map = love.filesystem.load(path)() local i, name = map.portrait, map.name + map.filepath = path if i then table.insert(icons, love.graphics.newQuad((i-1)*76, 0, 76, 37, 532, 37)) table.insert(maps, map) -- cgit v1.1 From 9fb64e49be5d991a0bf4bc1f6f162f40276ba2f5 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 02:41:02 +0200 Subject: Disallow nauts duplicates and empty as selection --- config/menus/select.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'config/menus') diff --git a/config/menus/select.lua b/config/menus/select.lua index 2341556..0540bd5 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -16,8 +16,6 @@ end -- TODO: Temporary group for naut selectors. This isn't production code at any means! -- TODO: New nauts selector is missing random rolling! --- TODO: New nauts selector allows empty naut as selection! --- TODO: New nauts selector allows non-unique selections within groups! local group, get do local atlas = love.graphics.newImage("assets/portraits.png") @@ -29,10 +27,26 @@ do group = Group(menu) + local + function attack (self) + if not self.lock then + if self.index == 1 then + return + end + if self.index == 2 then + return -- roll random, soon. + 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) -- cgit v1.1 From 84f6ec47be56d397fe140b5707b76078917fe8fb Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 03:49:33 +0200 Subject: Random naut selection is back! --- config/menus/select.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/menus') diff --git a/config/menus/select.lua b/config/menus/select.lua index 0540bd5..d350c32 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -34,7 +34,7 @@ do return end if self.index == 2 then - return -- roll random, soon. + self.index = self:rollRandom({1, 2}) end if self:isUnique() then self.lock = true -- cgit v1.1 From 3cb43876bc41e3074b7235b484f6b2f7622b5eda Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 04:01:56 +0200 Subject: Display map name instead of table ref --- config/menus/host.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'config/menus') diff --git a/config/menus/host.lua b/config/menus/host.lua index 5595f8b..6861d91 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -37,6 +37,9 @@ return { :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") -- cgit v1.1 From 50eefa52a843f03fd5dda4c8628d558bc00ced87 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 5 Sep 2017 04:03:22 +0200 Subject: It isn't anymore --- config/menus/select.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'config/menus') diff --git a/config/menus/select.lua b/config/menus/select.lua index d350c32..1e57960 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -15,7 +15,6 @@ if background == nil or not background:is(require "not.MenuBackground") then end -- TODO: Temporary group for naut selectors. This isn't production code at any means! --- TODO: New nauts selector is missing random rolling! local group, get do local atlas = love.graphics.newImage("assets/portraits.png") -- cgit v1.1 From 37da34f0dbc6f6fe58629e52a7126caed4f10434 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 7 Sep 2017 04:45:33 +0200 Subject: Renamed filepath to filename --- config/menus/host.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/menus') diff --git a/config/menus/host.lua b/config/menus/host.lua index 6861d91..07c5b80 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -19,7 +19,7 @@ do if love.filesystem.isFile(path) and filename ~= "readme.md" then local map = love.filesystem.load(path)() local i, name = map.portrait, map.name - map.filepath = path + map.filename = path if i then table.insert(icons, love.graphics.newQuad((i-1)*76, 0, 76, 37, 532, 37)) table.insert(maps, map) -- cgit v1.1 From 1546be903cbf7a09eb5ff3fbd7c040f842d366a5 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 19 Sep 2017 18:54:51 +0200 Subject: Changed host map icons sheet width --- config/menus/host.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/menus') diff --git a/config/menus/host.lua b/config/menus/host.lua index 07c5b80..c8ef4d8 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -21,7 +21,7 @@ do 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, 532, 37)) + table.insert(icons, love.graphics.newQuad((i-1)*76, 0, 76, 37, 608, 37)) table.insert(maps, map) end end -- cgit v1.1