mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 13:52:34 +00:00
Dual screen game clock now working
This commit is contained in:
@@ -4,13 +4,13 @@ module TAC
|
|||||||
CLOCK_SIZE = Gosu.screen_height
|
CLOCK_SIZE = Gosu.screen_height
|
||||||
TITLE_SIZE = 128
|
TITLE_SIZE = 128
|
||||||
|
|
||||||
attr_reader :title
|
attr_reader :title, :controller
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@title = CyberarmEngine::Text.new("FIRST TECH CHALLENGE", size: TITLE_SIZE, text_shadow: true, y: 10, color: Gosu::Color::GRAY)
|
@title = CyberarmEngine::Text.new("FIRST TECH CHALLENGE", size: TITLE_SIZE, text_shadow: true, y: 10, color: Gosu::Color::GRAY)
|
||||||
@title.x = $window.width / 2 - @title.width / 2
|
@title.x = $window.width / 2 - @title.width / 2
|
||||||
|
|
||||||
@text = CyberarmEngine::Text.new(":1234567890", size: CLOCK_SIZE, text_shadow: true, shadow_size: 2, shadow_color: Gosu::Color::GRAY)
|
@text = CyberarmEngine::Text.new(":1234567890", size: CLOCK_SIZE, text_border: true, border_size: 2, border_color: Gosu::Color::GRAY)
|
||||||
@text.width # trigger font-eager loading
|
@text.width # trigger font-eager loading
|
||||||
|
|
||||||
@title.z, @text.z = -1, -1
|
@title.z, @text.z = -1, -1
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def abort_clock
|
def abort_clock
|
||||||
$window.current_state&.get_sample("media/fogblast.wav")&.play if @clock.active?
|
@clock.controller&.play_sound(:abort_match) if @clock.active?
|
||||||
@clock.controller = nil
|
@clock.controller = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -116,10 +116,9 @@ module TAC
|
|||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_abort_clock)
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_abort_clock)
|
||||||
end
|
end
|
||||||
|
|
||||||
button "Shutdown", width: 1.0, **DANGEROUS_BUTTON do
|
button "Shutdown", width: 1.0, **TAC::THEME_DANGER_BUTTON do
|
||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_shutdown)
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_shutdown)
|
||||||
sleep 1 # let packet escape before closing
|
sleep 1 # let packet escape before closing
|
||||||
exit
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -222,7 +221,7 @@ module TAC
|
|||||||
@randomizer_label = title "Not Visible"
|
@randomizer_label = title "Not Visible"
|
||||||
end
|
end
|
||||||
|
|
||||||
button "Randomizer", width: 1.0, **DANGEROUS_BUTTON do
|
button "Randomizer", width: 1.0, **TAC::THEME_DANGER_BUTTON do
|
||||||
@randomizer_visible = !@randomizer_visible
|
@randomizer_visible = !@randomizer_visible
|
||||||
|
|
||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_randomizer_visible(@randomizer_visible))
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_randomizer_visible(@randomizer_visible))
|
||||||
|
|||||||
@@ -1,36 +1,5 @@
|
|||||||
module TAC
|
module TAC
|
||||||
class PracticeGameClock
|
class PracticeGameClock
|
||||||
module Palette
|
|
||||||
TACNET_CONNECTED = Gosu::Color.new(0xff_008000)
|
|
||||||
TACNET_CONNECTING = Gosu::Color.new(0xff_ff8800)
|
|
||||||
TACNET_CONNECTION_ERROR = Gosu::Color.new(0xff_800000)
|
|
||||||
TACNET_NOT_CONNECTED = Gosu::Color.new(0xff_222222)
|
|
||||||
|
|
||||||
TIMECRAFTERS_PRIMARY = Gosu::Color.new(0xff_008000)
|
|
||||||
TIMECRAFTERS_SECONDARY = Gosu::Color.new(0xff_006000)
|
|
||||||
TIMECRAFTERS_TERTIARY = Gosu::Color.new(0xff_00d000)
|
|
||||||
|
|
||||||
BLUE_ALLIANCE = Gosu::Color.new(0xff_000080)
|
|
||||||
RED_ALLIANCE = Gosu::Color.new(0xff_800000)
|
|
||||||
|
|
||||||
TACNET_PRIMARY = Gosu::Color.new(0xff000080)
|
|
||||||
TACNET_SECONDARY = Gosu::Color.new(0xff000060)
|
|
||||||
|
|
||||||
GROUPS_PRIMARY = Gosu::Color.new(0xff_444444)
|
|
||||||
GROUPS_SECONDARY = Gosu::Color.new(0xff_444444)
|
|
||||||
|
|
||||||
ACTIONS_PRIMARY = Gosu::Color.new(0xff_4444aa)
|
|
||||||
ACTIONS_SECONDARY = Gosu::Color.new(0xff_040404)
|
|
||||||
|
|
||||||
VARIABLES_PRIMARY = Gosu::Color.new(0xff_660066)
|
|
||||||
VARIABLES_SECONDARY = Gosu::Color.new(0xff_440044)
|
|
||||||
|
|
||||||
EDITOR_PRIMARY = Gosu::Color.new(0xff_446688)
|
|
||||||
EDITOR_SECONDARY = Gosu::Color.new(0xff_224466)
|
|
||||||
|
|
||||||
ALERT = TACNET_CONNECTING
|
|
||||||
end
|
|
||||||
|
|
||||||
THEME = {
|
THEME = {
|
||||||
TextBlock: {
|
TextBlock: {
|
||||||
font: "Canterell",
|
font: "Canterell",
|
||||||
@@ -55,19 +24,7 @@ module TAC
|
|||||||
ToggleButton: {
|
ToggleButton: {
|
||||||
width: 18,
|
width: 18,
|
||||||
checkmark_image: "#{File.expand_path("..", __dir__)}/media/icons/checkmark.png",
|
checkmark_image: "#{File.expand_path("..", __dir__)}/media/icons/checkmark.png",
|
||||||
},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
DANGEROUS_BUTTON = {
|
|
||||||
background: 0xff_800000,
|
|
||||||
border_thickness: 1,
|
|
||||||
border_color: Gosu::Color.new(0xff_111111),
|
|
||||||
hover: {
|
|
||||||
background: 0xff_600000,
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
background: 0xff_f00000,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ module TAC
|
|||||||
@escape_counter = 0
|
@escape_counter = 0
|
||||||
|
|
||||||
@background_image = get_image("#{ROOT_PATH}/media/background.png")
|
@background_image = get_image("#{ROOT_PATH}/media/background.png")
|
||||||
|
@menu_background = 0xaa004000
|
||||||
@mouse = Mouse.new(window)
|
@mouse = Mouse.new(window)
|
||||||
@clock = Clock.new
|
@clock = Clock.new
|
||||||
@clock.controller = nil
|
@clock.controller = nil
|
||||||
@@ -26,7 +27,7 @@ module TAC
|
|||||||
|
|
||||||
@menu_container = flow width: 1.0 do
|
@menu_container = flow width: 1.0 do
|
||||||
stack(width: 0.35, padding: 5) do
|
stack(width: 0.35, padding: 5) do
|
||||||
background 0x55004159
|
background @menu_background
|
||||||
|
|
||||||
title "Match", width: 1.0, text_align: :center
|
title "Match", width: 1.0, text_align: :center
|
||||||
button "Start Match", width: 1.0, margin_bottom: 50 do
|
button "Start Match", width: 1.0, margin_bottom: 50 do
|
||||||
@@ -54,7 +55,7 @@ module TAC
|
|||||||
@clock_proxy.abort_clock
|
@clock_proxy.abort_clock
|
||||||
end
|
end
|
||||||
|
|
||||||
button "Close", width: 1.0, **DANGEROUS_BUTTON do
|
button "Close", width: 1.0, **TAC::THEME_DANGER_BUTTON do
|
||||||
if window.instance_variable_get(:"@states").size == 1
|
if window.instance_variable_get(:"@states").size == 1
|
||||||
window.close
|
window.close
|
||||||
else
|
else
|
||||||
@@ -67,7 +68,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
stack width: 0.4, padding_left: 50 do
|
stack width: 0.4, padding_left: 50 do
|
||||||
background 0x55004159
|
background @menu_background
|
||||||
|
|
||||||
flow do
|
flow do
|
||||||
label "♫ Now playing:"
|
label "♫ Now playing:"
|
||||||
@@ -135,7 +136,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
stack width: 1.0 do
|
stack width: 1.0 do
|
||||||
button "Randomizer", width: 1.0, **DANGEROUS_BUTTON do
|
button "Randomizer", width: 1.0, **TAC::THEME_DANGER_BUTTON do
|
||||||
unless @clock.active?
|
unless @clock.active?
|
||||||
push_state(Randomizer)
|
push_state(Randomizer)
|
||||||
end
|
end
|
||||||
@@ -226,8 +227,12 @@ module TAC
|
|||||||
if @escape_counter >= 3
|
if @escape_counter >= 3
|
||||||
@server&.close
|
@server&.close
|
||||||
|
|
||||||
window.fullscreen = false
|
if window.instance_variable_get(:"@states").size == 1
|
||||||
window.pop_state
|
window.close
|
||||||
|
else
|
||||||
|
window.fullscreen = false
|
||||||
|
window.pop_state
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@escape_counter = 0
|
@escape_counter = 0
|
||||||
|
|||||||
@@ -20,7 +20,17 @@ module TAC
|
|||||||
window.fullscreen = true
|
window.fullscreen = true
|
||||||
end
|
end
|
||||||
|
|
||||||
button "Dual Screen Game Clock", width: 1.0, enabled: false do
|
button "Dual Screen Game Clock", width: 1.0 do
|
||||||
|
# Spawn game clock window
|
||||||
|
$clock_pid = Process.spawn(
|
||||||
|
RbConfig.ruby,
|
||||||
|
"#{ROOT_PATH}/timecrafters_configuration_tool.rb",
|
||||||
|
"--game-clock-remote-display"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# switch to remote control
|
||||||
|
push_state(PracticeGameClock::RemoteControl::NetConnect)
|
||||||
end
|
end
|
||||||
|
|
||||||
title "Remote", width: 1.0, text_align: :center, margin_top: 32
|
title "Remote", width: 1.0, text_align: :center, margin_top: 32
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
module TAC
|
module TAC
|
||||||
class Window < CyberarmEngine::Window
|
class Window < CyberarmEngine::Window
|
||||||
attr_reader :backend, :notification_manager
|
attr_reader :backend, :notification_manager
|
||||||
|
|
||||||
def initialize(**args)
|
def initialize(**args)
|
||||||
super(**args)
|
super(**args)
|
||||||
|
|
||||||
@@ -8,7 +9,11 @@ module TAC
|
|||||||
@backend = Backend.new
|
@backend = Backend.new
|
||||||
@notification_manager = GosuNotifications::NotificationManager.new(window: self, edge: :bottom)
|
@notification_manager = GosuNotifications::NotificationManager.new(window: self, edge: :bottom)
|
||||||
|
|
||||||
push_state(TAC::States::Boot)
|
if ARGV.join.include?("--game-clock-remote-display")
|
||||||
|
push_state(PracticeGameClock::View, remote_control_mode: true)
|
||||||
|
else
|
||||||
|
push_state(TAC::States::Boot)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
|
|||||||
@@ -77,3 +77,5 @@ BORDERLESS = ARGV.include?("--borderless")
|
|||||||
if not defined?(Ocra)
|
if not defined?(Ocra)
|
||||||
TAC::Window.new(width: (Gosu.screen_width * 0.8).round, height: (Gosu.screen_height * 0.8).round, resizable: true, borderless: BORDERLESS).show
|
TAC::Window.new(width: (Gosu.screen_width * 0.8).round, height: (Gosu.screen_height * 0.8).round, resizable: true, borderless: BORDERLESS).show
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Process.wait($clock_pid) if $clock_pid
|
||||||
|
|||||||
Reference in New Issue
Block a user