summaryrefslogtreecommitdiffhomepage
path: root/config/menus/select.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-04-09 22:07:04 +0200
committerAki <nthirtyone@gmail.com>2017-04-09 22:07:04 +0200
commit0dd01913fe0eefc7ba4bc0797877f40fdedf9315 (patch)
tree8d270eb07f589d2487b3ce66d4865e5a4718042a /config/menus/select.lua
parent55b0cf1a22e4a7e41fe00aa693445d6c4bd0652d (diff)
parenta03c1125f10fbbad253a0efc4727072fcbd55345 (diff)
downloadroflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.zip
roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.gz
roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.bz2
Merge branch 'com'
Diffstat (limited to 'config/menus/select.lua')
-rw-r--r--config/menus/select.lua76
1 files changed, 76 insertions, 0 deletions
diff --git a/config/menus/select.lua b/config/menus/select.lua
new file mode 100644
index 0000000..804b4eb
--- /dev/null
+++ b/config/menus/select.lua
@@ -0,0 +1,76 @@
+local menu = ...
+
+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
+
+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", nautsList)
+ :set("global", false)
+ :set("icons_i", love.graphics.newImage("assets/portraits.png"))
+ :set("icons_q", 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