From 37767d6c54ea6af0b4631b5ce838ee584603895e Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 7 Apr 2017 02:53:36 +0200 Subject: Moved menu configs to subdirectory --- config/menus/select.lua | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 config/menus/select.lua (limited to 'config/menus/select.lua') diff --git a/config/menus/select.lua b/config/menus/select.lua new file mode 100644 index 0000000..452a3bf --- /dev/null +++ b/config/menus/select.lua @@ -0,0 +1,73 @@ +local menu = ... + +local button = require "button" +local selector = require "selector" +local element = require "element" + +local width, height = love.graphics.getWidth()/getScale(), love.graphics.getHeight()/getScale() +local bx = width/2-29 + +local naut_selector = selector:new(menu) +local start_button = button:new(menu) + +return { + naut_selector + :setPosition(width/2,60) + :setMargin(8) + :setSize(32, 32) + :set("list", require "nautslist") + :set("global", false) + :set("icons_i", love.graphics.newImage("assets/portraits.png")) + :set("icons_q", require "nautsicons") + :init() + , + start_button + :setText("Force start") + :setPosition(bx,134) + :set("isEnabled", function () + if #naut_selector:getFullSelection(false) > 1 then + return true + end + return false + end) + :set("active", function (self) + local nauts = naut_selector:getFullSelection(false) + if #nauts > 1 then + changeScene(World:new(MAP, nauts)) + end + end) + , + button:new(menu) + :setText("Go back") + :setPosition(bx,150) + :set("active", function (self) + self.parent:open("host") + end) + , + element:new(menu) + :setPosition(bx, 101) + :set("the_final_countdown", 9) + :set("draw", function (self, scale) + if self.the_final_countdown ~= 9 then + local x,y = self:getPosition() + local countdown = math.max(1, math.ceil(self.the_final_countdown)) + love.graphics.setColor(255, 255, 255, 255) + love.graphics.setFont(Font) + love.graphics.print("Autostart in:", (x-16)*scale, (y+10)*scale, 0, scale, scale) + love.graphics.setFont(Bold) + love.graphics.printf(countdown, (x+40)*scale, (y)*scale, 36, "center", 0, scale, scale) + end + end) + :set("update", function (self, dt) + local total = #naut_selector:getFullSelection(false) + if total > 1 then + self.the_final_countdown = self.the_final_countdown - dt + else + self.the_final_countdown = 9 + end + if self.the_final_countdown < 0 then + start_button:active() + end + end) + , +} \ No newline at end of file -- cgit v1.1 From d1a19fea50aefc9d7fb52568a5bdcfb56d75eccf Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 7 Apr 2017 03:24:40 +0200 Subject: Moved menu elements to /not/ --- config/menus/select.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'config/menus/select.lua') diff --git a/config/menus/select.lua b/config/menus/select.lua index 452a3bf..e759f40 100644 --- a/config/menus/select.lua +++ b/config/menus/select.lua @@ -1,8 +1,8 @@ local menu = ... -local button = require "button" -local selector = require "selector" -local element = require "element" +local button = require "not.Button" +local selector = require "not.Selector" +local element = require "not.Element" local width, height = love.graphics.getWidth()/getScale(), love.graphics.getHeight()/getScale() local bx = width/2-29 -- cgit v1.1 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/menus/select.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'config/menus/select.lua') 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 -- cgit v1.1