From 1c3040de93f9d5a164ccb06194eacc28eead0234 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 7 Apr 2017 21:05:41 +0200 Subject: Maps and nauts list moved to config Implemented functions to create icons list for them Changed so game uses these functions now --- config/maps.lua | 9 +++++++++ config/menus/host.lua | 7 +++++-- config/menus/select.lua | 7 +++++-- config/nauts.lua | 40 ++++++++++++++++++++++++++++++++++++++++ iconsList.lua | 37 +++++++++++++++++++++++++++++++++++++ main.lua | 1 + mapicons.lua | 12 ------------ maplist.lua | 9 --------- nautsicons.lua | 11 ----------- nautslist.lua | 35 ----------------------------------- not/Hero.lua | 2 +- 11 files changed, 98 insertions(+), 72 deletions(-) create mode 100644 config/maps.lua create mode 100644 config/nauts.lua create mode 100644 iconsList.lua delete mode 100644 mapicons.lua delete mode 100644 maplist.lua delete mode 100644 nautsicons.lua delete mode 100644 nautslist.lua diff --git a/config/maps.lua b/config/maps.lua new file mode 100644 index 0000000..32e89a5 --- /dev/null +++ b/config/maps.lua @@ -0,0 +1,9 @@ +return { + "default", + "rill", + "ribbit", + "starstorm", + "aiguillon", + "sorona", + "alpha abyss" +} 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/config/nauts.lua b/config/nauts.lua new file mode 100644 index 0000000..2eea71a --- /dev/null +++ b/config/nauts.lua @@ -0,0 +1,40 @@ +-- List of characters with empty character included +-- icons list is generated from this file +return { + "empty", -- empty + "random", --random + "froggo", -- froggy + "cowboy", -- lonestar + "honic", -- leon + "gelato", -- scoop + "veno", -- gnaw + "lady", -- raelynn + "girl", -- ayla + "megoman", -- clunk + "brainos", -- voltar + "woman", -- coco + "bison", -- skolldir + "bobito", -- yuri + "slugzor", -- derpl + "capone", -- vinnie + "nemo", -- spike + "bug", -- genji + "calamari", -- swiggins + "quack", -- rocco + "scissors", -- ksenia + "link", -- ix + "marine", -- ted + "scooter", -- penny + "phonebooth", -- sentry + "weed", -- skree + "gummybear", -- nibbs + "gramps", -- yoolip + "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 diff --git a/main.lua b/main.lua index 0c20b34..11e4d95 100644 --- a/main.lua +++ b/main.lua @@ -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/maplist.lua b/maplist.lua deleted file mode 100644 index 32e89a5..0000000 --- a/maplist.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - "default", - "rill", - "ribbit", - "starstorm", - "aiguillon", - "sorona", - "alpha abyss" -} 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/nautslist.lua b/nautslist.lua deleted file mode 100644 index d0c7a61..0000000 --- a/nautslist.lua +++ /dev/null @@ -1,35 +0,0 @@ --- List of characters with empty character included --- icons list is generated from this file -return { - "empty", -- empty - "random", --random - "froggo", -- froggy - "cowboy", -- lonestar - "honic", -- leon - "gelato", -- scoop - "veno", -- gnaw - "lady", -- raelynn - "girl", -- ayla - "megoman", -- clunk - "brainos", -- voltar - "woman", -- coco - "bison", -- skolldir - "bobito", -- yuri - "slugzor", -- derpl - "capone", -- vinnie - "nemo", -- spike - "bug", -- genji - "calamari", -- swiggins - "quack", -- rocco - "scissors", -- ksenia - "link", -- ix - "marine", -- ted - "scooter", -- penny - "phonebooth", -- sentry - "weed", -- skree - "gummybear", -- nibbs - "gramps", -- yoolip - "biker", -- chucho - "vrooom", -- lux - "shutter", -- max -} 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", } -- cgit v1.1