diff options
-rw-r--r-- | config/maps.lua (renamed from maplist.lua) | 0 | ||||
-rw-r--r-- | config/menus/host.lua | 7 | ||||
-rw-r--r-- | config/menus/select.lua | 7 | ||||
-rw-r--r-- | config/nauts.lua (renamed from nautslist.lua) | 5 | ||||
-rw-r--r-- | iconsList.lua | 37 | ||||
-rw-r--r-- | main.lua | 1 | ||||
-rw-r--r-- | mapicons.lua | 12 | ||||
-rw-r--r-- | nautsicons.lua | 11 | ||||
-rw-r--r-- | not/Hero.lua | 2 |
9 files changed, 54 insertions, 28 deletions
diff --git a/maplist.lua b/config/maps.lua index 32e89a5..32e89a5 100644 --- a/maplist.lua +++ b/config/maps.lua diff --git a/config/menus/host.lua b/config/menus/host.lua index 8a4887e..b318a5b 100644 --- a/config/menus/host.lua +++ b/config/menus/host.lua @@ -8,6 +8,9 @@ local bx = width/2-29 local map_selector = selector:new(menu) +require "iconsList" +local icons, maps = getMapsIconsList() + return { map_selector :setPosition(width/2, 40) @@ -15,9 +18,9 @@ return { :setMargin(0) :set("global", true) :set("first", true) - :set("list", require "maplist") + :set("list", maps) :set("icons_i", love.graphics.newImage("assets/maps.png")) - :set("icons_q", require "mapicons") + :set("icons_q", icons) :set("shape", "panorama") :init() , diff --git a/config/menus/select.lua b/config/menus/select.lua index e759f40..804b4eb 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -10,15 +10,18 @@ local bx = width/2-29 local naut_selector = selector:new(menu) local start_button = button:new(menu) +require "iconsList" +local nautsIcons, nautsList = getNautsIconsList() + return { naut_selector :setPosition(width/2,60) :setMargin(8) :setSize(32, 32) - :set("list", require "nautslist") + :set("list", nautsList) :set("global", false) :set("icons_i", love.graphics.newImage("assets/portraits.png")) - :set("icons_q", require "nautsicons") + :set("icons_q", nautsIcons) :init() , start_button diff --git a/nautslist.lua b/config/nauts.lua index d0c7a61..2eea71a 100644 --- a/nautslist.lua +++ b/config/nauts.lua @@ -32,4 +32,9 @@ return { "biker", -- chucho "vrooom", -- lux "shutter", -- max + "disco", -- esc rocco + "yarr", -- ted pirate + "blblal", -- blabl zork + "kong", -- ronimo + "rock", -- rock } diff --git a/iconsList.lua b/iconsList.lua new file mode 100644 index 0000000..4a384dc --- /dev/null +++ b/iconsList.lua @@ -0,0 +1,37 @@ +-- TODO: These should be part of non-existent AssetsManager or something similar. +local function testAvoidList (i, avoidList) + for key,value in pairs(avoidList) do + if i == value then + table.remove(avoidList, key) + return false + end + end + return true +end + +function createIconsList (sheetWidth, sheetHeight, iconWidth, keysList, avoidList) + local avoidList = avoidList or {} + local iconsList, newKeysList = {}, {} + local iconsNumber = math.floor(sheetWidth / iconWidth) + local iconHeight = sheetHeight + for i=1,iconsNumber do + if testAvoidList(i, avoidList) then + iconsList[keysList[i]] = love.graphics.newQuad((i-1)*iconWidth, 0, iconWidth, iconHeight, sheetWidth, sheetHeight) + table.insert(newKeysList, keysList[i]) + end + end + return iconsList, newKeysList +end + +function getNautsIconsList (avoidList) + local avoidList = avoidList or {32,33,34,35,36} + local keysList = require "config.nauts" + local iconsList, newKeysList = createIconsList(1008, 27, 28, keysList, avoidList) + return iconsList, newKeysList +end + +function getMapsIconsList (avoidList) + local keysList = require "config.maps" + local iconsList, newKeysList = createIconsList(532, 37, 76, keysList, avoidList) + return iconsList, newKeysList +end @@ -23,6 +23,7 @@ function getRealScale () end -- Require +require "iconsList" require "not.World" require "not.Camera" require "not.Menu" diff --git a/mapicons.lua b/mapicons.lua deleted file mode 100644 index 8729a56..0000000 --- a/mapicons.lua +++ /dev/null @@ -1,12 +0,0 @@ --- Maps icons list generation file --- TODO: it is so similar to `nautsicons.lua` they could be merged together into one function that returns icon quad sequences (`createIconList(image, width, number, mask...) --[[ body ]] return image, icons, list end` or similar). On the other hand extended lists with maps/nauts in config would be enough. -local maps = require "maplist" -local w, h = 532, 37 -local icons = {} - -local i = 0 -for _,map in pairs(maps) do - icons[map] = love.graphics.newQuad(i*76, 0, 76, 37, w, h) - i = i + 1 -end -return icons diff --git a/nautsicons.lua b/nautsicons.lua deleted file mode 100644 index 6c09a8f..0000000 --- a/nautsicons.lua +++ /dev/null @@ -1,11 +0,0 @@ --- Spritesheet for character portraits -local nauts = require "nautslist" -local w, h = 1008, 27 -local icons = {} - -local i = 0 -for _,naut in pairs(nauts) do - icons[naut] = love.graphics.newQuad(i*28, 0, 28, 27, w, h) - i = i + 1 -end -return icons diff --git a/not/Hero.lua b/not/Hero.lua index a22cc2e..4150024 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -26,7 +26,7 @@ Hero = { -- Statics portrait_sprite = nil, portrait_frame = nil, - portrait_sheet = require "nautsicons", + portrait_sheet = getNautsIconsList(), portrait_box = love.graphics.newQuad( 0, 15, 32,32, 80,130), sfx = require "sounds", } |