Fix up game clock a bit more so that it correctly requests repaints when remotely controlled, fixed layout issues with Drive Team Rotation Generator, update README

This commit is contained in:
2023-01-30 15:52:21 -06:00
parent c312f4839d
commit 94cd822b0c
5 changed files with 92 additions and 30 deletions

View File

@@ -1 +1,42 @@
# TimeCrafters Configuration Tool for Desktop # TimeCrafters Configuration Tool for Desktop
A desktop app for editing, either locally or remotely, JSON configuration files on the Robot Controller/Rev Control Hub.
![Screenshot of Editor](https://raw.githubusercontent.com/TimeCrafters/timecrafters_configuration_tool_desktop/master/media/screenshots/screenshot_editor.png)
## Features
* TACNET - **T**imeCrafters **A**uxiliary **C**onfiguration **NET**work.
* Enables syncing configurations between devices.
* Multiple Configurations
* Create multiple configurations for specific robots/projects.
* Presets
* Save Groups or Actions as Presets to quickly add pre-configurated Groups and Actions.
* Search
* Search through the active configurations Groups, Actions, Variables and Presets.
* Built-in practice clock
* Supports multiple screens or network remote control.
* Supports official clock sounds (must be added manually.)
* Built-in jukebox.
* Simulator
* Create a simple 2D simulation of your robot's path.
* Field Planner
* Estimate distances on the field using imperial or metric units.
## Usage
* Download from [Releases](https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop/releases/latest)
## Developing
* Install [Ruby](https://ruby-lang.org)
* Run `bundle install`
* Run `bundle exec ruby timecrafters_configuration_tool.rb`
## Contributing
* Clone this repo and create a new branch for your feature/patch.
* Author your changes
* Commit your changes and push to your fork
* Open a pull request

View File

@@ -71,6 +71,10 @@ module TAC
end end
end end
def particle_count
@particles.size
end
def clock_active! def clock_active!
@clock_active = true @clock_active = true
@particles.each(&:clock_active!) @particles.each(&:clock_active!)

View File

@@ -17,6 +17,7 @@ module TAC
@clock = Clock.new @clock = Clock.new
@clock.controller = nil @clock.controller = nil
@last_clock_display_value = @clock.value @last_clock_display_value = @clock.value
@last_clock_title_value = @clock.title.text
@particle_emitters = [ @particle_emitters = [
PracticeGameClock::ParticleEmitter.new PracticeGameClock::ParticleEmitter.new
@@ -72,17 +73,17 @@ module TAC
stack width: 0.4, padding_left: 50 do stack width: 0.4, padding_left: 50 do
background @menu_background background @menu_background
flow do flow(width: 1.0) do
label "♫ Now playing:" label "♫ Now playing:"
@current_song_label = label "♫ ♫ ♫" @current_song_label = label "♫ ♫ ♫"
end end
flow do flow(width: 1.0) do
label "Volume:" label "Volume:"
@current_volume_label = label "100%" @current_volume_label = label "100%"
end end
flow do flow(width: 1.0) do
button get_image("#{ROOT_PATH}/media/icons/previous.png") do button get_image("#{ROOT_PATH}/media/icons/previous.png") do
@jukebox.previous_track @jukebox.previous_track
end end
@@ -137,7 +138,7 @@ module TAC
end end
end end
stack width: 1.0 do stack(width: 1.0) do
button "Randomizer", width: 1.0, **TAC::THEME_DANGER_BUTTON do button "Randomizer", width: 1.0, **TAC::THEME_DANGER_BUTTON do
unless @clock.active? unless @clock.active?
push_state(Randomizer) push_state(Randomizer)
@@ -195,11 +196,19 @@ module TAC
if @clock.value != @last_clock_display_value if @clock.value != @last_clock_display_value
@last_clock_display_value = @clock.value @last_clock_display_value = @clock.value
request_repaint
if @remote_control_mode && @server.active_client if @remote_control_mode && @server.active_client
@server.active_client.puts(ClockNet::PacketHandler.packet_clock_time(@last_clock_display_value)) @server.active_client.puts(ClockNet::PacketHandler.packet_clock_time(@last_clock_display_value))
end end
end end
if @clock.title.text != @last_clock_title_value
@last_clock_title_value = @clock.title.text
request_repaint
end
if @last_track_name != @jukebox.current_track if @last_track_name != @jukebox.current_track
track_changed(@jukebox.current_track) track_changed(@jukebox.current_track)
end end
@@ -213,6 +222,14 @@ module TAC
@last_clock_state = @clock.active? @last_clock_state = @clock.active?
end end
def request_repaint
if @particle_emitters && @particle_emitters.map(&:particle_count).sum.positive?
true
else
super
end
end
def update_non_gui def update_non_gui
if @remote_control_mode if @remote_control_mode
while (o = RemoteControl.server.proxy_object.queue.shift) while (o = RemoteControl.server.proxy_object.queue.shift)

View File

@@ -7,18 +7,20 @@ module TAC
header_bar("Drive Team Rotation Generator") header_bar("Drive Team Rotation Generator")
@roster ||= [ @roster ||= [
"Alexander",
"Aubrey", "Aubrey",
"Cayden", "Cayden",
"Dan",
"Gabe", "Gabe",
"Spencer", "Spencer",
"Olivia" "Sodi",
"Trent"
] ]
@roles ||= [ @roles ||= [
"Coach", "Coach",
"Driver A", "Driver A",
"Driver B" "Driver B",
"Human"
] ]
menu_bar.clear do menu_bar.clear do
@@ -37,12 +39,12 @@ module TAC
body.clear do body.clear do
flow(margin_left: 20, width: 1.0, height: 1.0) do flow(margin_left: 20, width: 1.0, height: 1.0) do
stack(width: 0.25) do stack(width: 0.25, height: 1.0) do
title "Roles", width: 1.0, margin_bottom: 4, text_align: :center title "Roles", width: 1.0, margin_bottom: 4, text_align: :center
flow(width: 1.0, margin_bottom: 20) do flow(width: 1.0, height: 32, margin_bottom: 20) do
@role_name = edit_line "", placeholder: "Add role", width: 0.9 @role_name = edit_line "", placeholder: "Add role", fill: true, height: 1.0
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 0.1, tip: "Add role" do button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_height: 1.0, tip: "Add role" do
if @role_name.value.strip.length.positive? if @role_name.value.strip.length.positive?
@roles.push(@role_name.value.strip) @roles.push(@role_name.value.strip)
@role_name.value = "" @role_name.value = ""
@@ -52,16 +54,16 @@ module TAC
end end
end end
@roles_container = stack(width: 1.0, height: 0.835, scroll: true) do @roles_container = stack(width: 1.0, fill: true, scroll: true) do
end end
end end
stack(margin_left: 20, width: 0.25, height: 1.0) do stack(margin_left: 20, width: 0.25, height: 1.0) do
title "Roster", width: 1.0, margin_bottom: 4, text_align: :center title "Roster", width: 1.0, margin_bottom: 4, text_align: :center
flow(width: 1.0, margin_bottom: 20) do flow(width: 1.0, height: 32, margin_bottom: 20) do
@roster_name = edit_line "", placeholder: "Add name", width: 0.9 @roster_name = edit_line "", placeholder: "Add name", height: 1.0, fill: true
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 0.1, tip: "Add name" do button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_height: 1.0, tip: "Add name" do
if @roster_name.value.strip.length.positive? if @roster_name.value.strip.length.positive?
@roster.push(@roster_name.value.strip) @roster.push(@roster_name.value.strip)
@roster_name.value = "" @roster_name.value = ""
@@ -71,14 +73,14 @@ module TAC
end end
end end
@roster_container = stack(width: 1.0, height: 0.835, scroll: true) do @roster_container = stack(width: 1.0, fill: true, scroll: true) do
end end
end end
stack(margin_left: 20, margin_right: 20, width: 0.5, height: 1.0) do stack(margin_left: 20, margin_right: 20, fill: true, height: 1.0) do
title "Rotation", width: 1.0, margin_bottom: 4, text_align: :center title "Rotation", width: 1.0, margin_bottom: 4, text_align: :center
@rotation_container = stack(width: 1.0, height: 0.835, scroll: true) do @rotation_container = stack(width: 1.0, fill: true, scroll: true) do
end end
end end
end end
@@ -92,11 +94,11 @@ module TAC
def populate_roles def populate_roles
@roles_container.clear do @roles_container.clear do
@roles.each_with_index do |name, i| @roles.each_with_index do |name, i|
flow(width: 1.0, padding: 2) do flow(width: 1.0, height: 32, padding: 2) do
background i.even? ? 0xff_007000 : 0xff_006000 background i.even? ? 0xff_007000 : 0xff_006000
tagline name, width: 0.9 tagline name, fill: true
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 0.1, tip: "Remove role", **THEME_DANGER_BUTTON do button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_height: 1.0, tip: "Remove role", **THEME_DANGER_BUTTON do
@roles.delete(name) @roles.delete(name)
populate_roles populate_roles
end end
@@ -108,11 +110,11 @@ module TAC
def populate_roster def populate_roster
@roster_container.clear do @roster_container.clear do
@roster.each_with_index do |name, i| @roster.each_with_index do |name, i|
flow(width: 1.0, padding: 2) do flow(width: 1.0, height: 32, padding: 2) do
background i.even? ? 0xff_007000 : 0xff_006000 background i.even? ? 0xff_007000 : 0xff_006000
tagline name, width: 0.9 tagline name, fill: true
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 0.1, tip: "Remove name", **THEME_DANGER_BUTTON do button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_height: 1.0, tip: "Remove name", **THEME_DANGER_BUTTON do
@roster.delete(name) @roster.delete(name)
populate_roster populate_roster
end end
@@ -125,13 +127,11 @@ module TAC
@rotation = Generator.new(roster: @roster, team_size: @roles.count) @rotation = Generator.new(roster: @roster, team_size: @roles.count)
@rotation_container.clear do @rotation_container.clear do
fraction = (1.0 / @rotation.team_size) - 0.02 flow(width: 1.0, height: 32, padding: 2) do
flow(width: 1.0, padding: 2) do
background Gosu::Color::BLACK background Gosu::Color::BLACK
@roles.each do |role| @roles.each do |role|
tagline "<b>#{role}</b>", width: fraction tagline "<b>#{role}</b>", fill: true
end end
end end
@@ -139,11 +139,11 @@ module TAC
teams = @rotation.teams.shuffle if @shuffle_teams&.value teams = @rotation.teams.shuffle if @shuffle_teams&.value
teams.each_with_index do |team, i| teams.each_with_index do |team, i|
flow(width: 1.0, padding: 2) do flow(width: 1.0, height: 32, padding: 2) do
background i.even? ? 0xff_007000 : 0xff_006000 background i.even? ? 0xff_007000 : 0xff_006000
team.each do |player| team.each do |player|
tagline player, width: fraction tagline player, fill: true
end end
end end
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB