10 Commits

Author SHA1 Message Date
c312f4839d Fixed indentation, fixed calling .strip on nil in TACNET Client#read 2023-01-30 08:42:46 -06:00
3a8f4e5860 Added used software section to home page 2023-01-30 08:38:26 -06:00
7e09031257 Fixed Boot animation not requesting repaint every frame 2023-01-30 08:37:56 -06:00
905ced174b Fixed when adding action from preset: editing comment before adding was not preserved, and not defaulting to enabled 2023-01-30 08:37:30 -06:00
510a24644b Make titlebar TACNET_PRIMARY (blue) when connected, log tacnet read error. 2023-01-26 10:25:42 -06:00
570d965669 VariableDialog now reports an error if attempting to name a variable to one that already exists 2023-01-22 09:53:03 -06:00
60356fc7fa Added 'Open Folder' button on configurations page, replaced target icon with 'Generate' text for generate roster button on team rotation generator page, make group/action get highlighted correctly when selected from search. 2023-01-22 09:39:27 -06:00
41f5710b4a FieldPlanner: Fixed wrong inch to metric maths, fixed node counter and total distance labels overlapping, added toolip when hovering over the field showing the X/Y coordinate in 'unit' with the origin at field center. 2023-01-21 22:37:19 -06:00
1e21c64a18 Fixed using File.exists? instead of File.exist?, updated Randomizer to PowerPlay (with ducks), misc. tweaking. 2023-01-19 12:33:51 -06:00
451568003a Remove no longer needed clipboard and ffi gems, use new CyberarmEngine::GuiState#needs_repaint? method to only paint when needed- should avoid wasting CPU/GPU time (gain a bit more battery life?), make TACNET connection error visually change UI and also trigger a TACNET dialog when not on the TACNET page 2023-01-05 08:42:29 -06:00
15 changed files with 196 additions and 47 deletions

View File

@@ -2,8 +2,6 @@ source "https://rubygems.org"
gem "cyberarm_engine"
gem "gosu_notifications"
gem "ffi"
gem "clipboard"
group :packaging do
gem "ocra"

View File

@@ -42,13 +42,13 @@ module TAC
end
def move_config(old_name, new_name)
if not File.exists?("#{TAC::CONFIGS_PATH}/#{old_name}.json") or
if not File.exist?("#{TAC::CONFIGS_PATH}/#{old_name}.json") or
File.directory?("#{TAC::CONFIGS_PATH}/#{old_name}.json")
# move_config: Can not move config file "#{old_name}" does not exist!
return false
end
if File.exists?("#{TAC::CONFIGS_PATH}/#{new_name}.json") &&
if File.exist?("#{TAC::CONFIGS_PATH}/#{new_name}.json") &&
!File.directory?("#{TAC::CONFIGS_PATH}/#{old_name}.json")
# move_config: Config file "#{new_name}" already exist!
return false
@@ -61,7 +61,7 @@ module TAC
end
def delete_config(config_name)
FileUtils.rm("#{TAC::CONFIGS_PATH}/#{config_name}.json") if File.exists?("#{TAC::CONFIGS_PATH}/#{config_name}.json")
FileUtils.rm("#{TAC::CONFIGS_PATH}/#{config_name}.json") if File.exist?("#{TAC::CONFIGS_PATH}/#{config_name}.json")
end

View File

@@ -79,11 +79,22 @@ module TAC
def valid?
valid = true
name = @name.value.strip
if @name.value.strip.empty?
if name.empty?
@name_error.value = "Error: Name cannot be blank or only whitespace."
@name_error.show
valid = false
### Don't error if renaming variable to itself
elsif @options[:variable] && @options[:variable].name == name
@name_error.value = ""
@name_error.hide
elsif @options[:list].find { |variable| variable.name == name }
@name_error.value = "Error: Name is not unique!"
@name_error.show
valid = false
end
if not @type

View File

@@ -52,7 +52,7 @@ module TAC
return minutes + seconds
end
def play_sound(sound)
def play_sound(sound)
path = nil
case sound
when :autonomous_countdown

View File

