mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 13:52:34 +00:00
Compare commits
20 Commits
v0.6.0
...
07fdf0055e
| Author | SHA1 | Date | |
|---|---|---|---|
| 07fdf0055e | |||
| 2a8a2d1bbf | |||
| 48b4d6ddcf | |||
| 0cd4475a8f | |||
| acc0792d17 | |||
| 6f211adf28 | |||
| 3d29ff46e6 | |||
| 27d0b7314f | |||
| 308575dc63 | |||
| 94cd822b0c | |||
| c312f4839d | |||
| 3a8f4e5860 | |||
| 7e09031257 | |||
| 905ced174b | |||
| 510a24644b | |||
| 570d965669 | |||
| 60356fc7fa | |||
| 41f5710b4a | |||
| 1e21c64a18 | |||
| 451568003a |
2
Gemfile
2
Gemfile
@@ -2,8 +2,6 @@ source "https://rubygems.org"
|
||||
|
||||
gem "cyberarm_engine"
|
||||
gem "gosu_notifications"
|
||||
gem "ffi"
|
||||
gem "clipboard"
|
||||
|
||||
group :packaging do
|
||||
gem "ocra"
|
||||
|
||||
16
Gemfile.lock
16
Gemfile.lock
@@ -1,16 +1,13 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
clipboard (1.3.6)
|
||||
cri (2.1.0)
|
||||
cyberarm_engine (0.19.1)
|
||||
clipboard (~> 1.3.5)
|
||||
excon (~> 0.78.0)
|
||||
cyberarm_engine (0.23.0)
|
||||
excon (~> 0.88)
|
||||
gosu (~> 1.1)
|
||||
gosu_more_drawables (~> 0.3)
|
||||
excon (0.78.1)
|
||||
ffi (1.15.4-x64-mingw32)
|
||||
gosu (1.2.0)
|
||||
excon (0.98.0)
|
||||
gosu (1.4.5)
|
||||
gosu_more_drawables (0.3.1)
|
||||
gosu_notifications (0.1.0)
|
||||
ocra (1.3.11)
|
||||
@@ -22,16 +19,15 @@ GEM
|
||||
rake (>= 0.9.2.2)
|
||||
|
||||
PLATFORMS
|
||||
x64-mingw-ucrt
|
||||
x64-mingw32
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
clipboard
|
||||
cyberarm_engine
|
||||
ffi
|
||||
gosu_notifications
|
||||
ocra
|
||||
releasy
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.28
|
||||
2.4.3
|
||||
|
||||
41
README.md
41
README.md
@@ -1 +1,42 @@
|
||||
# TimeCrafters Configuration Tool for Desktop
|
||||
A desktop app for editing, either locally or remotely, JSON configuration files on the Robot Controller/Rev Control Hub.
|
||||
|
||||

