summaryrefslogtreecommitdiffhomepage
path: root/config/menus/select.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-22 19:20:30 +0200
committerAki <nthirtyone@gmail.com>2017-09-22 19:20:30 +0200
commitb9f8a7bf85c88a3955d28824627a65efa193e8ad (patch)
tree81c078c26e9b51e6458e559f1b034abe0fa49453 /config/menus/select.lua
parent86c552cab9d245b6d58638179df2ae657ef9a5db (diff)
downloadroflnauts-b9f8a7bf85c88a3955d28824627a65efa193e8ad.zip
roflnauts-b9f8a7bf85c88a3955d28824627a65efa193e8ad.tar.gz
roflnauts-b9f8a7bf85c88a3955d28824627a65efa193e8ad.tar.bz2
Cleaned-up icons and items population for selectors in menu
Diffstat (limited to 'config/menus/select.lua')
-rw-r--r--config/menus/select.lua31
1 files changed, 18 insertions, 13 deletions
diff --git a/config/menus/select.lua b/config/menus/select.lua
index a803295..91da7c9 100644
--- a/config/menus/select.lua
+++ b/config/menus/select.lua
@@ -14,22 +14,27 @@ if background == nil or not background:is(require "not.MenuBackground") then
background = require "not.MenuBackground"(menu)
end
--- TODO: Clean-up menus/select, menus/host and Hero after portraits split.
-local group, get
-do
- local nauts, icons = {}, {}
- local files = love.filesystem.getDirectoryItems("config/nauts")
- for _,filename in pairs(files) do
- local path = string.format("config/nauts/%s", filename)
- if love.filesystem.isFile(path) and filename ~= "readme.md" then
- local naut = love.filesystem.load(path)()
- local i, name = naut.portrait, naut.name
- if naut.available then
- table.insert(icons, love.graphics.newImage(naut.portrait))
- table.insert(nauts, naut)
+-- TODO: loadConfigs is duplicated in menus/select and menus/host.
+local
+function loadConfigs (dir, process)
+ local items, icons = {}, {}
+ for _,file in pairs(love.filesystem.getDirectoryItems(dir)) do
+ local path = string.format("%s/%s", dir, file)
+ if love.filesystem.isFile(path) and file ~= "readme.md" then
+ local item = love.filesystem.load(path)()
+ if item and process(item) then
+ table.insert(icons, love.graphics.newImage(item.portrait))
+ table.insert(items, item)
end
end
end
+ return items, icons
+end
+
+-- TODO: Clean-up menus/select, menus/host and Hero after portraits split.
+local group, get
+do
+ local nauts, icons = loadConfigs("config/nauts", function (naut) return naut.available end)
-- TODO: Find a better way to add empty and random entries to naut Selector.
table.insert(icons, 1, false)