@@ -23,14 +23,22 @@ module TAC
when 2, 5
#Blue and Red: Center
@ducks << Ducky.new(window: window, alliance: :blue, slot: 2, speed: 512, die_size: @size)
@ducks << Ducky.new(window: window, alliance: :red, slot: 2, speed: 512, die_size: @size)
@ducks << Ducky.new(window: window, alliance: :blue, slot: 1, speed: 512, die_size: @size)
@ducks << Ducky.new(window: window, alliance: :blue, slot: 3, speed: 512, die_size: @size)
@ducks << Ducky.new(window: window, alliance: :red, slot: 3, speed: 512, die_size: @size)
@ducks << Ducky.new(window: window, alliance: :red, slot: 1, speed: 512, die_size: @size)
when 3, 6
# Blue: Left
# Red: Right
@ducks << Ducky.new(window: window, alliance: :blue, slot: 1, speed: 512, die_size: @size)
@ducks << Ducky.new(window: window, alliance: :blue, slot: 2, speed: 512, die_size: @size)
@ducks << Ducky.new(window: window, alliance: :blue, slot: 3, speed: 512, die_size: @size)
@ducks << Ducky.new(window: window, alliance: :red, slot: 3, speed: 512, die_size: @size)
@ducks << Ducky.new(window: window, alliance: :red, slot: 2, speed: 512, die_size: @size)
@ducks << Ducky.new(window: window, alliance: :red, slot: 1, speed: 512, die_size: @size)
end
end

View File

@@ -13,6 +13,16 @@ module TAC
populate_configs
})
end
button "Open Folder", tip: "Open folder containing configurations", height: 1.0 do
if RUBY_PLATFORM =~ /mingw/
system("start \"#{TAC::CONFIGS_PATH}\"")
elsif RUBY_PLATFORM =~ /darwin/
system("open \"#{TAC::CONFIGS_PATH}\"")
else
system("xdg-open \"#{TAC::CONFIGS_PATH}\"")
end
end
end
status_bar.clear do

View File

@@ -30,7 +30,7 @@ module TAC
end
end
button get_image("#{TAC::ROOT_PATH}/media/icons/target.png"), margin_right: 10, image_height: 1.0, tip: "Generate rotation" do
button "Generate", margin_right: 10, height: 1.0, tip: "Generate rotation" do
populate_rotation
end
end

View File

