summaryrefslogtreecommitdiffhomepage
path: root/config/menus/host.lua
diff options
context:
space:
mode:
Diffstat (limited to 'config/menus/host.lua')
-rw-r--r--config/menus/host.lua48
1 files changed, 30 insertions, 18 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)
,