mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 05:42:35 +00:00
Compare commits
2 Commits
1145ac646d
...
ffe946ae15
| Author | SHA1 | Date | |
|---|---|---|---|
| ffe946ae15 | |||
| d94490110e |
@@ -129,7 +129,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return message.strip
|
return message.to_s.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
def puts(message)
|
def puts(message)
|
||||||
|
|||||||
@@ -80,7 +80,10 @@ module TAC
|
|||||||
|
|
||||||
@jukebox_volume = 1.0
|
@jukebox_volume = 1.0
|
||||||
@jukebox_sound_effects = true
|
@jukebox_sound_effects = true
|
||||||
|
@locked_buttons_randomizer_visible = []
|
||||||
|
@locked_buttons_clock_active = []
|
||||||
@randomizer_visible = false
|
@randomizer_visible = false
|
||||||
|
@clock_updated_at = -1000
|
||||||
|
|
||||||
RemoteControl.connection.proxy_object.register(:track_changed, method(:track_changed))
|
RemoteControl.connection.proxy_object.register(:track_changed, method(:track_changed))
|
||||||
RemoteControl.connection.proxy_object.register(:volume_changed, method(:volume_changed))
|
RemoteControl.connection.proxy_object.register(:volume_changed, method(:volume_changed))
|
||||||
@@ -94,25 +97,25 @@ module TAC
|
|||||||
flow width: 1.0, height: 1.0 do
|
flow width: 1.0, height: 1.0 do
|
||||||
stack width: 0.5 do
|
stack width: 0.5 do
|
||||||
title "Match", width: 1.0, text_align: :center
|
title "Match", width: 1.0, text_align: :center
|
||||||
button "Start Match", width: 1.0, text_size: 48, margin_bottom: 50 do
|
@start_match_btn = button "Start Match", width: 1.0, text_size: 48, margin_bottom: 50 do
|
||||||
start_clock(:full_match)
|
start_clock(:full_match)
|
||||||
end
|
end
|
||||||
|
|
||||||
title "Practice", width: 1.0, text_align: :center
|
title "Practice", width: 1.0, text_align: :center
|
||||||
button "Autonomous", width: 1.0 do
|
@autonomous_btn = button "Autonomous", width: 1.0 do
|
||||||
start_clock(:autonomous)
|
start_clock(:autonomous)
|
||||||
end
|
end
|
||||||
button "TeleOp with Countdown", width: 1.0 do
|
@teleop_with_countdown_btn = button "TeleOp with Countdown", width: 1.0 do
|
||||||
start_clock(:full_teleop)
|
start_clock(:full_teleop)
|
||||||
end
|
end
|
||||||
button "TeleOp", width: 1.0 do
|
@teleop_btn = button "TeleOp", width: 1.0 do
|
||||||
start_clock(:teleop_only)
|
start_clock(:teleop_only)
|
||||||
end
|
end
|
||||||
button "TeleOp Endgame", width: 1.0, margin_bottom: 50 do
|
@teleop_endgame_btn = button "TeleOp Endgame", width: 1.0, margin_bottom: 50 do
|
||||||
start_clock(:endgame_only)
|
start_clock(:endgame_only)
|
||||||
end
|
end
|
||||||
|
|
||||||
button "Abort Match", width: 1.0 do
|
@abort_match_btn = button "Abort Match", width: 1.0 do
|
||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_abort_clock)
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_abort_clock)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -219,7 +222,7 @@ module TAC
|
|||||||
@randomizer_label = title "Not Visible"
|
@randomizer_label = title "Not Visible"
|
||||||
end
|
end
|
||||||
|
|
||||||
button "Randomizer", width: 1.0, **TAC::THEME_DANGER_BUTTON do
|
@randomizer_btn = 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))
|
||||||
@@ -227,6 +230,24 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@locked_buttons_clock_active.push(
|
||||||
|
@start_match_btn,
|
||||||
|
@autonomous_btn,
|
||||||
|
@teleop_with_countdown_btn,
|
||||||
|
@teleop_btn,
|
||||||
|
@teleop_endgame_btn,
|
||||||
|
@randomizer_btn
|
||||||
|
)
|
||||||
|
|
||||||
|
@locked_buttons_randomizer_visible.push(
|
||||||
|
@start_match_btn,
|
||||||
|
@autonomous_btn,
|
||||||
|
@teleop_with_countdown_btn,
|
||||||
|
@teleop_btn,
|
||||||
|
@teleop_endgame_btn,
|
||||||
|
@abort_match_btn
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@@ -236,6 +257,8 @@ module TAC
|
|||||||
o.call
|
o.call
|
||||||
end
|
end
|
||||||
|
|
||||||
|
manage_button_enablement
|
||||||
|
|
||||||
return if RemoteControl.connection.connected?
|
return if RemoteControl.connection.connected?
|
||||||
|
|
||||||
# We've lost connection, unset window's connection object
|
# We've lost connection, unset window's connection object
|
||||||
@@ -258,6 +281,8 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clock_changed(string)
|
def clock_changed(string)
|
||||||
|
@clock_updated_at = Gosu.milliseconds if @clock_label.value != string
|
||||||
|
|
||||||
@clock_label.value = string
|
@clock_label.value = string
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -265,6 +290,22 @@ module TAC
|
|||||||
@randomizer_label.value = "Visible" if boolean
|
@randomizer_label.value = "Visible" if boolean
|
||||||
@randomizer_label.value = "Not Visible" unless boolean
|
@randomizer_label.value = "Not Visible" unless boolean
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def manage_button_enablement
|
||||||
|
if @randomizer_visible
|
||||||
|
@locked_buttons_randomizer_visible.each do |btn|
|
||||||
|
btn.enabled = false
|
||||||
|
end
|
||||||
|
elsif Gosu.milliseconds - @clock_updated_at <= 1_250
|
||||||
|
@locked_buttons_clock_active.each do |btn|
|
||||||
|
btn.enabled = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
(@locked_buttons_clock_active + @locked_buttons_randomizer_visible).uniq.each do |btn|
|
||||||
|
btn.enabled = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,7 +10,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")
|
||||||
# Preload duck image since Gosu and windows threads don't get along with OpenGL (image is blank if loaded in a threaded context)
|
# Preload duck image since Gosu and Windows threads don't get along with OpenGL (image is blank if loaded in a threaded context)
|
||||||
get_image("#{ROOT_PATH}/media/openclipart_ducky.png")
|
get_image("#{ROOT_PATH}/media/openclipart_ducky.png")
|
||||||
@menu_background = 0xaa004000
|
@menu_background = 0xaa004000
|
||||||
@mouse = Mouse.new(window)
|
@mouse = Mouse.new(window)
|
||||||
@@ -25,6 +25,10 @@ module TAC
|
|||||||
|
|
||||||
@last_clock_state = @clock.active?
|
@last_clock_state = @clock.active?
|
||||||
|
|
||||||
|
@locked_buttons_randomizer_visible = []
|
||||||
|
@locked_buttons_clock_active = []
|
||||||
|
@randomizer_visible = false
|
||||||
|
|
||||||
theme(THEME)
|
theme(THEME)
|
||||||
|
|
||||||
@menu_container = flow width: 1.0 do
|
@menu_container = flow width: 1.0 do
|
||||||
@@ -32,28 +36,45 @@ module TAC
|
|||||||
background @menu_background
|
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
|
@start_match_btn = button "Start Match", width: 1.0, margin_bottom: 50 do |btn|
|
||||||
|
@locked_buttons_clock_active << btn
|
||||||
|
@locked_buttons_randomizer_visible << btn
|
||||||
|
|
||||||
@clock_proxy.start_clock(:full_match)
|
@clock_proxy.start_clock(:full_match)
|
||||||
end
|
end
|
||||||
|
|
||||||
title "Practice", width: 1.0, text_align: :center
|
title "Practice", width: 1.0, text_align: :center
|
||||||
button "Autonomous", width: 1.0 do
|
@autonomous_btn = button "Autonomous", width: 1.0 do |btn|
|
||||||
|
@locked_buttons_clock_active << btn
|
||||||
|
@locked_buttons_randomizer_visible << btn
|
||||||
|
|
||||||
@clock_proxy.start_clock(:autonomous)
|
@clock_proxy.start_clock(:autonomous)
|
||||||
end
|
end
|
||||||
|
|
||||||
button "TeleOp with Countdown", width: 1.0 do
|
@teleop_with_countdown_btn = button "TeleOp with Countdown", width: 1.0 do |btn|
|
||||||
|
@locked_buttons_clock_active << btn
|
||||||
|
@locked_buttons_randomizer_visible << btn
|
||||||
|
|
||||||
@clock_proxy.start_clock(:full_teleop)
|
@clock_proxy.start_clock(:full_teleop)
|
||||||
end
|
end
|
||||||
|
|
||||||
button "TeleOp", width: 1.0 do
|
@teleop_btn = button "TeleOp", width: 1.0 do |btn|
|
||||||
|
@locked_buttons_clock_active << btn
|
||||||
|
@locked_buttons_randomizer_visible << btn
|
||||||
|
|
||||||
@clock_proxy.start_clock(:teleop_only)
|
@clock_proxy.start_clock(:teleop_only)
|
||||||
end
|
end
|
||||||
|
|
||||||
button "TeleOp Endgame", width: 1.0 do
|
@teleop_endgame_btn = button "TeleOp Endgame", width: 1.0 do |btn|
|
||||||
|
@locked_buttons_clock_active << btn
|
||||||
|
@locked_buttons_randomizer_visible << btn
|
||||||
|
|
||||||
@clock_proxy.start_clock(:endgame_only)
|
@clock_proxy.start_clock(:endgame_only)
|
||||||
end
|
end
|
||||||
|
|
||||||
button "Abort Match", width: 1.0, margin_top: 50 do
|
@abort_match_btn = button "Abort Match", width: 1.0, margin_top: 50 do |btn|
|
||||||
|
@locked_buttons_randomizer_visible << btn
|
||||||
|
|
||||||
@clock_proxy.abort_clock
|
@clock_proxy.abort_clock
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -139,7 +160,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
stack(width: 1.0) do
|
stack(width: 1.0) do
|
||||||
button "Randomizer", width: 1.0, **TAC::THEME_DANGER_BUTTON do
|
@randomizer_btn = button "Randomizer", width: 1.0, **TAC::THEME_DANGER_BUTTON do |btn|
|
||||||
unless @clock.active?
|
unless @clock.active?
|
||||||
push_state(Randomizer)
|
push_state(Randomizer)
|
||||||
end
|
end
|
||||||
@@ -148,6 +169,24 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@locked_buttons_clock_active.push(
|
||||||
|
@start_match_btn,
|
||||||
|
@autonomous_btn,
|
||||||
|
@teleop_with_countdown_btn,
|
||||||
|
@teleop_btn,
|
||||||
|
@teleop_endgame_btn,
|
||||||
|
@randomizer_btn
|
||||||
|
)
|
||||||
|
|
||||||
|
@locked_buttons_randomizer_visible.push(
|
||||||
|
@start_match_btn,
|
||||||
|
@autonomous_btn,
|
||||||
|
@teleop_with_countdown_btn,
|
||||||
|
@teleop_btn,
|
||||||
|
@teleop_endgame_btn,
|
||||||
|
@abort_match_btn
|
||||||
|
)
|
||||||
|
|
||||||
@jukebox = Jukebox.new(@clock)
|
@jukebox = Jukebox.new(@clock)
|
||||||
|
|
||||||
@clock_proxy = ClockProxy.new(@clock, @jukebox)
|
@clock_proxy = ClockProxy.new(@clock, @jukebox)
|
||||||
@@ -191,6 +230,8 @@ module TAC
|
|||||||
@menu_container.hide if @menu_container.visible?
|
@menu_container.hide if @menu_container.visible?
|
||||||
window.show_cursor = false
|
window.show_cursor = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
manage_button_enablement
|
||||||
end
|
end
|
||||||
|
|
||||||
if @clock.value != @last_clock_display_value
|
if @clock.value != @last_clock_display_value
|
||||||
@@ -222,9 +263,9 @@ module TAC
|
|||||||
@last_clock_state = @clock.active?
|
@last_clock_state = @clock.active?
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_repaint
|
def needs_repaint?
|
||||||
if @particle_emitters && @particle_emitters.map(&:particle_count).sum.positive?
|
if @particle_emitters && @particle_emitters.map(&:particle_count).sum.positive?
|
||||||
true
|
@needs_repaint = true
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@@ -241,6 +282,22 @@ module TAC
|
|||||||
@jukebox.update
|
@jukebox.update
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def manage_button_enablement
|
||||||
|
if @randomizer_visible
|
||||||
|
@locked_buttons_randomizer_visible.each do |btn|
|
||||||
|
btn.enabled = false
|
||||||
|
end
|
||||||
|
elsif @clock.active?
|
||||||
|
@locked_buttons_clock_active.each do |btn|
|
||||||
|
btn.enabled = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
(@locked_buttons_clock_active + @locked_buttons_randomizer_visible).uniq.each do |btn|
|
||||||
|
btn.enabled = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def button_down(id)
|
def button_down(id)
|
||||||
super
|
super
|
||||||
|
|
||||||
@@ -274,6 +331,8 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def randomizer_changed(boolean)
|
def randomizer_changed(boolean)
|
||||||
|
@randomizer_visible = boolean
|
||||||
|
|
||||||
if boolean
|
if boolean
|
||||||
push_state(Randomizer) unless @clock.active?
|
push_state(Randomizer) unless @clock.active?
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module TAC
|
|||||||
refresh_panel
|
refresh_panel
|
||||||
end
|
end
|
||||||
|
|
||||||
list_box items: ["Power Play", "Freight Frenzy", "Ultimate Goal", "Skystone"], width: 200, height: 1.0 do |item|
|
list_box items: ["CENTERSTAGE", "Power Play", "Freight Frenzy", "Ultimate Goal", "Skystone"], width: 200, height: 1.0 do |item|
|
||||||
season = item.downcase.gsub(" ", "_").to_sym
|
season = item.downcase.gsub(" ", "_").to_sym
|
||||||
@field = TAC::Simulator::Field.new(container: @field_container, season: season, simulation: nil)
|
@field = TAC::Simulator::Field.new(container: @field_container, season: season, simulation: nil)
|
||||||
end
|
end
|
||||||
@@ -68,7 +68,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@field = TAC::Simulator::Field.new(container: @field_container, season: :power_play, simulation: nil)
|
@field = TAC::Simulator::Field.new(container: @field_container, season: :centerstage, simulation: nil)
|
||||||
@nodes ||= []
|
@nodes ||= []
|
||||||
@unit = :inches
|
@unit = :inches
|
||||||
@total_distance = 0
|
@total_distance = 0
|
||||||
|
|||||||
@@ -336,6 +336,10 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def draw_field_centerstage
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def draw_tile_box(color)
|
def draw_tile_box(color)
|
||||||
Gosu.draw_rect(0, 0, 24, 2, color, @z)
|
Gosu.draw_rect(0, 0, 24, 2, color, @z)
|
||||||
Gosu.draw_rect(22, 2, 2, 22, color, @z)
|
Gosu.draw_rect(22, 2, 2, 22, color, @z)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module TAC
|
|||||||
@field_container = field_container
|
@field_container = field_container
|
||||||
|
|
||||||
@robots = []
|
@robots = []
|
||||||
@field = Field.new(simulation: self, season: :power_play, container: @field_container)
|
@field = Field.new(simulation: self, season: :centerstage, container: @field_container)
|
||||||
@show_paths = false
|
@show_paths = false
|
||||||
|
|
||||||
@last_milliseconds = Gosu.milliseconds
|
@last_milliseconds = Gosu.milliseconds
|
||||||
|
|||||||
Reference in New Issue
Block a user