From b2da7e5dda158f0194df3321b5ea10d0f23c8a69 Mon Sep 17 00:00:00 2001 From: Yan Couto Date: Fri, 14 Dec 2018 01:42:13 -0200 Subject: [PATCH] Fixing Timers not updating in menu (closes #30) Also checkbox now can only be clicked when the mouse is exactly above it. --- client/gamestates/connection_menu.lua | 2 ++ client/gamestates/wait_room.lua | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client/gamestates/connection_menu.lua b/client/gamestates/connection_menu.lua index 554cf09..fc55b3a 100644 --- a/client/gamestates/connection_menu.lua +++ b/client/gamestates/connection_menu.lua @@ -82,6 +82,8 @@ function state:update(dt) if connect or hit then connect_to_server(options, host_input.text, chars[chosen_char]) end + + Util.updateTimers(dt) end function state:draw() diff --git a/client/gamestates/wait_room.lua b/client/gamestates/wait_room.lua index f4745f9..ea6f3b0 100644 --- a/client/gamestates/wait_room.lua +++ b/client/gamestates/wait_room.lua @@ -15,7 +15,7 @@ local larger_font local title_font local room_input = { text = "" } -local ready_checkbox = { text = "Ready", checked = false } +local ready_checkbox = { checked = false } function state:enter(prev, options, char_type) room = 'none' @@ -45,7 +45,7 @@ function state:enter(prev, options, char_type) if options.auto_ready then MAIN_TIMER:after(tonumber(options.auto_ready) or 0, function() ready_checkbox.checked = true - Client.send('ready', ready) + Client.send('ready', true) end) end @@ -70,9 +70,13 @@ function state:update(dt) Client.send('change room', room) end - if suit.Checkbox(ready_checkbox, suit.layout:row()).hit then - Client.send('ready', ready_checkbox.checked) - end + suit.layout:push(suit.layout:row()) + if suit.Checkbox(ready_checkbox, suit.layout:row(50, 50)).hit then + Client.send('ready', ready_checkbox.checked) + end + suit.Label("Ready", {align = 'left', font = larger_font}, suit.layout:col(100, 50)) + suit.layout:pop() + suit.Label("Current Room: " .. room, {font = larger_font}, suit.layout:row(400, 40)) -- Players list @@ -85,6 +89,8 @@ function state:update(dt) end suit.layout:row() end + + Util.updateTimers(dt) end function state:draw()