|
||||
|
||||
## 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
|
||||
|
||||
4
Rakefile
4
Rakefile
@@ -18,12 +18,12 @@ Releasy::Project.new do
|
||||
"media/music/.gitkeep",
|
||||
"media/particles/.gitkeep"
|
||||
]
|
||||
exclude_encoding # Applications that don't use advanced encoding (e.g. Japanese characters) can save build size with this.
|
||||
# exclude_encoding # Applications that don't use advanced encoding (e.g. Japanese characters) can save build size with this.
|
||||
verbose
|
||||
|
||||
add_build :windows_folder do
|
||||
icon "media/icon.ico"
|
||||
executable_type :console # Assuming you don't want it to run with a console window.
|
||||
executable_type :windows # Assuming you don't want it to run with a console window.
|
||||
add_package :exe # Windows self-extracting archive.
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -71,6 +71,10 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
def particle_count
|
||||
@particles.size
|
||||
end
|
||||
|
||||
def clock_active!
|
||||
@clock_active = true
|
||||
@particles.each(&:clock_active!)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ module TAC
|
||||
@clock = Clock.new
|
||||
@clock.controller = nil
|
||||
@last_clock_display_value = @clock.value
|
||||
@last_clock_title_value = @clock.title.text
|
||||
|
||||
@particle_emitters = [
|
||||
PracticeGameClock::ParticleEmitter.new
|
||||
@@ -72,17 +73,17 @@ module TAC
|
||||
stack width: 0.4, padding_left: 50 do
|
||||
background @menu_background
|
||||
|
||||
flow do
|
||||
flow(width: 1.0) do
|
||||
label "♫ Now playing:"
|
||||
@current_song_label = label "♫ ♫ ♫"
|
||||
end
|
||||
|
||||
flow do
|
||||
flow(width: 1.0) do
|
||||
label "Volume:"
|
||||
@current_volume_label = label "100%"
|
||||
end
|
||||
|
||||
flow do
|
||||
flow(width: 1.0) do
|
||||
button get_image("#{ROOT_PATH}/media/icons/previous.png") do
|
||||
@jukebox.previous_track
|
||||
end
|
||||
@@ -137,7 +138,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
|
||||
unless @clock.active?
|
||||
push_state(Randomizer)
|
||||
@@ -195,11 +196,19 @@ module TAC
|
||||
if @clock.value != @last_clock_display_value
|
||||
@last_clock_display_value = @clock.value
|
||||
|
||||
request_repaint
|
||||
|
||||
if @remote_control_mode && @server.active_client
|
||||
@server.active_client.puts(ClockNet::PacketHandler.packet_clock_time(@last_clock_display_value))
|
||||
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
|
||||
track_changed(@jukebox.current_track)
|
||||
end
|
||||
@@ -213,6 +222,14 @@ module TAC
|
||||
@last_clock_state = @clock.active?
|
||||
end
|
||||
|
||||
def request_repaint
|
||||
if @particle_emitters && @particle_emitters.map(&:particle_count).sum.positive?
|
||||
true
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def update_non_gui
|
||||
if @remote_control_mode
|
||||
while (o = RemoteControl.server.proxy_object.queue.shift)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,18 +7,20 @@ module TAC
|
||||
header_bar("Drive Team Rotation Generator")
|
||||
|
||||
@roster ||= [
|
||||
"Alexander",
|
||||
"Aubrey",
|
||||
"Cayden",
|
||||
"Dan",
|
||||
"Gabe",
|
||||
"Spencer",
|
||||
"Olivia"
|
||||
"Sodi",
|
||||
"Trent"
|
||||
]
|
||||
|
||||
@roles ||= [
|
||||
"Coach",
|
||||
"Driver A",
|
||||
"Driver B"
|
||||
"Driver B",
|
||||
"Human"
|
||||
]
|
||||
|
||||
menu_bar.clear do
|
||||
@@ -30,19 +32,19 @@ 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
|
||||
|
||||
body.clear 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
|
||||
|
||||
flow(width: 1.0, margin_bottom: 20) do
|
||||
@role_name = edit_line "", placeholder: "Add role", width: 0.9
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 0.1, tip: "Add role" do
|
||||
flow(width: 1.0, height: 32, margin_bottom: 20) do
|
||||
@role_name = edit_line "", placeholder: "Add role", fill: true, height: 1.0
|
||||
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?
|
||||
@roles.push(@role_name.value.strip)
|
||||
@role_name.value = ""
|
||||
@@ -52,16 +54,16 @@ module TAC
|
||||
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
|
||||
|
||||
stack(margin_left: 20, width: 0.25, height: 1.0) do
|
||||
title "Roster", width: 1.0, margin_bottom: 4, text_align: :center
|
||||
|
||||
flow(width: 1.0, margin_bottom: 20) do
|
||||
@roster_name = edit_line "", placeholder: "Add name", width: 0.9
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_width: 0.1, tip: "Add name" do
|
||||
flow(width: 1.0, height: 32, margin_bottom: 20) do
|
||||
@roster_name = edit_line "", placeholder: "Add name", height: 1.0, fill: true
|
||||
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?
|
||||
@roster.push(@roster_name.value.strip)
|
||||
@roster_name.value = ""
|
||||
@@ -71,14 +73,14 @@ module TAC
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@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
|
||||
@@ -92,11 +94,11 @@ module TAC
|
||||
def populate_roles
|
||||
@roles_container.clear do
|
||||
@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
|
||||
|
||||
tagline name, width: 0.9
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 0.1, tip: "Remove role", **THEME_DANGER_BUTTON do
|
||||
tagline name, fill: true
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_height: 1.0, tip: "Remove role", **THEME_DANGER_BUTTON do
|
||||
@roles.delete(name)
|
||||
populate_roles
|
||||
end
|
||||
@@ -108,11 +110,11 @@ module TAC
|
||||
def populate_roster
|
||||
@roster_container.clear do
|
||||
@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
|
||||
|
||||
tagline name, width: 0.9
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: 0.1, tip: "Remove name", **THEME_DANGER_BUTTON do
|
||||
tagline name, fill: true
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_height: 1.0, tip: "Remove name", **THEME_DANGER_BUTTON do
|
||||
@roster.delete(name)
|
||||
populate_roster
|
||||
end
|
||||
@@ -125,13 +127,11 @@ module TAC
|
||||
@rotation = Generator.new(roster: @roster, team_size: @roles.count)
|
||||
|
||||
@rotation_container.clear do
|
||||
fraction = (1.0 / @rotation.team_size) - 0.02
|
||||
|
||||
flow(width: 1.0, padding: 2) do
|
||||
flow(width: 1.0, height: 32, padding: 2) do
|
||||
background Gosu::Color::BLACK
|
||||
|
||||
@roles.each do |role|
|
||||
tagline "<b>#{role}</b>", width: fraction
|
||||
tagline "<b>#{role}</b>", fill: true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -139,11 +139,11 @@ module TAC
|
||||
teams = @rotation.teams.shuffle if @shuffle_teams&.value
|
||||
|
||||
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
|
||||
|
||||
team.each do |player|
|
||||
tagline player, width: fraction
|
||||
tagline player, fill: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,18 @@ module TAC
|
||||
@active_group = nil
|
||||
@active_action = nil
|
||||
|
||||
@scroll_into_view_list = []
|
||||
@highlight_item_container = nil
|
||||
@highlight_from_color = Gosu::Color.rgba(0, 0, 0, 0)
|
||||
@highlight_to_color = Gosu::Color.rgba(THEME_HIGHLIGHTED_COLOR.red, THEME_HIGHLIGHTED_COLOR.green, THEME_HIGHLIGHTED_COLOR.blue, 200)
|
||||
|
||||
@highlight_animator = CyberarmEngine::Animator.new(
|
||||
start_time: Gosu.milliseconds - 1,
|
||||
duration: 0,
|
||||
from: Gosu::Color.rgba(0, 0, 0, 0),
|
||||
to: THEME_HIGHLIGHTED_COLOR
|
||||
)
|
||||
|
||||
menu_bar.clear do
|
||||
if @options[:group_is_preset]
|
||||
title "Editing group preset: #{@options[:group].name}"
|
||||
@@ -42,11 +54,18 @@ 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!
|
||||
|
||||
populate_groups_list
|
||||
@groups_list.append do
|
||||
add_group_container(clone)
|
||||
end
|
||||
|
||||
update_list_children(@groups_list)
|
||||
|
||||
scroll_into_view(clone)
|
||||
})
|
||||
else
|
||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to clone group, no group selected.")
|
||||
@@ -57,7 +76,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,12 +93,19 @@ 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!
|
||||
|
||||
populate_groups_list
|
||||
@groups_list.append do
|
||||
add_group_container(clone)
|
||||
end
|
||||
|
||||
update_list_children(@groups_list)
|
||||
|
||||
scroll_into_view(clone)
|
||||
})
|
||||
})
|
||||
end
|
||||
@@ -106,10 +133,17 @@ 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!
|
||||
|
||||
populate_actions_list(@active_group)
|
||||
@actions_list.append do
|
||||
add_action_container(clone)
|
||||
end
|
||||
|
||||
update_list_children(@actions_list)
|
||||
|
||||
scroll_into_view(clone)
|
||||
})
|
||||
else
|
||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to clone action, no action selected.")
|
||||
@@ -121,6 +155,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,14 +170,23 @@ 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!
|
||||
|
||||
populate_actions_list(@active_group)
|
||||
@actions_list.append do
|
||||
add_action_container(clone)
|
||||
end
|
||||
|
||||
update_list_children(@actions_list)
|
||||
|
||||
scroll_into_view(clone)
|
||||
})
|
||||
})
|
||||
else
|
||||
@@ -160,7 +204,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,59 +217,103 @@ 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
|
||||
|
||||
if @options[:action]
|
||||
@active_action = @options[:action]
|
||||
@active_action_label.value = @active_action.name
|
||||
end
|
||||
|
||||
populate_groups_list
|
||||
populate_actions_list(@active_group)
|
||||
populate_variables_list(@active_action) if @active_action
|
||||
|
||||
@groups_menu.hide
|
||||
|
||||
scroll_into_view(@active_group)
|
||||
scroll_into_view(@active_action) if @active_action
|
||||
scroll_into_view(@options[:variable]) if @options[:variable]
|
||||
|
||||
elsif @options[:action_is_preset]
|
||||
@active_action = @options[:action]
|
||||
@active_action_label.value = @active_action.name
|
||||
|
||||
populate_variables_list(@options[:action])
|
||||
populate_variables_list(@active_action)
|
||||
|
||||
@groups_menu.hide
|
||||
@actions_menu.hide
|
||||
|
||||
scroll_into_view(@active_action)
|
||||
scroll_into_view(@options[:variable]) if @options[:variable]
|
||||
|
||||
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]
|
||||
|
||||
scroll_into_view(@active_group)
|
||||
|
||||
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]
|
||||
# Scroll into view?
|
||||
end
|
||||
scroll_into_view(@active_action)
|
||||
scroll_into_view(@options[:variable]) if @options[:variable]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
populate_groups_list unless populated_groups_list
|
||||
end
|
||||
|
||||
def create_group(name)
|
||||
window.backend.config.groups << TAC::Config::Group.new(name: name, actions: [])
|
||||
group = TAC::Config::Group.new(name: name, actions: [])
|
||||
|
||||
window.backend.config.groups << group
|
||||
window.backend.config.groups.sort_by! { |g| g.name.downcase }
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_groups_list
|
||||
@groups_list.append do
|
||||
add_group_container(group)
|
||||
end
|
||||
|
||||
update_list_children(@groups_list)
|
||||
|
||||
scroll_into_view(group)
|
||||
end
|
||||
|
||||
def update_group(group, name)
|
||||
old_name = group.name
|
||||
|
||||
group.name = name
|
||||
window.backend.config.groups.sort_by! { |g| g.name.downcase }
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_groups_list
|
||||
group_container = find_element_by_tag(@groups_list, old_name)
|
||||
label = find_element_by_tag(group_container, "label")
|
||||
|
||||
label.value = name
|
||||
|
||||
group_container.style.tag = name
|
||||
|
||||
update_list_children(@groups_list)
|
||||
|
||||
scroll_into_view(group)
|
||||
end
|
||||
|
||||
def delete_group(group)
|
||||
@@ -242,24 +330,58 @@ module TAC
|
||||
@actions_list.clear
|
||||
@variables_list.clear
|
||||
|
||||
populate_groups_list
|
||||
# Remove deleted action from list
|
||||
container = find_element_by_tag(@groups_list, group.name)
|
||||
@groups_list.remove(container)
|
||||
|
||||
update_list_children(@groups_list)
|
||||
end
|
||||
|
||||
def create_action(name, comment)
|
||||
@active_group.actions << TAC::Config::Action.new(name: name, comment: comment, enabled: true, variables: [])
|
||||
action = TAC::Config::Action.new(name: name, comment: comment, enabled: true, variables: [])
|
||||
|
||||
@active_group.actions << action
|
||||
@active_group.actions.sort_by! { |a| a.name.downcase }
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_actions_list(@active_group)
|
||||
@actions_list.append do
|
||||
add_action_container(action)
|
||||
end
|
||||
|
||||
update_list_children(@actions_list)
|
||||
|
||||
scroll_into_view(action)
|
||||
end
|
||||
|
||||
def update_action(action, name, comment)
|
||||
old_name = action.name
|
||||
|
||||
action.name = name
|
||||
action.comment = comment
|
||||
@active_group.actions.sort_by! { |a| a.name.downcase }
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_actions_list(@active_group)
|
||||
action_container = find_element_by_tag(@actions_list, old_name)
|
||||
label = find_element_by_tag(action_container, "label")
|
||||
comment_container = find_element_by_tag(action_container, "comment_container")
|
||||
comment_label = find_element_by_tag(action_container, "comment")
|
||||
|
||||
label.value = name
|
||||
if comment.empty?
|
||||
action_container.style.height = 36
|
||||
comment_container.hide
|
||||
comment_label.value = ""
|
||||
else
|
||||
action_container.style.height = 72
|
||||
comment_container.show
|
||||
comment_label.value = comment.to_s
|
||||
end
|
||||
|
||||
action_container.style.tag = name
|
||||
|
||||
update_list_children(@actions_list)
|
||||
|
||||
scroll_into_view(action)
|
||||
end
|
||||
|
||||
def delete_action(action)
|
||||
@@ -271,18 +393,32 @@ module TAC
|
||||
@active_action_label.value = ""
|
||||
@variables_list.clear
|
||||
|
||||
populate_actions_list(@active_group)
|
||||
# Remove deleted action from list
|
||||
container = find_element_by_tag(@actions_list, action.name)
|
||||
@actions_list.remove(container)
|
||||
|
||||
update_list_children(@actions_list)
|
||||
end
|
||||
|
||||
def create_variable(name, type, value)
|
||||
@active_action.variables << TAC::Config::Variable.new(name: name, type: type, value: value)
|
||||
variable = TAC::Config::Variable.new(name: name, type: type, value: value)
|
||||
|
||||
@active_action.variables << variable
|
||||
@active_action.variables.sort_by! { |v| v.name.downcase }
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_variables_list(@active_action)
|
||||
@variables_list.append do
|
||||
add_variable_container(variable)
|
||||
end
|
||||
|
||||
update_list_children(@variables_list)
|
||||
|
||||
scroll_into_view(variable)
|
||||
end
|
||||
|
||||
def update_variable(variable, name, type, value)
|
||||
old_name = variable.name
|
||||
|
||||
variable.name = name
|
||||
variable.type = type
|
||||
variable.value = value
|
||||
@@ -291,7 +427,20 @@ module TAC
|
||||
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_variables_list(@active_action)
|
||||
variable_container = find_element_by_tag(@variables_list, old_name)
|
||||
label = find_element_by_tag(variable_container, "label")
|
||||
type = find_element_by_tag(variable_container, "type")
|
||||
value = find_element_by_tag(variable_container, "value")
|
||||
|
||||
label.value = name
|
||||
type.value = "Type: #{variable.type}"
|
||||
value.value = "Value: #{variable.value}"
|
||||
|
||||
variable_container.style.tag = name
|
||||
|
||||
update_list_children(@variables_list)
|
||||
|
||||
scroll_into_view(variable)
|
||||
end
|
||||
|
||||
def delete_variable(variable)
|
||||
@@ -299,7 +448,48 @@ module TAC
|
||||
@active_action.variables.sort_by! { |v| v.name.downcase }
|
||||
window.backend.config_changed!
|
||||
|
||||
populate_variables_list(@active_action)
|
||||
# Remove deleted variable from list
|
||||
container = find_element_by_tag(@variables_list, variable.name)
|
||||
@variables_list.remove(container)
|
||||
|
||||
update_list_children(@variables_list)
|
||||
end
|
||||
|
||||
def update_list_children(list)
|
||||
is_group = list == @groups_list
|
||||
is_action = list == @actions_list
|
||||
is_variable = list == @variables_list
|
||||
|
||||
list.children.sort_by! { |i| i.style.tag.downcase }
|
||||
|
||||
list.children.each_with_index do |child, i|
|
||||
bg_color = i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
bg_color = THEME_HIGHLIGHTED_COLOR if is_group && @active_group&.name == child.style.tag
|
||||
bg_color = THEME_HIGHLIGHTED_COLOR if is_action && @active_action&.name == child.style.tag
|
||||
|
||||
child.style.default[:background] = bg_color
|
||||
|
||||
child.root.gui_state.request_recalculate
|
||||
end
|
||||
end
|
||||
|
||||
def scroll_into_view(item)
|
||||
list_container = nil
|
||||
item_container = nil
|
||||
|
||||
if item.is_a?(TAC::Config::Group)
|
||||
list_container = @groups_list
|
||||
elsif item.is_a?(TAC::Config::Action)
|
||||
list_container = @actions_list
|
||||
elsif item.is_a?(TAC::Config::Variable)
|
||||
list_container = @variables_list
|
||||
else
|
||||
raise "Unsupported item type: #{item.class}"
|
||||
end
|
||||
|
||||
item_container = find_element_by_tag(list_container, item.name)
|
||||
|
||||
@scroll_into_view_list << { list: list_container, item: item_container }
|
||||
end
|
||||
|
||||
def populate_groups_list
|
||||
@@ -312,23 +502,53 @@ module TAC
|
||||
end
|
||||
|
||||
@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
|
||||
|
||||
button group.name, fill: true, text_size: THEME_ICON_SIZE - 3 do
|
||||
if (old_i = groups.index(@active_group))
|
||||
@active_group_container.style.default[:background] = old_i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
groups.each do |group|
|
||||
add_group_container(group)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def populate_actions_list(group)
|
||||
@actions_list.scroll_top = 0
|
||||
|
||||
actions = group.actions
|
||||
|
||||
@actions_list.clear do
|
||||
actions.each do |action|
|
||||
add_action_container(action)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def populate_variables_list(action)
|
||||
@variables_list.scroll_top = 0
|
||||
|
||||
variables = action.variables
|
||||
|
||||
@variables_list.clear do
|
||||
variables.each do |variable|
|
||||
add_variable_container(variable)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def add_group_container(group)
|
||||
index = window.backend.config.groups.index(group)
|
||||
|
||||
flow width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING, tag: group.name do |container|
|
||||
background group == @active_group ? THEME_HIGHLIGHTED_COLOR : (index.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, tag: "label" do
|
||||
@active_group = group
|
||||
@active_group_container = container
|
||||
@active_group_container.style.default[:background] = THEME_HIGHLIGHTED_COLOR
|
||||
@active_group_label.value = group.name
|
||||
@active_action = nil
|
||||
@active_action_container = nil
|
||||
@active_action_label.value = ""
|
||||
|
||||
update_list_children(@groups_list)
|
||||
|
||||
populate_actions_list(group)
|
||||
@variables_list.clear
|
||||
end
|
||||
@@ -341,30 +561,22 @@ module TAC
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def populate_actions_list(group)
|
||||
@actions_list.scroll_top = 0
|
||||
def add_action_container(action)
|
||||
index = @active_group.actions.index(action)
|
||||
|
||||
actions = group.actions
|
||||
|
||||
@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
|
||||
stack width: 1.0, height: action.comment.empty? ? 36 : 72, **THEME_ITEM_CONTAINER_PADDING, tag: action.name do |container|
|
||||
background action == @active_action ? THEME_HIGHLIGHTED_COLOR : (index.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
|
||||
if (old_i = actions.index(@active_action))
|
||||
@active_action_container.style.default[:background] = old_i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
end
|
||||
|
||||
button action.name, fill: true, text_size: THEME_ICON_SIZE - 3, tag: "label" do
|
||||
@active_action = action
|
||||
@active_action_container = container
|
||||
@active_action_container.style.default[:background] = THEME_HIGHLIGHTED_COLOR
|
||||
@active_action_label.value = action.name
|
||||
|
||||
update_list_children(@actions_list)
|
||||
|
||||
populate_variables_list(action)
|
||||
end
|
||||
|
||||
@@ -375,7 +587,7 @@ module TAC
|
||||
end
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit action" do
|
||||
push_state(Dialog::ActionDialog, title: "Rename Action", action: action, list: @active_group.actions, callback_method: method(:update_action))
|
||||
push_state(Dialog::ActionDialog, title: "Edit Action", action: action, list: @active_group.actions, callback_method: method(:update_action))
|
||||
end
|
||||
|
||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete action", **THEME_DANGER_BUTTON do
|
||||
@@ -383,29 +595,21 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
unless action.comment.empty?
|
||||
stack(width: 1.0, fill: true, scroll: true) do
|
||||
caption action.comment.to_s, width: 1.0, text_wrap: :word_wrap, text_border: true, text_border_size: 1, text_border_color: 0xaa_000000
|
||||
end
|
||||
end
|
||||
end
|
||||
stack(width: 1.0, fill: true, scroll: true, visible: !action.comment.empty?, tag: "comment_container") do
|
||||
caption action.comment.to_s, width: 1.0, text_wrap: :word_wrap, text_border: true, text_border_size: 1, text_border_color: 0xaa_000000, tag: "comment"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def populate_variables_list(action)
|
||||
@variables_list.scroll_top = 0
|
||||
def add_variable_container(variable)
|
||||
index = @active_action.variables.index(variable)
|
||||
|
||||
variables = action.variables
|
||||
|
||||
@variables_list.clear do
|
||||
variables.each_with_index do |variable, i|
|
||||
stack width: 1.0, height: 96, **THEME_ITEM_CONTAINER_PADDING do
|
||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
stack width: 1.0, height: 96, **THEME_ITEM_CONTAINER_PADDING, tag: variable.name do
|
||||
background index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
|
||||
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))
|
||||
button variable.name, fill: true, text_size: THEME_ICON_SIZE - 3, tip: "Edit variable", tag: "label" do
|
||||
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
|
||||
@@ -413,10 +617,53 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
caption "Type: #{variable.type}"
|
||||
caption "Value: #{variable.value}"
|
||||
caption "Type: #{variable.type}", tag: "type", fill: true
|
||||
caption "Value: #{variable.value}", tag: "value", fill: true
|
||||
end
|
||||
end
|
||||
|
||||
def draw
|
||||
super
|
||||
|
||||
unless @highlight_animator.complete?
|
||||
current_state.request_repaint
|
||||
|
||||
item = @highlight_item_container
|
||||
|
||||
Gosu.draw_rect(
|
||||
item.x, item.y,
|
||||
item.width, item.height,
|
||||
@highlight_animator.color_transition,
|
||||
item.z + 1
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
|
||||
while (hash = @scroll_into_view_list.shift)
|
||||
list_container = hash[:list]
|
||||
item_container = hash[:item]
|
||||
|
||||
return unless list_container
|
||||
return unless item_container
|
||||
|
||||
unless (item_container.y + item_container.height).between?(list_container.y, list_container.y + list_container.height)
|
||||
|
||||
list_container.scroll_top = (item_container.y + item_container.height) - (list_container.y + list_container.height)
|
||||
|
||||
list_container.recalculate
|
||||
end
|
||||
|
||||
@highlight_item_container = item_container
|
||||
@highlight_animator = CyberarmEngine::Animator.new(
|
||||
start_time: Gosu.milliseconds,
|
||||
duration: 750,
|
||||
from: @highlight_from_color,
|
||||
to: @highlight_to_color,
|
||||
tween: :ease_in_out_back
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -453,6 +700,7 @@ module TAC
|
||||
push_state(
|
||||
TAC::Dialog::VariableDialog,
|
||||
title: "Create Variable",
|
||||
list: @active_action.variables,
|
||||
callback_method: method(:create_variable)
|
||||
)
|
||||
else
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -34,8 +34,42 @@ 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
|
||||
|
||||
@@ -22,7 +22,7 @@ module TAC
|
||||
shared_index = 0
|
||||
|
||||
flow(width: 1.0, height: 1.0) do
|
||||
stack(width: 0.495, height: 1.0, scroll: true) do
|
||||
stack(fill: true, height: 1.0, scroll: true, padding: 20, padding_right: 10) do
|
||||
if search_results.groups.size.positive?
|
||||
title "Groups"
|
||||
|
||||
@@ -44,7 +44,9 @@ module TAC
|
||||
search_results.actions.each do |result|
|
||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
button result.highlight(result.action.name), width: 1.0 do
|
||||
tip = "Group: #{result.group.name}"
|
||||
|
||||
button result.highlight(result.action.name), width: 1.0, tip: tip do
|
||||
page(TAC::Pages::Editor, { group: result.group, action: result.action, is_search: true })
|
||||
end
|
||||
|
||||
@@ -63,7 +65,9 @@ module TAC
|
||||
search_results.variables.each do |result|
|
||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
button "#{result.highlight(result.variable.name)} [#{result.highlight(result.variable.value)}]", width: 1.0 do
|
||||
tip = "Group: #{result.group.name}, Action: #{result.action.name}"
|
||||
|
||||
button "#{result.highlight(result.variable.name)} [#{result.variable.type}: #{result.highlight(result.variable.value)}]", width: 1.0, tip: tip do
|
||||
page(TAC::Pages::Editor, { group: result.group, action: result.action, variable: result.variable, is_search: true })
|
||||
end
|
||||
end
|
||||
@@ -73,13 +77,14 @@ module TAC
|
||||
end
|
||||
end
|
||||
|
||||
stack(width: 0.495, height: 1.0, scroll: true) do
|
||||
stack(fill: true, height: 1.0, scroll: true, padding: 20, padding_left: 10) do
|
||||
if search_results.group_presets.size.positive?
|
||||
title "Group Presets"
|
||||
|
||||
search_results.group_presets.each do |result|
|
||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
|
||||
button result.highlight(result.group.name), width: 1.0 do
|
||||
page(TAC::Pages::Editor, { group: result.group, group_is_preset: true, is_search: true })
|
||||
end
|
||||
@@ -95,7 +100,9 @@ module TAC
|
||||
search_results.action_presets.each do |result|
|
||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
button result.highlight(result.action.name), width: 1.0 do
|
||||
tip = result.group ? "Group: #{result.group.name}" : nil
|
||||
|
||||
button result.highlight(result.action.name), width: 1.0, tip: tip do
|
||||
if result.group.nil?
|
||||
page(TAC::Pages::Editor, { action: result.action, action_is_preset: true, is_search: true })
|
||||
else
|
||||
@@ -118,7 +125,9 @@ module TAC
|
||||
search_results.variables_from_presets.each do |result|
|
||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||
button "#{result.highlight(result.variable.name)} [#{result.highlight(result.variable.value)}]", width: 1.0 do
|
||||
tip = result.group ? "Group: #{result.group.name}, Action: #{result.action.name}" : "Action: #{result.action.name}"
|
||||
|
||||
button "#{result.highlight(result.variable.name)} [#{result.variable.type}: #{result.highlight(result.variable.value)}]", width: 1.0, tip: tip do
|
||||
if result.group.nil?
|
||||
page(TAC::Pages::Editor, { action: result.action, variable: result.variable, action_is_preset: true, is_search: true })
|
||||
else
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
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
|
||||
when :connected
|
||||
@tacnet_button.style.color = TAC::Palette::TACNET_CONNECTED
|
||||
@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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module TAC
|
||||
class TACNET
|
||||
DEFAULT_HOSTNAME = "192.168.49.1"
|
||||
DEFAULT_HOSTNAME = "192.168.49.1".freeze
|
||||
DEFAULT_PORT = 8962
|
||||
|
||||
SYNC_INTERVAL = 250 # ms
|
||||
@@ -30,7 +30,7 @@ module TAC
|
||||
end
|
||||
|
||||
def full_status
|
||||
_status = status.to_s.split("_").map { |c| c.capitalize }.join(" ")
|
||||
_status = status.to_s.split("_").map(&:capitalize).join(" ")
|
||||
|
||||
if connected?
|
||||
net_stats = ""
|
||||
@@ -42,7 +42,7 @@ module TAC
|
||||
|
||||
"<b>Status:</b> #{_status}\n\n#{net_stats}"
|
||||
elsif @connection&.client && @connection.client.socket_error?
|
||||
"<b>Status:</b> #{_status}\n\n#{@connection.client.last_socket_error.to_s}"
|
||||
"<b>Status:</b> #{_status}\n\n#{@connection.client.last_socket_error}"
|
||||
else
|
||||
"<b>Status:</b> #{_status}"
|
||||
end
|
||||
@@ -53,11 +53,11 @@ module TAC
|
||||
end
|
||||
|
||||
def close
|
||||
if connected?
|
||||
return unless connected?
|
||||
|
||||
@connection.close
|
||||
@connection = nil
|
||||
end
|
||||
end
|
||||
|
||||
def client
|
||||
@connection.client
|
||||
|
||||
@@ -8,7 +8,9 @@ module TAC
|
||||
attr_reader :uuid, :read_queue, :write_queue, :socket,
|
||||
:packets_sent, :packets_received,
|
||||
:data_sent, :data_received
|
||||
|
||||
attr_accessor :sync_interval, :last_socket_error, :socket_error
|
||||
|
||||
def initialize
|
||||
@uuid = SecureRandom.uuid
|
||||
@read_queue = []
|
||||
@@ -20,8 +22,11 @@ module TAC
|
||||
@socket_error = false
|
||||
@bound = false
|
||||
|
||||
@packets_sent, @packets_received = 0, 0
|
||||
@data_sent, @data_received = 0, 0
|
||||
@packets_sent = 0
|
||||
@packets_received = 0
|
||||
|
||||
@data_sent = 0
|
||||
@data_received = 0
|
||||
end
|
||||
|
||||
def uuid=(id)
|
||||
@@ -39,18 +44,16 @@ module TAC
|
||||
Thread.new do
|
||||
while connected?
|
||||
# Read from socket
|
||||
while message_in = read
|
||||
if message_in.empty?
|
||||
break
|
||||
else
|
||||
log.i(TAG, "Read: " + message_in)
|
||||
while (message_in = read)
|
||||
break if message_in.empty?
|
||||
|
||||
log.i(TAG, "Read: #{message_in}")
|
||||
|
||||
@read_queue << message_in
|
||||
|
||||
@packets_received += 1
|
||||
@data_received += message_in.length
|
||||
end
|
||||
end
|
||||
|
||||
sleep @sync_interval / 1000.0
|
||||
end
|
||||
@@ -59,12 +62,12 @@ module TAC
|
||||
Thread.new do
|
||||
while connected?
|
||||
# Write to socket
|
||||
while message_out = @write_queue.shift
|
||||
while (message_out = @write_queue.shift)
|
||||
write(message_out)
|
||||
|
||||
@packets_sent += 1
|
||||
@data_sent += message_out.to_s.length
|
||||
log.i(TAG, "Write: " + message_out.to_s)
|
||||
log.i(TAG, "Write: #{message_out}")
|
||||
end
|
||||
|
||||
sleep @sync_interval / 1000.0
|
||||
@@ -82,7 +85,7 @@ module TAC
|
||||
while message
|
||||
puts(message)
|
||||
|
||||
log.i(TAG, "Writing to Queue: " + message)
|
||||
log.i(TAG, "Writing to Queue: #{message}")
|
||||
|
||||
message = gets
|
||||
end
|
||||
@@ -101,32 +104,29 @@ module TAC
|
||||
end
|
||||
|
||||
def closed?
|
||||
@socket.closed? if @socket
|
||||
@socket&.closed?
|
||||
end
|
||||
|
||||
def write(message)
|
||||
begin
|
||||
@socket.puts("#{message}#{PACKET_TAIL}")
|
||||
@socket.puts("#{message}#{PACKET_TAIL}") if connected?
|
||||
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 if connected?
|
||||
rescue => error
|
||||
@last_socket_error = error
|
||||
@socket_error = true
|
||||
|
||||
message = ""
|
||||
end
|
||||
log.e(TAG, error.message)
|
||||
|
||||
|
||||
return message.strip
|
||||
close
|
||||
end
|
||||
|
||||
def puts(message)
|
||||
@@ -138,11 +138,11 @@ module TAC
|
||||
end
|
||||
|
||||
def encode(message)
|
||||
return message
|
||||
message
|
||||
end
|
||||
|
||||
def decode(blob)
|
||||
return blob
|
||||
blob
|
||||
end
|
||||
|
||||
def flush
|
||||
@@ -151,7 +151,8 @@ module TAC
|
||||
|
||||
def close(reason = nil)
|
||||
write(reason) if reason
|
||||
@socket.close if @socket
|
||||
|
||||
@socket&.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module TAC
|
||||
NAME = "TimeCrafters Configuration Tool"
|
||||
VERSION = "0.6.0"
|
||||
VERSION = "0.7.0"
|
||||
RELEASE_NAME = "Beta"
|
||||
end
|
||||
@@ -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,
|
||||
|
||||
BIN
media/screenshots/screenshot_editor.png
Normal file
BIN
media/screenshots/screenshot_editor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 280 KiB |
Reference in New Issue
Block a user