@@ -42,7 +42,8 @@ module TAC
if @active_group
push_state(Dialog::NamePromptDialog, title: "Clone Group", renaming: @active_group, accept_label: "Clone", list: window.backend.config.groups, callback_method: proc { |group, name|
clone = TAC::Config::Group.from_json( JSON.parse( @active_group.to_json, symbolize_names: true ))
clone.name = "#{name}"
clone.name = name.to_s
window.backend.config.groups << clone
window.backend.config_changed!
@@ -57,7 +58,8 @@ module TAC
if @active_group
push_state(Dialog::NamePromptDialog, title: "Save Group Preset", renaming: @active_group, accept_label: "Save", list: window.backend.config.presets.groups, callback_method: proc { |group, name|
clone = TAC::Config::Group.from_json( JSON.parse( @active_group.to_json, symbolize_names: true ))
clone.name = "#{name}"
clone.name = name.to_s
window.backend.config.presets.groups << clone
window.backend.config.presets.groups.sort_by! { |g| g.name.downcase }
window.backend.config_changed!
@@ -73,7 +75,8 @@ module TAC
push_state(Dialog::PickPresetDialog, title: "Pick Group Preset", limit: :groups, callback_method: proc { |preset|
push_state(Dialog::NamePromptDialog, title: "Name Group", renaming: preset, accept_label: "Add", list: window.backend.config.groups, callback_method: proc { |group, name|
clone = TAC::Config::Group.from_json( JSON.parse( group.to_json, symbolize_names: true ))
clone.name = "#{name}"
clone.name = name.to_s
window.backend.config.groups << clone
window.backend.config.groups.sort_by! { |g| g.name.downcase }
window.backend.config_changed!
@@ -106,6 +109,7 @@ module TAC
clone = TAC::Config::Action.from_json( JSON.parse( @active_action.to_json, symbolize_names: true ))
clone.name = name
clone.comment = comment
@active_group.actions << clone
window.backend.config_changed!
@@ -121,6 +125,7 @@ module TAC
push_state(Dialog::NamePromptDialog, title: "Save Action Preset", renaming: @active_action, accept_label: "Save", list: window.backend.config.presets.actions, callback_method: proc { |action, name|
clone = TAC::Config::Action.from_json( JSON.parse( @active_action.to_json, symbolize_names: true ))
clone.name = "#{name}"
window.backend.config.presets.actions << clone
window.backend.config.presets.actions.sort_by! { |a| a.name.downcase }
window.backend.config_changed!
@@ -135,9 +140,12 @@ module TAC
button get_image("#{TAC::ROOT_PATH}/media/icons/import.png"), image_width: THEME_ICON_SIZE, tip: "Import action from preset" do
if @active_group
push_state(Dialog::PickPresetDialog, title: "Pick Action Preset", limit: :actions, callback_method: proc { |preset|
push_state(Dialog::ActionDialog, title: "Name Action", action: preset, accept_label: "Add", list: @active_group.actions, callback_method: proc { |action, name|
push_state(Dialog::ActionDialog, title: "Name Action", action: preset, accept_label: "Add", list: @active_group.actions, callback_method: proc { |action, name, comment|
clone = TAC::Config::Action.from_json( JSON.parse( action.to_json, symbolize_names: true ))
clone.name = "#{name}"
clone.name = name.to_s
clone.comment = comment.to_s
clone.enabled = true
@active_group.actions << clone
@active_group.actions.sort_by! { |a| a.name.downcase }
window.backend.config_changed!
@@ -160,7 +168,7 @@ module TAC
label "Variables", text_size: THEME_SUBHEADING_TEXT_SIZE, fill: true, text_align: :center
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add variable" do
if @active_action
push_state(TAC::Dialog::VariableDialog, title: "Create Variable", callback_method: method(:create_variable))
push_state(TAC::Dialog::VariableDialog, title: "Create Variable", list: @active_action.variables, callback_method: method(:create_variable))
else
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to create variable, no action selected.")
end
@@ -173,11 +181,15 @@ module TAC
end
end
populate_groups_list
populated_groups_list = false
if @options[:group_is_preset]
populated_groups_list = true
@active_group = @options[:group]
@active_group_label.value = @active_group.name
populate_groups_list
populate_actions_list(@active_group)
@groups_menu.hide
@@ -193,15 +205,20 @@ module TAC
else
if @options[:group]
populated_groups_list = true
@active_group = @options[:group]
@active_group_label.value = @active_group.name
populate_actions_list(@active_group)
populate_groups_list
populate_actions_list(@active_group) unless @options[:action]
if @options[:action]
@active_action = @options[:action]
@active_action_label.value = @active_action.name
populate_actions_list(@active_group)
populate_variables_list(@active_action)
if @options[:variable]
@@ -210,6 +227,8 @@ module TAC
end
end
end
populate_groups_list unless populated_groups_list
end
def create_group(name)
@@ -314,7 +333,8 @@ module TAC
@groups_list.clear do
groups.each_with_index do |group, i|
flow width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING do |container|
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
background group == @active_group ? THEME_HIGHLIGHTED_COLOR : (i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR)
@active_group_container = container if group == @active_group
button group.name, fill: true, text_size: THEME_ICON_SIZE - 3 do
if (old_i = groups.index(@active_group))
@@ -352,7 +372,8 @@ module TAC
@actions_list.clear do
actions.each_with_index do |action, i|
stack width: 1.0, height: action.comment.empty? ? 36 : 72, **THEME_ITEM_CONTAINER_PADDING do |container|
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
background action == @active_action ? THEME_HIGHLIGHTED_COLOR : (i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR)
@active_action_container = container if action == @active_action
flow width: 1.0, height: 36 do
button action.name, fill: true, text_size: THEME_ICON_SIZE - 3 do
@@ -405,7 +426,7 @@ module TAC
flow(width: 1.0, fill: true) do
button "#{variable.name}", fill: true, text_size: THEME_ICON_SIZE - 3, tip: "Edit variable" do
push_state(Dialog::VariableDialog, title: "Edit Variable", variable: variable, callback_method: method(:update_variable))
push_state(Dialog::VariableDialog, title: "Edit Variable", variable: variable, list: @active_action.variables, callback_method: method(:update_variable))
end
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete variable", **THEME_DANGER_BUTTON do
@@ -453,6 +474,7 @@ module TAC
push_state(
TAC::Dialog::VariableDialog,
title: "Create Variable",
list: @active_action.variables,
callback_method: method(:create_variable)
)
else

View File

@@ -33,6 +33,8 @@ module TAC
button "Reset", text_size: THEME_HEADING_TEXT_SIZE, **THEME_DANGER_BUTTON do
@nodes.clear
measure_path
refresh_panel
end
@@ -48,7 +50,7 @@ module TAC
tagline "Nodes:"
@nodes_count_label = tagline "0"
tagline "Total Distance:"
tagline "Total Distance:", margin_left: 20
@total_distance_label = tagline "0"
@units_label = tagline "Inches"
@@ -77,6 +79,8 @@ module TAC
@node_radius = 6
@segment_thickness = 2
@font = CyberarmEngine::Text.new(font: THEME_BOLD_FONT, size: 18, border: true, static: true)
measure_path
refresh_panel
end
@@ -85,6 +89,28 @@ module TAC
@field.draw
display_path
if @field_container.hit?(window.mouse_x, window.mouse_y)
x = (window.mouse_x - @field_container.x) / @field.scale - 72
y = (window.mouse_y - @field_container.y) / @field.scale - 72
@font.text = "X: #{inches_to_unit(x).round(2)} Y: #{inches_to_unit(y).round(2)} (#{@unit.to_s})"
@font.x = window.mouse_x + 6
@font.y = window.mouse_y - (@font.height / 2.0 + 24)
@font.z = 100_001
Gosu.draw_rect(
window.mouse_x,
@font.y - 6,
@font.width + 12,
@font.height + 12,
0xaa_000000,
100_000)
@font.draw
end
end
def update
@@ -186,6 +212,10 @@ module TAC
@total_distance_label.value = "#{inches_to_unit(@total_distance).round(2)}"
@units_label.value = @unit.to_s.capitalize
status_bar.recalculate
status_bar.recalculate
status_bar.recalculate
# @points_container.clear do
# v1 = @nodes.first
# break unless v1
@@ -216,11 +246,11 @@ module TAC
when :feet
inches / 12.0
when :millimeters
inches / 0.254
inches * 25.4
when :centimeters
inches / 2.54
inches * 2.54
when :meters
inches / 25.4
inches * 0.0254
end
end
end

View File

@@ -34,9 +34,43 @@ module TAC
label "Total actions: #{actions.size}"
label "Total variables: #{variables.size}"
end
stack(width: 1.0, fill: true, scroll: true, margin_top: 32) do
heading, items = Gosu::LICENSES.split("\n\n")
title heading
items.split("\n").each do |item|
name, website, license, license_website = item.split(",").map(&:strip)
flow(width: 1.0, height: 28) do
tagline "#{name} - "
button "Website", height: 1.0, tip: website do
open_url(website)
end
end
flow(width: 1.0, height: 22, margin_bottom: 20) do
para "#{license} - "
button "License Website", height: 1.0, text_size: 16, tip: license_website do
open_url(license_website)
end
end
end
end
end
end
end
def open_url(url)
case RUBY_PLATFORM
when /mingw/ # windows
system("start #{url}")
when /linux/
system("xdg-open #{url}")
when /darwin/ # macos
system("open #{url}")
end
end
end
end
end

View File

@@ -49,7 +49,7 @@ robot.forward 100
robot.turn -90
robot.forward 100"
source_code = File.read(SOURCE_FILE_PATH) if File.exists?(SOURCE_FILE_PATH)
source_code = File.read(SOURCE_FILE_PATH) if File.exist?(SOURCE_FILE_PATH)
@source_code = edit_box source_code, width: 1.0, height: 1.0
end
@@ -77,6 +77,7 @@ robot.forward 100"
@simulation.update
unless @simulation.robots.all? { |robot| robot.queue.empty? } # Only update clock if simulation is running
current_state.request_repaint
@simulation_status.value = "Time: #{(@simulation.simulation_time).round(1)} seconds"
end
end

View File

@@ -11,9 +11,9 @@ module TAC
@title_font = CyberarmEngine::Text.new(TAC::NAME, z: 100, size: 72, border: true, border_size: 2, border_color: 0xff_000000, font: THEME[:TextBlock][:font], static: true)
@logo = Gosu::Image.new("#{TAC::ROOT_PATH}/media/logo.png")
@title_animator = CyberarmEngine::Animator.new(start_time: 0, duration: 750, from: 0.0, to: 1.0, tween: :swing_from_to)
@logo_animator = CyberarmEngine::Animator.new(start_time: 750, duration: 1_000, from: 0.0, to: 1.0, tween: :swing_to)
@transition_animator = CyberarmEngine::Animator.new(start_time: 2_250, duration: 750, from: 0, to: 255, tween: :ease_out)
@title_animator = CyberarmEngine::Animator.new(start_time: Gosu.milliseconds + 0, duration: 750, from: 0.0, to: 1.0, tween: :swing_from_to)
@logo_animator = CyberarmEngine::Animator.new(start_time: Gosu.milliseconds + 750, duration: 1_000, from: 0.0, to: 1.0, tween: :swing_to)
@transition_animator = CyberarmEngine::Animator.new(start_time: Gosu.milliseconds + 2_250, duration: 750, from: 0, to: 255, tween: :ease_out)
@transition_color = Gosu::Color.new(0x00_111111)
@next_state = Editor
@@ -30,15 +30,20 @@ module TAC
def update
super
request_repaint
@title_font.x = window.width / 2 - @title_font.width / 2
@title_font.y = (window.height / 2 - (@logo.height / 2 + @title_font.height)) * @title_animator.transition
@transition_color.alpha = @transition_animator.transition
push_state(@next_state) if @transition_color.alpha >= 255
if @transition_color.alpha >= 255
pop_state
push_state(@next_state)
end
end
def button_up(id)
def button_down(id)
super
push_state(@next_state)

View File

@@ -8,6 +8,8 @@ class Editor < CyberarmEngine::GuiState
@window_width = 0
@window_height = 0
@last_tacnet_status = nil
@pages = {}
@page = nil
@@ -34,9 +36,9 @@ class Editor < CyberarmEngine::GuiState
@header_bar = flow(width: 1.0, height: 36) do
background 0xff_006000
@header_bar_label = label TAC::NAME, width: 1.0, text_align: :center, text_size: 32, font: TAC::THEME_BOLD_FONT
@header_bar_label = label TAC::NAME, fill: true, text_align: :center, text_size: 32, font: TAC::THEME_BOLD_FONT, margin_left: BORDERLESS ? 36 * 3 : 0
@window_controls = flow(x: window.width - 36 * 2, y: 0, height: 1.0) do
@window_controls = flow(width: 36 * 3, height: 1.0) do
button get_image("#{TAC::ROOT_PATH}/media/icons/minus.png"), tip: "Minimize", image_height: 1.0 do
window.minimize if window.respond_to?(:minimize)
end
@@ -138,15 +140,35 @@ class Editor < CyberarmEngine::GuiState
@page.update if @page
case window.backend.tacnet.status
when :not_connected
@tacnet_button.style.color = Gosu::Color::WHITE
when :connecting
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTING
when :connected
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTED
when :connection_error
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTION_ERROR
if @last_tacnet_status != window.backend.tacnet.status
@last_tacnet_status = window.backend.tacnet.status
case window.backend.tacnet.status
when :not_connected
@tacnet_button.style.color = Gosu::Color::WHITE
@header_bar.style.background = 0xff_006000
when :connected
@tacnet_button.style.color = Gosu::Color::WHITE
@header_bar.style.background = TAC::Palette::TACNET_PRIMARY
when :connecting
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTING
@header_bar.style.background = TAC::Palette::TACNET_CONNECTING
when :connection_error
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTION_ERROR
@header_bar.style.background = TAC::Palette::TACNET_CONNECTION_ERROR
unless @page.is_a?(TAC::Pages::TACNET)
push_state(TAC::Dialog::TACNETDialog, title: "TACNET Connection Error", message: window.backend.tacnet.full_status)
end
end
@tacnet_button.style.default[:color] = @tacnet_button.style.color
@header_bar.style.default[:background] = @header_bar.style.background
@tacnet_button.recalculate
@header_bar.recalculate
request_repaint
end
window.width = Gosu.available_width / 2 if window.width < Gosu.available_width / 2

View File

@@ -110,23 +110,25 @@ module TAC
rescue => error
@last_socket_error = error
@socket_error = true
log.e(TAG, error.message)
close
end
end
def read
begin
message = @socket.gets
@socket.gets&.strip
rescue => error
@last_socket_error = error
@socket_error = true
message = ""
log.e(TAG, error.message)
""
end
return message.strip
end
def puts(message)

View File

@@ -11,6 +11,8 @@ module TAC
if ARGV.join.include?("--game-clock-remote-display")
push_state(PracticeGameClock::View, remote_control_mode: true)
elsif ARGV.join.include?("--intro")
push_state(CyberarmEngine::IntroState, forward: TAC::States::Boot)
else
push_state(TAC::States::Boot)
end
@@ -29,6 +31,10 @@ module TAC
@notification_manager.update
end
def needs_redraw?
states.any?(&:needs_repaint?) || @notification_manager.instance_variable_get(:@drivers).size.positive?
end
def toast(title, message = nil)
@notification_manager.create_notification(
priority: GosuNotifications::Notification::PRIORITY_HIGH,