mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 22:02:34 +00:00
Compare commits
33 Commits
308575dc63
...
v0.8.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 86c1f24337 | |||
| 3aa63b4ad1 | |||
| abdb86440f | |||
| b8cb9b9ab8 | |||
| c4622fa563 | |||
| d49938855d | |||
| 6554140acf | |||
| 43510faaa2 | |||
| 3350f4f063 | |||
| 49133bb49d | |||
| 8aaed6bc8d | |||
| 4bdc12ce46 | |||
| f98edc1744 | |||
| 9940837065 | |||
| a8ebaebe4c | |||
| 08bbd2c638 | |||
| 08fdd1de1b | |||
| ffe946ae15 | |||
| d94490110e | |||
| 1145ac646d | |||
| be1c1f4989 | |||
| caa2000e91 | |||
| 7bcc32097f | |||
| 2d2a4e0733 | |||
| d61785c98a | |||
| 07fdf0055e | |||
| 2a8a2d1bbf | |||
| 48b4d6ddcf | |||
| 0cd4475a8f | |||
| acc0792d17 | |||
| 6f211adf28 | |||
| 3d29ff46e6 | |||
| 27d0b7314f |
5
Gemfile
5
Gemfile
@@ -1,9 +1,8 @@
|
|||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem "cyberarm_engine"
|
gem "cyberarm_engine"
|
||||||
gem "gosu_notifications"
|
|
||||||
|
|
||||||
group :packaging do
|
group :packaging do
|
||||||
gem "ocra"
|
gem "ocran"
|
||||||
gem "releasy"
|
# gem "releasy", path: "../releasy"
|
||||||
end
|
end
|
||||||
32
Gemfile.lock
32
Gemfile.lock
@@ -1,37 +1,21 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
clipboard (1.3.6)
|
cyberarm_engine (0.24.1)
|
||||||
cri (2.1.0)
|
excon (~> 0.88)
|
||||||
cyberarm_engine (0.19.1)
|
|
||||||
clipboard (~> 1.3.5)
|
|
||||||
excon (~> 0.78.0)
|
|
||||||
gosu (~> 1.1)
|
gosu (~> 1.1)
|
||||||
gosu_more_drawables (~> 0.3)
|
gosu_more_drawables (~> 0.3)
|
||||||
excon (0.78.1)
|
excon (0.109.0)
|
||||||
ffi (1.15.4-x64-mingw32)
|
gosu (1.4.6)
|
||||||
gosu (1.2.0)
|
|
||||||
gosu_more_drawables (0.3.1)
|
gosu_more_drawables (0.3.1)
|
||||||
gosu_notifications (0.1.0)
|
ocran (1.3.15)
|
||||||
ocra (1.3.11)
|
|
||||||
rake (13.0.6)
|
|
||||||
releasy (0.2.3)
|
|
||||||
bundler (>= 1.2.1)
|
|
||||||
cri (~> 2.1.0)
|
|
||||||
ocra (~> 1.3.0)
|
|
||||||
rake (>= 0.9.2.2)
|
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
x64-mingw32
|
x64-mingw-ucrt
|
||||||
x86_64-linux
|
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
clipboard
|
|
||||||
cyberarm_engine
|
cyberarm_engine
|
||||||
ffi
|
ocran
|
||||||
gosu_notifications
|
|
||||||
ocra
|
|
||||||
releasy
|
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.2.28
|
2.5.3
|
||||||
|
|||||||
4
Rakefile
4
Rakefile
@@ -18,12 +18,12 @@ Releasy::Project.new do
|
|||||||
"media/music/.gitkeep",
|
"media/music/.gitkeep",
|
||||||
"media/particles/.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
|
verbose
|
||||||
|
|
||||||
add_build :windows_folder do
|
add_build :windows_folder do
|
||||||
icon "media/icon.ico"
|
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.
|
add_package :exe # Windows self-extracting archive.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ module TAC
|
|||||||
class Backend
|
class Backend
|
||||||
attr_reader :config, :settings, :tacnet
|
attr_reader :config, :settings, :tacnet
|
||||||
def initialize
|
def initialize
|
||||||
|
create_directories
|
||||||
|
|
||||||
load_settings
|
load_settings
|
||||||
load_config(@settings.config) if @settings.config && File.exist?("#{TAC::CONFIGS_PATH}/#{@settings.config}.json")
|
load_config(@settings.config) if @settings.config && File.exist?("#{TAC::CONFIGS_PATH}/#{@settings.config}.json")
|
||||||
@tacnet = TACNET.new
|
@tacnet = TACNET.new
|
||||||
@@ -113,6 +115,12 @@ module TAC
|
|||||||
@settings_changed
|
@settings_changed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_directories
|
||||||
|
FileUtils.mkdir_p(TAC::ROOT_PATH) unless File.exist?(TAC::ROOT_PATH)
|
||||||
|
FileUtils.mkdir_p(TAC::CONFIGS_PATH) unless File.exist?(TAC::CONFIGS_PATH)
|
||||||
|
# FileUtils.mkdir_p(TAC::SETTINGS_PATH) unless File.exist?(TAC::SETTINGS_PATH)
|
||||||
|
end
|
||||||
|
|
||||||
def load_settings
|
def load_settings
|
||||||
if File.exist?(TAC::SETTINGS_PATH)
|
if File.exist?(TAC::SETTINGS_PATH)
|
||||||
@settings = TAC::Settings.new
|
@settings = TAC::Settings.new
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ module TAC
|
|||||||
|
|
||||||
label @title, text_size: THEME_SUBHEADING_TEXT_SIZE, font: TAC::THEME_BOLD_FONT, fill: true, text_align: :center, text_border: true, text_border_color: 0xaa_222222, text_border_size: 1
|
label @title, text_size: THEME_SUBHEADING_TEXT_SIZE, font: TAC::THEME_BOLD_FONT, fill: true, text_align: :center, text_border: true, text_border_color: 0xaa_222222, text_border_size: 1
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/cross.png"), image_height: 1.0, **THEME_DANGER_BUTTON do
|
button get_image("#{TAC::MEDIA_PATH}/icons/cross.png"), image_height: 1.0, **THEME_DANGER_BUTTON do
|
||||||
close
|
close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module TAC
|
|||||||
background Gosu::Color::GRAY
|
background Gosu::Color::GRAY
|
||||||
label @options[:message], width: 1.0
|
label @options[:message], width: 1.0
|
||||||
|
|
||||||
@sound = Gosu::Sample.new("#{TAC::ROOT_PATH}/media/error_alarm.ogg").play(1, 1, true)
|
@sound = Gosu::Sample.new("#{TAC::MEDIA_PATH}/error_alarm.ogg").play(1, 1, true)
|
||||||
|
|
||||||
button "Close", width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
button "Close", width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
||||||
try_commit
|
try_commit
|
||||||
|
|||||||
@@ -57,13 +57,12 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clock_time(time_left)
|
def clock_time(time_left)
|
||||||
minutes = ((time_left + 0.5) / 60.0).floor
|
minutes = ((time_left + 1.0) / 60.0).floor
|
||||||
|
|
||||||
seconds = time_left.round % 60
|
seconds = format("%02d", time_left.ceil % 60)
|
||||||
seconds = "0#{seconds}" if seconds < 10
|
|
||||||
|
|
||||||
return "#{minutes}:#{seconds}" if time_left.round.even?
|
return "#{minutes}:#{seconds}" if time_left.ceil.even?
|
||||||
return "#{minutes}<c=999999>:</c>#{seconds}" if time_left.round.odd?
|
return "#{minutes}<c=999999>:</c>#{seconds}" if time_left.ceil.odd?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ module TAC
|
|||||||
create_event(:change_countdown, 33.0, "0:08"),
|
create_event(:change_countdown, 33.0, "0:08"),
|
||||||
create_event(:change_display, 33.0, :countdown),
|
create_event(:change_display, 33.0, :countdown),
|
||||||
create_event(:start_countdown, 33.0),
|
create_event(:start_countdown, 33.0),
|
||||||
create_event(:play_sound, 34.5, :teleop_pickup_controllers),
|
create_event(:play_sound, 35.0, :teleop_pickup_controllers),
|
||||||
create_event(:change_color, 37.0, :red),
|
create_event(:change_color, 38.0, :red),
|
||||||
create_event(:play_sound, 38.0, :teleop_countdown),
|
create_event(:play_sound, 38.0, :teleop_countdown),
|
||||||
create_event(:stop_countdown, 41.0),
|
create_event(:stop_countdown, 41.0),
|
||||||
].freeze
|
].freeze
|
||||||
@@ -44,7 +44,7 @@ module TAC
|
|||||||
create_event(:change_clock, 131.0, "0:30"),
|
create_event(:change_clock, 131.0, "0:30"),
|
||||||
create_event(:start_clock, 131.0),
|
create_event(:start_clock, 131.0),
|
||||||
create_event(:play_sound, 131.0, :end_game),
|
create_event(:play_sound, 131.0, :end_game),
|
||||||
create_event(:play_sound, 158.0, :autonomous_countdown),
|
# create_event(:play_sound, 158.0, :autonomous_countdown), # Not played here anymore
|
||||||
create_event(:play_sound, 161.0, :end_match),
|
create_event(:play_sound, 161.0, :end_match),
|
||||||
create_event(:stop_clock, 161.0),
|
create_event(:stop_clock, 161.0),
|
||||||
].freeze
|
].freeze
|
||||||
@@ -128,7 +128,7 @@ module TAC
|
|||||||
elsif @countdown_running
|
elsif @countdown_running
|
||||||
return @countdown_time
|
return @countdown_time
|
||||||
else
|
else
|
||||||
return 60 * 2 + 30
|
return 0 # Clock defaults to showing "0:00" if there is no clock or countdown
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ module TAC
|
|||||||
Gosu::Color.rgb(150, 0, 0)
|
Gosu::Color.rgb(150, 0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
### --- ###
|
||||||
|
# OVERRIDE: offical CenterStage game clock no longer has colors
|
||||||
|
### --- ###
|
||||||
|
|
||||||
|
out = Gosu::Color::WHITE
|
||||||
|
|
||||||
@display_color = out
|
@display_color = out
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -56,26 +62,26 @@ module TAC
|
|||||||
path = nil
|
path = nil
|
||||||
case sound
|
case sound
|
||||||
when :autonomous_countdown
|
when :autonomous_countdown
|
||||||
path = "media/sounds/3-2-1.wav"
|
path = "sounds/3-2-1.wav"
|
||||||
when :autonomous_start
|
when :autonomous_start
|
||||||
path = "media/sounds/charge.wav"
|
path = "sounds/charge.wav"
|
||||||
when :autonomous_ended
|
when :autonomous_ended
|
||||||
path = "media/sounds/endauto.wav"
|
path = "sounds/endauto.wav"
|
||||||
when :teleop_pickup_controllers
|
when :teleop_pickup_controllers
|
||||||
path = "media/sounds/Pick_Up_Controllers.wav"
|
path = "sounds/Pick_Up_Controllers.wav"
|
||||||
when :abort_match
|
when :abort_match
|
||||||
path = "media/sounds/fogblast.wav"
|
path = "sounds/fogblast.wav"
|
||||||
when :teleop_countdown
|
when :teleop_countdown
|
||||||
path = "media/sounds/3-2-1.wav"
|
path = "sounds/3-2-1.wav"
|
||||||
when :teleop_started
|
when :teleop_started
|
||||||
path = "media/sounds/firebell.wav"
|
path = "sounds/firebell.wav"
|
||||||
when :end_game
|
when :end_game
|
||||||
path = "media/sounds/factwhistle.wav"
|
path = "sounds/factwhistle.wav"
|
||||||
when :end_match
|
when :end_match
|
||||||
path = "media/sounds/endmatch.wav"
|
path = "sounds/endmatch.wav"
|
||||||
end
|
end
|
||||||
|
|
||||||
path = "#{ROOT_PATH}/#{path}"
|
path = "#{MEDIA_PATH}/#{path}"
|
||||||
|
|
||||||
if path && File.exist?(path) && !File.directory?(path)
|
if path && File.exist?(path) && !File.directory?(path)
|
||||||
Jukebox::SAMPLES[path] = Gosu::Sample.new(path) unless Jukebox::SAMPLES[path].is_a?(Gosu::Sample)
|
Jukebox::SAMPLES[path] = Gosu::Sample.new(path) unless Jukebox::SAMPLES[path].is_a?(Gosu::Sample)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
module TAC
|
module TAC
|
||||||
class PracticeGameClock
|
class PracticeGameClock
|
||||||
class Jukebox
|
class Jukebox
|
||||||
MUSIC = Dir.glob(ROOT_PATH + "/media/music/*.*").freeze
|
MUSIC = Dir.glob(MEDIA_PATH + "/music/*.*").freeze
|
||||||
SAMPLES = {}
|
SAMPLES = {}
|
||||||
|
|
||||||
if File.exist?(ROOT_PATH + "/media/sounds/skystone")
|
if File.exist?(MEDIA_PATH + "/sounds/skystone")
|
||||||
BEEPS_AND_BOOPS = Dir.glob(ROOT_PATH + "/media/sounds/skystone/*.*").freeze
|
BEEPS_AND_BOOPS = Dir.glob(MEDIA_PATH + "/sounds/skystone/*.*").freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :volume, :now_playing
|
attr_reader :volume, :now_playing
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return message.strip
|
return message.to_s.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
def puts(message)
|
def puts(message)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module TAC
|
|||||||
@z = -2
|
@z = -2
|
||||||
|
|
||||||
@particles = []
|
@particles = []
|
||||||
@image_options = Dir.glob("#{ROOT_PATH}/media/particles/*.*")
|
@image_options = Dir.glob("#{MEDIA_PATH}/particles/*.*")
|
||||||
@last_spawned = 0
|
@last_spawned = 0
|
||||||
@clock_active = false
|
@clock_active = false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,30 +15,20 @@ module TAC
|
|||||||
|
|
||||||
case @roll
|
case @roll
|
||||||
when 1, 4
|
when 1, 4
|
||||||
# Blue: Right
|
#Blue and Red: Left
|
||||||
# Red: Left
|
|
||||||
|
|
||||||
@ducks << Ducky.new(window: window, alliance: :blue, slot: 3, speed: 512, die_size: @size)
|
@ducks << Ducky.new(window: window, alliance: :blue, slot: 1, speed: 1010, die_size: @size, label: "Left")
|
||||||
@ducks << Ducky.new(window: window, alliance: :red, slot: 1, speed: 512, die_size: @size)
|
@ducks << Ducky.new(window: window, alliance: :red, slot: 1, speed: 1010, die_size: @size, label: "Left")
|
||||||
when 2, 5
|
when 2, 5
|
||||||
#Blue and Red: Center
|
#Blue and Red: Center
|
||||||
|
|
||||||
@ducks << Ducky.new(window: window, alliance: :blue, slot: 1, speed: 512, die_size: @size)
|
@ducks << Ducky.new(window: window, alliance: :blue, slot: 2, speed: 1010, die_size: @size, label: "Center")
|
||||||
@ducks << Ducky.new(window: window, alliance: :blue, slot: 3, speed: 512, die_size: @size)
|
@ducks << Ducky.new(window: window, alliance: :red, slot: 2, speed: 1010, die_size: @size, label: "Center")
|
||||||
|
|
||||||
@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
|
when 3, 6
|
||||||
# Blue: Left
|
#Blue and Red: Right
|
||||||
# Red: Right
|
|
||||||
|
|
||||||
@ducks << Ducky.new(window: window, alliance: :blue, slot: 1, speed: 512, die_size: @size)
|
@ducks << Ducky.new(window: window, alliance: :blue, slot: 3, speed: 1010, die_size: @size, label: "Right")
|
||||||
@ducks << Ducky.new(window: window, alliance: :blue, slot: 2, speed: 512, die_size: @size)
|
@ducks << Ducky.new(window: window, alliance: :red, slot: 3, speed: 1010, die_size: @size, label: "Right")
|
||||||
@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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -121,14 +111,17 @@ module TAC
|
|||||||
SIZE = 0.20
|
SIZE = 0.20
|
||||||
HALF_SIZE = SIZE * 0.5
|
HALF_SIZE = SIZE * 0.5
|
||||||
|
|
||||||
def initialize(window:, alliance:, slot:, speed:, die_size:)
|
def initialize(window:, alliance:, slot:, speed:, die_size:, label:)
|
||||||
@window = window
|
@window = window
|
||||||
@alliance = alliance
|
@alliance = alliance
|
||||||
@slot = slot
|
@slot = slot
|
||||||
@speed = speed
|
@speed = speed
|
||||||
|
@die_size = die_size
|
||||||
|
@label = label
|
||||||
|
|
||||||
@image = @window.get_image("#{ROOT_PATH}/media/openclipart_ducky.png")
|
@image = @window.get_image("#{MEDIA_PATH}/openclipart_ducky.png")
|
||||||
@debug_text = Gosu::Font.new(28)
|
@debug_text = Gosu::Font.new(28)
|
||||||
|
@label_text = CyberarmEngine::Text.new(@label, static: true, size: 28, alignment: :center)
|
||||||
|
|
||||||
if @alliance == :blue
|
if @alliance == :blue
|
||||||
@position = CyberarmEngine::Vector.new(@window.width, die_size)
|
@position = CyberarmEngine::Vector.new(@window.width, die_size)
|
||||||
@@ -146,6 +139,10 @@ module TAC
|
|||||||
duck_scale = (size * (SIZE + HALF_SIZE)) / @image.width
|
duck_scale = (size * (SIZE + HALF_SIZE)) / @image.width
|
||||||
duck_scale_x = @alliance == :blue ? -duck_scale : duck_scale
|
duck_scale_x = @alliance == :blue ? -duck_scale : duck_scale
|
||||||
@image.draw_rot(slot_position(size), size * SIZE + float_y(size), 1, 0, 0.5, 0.5, duck_scale_x, duck_scale)
|
@image.draw_rot(slot_position(size), size * SIZE + float_y(size), 1, 0, 0.5, 0.5, duck_scale_x, duck_scale)
|
||||||
|
|
||||||
|
@label_text.x = slot_position(size) + (@alliance == :blue ? -170 : 110)
|
||||||
|
@label_text.y = float_y(size) + 52
|
||||||
|
@label_text.draw
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
@@ -146,48 +149,48 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
flow width: 1.0 do
|
flow width: 1.0 do
|
||||||
button get_image("#{ROOT_PATH}/media/icons/previous.png") do
|
button get_image("#{MEDIA_PATH}/icons/previous.png") do
|
||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_previous_track)
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_previous_track)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/right.png") do |button|
|
button get_image("#{MEDIA_PATH}/icons/right.png") do |button|
|
||||||
if @jukebox_playing
|
if @jukebox_playing
|
||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_pause)
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_pause)
|
||||||
button.value = get_image("#{ROOT_PATH}/media/icons/right.png")
|
button.value = get_image("#{MEDIA_PATH}/icons/right.png")
|
||||||
@jukebox_playing = false
|
@jukebox_playing = false
|
||||||
else
|
else
|
||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_play)
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_play)
|
||||||
button.value = get_image("#{ROOT_PATH}/media/icons/pause.png")
|
button.value = get_image("#{MEDIA_PATH}/icons/pause.png")
|
||||||
@jukebox_playing = true
|
@jukebox_playing = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/stop.png") do
|
button get_image("#{MEDIA_PATH}/icons/stop.png") do
|
||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_stop)
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_stop)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/next.png") do
|
button get_image("#{MEDIA_PATH}/icons/next.png") do
|
||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_next_track)
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_next_track)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/minus.png"), margin_left: 20 do
|
button get_image("#{MEDIA_PATH}/icons/minus.png"), margin_left: 20 do
|
||||||
@jukebox_volume -= 0.1
|
@jukebox_volume -= 0.1
|
||||||
@jukebox_volume = 0.1 if @jukebox_volume < 0.1
|
@jukebox_volume = 0.1 if @jukebox_volume < 0.1
|
||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_set_volume(@jukebox_volume))
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_set_volume(@jukebox_volume))
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/plus.png") do
|
button get_image("#{MEDIA_PATH}/icons/plus.png") do
|
||||||
@jukebox_volume += 0.1
|
@jukebox_volume += 0.1
|
||||||
@jukebox_volume = 1.0 if @jukebox_volume > 1.0
|
@jukebox_volume = 1.0 if @jukebox_volume > 1.0
|
||||||
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_set_volume(@jukebox_volume))
|
RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_set_volume(@jukebox_volume))
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/musicOn.png"), margin_left: 20, tip: "Toggle Sound Effects" do |button|
|
button get_image("#{MEDIA_PATH}/icons/musicOn.png"), margin_left: 20, tip: "Toggle Sound Effects" do |button|
|
||||||
if @jukebox_sound_effects
|
if @jukebox_sound_effects
|
||||||
button.value = get_image("#{ROOT_PATH}/media/icons/musicOff.png")
|
button.value = get_image("#{MEDIA_PATH}/icons/musicOff.png")
|
||||||
@jukebox_sound_effects = false
|
@jukebox_sound_effects = false
|
||||||
else
|
else
|
||||||
button.value = get_image("#{ROOT_PATH}/media/icons/musicOn.png")
|
button.value = get_image("#{MEDIA_PATH}/icons/musicOn.png")
|
||||||
@jukebox_sound_effects = true
|
@jukebox_sound_effects = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -196,12 +199,12 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
button "Open Music Library", width: 1.0 do
|
button "Open Music Library", width: 1.0 do
|
||||||
path = "#{ROOT_PATH}/media/music"
|
path = "#{MEDIA_PATH}/music"
|
||||||
|
|
||||||
if RUBY_PLATFORM.match(/ming|msys|cygwin/)
|
if RUBY_PLATFORM.match(/ming|msys|cygwin/)
|
||||||
system("explorer \"#{path.gsub("/", "\\")}\"")
|
system("explorer \"#{path.gsub("/", "\\")}\"")
|
||||||
elsif RUBY_PLATFORM.match(/linux/)
|
elsif RUBY_PLATFORM.match(/linux/)
|
||||||
system("xdg-open \"#{ROOT_PATH}/media/music\"")
|
system("xdg-open \"#{MEDIA_PATH}/music\"")
|
||||||
else
|
else
|
||||||
# TODO.
|
# TODO.
|
||||||
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
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module TAC
|
|||||||
class PracticeGameClock
|
class PracticeGameClock
|
||||||
THEME = {
|
THEME = {
|
||||||
TextBlock: {
|
TextBlock: {
|
||||||
font: "Canterell",
|
font: "NotoSans-Bold",
|
||||||
color: Gosu::Color.new(0xee_ffffff)
|
color: Gosu::Color.new(0xee_ffffff)
|
||||||
},
|
},
|
||||||
Button: {
|
Button: {
|
||||||
@@ -23,7 +23,7 @@ module TAC
|
|||||||
},
|
},
|
||||||
ToggleButton: {
|
ToggleButton: {
|
||||||
width: 18,
|
width: 18,
|
||||||
checkmark_image: "#{File.expand_path("..", __dir__)}/media/icons/checkmark.png",
|
checkmark_image: "#{MEDIA_PATH}/icons/checkmark.png",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ module TAC
|
|||||||
window.show_cursor = !@remote_control_mode
|
window.show_cursor = !@remote_control_mode
|
||||||
@escape_counter = 0
|
@escape_counter = 0
|
||||||
|
|
||||||
@background_image = get_image("#{ROOT_PATH}/media/background.png")
|
@background_image = get_image("#{MEDIA_PATH}/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("#{MEDIA_PATH}/openclipart_ducky.png")
|
||||||
@menu_background = 0xaa004000
|
@menu_background = 0xaa004000
|
||||||
@mouse = Mouse.new(window)
|
@mouse = Mouse.new(window)
|
||||||
@clock = Clock.new
|
@clock = Clock.new
|
||||||
@@ -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
|
||||||
|
|
||||||
@@ -84,62 +105,62 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
flow(width: 1.0) do
|
flow(width: 1.0) do
|
||||||
button get_image("#{ROOT_PATH}/media/icons/previous.png") do
|
button get_image("#{MEDIA_PATH}/icons/previous.png") do
|
||||||
@jukebox.previous_track
|
@jukebox.previous_track
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/pause.png") do |button|
|
button get_image("#{MEDIA_PATH}/icons/pause.png") do |button|
|
||||||
if @jukebox.song && @jukebox.song.paused?
|
if @jukebox.song && @jukebox.song.paused?
|
||||||
button.value = get_image("#{ROOT_PATH}/media/icons/right.png")
|
button.value = get_image("#{MEDIA_PATH}/icons/right.png")
|
||||||
@jukebox.play
|
@jukebox.play
|
||||||
elsif !@jukebox.song
|
elsif !@jukebox.song
|
||||||
button.value = get_image("#{ROOT_PATH}/media/icons/right.png")
|
button.value = get_image("#{MEDIA_PATH}/icons/right.png")
|
||||||
@jukebox.play
|
@jukebox.play
|
||||||
else
|
else
|
||||||
button.value = get_image("#{ROOT_PATH}/media/icons/pause.png")
|
button.value = get_image("#{MEDIA_PATH}/icons/pause.png")
|
||||||
@jukebox.pause
|
@jukebox.pause
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/stop.png") do
|
button get_image("#{MEDIA_PATH}/icons/stop.png") do
|
||||||
@jukebox.stop
|
@jukebox.stop
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/next.png") do
|
button get_image("#{MEDIA_PATH}/icons/next.png") do
|
||||||
@jukebox.next_track
|
@jukebox.next_track
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/minus.png"), margin_left: 20 do
|
button get_image("#{MEDIA_PATH}/icons/minus.png"), margin_left: 20 do
|
||||||
@jukebox.set_volume(@jukebox.volume - 0.1)
|
@jukebox.set_volume(@jukebox.volume - 0.1)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/plus.png") do
|
button get_image("#{MEDIA_PATH}/icons/plus.png") do
|
||||||
@jukebox.set_volume(@jukebox.volume + 0.1)
|
@jukebox.set_volume(@jukebox.volume + 0.1)
|
||||||
end
|
end
|
||||||
|
|
||||||
button "Open Music Library", margin_left: 50 do
|
button "Open Music Library", margin_left: 50 do
|
||||||
if RUBY_PLATFORM.match(/ming|msys|cygwin/)
|
if RUBY_PLATFORM.match(/ming|msys|cygwin/)
|
||||||
system("explorer #{ROOT_PATH}/media/music")
|
system("explorer #{MEDIA_PATH}/music")
|
||||||
elsif RUBY_PLATFORM.match(/linux/)
|
elsif RUBY_PLATFORM.match(/linux/)
|
||||||
system("xdg-open #{ROOT_PATH}/media/music")
|
system("xdg-open #{MEDIA_PATH}/music")
|
||||||
else
|
else
|
||||||
# TODO.
|
# TODO.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{ROOT_PATH}/media/icons/musicOn.png"), margin_left: 50, tip: "Toggle Sound Effects" do |button|
|
button get_image("#{MEDIA_PATH}/icons/musicOn.png"), margin_left: 50, tip: "Toggle Sound Effects" do |button|
|
||||||
boolean = @jukebox.set_sfx(!@jukebox.play_sfx?)
|
boolean = @jukebox.set_sfx(!@jukebox.play_sfx?)
|
||||||
|
|
||||||
if boolean
|
if boolean
|
||||||
button.value = get_image("#{ROOT_PATH}/media/icons/musicOn.png")
|
button.value = get_image("#{MEDIA_PATH}/icons/musicOn.png")
|
||||||
else
|
else
|
||||||
button.value = get_image("#{ROOT_PATH}/media/icons/musicOff.png")
|
button.value = get_image("#{MEDIA_PATH}/icons/musicOff.png")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module TAC
|
|||||||
header_bar("Manage Configurations")
|
header_bar("Manage Configurations")
|
||||||
|
|
||||||
menu_bar.clear do
|
menu_bar.clear do
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_height: 1.0, tip: "Add configuration" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/plus.png"), image_height: 1.0, tip: "Add configuration" do
|
||||||
push_state(Dialog::NamePromptDialog, title: "Config Name", callback_method: proc { |name|
|
push_state(Dialog::NamePromptDialog, title: "Config Name", callback_method: proc { |name|
|
||||||
window.backend.write_new_config(name)
|
window.backend.write_new_config(name)
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ module TAC
|
|||||||
|
|
||||||
button "Open Folder", tip: "Open folder containing configurations", height: 1.0 do
|
button "Open Folder", tip: "Open folder containing configurations", height: 1.0 do
|
||||||
if RUBY_PLATFORM =~ /mingw/
|
if RUBY_PLATFORM =~ /mingw/
|
||||||
system("start \"#{TAC::CONFIGS_PATH}\"")
|
system("explorer \"#{TAC::CONFIGS_PATH.gsub("/", "\\")}\"")
|
||||||
elsif RUBY_PLATFORM =~ /darwin/
|
elsif RUBY_PLATFORM =~ /darwin/
|
||||||
system("open \"#{TAC::CONFIGS_PATH}\"")
|
system("open \"#{TAC::CONFIGS_PATH}\"")
|
||||||
else
|
else
|
||||||
@@ -45,7 +45,7 @@ module TAC
|
|||||||
@config_files_list = @config_files.map { |file| Dialog::NamePromptDialog::NameStub.new(File.basename(file, ".json")) }
|
@config_files_list = @config_files.map { |file| Dialog::NamePromptDialog::NameStub.new(File.basename(file, ".json")) }
|
||||||
|
|
||||||
@configs_list.clear do
|
@configs_list.clear do
|
||||||
@config_files.each_with_index do |config_file, i|
|
@config_files.sort_by { |f| [f.downcase] }.each_with_index do |config_file, i|
|
||||||
flow width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING do
|
flow width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING do
|
||||||
name = File.basename(config_file, ".json")
|
name = File.basename(config_file, ".json")
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Rename configuration" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Rename configuration" do
|
||||||
push_state(Dialog::NamePromptDialog, title: "Rename Config", renaming: @config_files_list.find { |c| c.name == name }, list: @config_files_list, accept_label: "Update", callback_method: proc { |old_name, new_name|
|
push_state(Dialog::NamePromptDialog, title: "Rename Config", renaming: @config_files_list.find { |c| c.name == name }, list: @config_files_list, accept_label: "Update", callback_method: proc { |old_name, new_name|
|
||||||
if not File.exist?("#{TAC::CONFIGS_PATH}/#{new_name}.json")
|
if not File.exist?("#{TAC::CONFIGS_PATH}/#{new_name}.json")
|
||||||
FileUtils.mv(
|
FileUtils.mv(
|
||||||
@@ -79,7 +79,7 @@ module TAC
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, **THEME_DANGER_BUTTON, tip: "Delete configuration" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/trashcan.png"), image_width: THEME_ICON_SIZE, **THEME_DANGER_BUTTON, tip: "Delete configuration" do
|
||||||
push_state(Dialog::ConfirmDialog, title: "Delete Config?", dangerous: true, callback_method: proc {
|
push_state(Dialog::ConfirmDialog, title: "Delete Config?", dangerous: true, callback_method: proc {
|
||||||
File.delete("#{TAC::CONFIGS_PATH}/#{name}.json")
|
File.delete("#{TAC::CONFIGS_PATH}/#{name}.json")
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ module TAC
|
|||||||
@roster ||= [
|
@roster ||= [
|
||||||
"Aubrey",
|
"Aubrey",
|
||||||
"Cayden",
|
"Cayden",
|
||||||
|
"Connor",
|
||||||
|
"Ben",
|
||||||
"Dan",
|
"Dan",
|
||||||
"Gabe",
|
"Gabe",
|
||||||
"Spencer",
|
"Spencer",
|
||||||
"Sodi",
|
"Sodi"
|
||||||
"Trent"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@roles ||= [
|
@roles ||= [
|
||||||
@@ -24,7 +25,7 @@ module TAC
|
|||||||
]
|
]
|
||||||
|
|
||||||
menu_bar.clear do
|
menu_bar.clear do
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/save.png"), image_height: 1.0, tip: "Export rotation as Comma-Seperated Values" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/save.png"), image_height: 1.0, tip: "Export rotation as Comma-Seperated Values" do
|
||||||
export_rotation
|
export_rotation
|
||||||
|
|
||||||
@status_bar.clear do
|
@status_bar.clear do
|
||||||
@@ -44,7 +45,7 @@ module TAC
|
|||||||
|
|
||||||
flow(width: 1.0, height: 32, margin_bottom: 20) do
|
flow(width: 1.0, height: 32, margin_bottom: 20) do
|
||||||
@role_name = edit_line "", placeholder: "Add role", fill: true, height: 1.0
|
@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
|
button get_image("#{TAC::MEDIA_PATH}/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 = ""
|
||||||
@@ -63,7 +64,7 @@ module TAC
|
|||||||
|
|
||||||
flow(width: 1.0, height: 32, margin_bottom: 20) do
|
flow(width: 1.0, height: 32, margin_bottom: 20) do
|
||||||
@roster_name = edit_line "", placeholder: "Add name", height: 1.0, fill: true
|
@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
|
button get_image("#{TAC::MEDIA_PATH}/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 = ""
|
||||||
@@ -98,7 +99,7 @@ module TAC
|
|||||||
background i.even? ? 0xff_007000 : 0xff_006000
|
background i.even? ? 0xff_007000 : 0xff_006000
|
||||||
|
|
||||||
tagline name, fill: true
|
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
|
button get_image("#{TAC::MEDIA_PATH}/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
|
||||||
@@ -114,7 +115,7 @@ module TAC
|
|||||||
background i.even? ? 0xff_007000 : 0xff_006000
|
background i.even? ? 0xff_007000 : 0xff_006000
|
||||||
|
|
||||||
tagline name, fill: true
|
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
|
button get_image("#{TAC::MEDIA_PATH}/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
|
||||||
|
|||||||
@@ -6,6 +6,18 @@ module TAC
|
|||||||
@active_group = nil
|
@active_group = nil
|
||||||
@active_action = 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
|
menu_bar.clear do
|
||||||
if @options[:group_is_preset]
|
if @options[:group_is_preset]
|
||||||
title "Editing group preset: #{@options[:group].name}"
|
title "Editing group preset: #{@options[:group].name}"
|
||||||
@@ -34,11 +46,11 @@ module TAC
|
|||||||
@groups_menu = flow(width: 1.0, height: 36) do
|
@groups_menu = flow(width: 1.0, height: 36) do
|
||||||
label "Groups", text_size: THEME_SUBHEADING_TEXT_SIZE, fill: true, text_align: :center
|
label "Groups", 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 group" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add group" do
|
||||||
push_state(TAC::Dialog::NamePromptDialog, title: "Create Group", list: window.backend.config.groups, callback_method: method(:create_group))
|
push_state(TAC::Dialog::NamePromptDialog, title: "Create Group", list: window.backend.config.groups, callback_method: method(:create_group))
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/button2.png"), image_width: THEME_ICON_SIZE, tip: "Clone currently selected group" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/button2.png"), image_width: THEME_ICON_SIZE, tip: "Clone currently selected group" do
|
||||||
if @active_group
|
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|
|
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 = TAC::Config::Group.from_json( JSON.parse( @active_group.to_json, symbolize_names: true ))
|
||||||
@@ -47,14 +59,20 @@ module TAC
|
|||||||
window.backend.config.groups << clone
|
window.backend.config.groups << clone
|
||||||
window.backend.config_changed!
|
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
|
else
|
||||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to clone group, no group selected.")
|
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to clone group, no group selected.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/save.png"), image_width: THEME_ICON_SIZE, tip: "Save group as preset" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/save.png"), image_width: THEME_ICON_SIZE, tip: "Save group as preset" do
|
||||||
if @active_group
|
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|
|
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 = TAC::Config::Group.from_json( JSON.parse( @active_group.to_json, symbolize_names: true ))
|
||||||
@@ -71,7 +89,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/import.png"), image_width: THEME_ICON_SIZE, tip: "Import group from preset" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/import.png"), image_width: THEME_ICON_SIZE, tip: "Import group from preset" do
|
||||||
push_state(Dialog::PickPresetDialog, title: "Pick Group Preset", limit: :groups, callback_method: proc { |preset|
|
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|
|
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 = TAC::Config::Group.from_json( JSON.parse( group.to_json, symbolize_names: true ))
|
||||||
@@ -81,7 +99,13 @@ module TAC
|
|||||||
window.backend.config.groups.sort_by! { |g| g.name.downcase }
|
window.backend.config.groups.sort_by! { |g| g.name.downcase }
|
||||||
window.backend.config_changed!
|
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
|
end
|
||||||
@@ -95,7 +119,27 @@ module TAC
|
|||||||
@actions_menu = flow(width: 1.0, height: 36) do
|
@actions_menu = flow(width: 1.0, height: 36) do
|
||||||
label "Actions", text_size: THEME_SUBHEADING_TEXT_SIZE, fill: true, text_align: :center
|
label "Actions", 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 action" do
|
# TODO: Implement this
|
||||||
|
# button get_image("#{TAC::MEDIA_PATH}/icons/barsHorizontal.png"), image_width: THEME_ICON_SIZE, tip: "Auto renumber engine actions", margin_right: 16, enabled: false do
|
||||||
|
# end
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/up.png"), image_width: THEME_ICON_SIZE, tip: "Move selected action up (and its children, if holding SHIFT)" do
|
||||||
|
if @active_group && @active_action
|
||||||
|
shift_action(@active_action, :up)
|
||||||
|
else
|
||||||
|
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action, no action selected.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/down.png"), image_width: THEME_ICON_SIZE, tip: "Move selected action down (and its children, if holding SHIFT)" do
|
||||||
|
if @active_group && @active_action
|
||||||
|
shift_action(@active_action, :down)
|
||||||
|
else
|
||||||
|
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action, no action selected.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add action", margin_left: 16 do
|
||||||
if @active_group
|
if @active_group
|
||||||
push_state(TAC::Dialog::ActionDialog, title: "Create Action", list: @active_group.actions, callback_method: method(:create_action))
|
push_state(TAC::Dialog::ActionDialog, title: "Create Action", list: @active_group.actions, callback_method: method(:create_action))
|
||||||
else
|
else
|
||||||
@@ -103,7 +147,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/button2.png"), image_width: THEME_ICON_SIZE, tip: "Clone currently selected action" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/button2.png"), image_width: THEME_ICON_SIZE, tip: "Clone currently selected action" do
|
||||||
if @active_group && @active_action
|
if @active_group && @active_action
|
||||||
push_state(Dialog::ActionDialog, title: "Clone Action", action: @active_action, cloning: true, accept_label: "Clone", list: @active_group.actions, callback_method: proc { |action, name, comment|
|
push_state(Dialog::ActionDialog, title: "Clone Action", action: @active_action, cloning: true, accept_label: "Clone", list: @active_group.actions, callback_method: proc { |action, name, comment|
|
||||||
clone = TAC::Config::Action.from_json( JSON.parse( @active_action.to_json, symbolize_names: true ))
|
clone = TAC::Config::Action.from_json( JSON.parse( @active_action.to_json, symbolize_names: true ))
|
||||||
@@ -113,14 +157,20 @@ module TAC
|
|||||||
@active_group.actions << clone
|
@active_group.actions << clone
|
||||||
window.backend.config_changed!
|
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
|
else
|
||||||
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to clone action, no action selected.")
|
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to clone action, no action selected.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/save.png"), image_width: THEME_ICON_SIZE, tip: "Save action as preset" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/save.png"), image_width: THEME_ICON_SIZE, tip: "Save action as preset" do
|
||||||
if @active_action
|
if @active_action
|
||||||
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|
|
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 = TAC::Config::Action.from_json( JSON.parse( @active_action.to_json, symbolize_names: true ))
|
||||||
@@ -137,10 +187,10 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/import.png"), image_width: THEME_ICON_SIZE, tip: "Import action from preset" do
|
button get_image("#{TAC::MEDIA_PATH}/icons/import.png"), image_width: THEME_ICON_SIZE, tip: "Import action from preset" do
|
||||||
if @active_group
|
if @active_group
|
||||||
push_state(Dialog::PickPresetDialog, title: "Pick Action Preset", limit: :actions, callback_method: proc { |preset|
|
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, comment|
|
push_state(Dialog::ActionDialog, title: "Name Action", action: preset, cloning: true, 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 = TAC::Config::Action.from_json( JSON.parse( action.to_json, symbolize_names: true ))
|
||||||
clone.name = name.to_s
|
clone.name = name.to_s
|
||||||
clone.comment = comment.to_s
|
clone.comment = comment.to_s
|
||||||
@@ -150,7 +200,13 @@ module TAC
|
|||||||
@active_group.actions.sort_by! { |a| a.name.downcase }
|
@active_group.actions.sort_by! { |a| a.name.downcase }
|
||||||
window.backend.config_changed!
|
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
|
else
|
||||||
@@ -166,7 +222,7 @@ module TAC
|
|||||||
stack fill: true, height: 1.0, padding_left: 2, padding_right: 2 do
|
stack fill: true, height: 1.0, padding_left: 2, padding_right: 2 do
|
||||||
@variables_menu = flow(width: 1.0, height: 36) do
|
@variables_menu = flow(width: 1.0, height: 36) do
|
||||||
label "Variables", text_size: THEME_SUBHEADING_TEXT_SIZE, fill: true, text_align: :center
|
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
|
button get_image("#{TAC::MEDIA_PATH}/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add variable" do
|
||||||
if @active_action
|
if @active_action
|
||||||
push_state(TAC::Dialog::VariableDialog, title: "Create Variable", list: @active_action.variables, callback_method: method(:create_variable))
|
push_state(TAC::Dialog::VariableDialog, title: "Create Variable", list: @active_action.variables, callback_method: method(:create_variable))
|
||||||
else
|
else
|
||||||
@@ -189,20 +245,33 @@ module TAC
|
|||||||
@active_group = @options[:group]
|
@active_group = @options[:group]
|
||||||
@active_group_label.value = @active_group.name
|
@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_groups_list
|
||||||
populate_actions_list(@active_group)
|
populate_actions_list(@active_group)
|
||||||
|
populate_variables_list(@active_action) if @active_action
|
||||||
|
|
||||||
@groups_menu.hide
|
@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]
|
elsif @options[:action_is_preset]
|
||||||
@active_action = @options[:action]
|
@active_action = @options[:action]
|
||||||
@active_action_label.value = @active_action.name
|
@active_action_label.value = @active_action.name
|
||||||
|
|
||||||
populate_variables_list(@options[:action])
|
populate_variables_list(@active_action)
|
||||||
|
|
||||||
@groups_menu.hide
|
@groups_menu.hide
|
||||||
@actions_menu.hide
|
@actions_menu.hide
|
||||||
|
|
||||||
|
scroll_into_view(@active_action)
|
||||||
|
scroll_into_view(@options[:variable]) if @options[:variable]
|
||||||
|
|
||||||
else
|
else
|
||||||
if @options[:group]
|
if @options[:group]
|
||||||
populated_groups_list = true
|
populated_groups_list = true
|
||||||
@@ -213,6 +282,8 @@ module TAC
|
|||||||
populate_groups_list
|
populate_groups_list
|
||||||
populate_actions_list(@active_group) unless @options[:action]
|
populate_actions_list(@active_group) unless @options[:action]
|
||||||
|
|
||||||
|
scroll_into_view(@active_group)
|
||||||
|
|
||||||
if @options[:action]
|
if @options[:action]
|
||||||
@active_action = @options[:action]
|
@active_action = @options[:action]
|
||||||
@active_action_label.value = @active_action.name
|
@active_action_label.value = @active_action.name
|
||||||
@@ -221,9 +292,8 @@ module TAC
|
|||||||
|
|
||||||
populate_variables_list(@active_action)
|
populate_variables_list(@active_action)
|
||||||
|
|
||||||
if @options[:variable]
|
scroll_into_view(@active_action)
|
||||||
# Scroll into view?
|
scroll_into_view(@options[:variable]) if @options[:variable]
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -232,19 +302,38 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_group(name)
|
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.groups.sort_by! { |g| g.name.downcase }
|
||||||
window.backend.config_changed!
|
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
|
end
|
||||||
|
|
||||||
def update_group(group, name)
|
def update_group(group, name)
|
||||||
|
old_name = group.name
|
||||||
|
|
||||||
group.name = name
|
group.name = name
|
||||||
window.backend.config.groups.sort_by! { |g| g.name.downcase }
|
window.backend.config.groups.sort_by! { |g| g.name.downcase }
|
||||||
window.backend.config_changed!
|
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
|
end
|
||||||
|
|
||||||
def delete_group(group)
|
def delete_group(group)
|
||||||
@@ -261,24 +350,64 @@ module TAC
|
|||||||
@actions_list.clear
|
@actions_list.clear
|
||||||
@variables_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
|
end
|
||||||
|
|
||||||
def create_action(name, comment)
|
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 }
|
@active_group.actions.sort_by! { |a| a.name.downcase }
|
||||||
window.backend.config_changed!
|
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
|
end
|
||||||
|
|
||||||
def update_action(action, name, comment)
|
def update_action(action, name, comment)
|
||||||
|
old_name = action.name
|
||||||
|
|
||||||
action.name = name
|
action.name = name
|
||||||
action.comment = comment
|
action.comment = comment
|
||||||
@active_group.actions.sort_by! { |a| a.name.downcase }
|
@active_group.actions.sort_by! { |a| a.name.downcase }
|
||||||
window.backend.config_changed!
|
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
|
||||||
|
|
||||||
|
if action_is_child?(action)
|
||||||
|
action_container.style.default[:margin_left] = 72
|
||||||
|
else
|
||||||
|
action_container.style.default[:margin_left] = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
action_container.style.tag = name
|
||||||
|
|
||||||
|
update_list_children(@actions_list)
|
||||||
|
|
||||||
|
scroll_into_view(action)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_action(action)
|
def delete_action(action)
|
||||||
@@ -290,18 +419,32 @@ module TAC
|
|||||||
@active_action_label.value = ""
|
@active_action_label.value = ""
|
||||||
@variables_list.clear
|
@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
|
end
|
||||||
|
|
||||||
def create_variable(name, type, value)
|
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 }
|
@active_action.variables.sort_by! { |v| v.name.downcase }
|
||||||
window.backend.config_changed!
|
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
|
end
|
||||||
|
|
||||||
def update_variable(variable, name, type, value)
|
def update_variable(variable, name, type, value)
|
||||||
|
old_name = variable.name
|
||||||
|
|
||||||
variable.name = name
|
variable.name = name
|
||||||
variable.type = type
|
variable.type = type
|
||||||
variable.value = value
|
variable.value = value
|
||||||
@@ -310,7 +453,20 @@ module TAC
|
|||||||
|
|
||||||
window.backend.config_changed!
|
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
|
end
|
||||||
|
|
||||||
def delete_variable(variable)
|
def delete_variable(variable)
|
||||||
@@ -318,7 +474,48 @@ module TAC
|
|||||||
@active_action.variables.sort_by! { |v| v.name.downcase }
|
@active_action.variables.sort_by! { |v| v.name.downcase }
|
||||||
window.backend.config_changed!
|
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
|
end
|
||||||
|
|
||||||
def populate_groups_list
|
def populate_groups_list
|
||||||
@@ -331,35 +528,8 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
@groups_list.clear do
|
@groups_list.clear do
|
||||||
groups.each_with_index do |group, i|
|
groups.each do |group|
|
||||||
flow width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING do |container|
|
add_group_container(group)
|
||||||
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))
|
|
||||||
@active_group_container.style.default[:background] = old_i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
|
||||||
end
|
|
||||||
|
|
||||||
@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 = ""
|
|
||||||
|
|
||||||
populate_actions_list(group)
|
|
||||||
@variables_list.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group" do
|
|
||||||
push_state(Dialog::NamePromptDialog, title: "Rename Group", renaming: group, list: window.backend.config.groups, callback_method: method(:update_group))
|
|
||||||
end
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete group", **THEME_DANGER_BUTTON do
|
|
||||||
push_state(Dialog::ConfirmDialog, dangerous: true, title: "Are you sure?", message: "Delete group and all of its actions and variables?", callback_method: proc { delete_group(group) })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -370,46 +540,8 @@ module TAC
|
|||||||
actions = group.actions
|
actions = group.actions
|
||||||
|
|
||||||
@actions_list.clear do
|
@actions_list.clear do
|
||||||
actions.each_with_index do |action, i|
|
actions.each do |action|
|
||||||
stack width: 1.0, height: action.comment.empty? ? 36 : 72, **THEME_ITEM_CONTAINER_PADDING do |container|
|
add_action_container(action)
|
||||||
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
|
|
||||||
if (old_i = actions.index(@active_action))
|
|
||||||
@active_action_container.style.default[:background] = old_i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
|
||||||
end
|
|
||||||
|
|
||||||
@active_action = action
|
|
||||||
@active_action_container = container
|
|
||||||
@active_action_container.style.default[:background] = THEME_HIGHLIGHTED_COLOR
|
|
||||||
@active_action_label.value = action.name
|
|
||||||
|
|
||||||
populate_variables_list(action)
|
|
||||||
end
|
|
||||||
|
|
||||||
action_enabled_toggle = toggle_button tip: "Enable action", checked: action.enabled
|
|
||||||
action_enabled_toggle.subscribe(:changed) do |sender, value|
|
|
||||||
action.enabled = value
|
|
||||||
window.backend.config_changed!
|
|
||||||
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))
|
|
||||||
end
|
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete action", **THEME_DANGER_BUTTON do
|
|
||||||
push_state(Dialog::ConfirmDialog, dangerous: true, title: "Are you sure?", message: "Delete action and all of its variables?", callback_method: proc { delete_action(action) })
|
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -420,24 +552,317 @@ module TAC
|
|||||||
variables = action.variables
|
variables = action.variables
|
||||||
|
|
||||||
@variables_list.clear do
|
@variables_list.clear do
|
||||||
variables.each_with_index do |variable, i|
|
variables.each do |variable|
|
||||||
stack width: 1.0, height: 96, **THEME_ITEM_CONTAINER_PADDING do
|
add_variable_container(variable)
|
||||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
flow(width: 1.0, fill: true) do
|
def add_group_container(group)
|
||||||
button "#{variable.name}", fill: true, text_size: THEME_ICON_SIZE - 3, tip: "Edit variable" do
|
index = window.backend.config.groups.index(group)
|
||||||
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
|
flow width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING, tag: group.name do |container|
|
||||||
push_state(Dialog::ConfirmDialog, title: "Are you sure?", message: "Delete variable?", callback_method: proc { delete_variable(variable) })
|
background group == @active_group ? THEME_HIGHLIGHTED_COLOR : (index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR)
|
||||||
end
|
@active_group_container = container if group == @active_group
|
||||||
end
|
|
||||||
|
|
||||||
caption "Type: #{variable.type}"
|
button group.name, fill: true, text_size: THEME_ICON_SIZE - 3, tag: "label" do
|
||||||
caption "Value: #{variable.value}"
|
@active_group = group
|
||||||
|
@active_group_container = container
|
||||||
|
@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
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group" do
|
||||||
|
push_state(Dialog::NamePromptDialog, title: "Rename Group", renaming: group, list: window.backend.config.groups, callback_method: method(:update_group))
|
||||||
|
end
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete group", **THEME_DANGER_BUTTON do
|
||||||
|
push_state(Dialog::ConfirmDialog, dangerous: true, title: "Are you sure?", message: "Delete group and all of its actions and variables?", callback_method: proc { delete_group(group) })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_action_container(action)
|
||||||
|
index = @active_group.actions.index(action)
|
||||||
|
|
||||||
|
# Determine whether we should intent this action's container element because it is for a child state (i.e. 00-01)
|
||||||
|
indent = action_is_child?(action)
|
||||||
|
|
||||||
|
stack width: 1.0, height: action.comment.empty? ? 36 : 72, **THEME_ITEM_CONTAINER_PADDING, margin_left: indent ? 72 : 0, 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, tag: "label" do
|
||||||
|
@active_action = action
|
||||||
|
@active_action_container = container
|
||||||
|
@active_action_label.value = action.name
|
||||||
|
|
||||||
|
update_list_children(@actions_list)
|
||||||
|
|
||||||
|
populate_variables_list(action)
|
||||||
|
end
|
||||||
|
|
||||||
|
action_enabled_toggle = toggle_button tip: "Enable action", checked: action.enabled
|
||||||
|
action_enabled_toggle.subscribe(:changed) do |sender, value|
|
||||||
|
action.enabled = value
|
||||||
|
window.backend.config_changed!
|
||||||
|
end
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit action" do
|
||||||
|
push_state(Dialog::ActionDialog, title: "Edit Action", action: action, list: @active_group.actions, callback_method: method(:update_action))
|
||||||
|
end
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete action", **THEME_DANGER_BUTTON do
|
||||||
|
push_state(Dialog::ConfirmDialog, dangerous: true, title: "Are you sure?", message: "Delete action and all of its variables?", callback_method: proc { delete_action(action) })
|
||||||
end
|
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 add_variable_container(variable)
|
||||||
|
index = @active_action.variables.index(variable)
|
||||||
|
|
||||||
|
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", 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::MEDIA_PATH}/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete variable", **THEME_DANGER_BUTTON do
|
||||||
|
push_state(Dialog::ConfirmDialog, title: "Are you sure?", message: "Delete variable?", callback_method: proc { delete_variable(variable) })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
caption "Type: #{variable.type}", tag: "type", fill: true
|
||||||
|
caption "Value: #{variable.value}", tag: "value", fill: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def shift_action(action, direction)
|
||||||
|
# Determine whether this action is named as required for this operation
|
||||||
|
valid_name = valid_engine_action_name?(action)
|
||||||
|
am_child = action_is_child?(action)
|
||||||
|
index = @active_group.actions.index(action)
|
||||||
|
move_children = shift_down? # require that a SHIFT key is down when moving childen with their current parent to prevent undesired relocations.
|
||||||
|
|
||||||
|
unless valid_name
|
||||||
|
push_state(TAC::Dialog::AlertDialog, title: "Error", message: "Unable to shift action, incorrectly formated name.\nExpected: name to be like '00-00' not '#{action.name}'")
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
base_int = valid_name[0]
|
||||||
|
subbase_int = valid_name[1]
|
||||||
|
|
||||||
|
return if direction == :up && index.zero?
|
||||||
|
|
||||||
|
index_before = index - 1 >= 0 ? index - 1 : nil
|
||||||
|
index_next = index + 1 < @active_group.actions.size ? index + 1 : nil
|
||||||
|
|
||||||
|
mutated = false
|
||||||
|
|
||||||
|
case direction
|
||||||
|
when :up
|
||||||
|
if index_before
|
||||||
|
other = @active_group.actions[index_before]
|
||||||
|
other_is_child = action_is_child?(other)
|
||||||
|
|
||||||
|
i = index
|
||||||
|
|
||||||
|
while(other && ((!am_child && other_is_child) || (am_child && !other_is_child)))
|
||||||
|
i -= 1
|
||||||
|
index_before = i - 1 >= 0 ? i - 1 : nil
|
||||||
|
|
||||||
|
return unless index_before
|
||||||
|
return if am_child && valid_engine_action_name?(other).to_a[0].to_i != base_int
|
||||||
|
|
||||||
|
other = @active_group.actions[index_before]
|
||||||
|
other_is_child = action_is_child?(other)
|
||||||
|
end
|
||||||
|
|
||||||
|
move_child_actions(other, action) if move_children
|
||||||
|
swap_action(action, other)
|
||||||
|
mutated = true
|
||||||
|
end
|
||||||
|
when :down
|
||||||
|
if index_next
|
||||||
|
other = @active_group.actions[index_next]
|
||||||
|
other_is_child = action_is_child?(other)
|
||||||
|
|
||||||
|
i = index
|
||||||
|
|
||||||
|
while(other && ((!am_child && other_is_child) || (am_child && !other_is_child)))
|
||||||
|
i += 1
|
||||||
|
index_next = i + 1 < @active_group.actions.size ? i + 1 : nil
|
||||||
|
|
||||||
|
return unless index_next
|
||||||
|
return if am_child && valid_engine_action_name?(other).to_a[0].to_i != base_int
|
||||||
|
|
||||||
|
other = @active_group.actions[index_next]
|
||||||
|
other_is_child = action_is_child?(other)
|
||||||
|
end
|
||||||
|
|
||||||
|
move_child_actions(action, other) if move_children
|
||||||
|
swap_action(action, other)
|
||||||
|
mutated = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless mutated
|
||||||
|
|
||||||
|
@active_group.actions.sort_by! { |a| a.name.downcase }
|
||||||
|
|
||||||
|
window.backend.config_changed!
|
||||||
|
|
||||||
|
@active_action_label.value = action.name
|
||||||
|
|
||||||
|
update_list_children(@actions_list)
|
||||||
|
|
||||||
|
scroll_into_view(action)
|
||||||
|
end
|
||||||
|
|
||||||
|
def swap_action(action, other)
|
||||||
|
old_name = action.name
|
||||||
|
new_name = other.name
|
||||||
|
|
||||||
|
action.name = other.name
|
||||||
|
other.name = old_name
|
||||||
|
|
||||||
|
action_container = find_element_by_tag(@actions_list, old_name)
|
||||||
|
action_label = find_element_by_tag(action_container, "label")
|
||||||
|
|
||||||
|
other_container = find_element_by_tag(@actions_list, new_name)
|
||||||
|
other_label = find_element_by_tag(other_container, "label")
|
||||||
|
|
||||||
|
action_container.style.tag = action.name
|
||||||
|
other_container.style.tag = other.name
|
||||||
|
action_label.value = action.name
|
||||||
|
other_label.value = other.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def move_child_actions(action, other)
|
||||||
|
# Ordered: OTHER, ACTION
|
||||||
|
children = [select_child_actions(other), select_child_actions(action)]
|
||||||
|
|
||||||
|
[action, other].each_with_index do |a, i|
|
||||||
|
new_base_int, _new_subbase_int = valid_engine_action_name?(a)
|
||||||
|
|
||||||
|
children[i].each do |child|
|
||||||
|
child_base_int, child_subbase_int = valid_engine_action_name?(child)
|
||||||
|
|
||||||
|
# puts format("MOVING CHILD: #{child.name} (#{child.comment}) from %02d-00 to %02d-00", child_base_int, new_base_int)
|
||||||
|
new_name = format("%02d-%02d", new_base_int, child_subbase_int)
|
||||||
|
|
||||||
|
action_container = find_element_by_tag(@actions_list, child.name)
|
||||||
|
action_label = find_element_by_tag(action_container, "label")
|
||||||
|
|
||||||
|
action_container.style.tag = new_name
|
||||||
|
action_label.value = new_name
|
||||||
|
|
||||||
|
child.name = new_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def select_child_actions(action)
|
||||||
|
valid_name = valid_engine_action_name?(action)
|
||||||
|
|
||||||
|
@active_group.actions.select do |a|
|
||||||
|
child_base_int, _child_subbase_int = valid_engine_action_name?(a)
|
||||||
|
|
||||||
|
next unless child_base_int
|
||||||
|
|
||||||
|
child_base_int == valid_name[0] && action_is_child?(a)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def valid_engine_action_name?(action)
|
||||||
|
base, subbase = action.name.split("-", 2)
|
||||||
|
base_int = -1
|
||||||
|
subbase_int = -1
|
||||||
|
|
||||||
|
return false unless base && subbase
|
||||||
|
|
||||||
|
return false unless base.length == 2 && subbase.length == 2
|
||||||
|
|
||||||
|
# Work around bug in Ruby's `Integer("08")` parser
|
||||||
|
base = base[0] == "0" ? base[1] : base
|
||||||
|
subbase = subbase[0] == "0" ? subbase[1] : subbase
|
||||||
|
|
||||||
|
begin
|
||||||
|
base_int = Integer(base)
|
||||||
|
subbase_int = Integer(subbase)
|
||||||
|
rescue ArgumentError
|
||||||
|
base_int = -1
|
||||||
|
subbase_int = -1
|
||||||
|
end
|
||||||
|
|
||||||
|
return [base_int, subbase_int] if base_int >= 0 && subbase_int >= 0
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
def action_is_child?(action)
|
||||||
|
_base_int, subbase_int = valid_engine_action_name?(action)
|
||||||
|
|
||||||
|
return (subbase_int && subbase_int > 0) ? true : false
|
||||||
|
end
|
||||||
|
|
||||||
|
def draw
|
||||||
|
super
|
||||||
|
|
||||||
|
unless @highlight_animator.complete?
|
||||||
|
item = @highlight_item_container
|
||||||
|
|
||||||
|
Gosu.draw_rect(
|
||||||
|
item.x, item.y + (item&.parent&.scroll_top || 0),
|
||||||
|
item.width, item.height,
|
||||||
|
@highlight_animator.color_transition,
|
||||||
|
item.z + 1
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
super
|
||||||
|
|
||||||
|
current_state.request_repaint unless @highlight_animator.complete?
|
||||||
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -80,12 +80,15 @@ module TAC
|
|||||||
@segment_thickness = 2
|
@segment_thickness = 2
|
||||||
|
|
||||||
@font = CyberarmEngine::Text.new(font: THEME_BOLD_FONT, size: 18, border: true, static: true)
|
@font = CyberarmEngine::Text.new(font: THEME_BOLD_FONT, size: 18, border: true, static: true)
|
||||||
|
@last_mouse_position = CyberarmEngine::Vector.new(window.mouse_x, window.mouse_y)
|
||||||
|
|
||||||
measure_path
|
measure_path
|
||||||
refresh_panel
|
refresh_panel
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
|
super
|
||||||
|
|
||||||
@field.draw
|
@field.draw
|
||||||
|
|
||||||
display_path
|
display_path
|
||||||
@@ -105,15 +108,19 @@ module TAC
|
|||||||
@font.width + 12,
|
@font.width + 12,
|
||||||
@font.height + 12,
|
@font.height + 12,
|
||||||
0xaa_000000,
|
0xaa_000000,
|
||||||
100_000)
|
100_000
|
||||||
|
)
|
||||||
@font.draw
|
|
||||||
|
|
||||||
|
@font.draw
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
super
|
||||||
|
|
||||||
|
current_state.request_repaint if window.mouse_x != @last_mouse_position.x || window.mouse_y != @last_mouse_position.y
|
||||||
|
@last_mouse_position = CyberarmEngine::Vector.new(window.mouse_x, window.mouse_y)
|
||||||
|
|
||||||
@field.update
|
@field.update
|
||||||
|
|
||||||
measure_path
|
measure_path
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module TAC
|
|||||||
# Spawn game clock window
|
# Spawn game clock window
|
||||||
$clock_pid = Process.spawn(
|
$clock_pid = Process.spawn(
|
||||||
RbConfig.ruby,
|
RbConfig.ruby,
|
||||||
"#{ROOT_PATH}/timecrafters_configuration_tool.rb",
|
"#{MEDIA_PATH}/../timecrafters_configuration_tool.rb",
|
||||||
"--game-clock-remote-display"
|
"--game-clock-remote-display"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -19,82 +19,197 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@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
|
||||||
|
)
|
||||||
|
|
||||||
populate_group_presets
|
populate_group_presets
|
||||||
populate_action_presets
|
populate_action_presets
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def draw
|
||||||
|
super
|
||||||
|
|
||||||
|
unless @highlight_animator.complete?
|
||||||
|
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
|
||||||
|
|
||||||
|
current_state.request_repaint unless @highlight_animator.complete?
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
def update_list_children(list)
|
||||||
|
list.children.sort_by! { |i| i.style.tag.downcase }
|
||||||
|
|
||||||
|
list.children.each_with_index do |child, i|
|
||||||
|
child.style.default[:background] = i.even? ? THEME_EVEN_COLOR : THEME_ODD_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 = @group_presets
|
||||||
|
elsif item.is_a?(TAC::Config::Action)
|
||||||
|
list_container = @action_presets
|
||||||
|
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 add_group_container(group)
|
||||||
|
index = window.backend.config.presets.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
|
||||||
|
page(TAC::Pages::Editor, { group: group, group_is_preset: true })
|
||||||
|
end
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group" do
|
||||||
|
push_state(
|
||||||
|
Dialog::NamePromptDialog,
|
||||||
|
title: "Rename Group Preset",
|
||||||
|
renaming: group,
|
||||||
|
list: window.backend.config.presets.groups,
|
||||||
|
callback_method: method(:update_group_preset)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete group", **THEME_DANGER_BUTTON do
|
||||||
|
push_state(
|
||||||
|
Dialog::ConfirmDialog,
|
||||||
|
title: "Are you sure?",
|
||||||
|
message: "Delete group preset and all of its actions and variables?",
|
||||||
|
callback_method: proc { delete_group_preset(group) }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_action_container(action)
|
||||||
|
index = window.backend.config.presets.actions.index(action)
|
||||||
|
|
||||||
|
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, tag: "label" do
|
||||||
|
page(TAC::Pages::Editor, { action: action, action_is_preset: true })
|
||||||
|
end
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit action" do
|
||||||
|
push_state(
|
||||||
|
Dialog::ActionDialog,
|
||||||
|
title: "Edit Action Preset",
|
||||||
|
action: action,
|
||||||
|
list: window.backend.config.presets.actions,
|
||||||
|
callback_method: method(:update_action_preset)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
button get_image("#{TAC::MEDIA_PATH}/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete action", **THEME_DANGER_BUTTON do
|
||||||
|
push_state(
|
||||||
|
Dialog::ConfirmDialog,
|
||||||
|
title: "Are you sure?",
|
||||||
|
message: "Delete action preset and all of its actions and variables?",
|
||||||
|
callback_method: proc { delete_action_preset(action) }
|
||||||
|
)
|
||||||
|
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_group_presets
|
def populate_group_presets
|
||||||
@group_presets.clear do
|
@group_presets.clear do
|
||||||
window.backend.config.presets.groups.each_with_index do |group, i|
|
window.backend.config.presets.groups.each do |group|
|
||||||
flow(width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING) do
|
add_group_container(group)
|
||||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
|
||||||
|
|
||||||
button group.name, fill: true, text_size: THEME_ICON_SIZE - 3 do
|
|
||||||
page(TAC::Pages::Editor, { group: group, group_is_preset: true })
|
|
||||||
end
|
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group preset" do
|
|
||||||
push_state(
|
|
||||||
Dialog::NamePromptDialog,
|
|
||||||
title: "Rename Group Preset",
|
|
||||||
renaming: group,
|
|
||||||
list: window.backend.config.presets.groups,
|
|
||||||
callback_method: method(:update_group_preset)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete group preset", **THEME_DANGER_BUTTON do
|
|
||||||
push_state(
|
|
||||||
Dialog::ConfirmDialog,
|
|
||||||
title: "Are you sure?",
|
|
||||||
message: "Delete group preset and all of its actions and variables?",
|
|
||||||
callback_method: proc { delete_group_preset(group) }
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def populate_action_presets
|
def populate_action_presets
|
||||||
@action_presets.clear do
|
@action_presets.clear do
|
||||||
window.backend.config.presets.actions.each_with_index do |action, i|
|
window.backend.config.presets.actions.each do |action|
|
||||||
flow(width: 1.0, height: 36, **THEME_ITEM_CONTAINER_PADDING) do
|
add_action_container(action)
|
||||||
background i.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
|
||||||
|
|
||||||
button action.name, fill: true, text_size: THEME_ICON_SIZE - 3 do
|
|
||||||
page(TAC::Pages::Editor, { action: action, action_is_preset: true })
|
|
||||||
end
|
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit action preset" do
|
|
||||||
push_state(
|
|
||||||
Dialog::NamePromptDialog,
|
|
||||||
title: "Rename Action Preset",
|
|
||||||
renaming: action,
|
|
||||||
list: window.backend.config.presets.actions,
|
|
||||||
callback_method: method(:update_action_preset)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete action preset", **THEME_DANGER_BUTTON do
|
|
||||||
push_state(
|
|
||||||
Dialog::ConfirmDialog,
|
|
||||||
title: "Are you sure?",
|
|
||||||
message: "Delete action preset and all of its actions and variables?",
|
|
||||||
callback_method: proc { delete_action_preset(action) }
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_group_preset(group, name)
|
def update_group_preset(group, name)
|
||||||
|
old_name = group.name
|
||||||
|
|
||||||
group.name = name
|
group.name = name
|
||||||
window.backend.config.presets.groups.sort_by! { |g| g.name.downcase }
|
window.backend.config.presets.groups.sort_by! { |g| g.name.downcase }
|
||||||
window.backend.config_changed!
|
window.backend.config_changed!
|
||||||
|
|
||||||
populate_group_presets
|
group_container = find_element_by_tag(@group_presets, old_name)
|
||||||
|
label = find_element_by_tag(group_container, "label")
|
||||||
|
|
||||||
|
label.value = name
|
||||||
|
|
||||||
|
group_container.style.tag = name
|
||||||
|
|
||||||
|
update_list_children(@group_presets)
|
||||||
|
|
||||||
|
scroll_into_view(group)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_group_preset(group)
|
def delete_group_preset(group)
|
||||||
@@ -102,15 +217,42 @@ module TAC
|
|||||||
window.backend.config.presets.groups.sort_by! { |g| g.name.downcase }
|
window.backend.config.presets.groups.sort_by! { |g| g.name.downcase }
|
||||||
window.backend.config_changed!
|
window.backend.config_changed!
|
||||||
|
|
||||||
populate_group_presets
|
# Remove deleted action from list
|
||||||
|
container = find_element_by_tag(@group_presets, group.name)
|
||||||
|
@group_presets.remove(container)
|
||||||
|
|
||||||
|
update_list_children(@group_presets)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_action_preset(action, name)
|
def update_action_preset(action, name, comment)
|
||||||
|
old_name = action.name
|
||||||
|
|
||||||
action.name = name
|
action.name = name
|
||||||
|
action.comment = comment
|
||||||
window.backend.config.presets.actions.sort_by! { |a| a.name.downcase }
|
window.backend.config.presets.actions.sort_by! { |a| a.name.downcase }
|
||||||
window.backend.config_changed!
|
window.backend.config_changed!
|
||||||
|
|
||||||
populate_action_presets
|
action_container = find_element_by_tag(@action_presets, 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(@action_presets)
|
||||||
|
|
||||||
|
scroll_into_view(action)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_action_preset(action)
|
def delete_action_preset(action)
|
||||||
@@ -118,7 +260,11 @@ module TAC
|
|||||||
window.backend.config.presets.actions.sort_by! { |a| a.name.downcase }
|
window.backend.config.presets.actions.sort_by! { |a| a.name.downcase }
|
||||||
window.backend.config_changed!
|
window.backend.config_changed!
|
||||||
|
|
||||||
populate_action_presets
|
# Remove deleted action from list
|
||||||
|
container = find_element_by_tag(@action_presets, action.name)
|
||||||
|
@action_presets.remove(container)
|
||||||
|
|
||||||
|
update_list_children(@action_presets)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ module TAC
|
|||||||
|
|
||||||
menu_bar.clear do
|
menu_bar.clear do
|
||||||
search = edit_line "", fill: true, height: 1.0
|
search = edit_line "", fill: true, height: 1.0
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/zoom.png"), image_height: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/zoom.png"), image_height: 1.0 do
|
||||||
unless search.value.strip.empty?
|
unless search.value.strip.empty?
|
||||||
search_results = search_config(search.value.strip)
|
search_results = search_config(search.value.strip)
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ module TAC
|
|||||||
shared_index = 0
|
shared_index = 0
|
||||||
|
|
||||||
flow(width: 1.0, height: 1.0) do
|
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?
|
if search_results.groups.size.positive?
|
||||||
title "Groups"
|
title "Groups"
|
||||||
|
|
||||||
@@ -44,7 +44,9 @@ module TAC
|
|||||||
search_results.actions.each do |result|
|
search_results.actions.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
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 })
|
page(TAC::Pages::Editor, { group: result.group, action: result.action, is_search: true })
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -63,7 +65,9 @@ module TAC
|
|||||||
search_results.variables.each do |result|
|
search_results.variables.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
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 })
|
page(TAC::Pages::Editor, { group: result.group, action: result.action, variable: result.variable, is_search: true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -73,13 +77,14 @@ module TAC
|
|||||||
end
|
end
|
||||||
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?
|
if search_results.group_presets.size.positive?
|
||||||
title "Group Presets"
|
title "Group Presets"
|
||||||
|
|
||||||
search_results.group_presets.each do |result|
|
search_results.group_presets.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
||||||
|
|
||||||
button result.highlight(result.group.name), width: 1.0 do
|
button result.highlight(result.group.name), width: 1.0 do
|
||||||
page(TAC::Pages::Editor, { group: result.group, group_is_preset: true, is_search: true })
|
page(TAC::Pages::Editor, { group: result.group, group_is_preset: true, is_search: true })
|
||||||
end
|
end
|
||||||
@@ -95,7 +100,9 @@ module TAC
|
|||||||
search_results.action_presets.each do |result|
|
search_results.action_presets.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
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?
|
if result.group.nil?
|
||||||
page(TAC::Pages::Editor, { action: result.action, action_is_preset: true, is_search: true })
|
page(TAC::Pages::Editor, { action: result.action, action_is_preset: true, is_search: true })
|
||||||
else
|
else
|
||||||
@@ -118,7 +125,9 @@ module TAC
|
|||||||
search_results.variables_from_presets.each do |result|
|
search_results.variables_from_presets.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
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?
|
if result.group.nil?
|
||||||
page(TAC::Pages::Editor, { action: result.action, variable: result.variable, action_is_preset: true, is_search: true })
|
page(TAC::Pages::Editor, { action: result.action, variable: result.variable, action_is_preset: true, is_search: true })
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ module TAC
|
|||||||
header_bar("Simulator")
|
header_bar("Simulator")
|
||||||
|
|
||||||
menu_bar.clear do
|
menu_bar.clear do
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/right.png"), tip: "Run Simulation", image_height: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/right.png"), tip: "Run Simulation", image_height: 1.0 do
|
||||||
save_source
|
save_source
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@@ -19,11 +19,11 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/stop.png"), tip: "Stop Simulation", image_height: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/stop.png"), tip: "Stop Simulation", image_height: 1.0 do
|
||||||
@simulation.robots.each { |robot| robot.queue.clear } if @simulation
|
@simulation.robots.each { |robot| robot.queue.clear } if @simulation
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/save.png"), tip: "Save", image_height: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/save.png"), tip: "Save", image_height: 1.0 do
|
||||||
save_source
|
save_source
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
status_bar.clear do
|
status_bar.clear do
|
||||||
@tacnet_icon = image "#{TAC::ROOT_PATH}/media/icons/signal3.png", height: 26
|
@tacnet_icon = image "#{TAC::MEDIA_PATH}/icons/signal3.png", height: 26
|
||||||
@status_label = label "TACNET: Not Connected", text_size: 26
|
@status_label = label "TACNET: Not Connected", text_size: 26
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -336,6 +336,111 @@ module TAC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
###########################
|
||||||
|
### --- CENTERSTAGE --- ###
|
||||||
|
###########################
|
||||||
|
def draw_field_centerstage
|
||||||
|
# Corner TAPE
|
||||||
|
2.times do |i|
|
||||||
|
Gosu.rotate((i + 2) * 90.0, 72, 72) do
|
||||||
|
Gosu.draw_quad(
|
||||||
|
24 - 2, 0, i.odd? ? @red : @blue,
|
||||||
|
24, 0, i.odd? ? @red : @blue,
|
||||||
|
0, 24 - 2, i.odd? ? @red : @blue,
|
||||||
|
0, 24, i.odd? ? @red : @blue,
|
||||||
|
@z
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Backstage TAPE
|
||||||
|
# BLUE
|
||||||
|
Gosu.draw_rect(0, 22, 58.5, 2, @blue, @z)
|
||||||
|
Gosu.draw_quad(
|
||||||
|
72 - 2, 0, @blue,
|
||||||
|
72, 0, @blue,
|
||||||
|
58.5 - 2, 24, @blue,
|
||||||
|
58.5, 24, @blue,
|
||||||
|
@z
|
||||||
|
)
|
||||||
|
# RED
|
||||||
|
Gosu.draw_rect(@field_size, 22, -58.5, 2, @red, @z)
|
||||||
|
Gosu.draw_quad(
|
||||||
|
@field_size - (72 - 2), 0, @red,
|
||||||
|
@field_size - 72, 0, @red,
|
||||||
|
@field_size - (58.5 - 2), 24, @red,
|
||||||
|
@field_size - 58.5, 24, @red,
|
||||||
|
@z
|
||||||
|
)
|
||||||
|
|
||||||
|
# Backstage BACKDROP
|
||||||
|
Gosu.draw_rect(24, 0, 24, 11.25, 0xff_252525, @z)
|
||||||
|
Gosu.draw_rect(@field_size - 48, 0, 24, 11.25, 0xff_252525, @z)
|
||||||
|
|
||||||
|
# Pixel TAPE
|
||||||
|
7.times do |i|
|
||||||
|
next if i == 3 # skip 4th iteration; empty slot
|
||||||
|
|
||||||
|
# TAPE
|
||||||
|
Gosu.draw_rect(24 + 11.5 + (12 * i), @field_size - 6, 1, 6, 0xff_dddddd, @z)
|
||||||
|
# Pixel
|
||||||
|
Gosu.rotate(30, 24 + 12 + (12 * i), @field_size - 1.75) do
|
||||||
|
Gosu.draw_circle(24 + 12 + (12 * i), @field_size - 1.75, 2.25, 6, 0xff_ffffff, @z)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Spike marks TAPE
|
||||||
|
# BLUE
|
||||||
|
2.times do |r|
|
||||||
|
2.times do |i|
|
||||||
|
Gosu.rotate(r * 180, @field_size / 2, @field_size / 2 + 12) do
|
||||||
|
c = r.even? ? @blue : @red
|
||||||
|
Gosu.translate(0, i * 48) do
|
||||||
|
Gosu.draw_rect(35.5, @field_size / 2 - 1.5, 12, 1, c, @z)
|
||||||
|
Gosu.draw_rect(47.5 - 1, @field_size / 2 - 18, 1, 12, c, @z)
|
||||||
|
Gosu.draw_rect(35.5, @field_size / 2 - 23.5, 12, 1, c, @z)
|
||||||
|
# --- mark
|
||||||
|
Gosu.draw_rect(35.5 + 6, @field_size / 2 - 1.5, 0.125, 1, 0xff_000000, @z)
|
||||||
|
Gosu.draw_rect(47.5 - 1, @field_size / 2 - 18 + 6, 1, 0.125, 0xff_000000, @z)
|
||||||
|
Gosu.draw_rect(35.5 + 6, @field_size / 2 - 23.5, 0.125, 1, 0xff_000000, @z)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Trusses
|
||||||
|
Gosu.draw_rect(0, @field_size / 2 - 2, 2, 28, 0xff_656565, @z)
|
||||||
|
Gosu.draw_rect(23, @field_size / 2 - 2, 2, 28, 0xff_656565, @z)
|
||||||
|
Gosu.draw_rect(47, @field_size / 2 - 2, 2, 28, 0xff_656565, @z)
|
||||||
|
Gosu.draw_rect(@field_size / 2 + 24 + -1, @field_size / 2 - 2, 2, 28, 0xff_656565, @z)
|
||||||
|
Gosu.draw_rect(@field_size / 2 + 24 + 23, @field_size / 2 - 2, 2, 28, 0xff_656565, @z)
|
||||||
|
Gosu.draw_rect(@field_size / 2 + 24 + 46, @field_size / 2 - 2, 2, 28, 0xff_656565, @z)
|
||||||
|
|
||||||
|
# Crossbeams
|
||||||
|
# BLUE
|
||||||
|
Gosu.draw_rect(0, @field_size / 2 + 12 + 2, 26, 2, @blue, @z)
|
||||||
|
Gosu.draw_rect(24, @field_size / 2 + 12 - 1, 24, 2, @blue, @z)
|
||||||
|
# YELLOW
|
||||||
|
# --- Blue
|
||||||
|
Gosu.draw_rect(0, @field_size / 2 + 2, 25, 1, @soft_orange, @z)
|
||||||
|
Gosu.draw_rect(23, @field_size / 2 + 21, 26, 1, @soft_orange, @z)
|
||||||
|
# --- Middle
|
||||||
|
Gosu.draw_rect(24 + 24, @field_size / 2 + 2, 48, 1, @soft_orange, @z)
|
||||||
|
Gosu.draw_rect(24 + 24, @field_size / 2 + 12 - 0.5, 48, 1, @soft_orange, @z)
|
||||||
|
Gosu.draw_rect(24 + 24, @field_size / 2 + 12 - 0.5, 48, 1, @soft_orange, @z)
|
||||||
|
# --- --- parallel beams
|
||||||
|
Gosu.draw_rect(24 + 28, @field_size / 2 + 2, 1, 10, @soft_orange, @z)
|
||||||
|
Gosu.draw_rect(@field_size / 2, @field_size / 2 + 2, 1, 10, @soft_orange, @z)
|
||||||
|
Gosu.draw_rect(24 + 72 - 4, @field_size / 2 + 2, 1, 10, @soft_orange, @z)
|
||||||
|
# --- Red
|
||||||
|
Gosu.draw_rect(47 + 72, @field_size / 2 + 2, 25, 1, @soft_orange, @z)
|
||||||
|
Gosu.draw_rect(23 + 72, @field_size / 2 + 21, 26, 1, @soft_orange, @z)
|
||||||
|
# RED
|
||||||
|
Gosu.draw_rect(24 + 72, @field_size / 2 + 12 - 1, 24, 2, @red, @z)
|
||||||
|
Gosu.draw_rect(46 + 72, @field_size / 2 + 12 + 2, 26, 2, @red, @z)
|
||||||
|
|
||||||
|
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
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
@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)
|
@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")
|
@logo = Gosu::Image.new("#{TAC::MEDIA_PATH}/logo.png")
|
||||||
|
|
||||||
@title_animator = CyberarmEngine::Animator.new(start_time: Gosu.milliseconds + 0, duration: 750, from: 0.0, to: 1.0, tween: :swing_from_to)
|
@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)
|
@logo_animator = CyberarmEngine::Animator.new(start_time: Gosu.milliseconds + 750, duration: 1_000, from: 0.0, to: 1.0, tween: :swing_to)
|
||||||
@@ -46,6 +46,7 @@ module TAC
|
|||||||
def button_down(id)
|
def button_down(id)
|
||||||
super
|
super
|
||||||
|
|
||||||
|
pop_state
|
||||||
push_state(@next_state)
|
push_state(@next_state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,15 +39,15 @@ class Editor < CyberarmEngine::GuiState
|
|||||||
@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
|
@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(width: 36 * 3, 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
|
button get_image("#{TAC::MEDIA_PATH}/icons/minus.png"), tip: "Minimize", image_height: 1.0 do
|
||||||
window.minimize if window.respond_to?(:minimize)
|
window.minimize if window.respond_to?(:minimize)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/larger.png"), tip: "Maximize", image_height: 1.0 do |btn|
|
button get_image("#{TAC::MEDIA_PATH}/icons/larger.png"), tip: "Maximize", image_height: 1.0 do |btn|
|
||||||
window.maximize if window.respond_to?(:maximize)
|
window.maximize if window.respond_to?(:maximize)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/cross.png"), tip: "Exit", image_height: 1.0, **TAC::THEME_DANGER_BUTTON do
|
button get_image("#{TAC::MEDIA_PATH}/icons/cross.png"), tip: "Exit", image_height: 1.0, **TAC::THEME_DANGER_BUTTON do
|
||||||
window.close
|
window.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -57,27 +57,27 @@ class Editor < CyberarmEngine::GuiState
|
|||||||
@navigation = stack(width: 64, height: 1.0, scroll: true) do
|
@navigation = stack(width: 64, height: 1.0, scroll: true) do
|
||||||
background 0xff_333333
|
background 0xff_333333
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/home.png"), margin: 4, tip: "Home", image_width: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/home.png"), margin: 4, tip: "Home", image_width: 1.0 do
|
||||||
page(TAC::Pages::Home)
|
page(TAC::Pages::Home)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/menuList.png"), margin: 4, tip: "Editor", image_width: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/menuList.png"), margin: 4, tip: "Editor", image_width: 1.0 do
|
||||||
page(TAC::Pages::Editor)
|
page(TAC::Pages::Editor)
|
||||||
end
|
end
|
||||||
|
|
||||||
@tacnet_button = button get_image("#{TAC::ROOT_PATH}/media/icons/signal3.png"), margin: 4, tip: "TACNET", image_width: 1.0 do
|
@tacnet_button = button get_image("#{TAC::MEDIA_PATH}/icons/signal3.png"), margin: 4, tip: "TACNET", image_width: 1.0 do
|
||||||
page(TAC::Pages::TACNET)
|
page(TAC::Pages::TACNET)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), margin: 4, tip: "Configurations", image_width: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/gear.png"), margin: 4, tip: "Configurations", image_width: 1.0 do
|
||||||
page(TAC::Pages::Configurations)
|
page(TAC::Pages::Configurations)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/menuGrid.png"), margin: 4, tip: "Presets", image_width: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/menuGrid.png"), margin: 4, tip: "Presets", image_width: 1.0 do
|
||||||
page(TAC::Pages::Presets)
|
page(TAC::Pages::Presets)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/zoom.png"), margin: 4, tip: "Search", image_width: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/zoom.png"), margin: 4, tip: "Search", image_width: 1.0 do
|
||||||
page(TAC::Pages::Search)
|
page(TAC::Pages::Search)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -86,23 +86,23 @@ class Editor < CyberarmEngine::GuiState
|
|||||||
para "Tools", width: 1.0, text_align: :center
|
para "Tools", width: 1.0, text_align: :center
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/right.png"), margin: 4, tip: "Simulator", image_width: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/right.png"), margin: 4, tip: "Simulator", image_width: 1.0 do
|
||||||
page(TAC::Pages::Simulator)
|
page(TAC::Pages::Simulator)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/joystickLeft.png"), margin: 4, tip: "Field Planner", image_width: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/joystickLeft.png"), margin: 4, tip: "Field Planner", image_width: 1.0 do
|
||||||
page(TAC::Pages::FieldPlanner)
|
page(TAC::Pages::FieldPlanner)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/massiveMultiplayer.png"), margin: 4, tip: "Drive Team Rotation Generator", image_width: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/massiveMultiplayer.png"), margin: 4, tip: "Drive Team Rotation Generator", image_width: 1.0 do
|
||||||
page(TAC::Pages::DriveTeamRotationGenerator)
|
page(TAC::Pages::DriveTeamRotationGenerator)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/custom_stopWatch.png"), margin: 4, tip: "Game Clock", image_width: 1.0 do
|
button get_image("#{TAC::MEDIA_PATH}/icons/custom_stopWatch.png"), margin: 4, tip: "Game Clock", image_width: 1.0 do
|
||||||
page(TAC::Pages::GameClock)
|
page(TAC::Pages::GameClock)
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{TAC::ROOT_PATH}/media/icons/power.png"), margin: 4, tip: "Exit", image_width: 1.0, **TAC::THEME_DANGER_BUTTON do
|
button get_image("#{TAC::MEDIA_PATH}/icons/power.png"), margin: 4, tip: "Exit", image_width: 1.0, **TAC::THEME_DANGER_BUTTON do
|
||||||
window.close
|
window.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
module TAC
|
module TAC
|
||||||
ROOT_PATH = File.expand_path("../..", __FILE__)
|
if ARGV.join.include?("--dev")
|
||||||
|
ROOT_PATH = File.expand_path("../..", __FILE__)
|
||||||
|
else
|
||||||
|
ROOT_PATH = "#{Dir.home}/TimeCrafters_Configuration_Tool"
|
||||||
|
end
|
||||||
CONFIGS_PATH = "#{ROOT_PATH}/data/configs"
|
CONFIGS_PATH = "#{ROOT_PATH}/data/configs"
|
||||||
SETTINGS_PATH = "#{ROOT_PATH}/data/settings.json"
|
SETTINGS_PATH = "#{ROOT_PATH}/data/settings.json"
|
||||||
|
|
||||||
|
MEDIA_PATH = "#{File.expand_path("../..", __FILE__)}/media"
|
||||||
|
|
||||||
CONFIG_SPEC_VERSION = 2
|
CONFIG_SPEC_VERSION = 2
|
||||||
end
|
end
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
module TAC
|
module TAC
|
||||||
THEME_FONT = "#{TAC::ROOT_PATH}/media/fonts/NotoSans-Bold.ttf"
|
THEME_FONT = "#{TAC::MEDIA_PATH}/fonts/NotoSans-Bold.ttf"
|
||||||
THEME_BOLD_FONT = "#{TAC::ROOT_PATH}/media/fonts/NotoSans-Black.ttf"
|
THEME_BOLD_FONT = "#{TAC::MEDIA_PATH}/fonts/NotoSans-Black.ttf"
|
||||||
THEME = {
|
THEME = {
|
||||||
TextBlock: {
|
TextBlock: {
|
||||||
text_static: true,
|
text_static: true,
|
||||||
@@ -27,7 +27,7 @@ module TAC
|
|||||||
},
|
},
|
||||||
ToggleButton: {
|
ToggleButton: {
|
||||||
width: 18,
|
width: 18,
|
||||||
checkmark_image: "#{TAC::ROOT_PATH}/media/icons/checkmark.png",
|
checkmark_image: "#{TAC::MEDIA_PATH}/icons/checkmark.png",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
module TAC
|
module TAC
|
||||||
NAME = "TimeCrafters Configuration Tool"
|
NAME = "TimeCrafters Configuration Tool"
|
||||||
VERSION = "0.6.0"
|
RELEASE_DATE = "2024-01-19" # ISO 8601 Date of version release
|
||||||
RELEASE_NAME = "Beta"
|
VERSION = "0.8.0"
|
||||||
|
RELEASE_NAME = "BETA"
|
||||||
end
|
end
|
||||||
@@ -5,9 +5,9 @@ module TAC
|
|||||||
def initialize(**args)
|
def initialize(**args)
|
||||||
super(**args)
|
super(**args)
|
||||||
|
|
||||||
self.caption = "#{TAC::NAME} v#{TAC::VERSION} (#{TAC::RELEASE_NAME})"
|
self.caption = "#{TAC::NAME} v#{TAC::VERSION} (#{TAC::RELEASE_NAME}) [#{TAC::RELEASE_DATE}]"
|
||||||
@backend = Backend.new
|
@backend = Backend.new
|
||||||
@notification_manager = GosuNotifications::NotificationManager.new(window: self, edge: :bottom)
|
@notification_manager = CyberarmEngine::NotificationManager.new(window: self, edge: :bottom)
|
||||||
|
|
||||||
if ARGV.join.include?("--game-clock-remote-display")
|
if ARGV.join.include?("--game-clock-remote-display")
|
||||||
push_state(PracticeGameClock::View, remote_control_mode: true)
|
push_state(PracticeGameClock::View, remote_control_mode: true)
|
||||||
@@ -26,9 +26,9 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
super
|
|
||||||
|
|
||||||
@notification_manager.update
|
@notification_manager.update
|
||||||
|
|
||||||
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def needs_redraw?
|
def needs_redraw?
|
||||||
@@ -37,7 +37,7 @@ module TAC
|
|||||||
|
|
||||||
def toast(title, message = nil)
|
def toast(title, message = nil)
|
||||||
@notification_manager.create_notification(
|
@notification_manager.create_notification(
|
||||||
priority: GosuNotifications::Notification::PRIORITY_HIGH,
|
priority: CyberarmEngine::Notification::PRIORITY_HIGH,
|
||||||
title: title,
|
title: title,
|
||||||
|
|
||||||
tagline: message ? message : "",
|
tagline: message ? message : "",
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
begin
|
begin
|
||||||
raise LoadError if defined?(Ocra)
|
raise LoadError if defined?(Ocra) || defined?(Ocran)
|
||||||
require_relative "../cyberarm_engine/lib/cyberarm_engine"
|
require_relative "../cyberarm_engine/lib/cyberarm_engine"
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
require "cyberarm_engine"
|
require "cyberarm_engine"
|
||||||
end
|
end
|
||||||
require "gosu_notifications"
|
|
||||||
require "socket"
|
require "socket"
|
||||||
require "securerandom"
|
require "securerandom"
|
||||||
require "json"
|
require "json"
|
||||||
@@ -74,7 +73,7 @@ require_relative "lib/game_clock/net/packet"
|
|||||||
USE_REDESIGN = ARGV.include?("--redesign")
|
USE_REDESIGN = ARGV.include?("--redesign")
|
||||||
BORDERLESS = ARGV.include?("--borderless")
|
BORDERLESS = ARGV.include?("--borderless")
|
||||||
|
|
||||||
if not defined?(Ocra)
|
unless defined?(Ocra) || defined?(Ocran)
|
||||||
TAC::Window.new(width: (Gosu.screen_width * 0.8).round, height: (Gosu.screen_height * 0.8).round, resizable: true, borderless: BORDERLESS).show
|
TAC::Window.new(width: (Gosu.screen_width * 0.8).round, height: (Gosu.screen_height * 0.8).round, resizable: true, borderless: BORDERLESS).show
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user