diff --git a/lib/backend.rb b/lib/backend.rb index 381e96c..14ec238 100644 --- a/lib/backend.rb +++ b/lib/backend.rb @@ -2,6 +2,8 @@ module TAC class Backend attr_reader :config, :settings, :tacnet def initialize + create_directories + load_settings load_config(@settings.config) if @settings.config && File.exist?("#{TAC::CONFIGS_PATH}/#{@settings.config}.json") @tacnet = TACNET.new @@ -113,6 +115,12 @@ module TAC @settings_changed 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 if File.exist?(TAC::SETTINGS_PATH) @settings = TAC::Settings.new diff --git a/lib/dialog.rb b/lib/dialog.rb index 1d6ef0b..551ac91 100644 --- a/lib/dialog.rb +++ b/lib/dialog.rb @@ -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 - 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 end end diff --git a/lib/dialogs/tacnet_dialog.rb b/lib/dialogs/tacnet_dialog.rb index b291934..2e87bd3 100644 --- a/lib/dialogs/tacnet_dialog.rb +++ b/lib/dialogs/tacnet_dialog.rb @@ -8,7 +8,7 @@ module TAC background Gosu::Color::GRAY 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 try_commit diff --git a/lib/game_clock/event_handlers.rb b/lib/game_clock/event_handlers.rb index 522c966..e328464 100644 --- a/lib/game_clock/event_handlers.rb +++ b/lib/game_clock/event_handlers.rb @@ -62,26 +62,26 @@ module TAC path = nil case sound when :autonomous_countdown - path = "media/sounds/3-2-1.wav" + path = "sounds/3-2-1.wav" when :autonomous_start - path = "media/sounds/charge.wav" + path = "sounds/charge.wav" when :autonomous_ended - path = "media/sounds/endauto.wav" + path = "sounds/endauto.wav" when :teleop_pickup_controllers - path = "media/sounds/Pick_Up_Controllers.wav" + path = "sounds/Pick_Up_Controllers.wav" when :abort_match - path = "media/sounds/fogblast.wav" + path = "sounds/fogblast.wav" when :teleop_countdown - path = "media/sounds/3-2-1.wav" + path = "sounds/3-2-1.wav" when :teleop_started - path = "media/sounds/firebell.wav" + path = "sounds/firebell.wav" when :end_game - path = "media/sounds/factwhistle.wav" + path = "sounds/factwhistle.wav" when :end_match - path = "media/sounds/endmatch.wav" + path = "sounds/endmatch.wav" end - path = "#{ROOT_PATH}/#{path}" + path = "#{MEDIA_PATH}/#{path}" if path && File.exist?(path) && !File.directory?(path) Jukebox::SAMPLES[path] = Gosu::Sample.new(path) unless Jukebox::SAMPLES[path].is_a?(Gosu::Sample) diff --git a/lib/game_clock/jukebox.rb b/lib/game_clock/jukebox.rb index 8477503..1f6db0a 100644 --- a/lib/game_clock/jukebox.rb +++ b/lib/game_clock/jukebox.rb @@ -1,11 +1,11 @@ module TAC class PracticeGameClock class Jukebox - MUSIC = Dir.glob(ROOT_PATH + "/media/music/*.*").freeze + MUSIC = Dir.glob(MEDIA_PATH + "/music/*.*").freeze SAMPLES = {} - if File.exist?(ROOT_PATH + "/media/sounds/skystone") - BEEPS_AND_BOOPS = Dir.glob(ROOT_PATH + "/media/sounds/skystone/*.*").freeze + if File.exist?(MEDIA_PATH + "/sounds/skystone") + BEEPS_AND_BOOPS = Dir.glob(MEDIA_PATH + "/sounds/skystone/*.*").freeze end attr_reader :volume, :now_playing diff --git a/lib/game_clock/particle_emitter.rb b/lib/game_clock/particle_emitter.rb index 9adf37c..1fb1e03 100644 --- a/lib/game_clock/particle_emitter.rb +++ b/lib/game_clock/particle_emitter.rb @@ -8,7 +8,7 @@ module TAC @z = -2 @particles = [] - @image_options = Dir.glob("#{ROOT_PATH}/media/particles/*.*") + @image_options = Dir.glob("#{MEDIA_PATH}/particles/*.*") @last_spawned = 0 @clock_active = false end diff --git a/lib/game_clock/randomizer.rb b/lib/game_clock/randomizer.rb index c76926b..a3d6252 100644 --- a/lib/game_clock/randomizer.rb +++ b/lib/game_clock/randomizer.rb @@ -119,7 +119,7 @@ module TAC @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) @label_text = CyberarmEngine::Text.new(@label, static: true, size: 28, alignment: :center) diff --git a/lib/game_clock/remote_control.rb b/lib/game_clock/remote_control.rb index fbb02a4..9abff20 100644 --- a/lib/game_clock/remote_control.rb +++ b/lib/game_clock/remote_control.rb @@ -149,48 +149,48 @@ module TAC end 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) 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 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 else 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 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) 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) 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 if @jukebox_volume < 0.1 RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_set_volume(@jukebox_volume)) 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 = 1.0 if @jukebox_volume > 1.0 RemoteControl.connection.puts(ClockNet::PacketHandler.packet_jukebox_set_volume(@jukebox_volume)) 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 - button.value = get_image("#{ROOT_PATH}/media/icons/musicOff.png") + button.value = get_image("#{MEDIA_PATH}/icons/musicOff.png") @jukebox_sound_effects = false else - button.value = get_image("#{ROOT_PATH}/media/icons/musicOn.png") + button.value = get_image("#{MEDIA_PATH}/icons/musicOn.png") @jukebox_sound_effects = true end @@ -199,12 +199,12 @@ module TAC end button "Open Music Library", width: 1.0 do - path = "#{ROOT_PATH}/media/music" + path = "#{MEDIA_PATH}/music" if RUBY_PLATFORM.match(/ming|msys|cygwin/) system("explorer \"#{path.gsub("/", "\\")}\"") elsif RUBY_PLATFORM.match(/linux/) - system("xdg-open \"#{ROOT_PATH}/media/music\"") + system("xdg-open \"#{MEDIA_PATH}/music\"") else # TODO. end diff --git a/lib/game_clock/theme.rb b/lib/game_clock/theme.rb index be9242a..4f074d2 100644 --- a/lib/game_clock/theme.rb +++ b/lib/game_clock/theme.rb @@ -2,7 +2,7 @@ module TAC class PracticeGameClock THEME = { TextBlock: { - font: "Canterell", + font: "NotoSans-Bold", color: Gosu::Color.new(0xee_ffffff) }, Button: { @@ -23,7 +23,7 @@ module TAC }, ToggleButton: { width: 18, - checkmark_image: "#{File.expand_path("..", __dir__)}/media/icons/checkmark.png", + checkmark_image: "#{MEDIA_PATH}/icons/checkmark.png", } } end diff --git a/lib/game_clock/view.rb b/lib/game_clock/view.rb index 249d59e..7cc0e97 100644 --- a/lib/game_clock/view.rb +++ b/lib/game_clock/view.rb @@ -9,9 +9,9 @@ module TAC window.show_cursor = !@remote_control_mode @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) - get_image("#{ROOT_PATH}/media/openclipart_ducky.png") + get_image("#{MEDIA_PATH}/openclipart_ducky.png") @menu_background = 0xaa004000 @mouse = Mouse.new(window) @clock = Clock.new @@ -105,56 +105,56 @@ module TAC end 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 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? - button.value = get_image("#{ROOT_PATH}/media/icons/right.png") + button.value = get_image("#{MEDIA_PATH}/icons/right.png") @jukebox.play elsif !@jukebox.song - button.value = get_image("#{ROOT_PATH}/media/icons/right.png") + button.value = get_image("#{MEDIA_PATH}/icons/right.png") @jukebox.play else - button.value = get_image("#{ROOT_PATH}/media/icons/pause.png") + button.value = get_image("#{MEDIA_PATH}/icons/pause.png") @jukebox.pause end end - button get_image("#{ROOT_PATH}/media/icons/stop.png") do + button get_image("#{MEDIA_PATH}/icons/stop.png") do @jukebox.stop end - button get_image("#{ROOT_PATH}/media/icons/next.png") do + button get_image("#{MEDIA_PATH}/icons/next.png") do @jukebox.next_track 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) 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) end button "Open Music Library", margin_left: 50 do if RUBY_PLATFORM.match(/ming|msys|cygwin/) - system("explorer #{ROOT_PATH}/media/music") + system("explorer #{MEDIA_PATH}/music") elsif RUBY_PLATFORM.match(/linux/) - system("xdg-open #{ROOT_PATH}/media/music") + system("xdg-open #{MEDIA_PATH}/music") else # TODO. 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?) if boolean - button.value = get_image("#{ROOT_PATH}/media/icons/musicOn.png") + button.value = get_image("#{MEDIA_PATH}/icons/musicOn.png") else - button.value = get_image("#{ROOT_PATH}/media/icons/musicOff.png") + button.value = get_image("#{MEDIA_PATH}/icons/musicOff.png") end end end diff --git a/lib/pages/configurations.rb b/lib/pages/configurations.rb index 36cdd55..2ef47b6 100644 --- a/lib/pages/configurations.rb +++ b/lib/pages/configurations.rb @@ -5,7 +5,7 @@ module TAC header_bar("Manage Configurations") 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| window.backend.write_new_config(name) @@ -60,7 +60,7 @@ module TAC 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| if not File.exist?("#{TAC::CONFIGS_PATH}/#{new_name}.json") FileUtils.mv( @@ -79,7 +79,7 @@ module TAC }) 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 { File.delete("#{TAC::CONFIGS_PATH}/#{name}.json") diff --git a/lib/pages/drive_team_rotation_generator.rb b/lib/pages/drive_team_rotation_generator.rb index 7dcdfcf..fa7678a 100644 --- a/lib/pages/drive_team_rotation_generator.rb +++ b/lib/pages/drive_team_rotation_generator.rb @@ -25,7 +25,7 @@ module TAC ] 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 @status_bar.clear do @@ -45,7 +45,7 @@ module TAC flow(width: 1.0, height: 32, margin_bottom: 20) do @role_name = edit_line "", placeholder: "Add role", fill: true, height: 1.0 - button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_height: 1.0, tip: "Add role" do + button get_image("#{TAC::MEDIA_PATH}/icons/plus.png"), image_height: 1.0, tip: "Add role" do if @role_name.value.strip.length.positive? @roles.push(@role_name.value.strip) @role_name.value = "" @@ -64,7 +64,7 @@ module TAC flow(width: 1.0, height: 32, margin_bottom: 20) do @roster_name = edit_line "", placeholder: "Add name", height: 1.0, fill: true - button get_image("#{TAC::ROOT_PATH}/media/icons/plus.png"), image_height: 1.0, tip: "Add name" do + button get_image("#{TAC::MEDIA_PATH}/icons/plus.png"), image_height: 1.0, tip: "Add name" do if @roster_name.value.strip.length.positive? @roster.push(@roster_name.value.strip) @roster_name.value = "" @@ -99,7 +99,7 @@ module TAC background i.even? ? 0xff_007000 : 0xff_006000 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) populate_roles end @@ -115,7 +115,7 @@ module TAC background i.even? ? 0xff_007000 : 0xff_006000 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) populate_roster end diff --git a/lib/pages/editor.rb b/lib/pages/editor.rb index 425c41f..fc7c6c5 100644 --- a/lib/pages/editor.rb +++ b/lib/pages/editor.rb @@ -46,11 +46,11 @@ module TAC @groups_menu = flow(width: 1.0, height: 36) do 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)) 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 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 )) @@ -72,7 +72,7 @@ module TAC 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 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 )) @@ -89,7 +89,7 @@ module TAC 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::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 )) @@ -119,7 +119,7 @@ module TAC @actions_menu = flow(width: 1.0, height: 36) do 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 + button get_image("#{TAC::MEDIA_PATH}/icons/plus.png"), image_width: THEME_ICON_SIZE, tip: "Add action" do if @active_group push_state(TAC::Dialog::ActionDialog, title: "Create Action", list: @active_group.actions, callback_method: method(:create_action)) else @@ -127,7 +127,7 @@ module TAC 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 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 )) @@ -150,7 +150,7 @@ module TAC 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 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 )) @@ -167,7 +167,7 @@ module TAC 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 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| @@ -202,7 +202,7 @@ module TAC stack fill: true, height: 1.0, padding_left: 2, padding_right: 2 do @variables_menu = flow(width: 1.0, height: 36) do 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 push_state(TAC::Dialog::VariableDialog, title: "Create Variable", list: @active_action.variables, callback_method: method(:create_variable)) else @@ -553,10 +553,10 @@ module TAC @variables_list.clear end - button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit group" do + 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::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete group", **THEME_DANGER_BUTTON do + 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 @@ -586,11 +586,11 @@ module TAC window.backend.config_changed! end - button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Edit action" do + 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::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete action", **THEME_DANGER_BUTTON do + 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 @@ -612,7 +612,7 @@ module TAC 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 + 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 diff --git a/lib/pages/game_clock.rb b/lib/pages/game_clock.rb index 9d27ca3..acf5896 100644 --- a/lib/pages/game_clock.rb +++ b/lib/pages/game_clock.rb @@ -24,7 +24,7 @@ module TAC # Spawn game clock window $clock_pid = Process.spawn( RbConfig.ruby, - "#{ROOT_PATH}/timecrafters_configuration_tool.rb", + "#{MEDIA_PATH}/../timecrafters_configuration_tool.rb", "--game-clock-remote-display" ) diff --git a/lib/pages/presets.rb b/lib/pages/presets.rb index 6aae028..5d138fb 100644 --- a/lib/pages/presets.rb +++ b/lib/pages/presets.rb @@ -118,7 +118,7 @@ module TAC 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" do + 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", @@ -128,7 +128,7 @@ module TAC ) end - button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete group", **THEME_DANGER_BUTTON do + 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?", @@ -151,7 +151,7 @@ module TAC 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" do + 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", @@ -161,7 +161,7 @@ module TAC ) end - button get_image("#{TAC::ROOT_PATH}/media/icons/trashcan.png"), image_width: THEME_ICON_SIZE, tip: "Delete action", **THEME_DANGER_BUTTON do + 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?", diff --git a/lib/pages/search.rb b/lib/pages/search.rb index e9f5810..1452028 100644 --- a/lib/pages/search.rb +++ b/lib/pages/search.rb @@ -6,7 +6,7 @@ module TAC menu_bar.clear do 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? search_results = search_config(search.value.strip) diff --git a/lib/pages/simulator.rb b/lib/pages/simulator.rb index 71105ba..3b832ec 100644 --- a/lib/pages/simulator.rb +++ b/lib/pages/simulator.rb @@ -6,7 +6,7 @@ module TAC header_bar("Simulator") 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 begin @@ -19,11 +19,11 @@ module TAC 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 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 end end diff --git a/lib/pages/tacnet.rb b/lib/pages/tacnet.rb index 9398334..4cba126 100644 --- a/lib/pages/tacnet.rb +++ b/lib/pages/tacnet.rb @@ -30,7 +30,7 @@ module TAC end 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 end diff --git a/lib/states/boot.rb b/lib/states/boot.rb index f5aae74..b20a3c7 100644 --- a/lib/states/boot.rb +++ b/lib/states/boot.rb @@ -9,7 +9,7 @@ module TAC 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) - @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) @logo_animator = CyberarmEngine::Animator.new(start_time: Gosu.milliseconds + 750, duration: 1_000, from: 0.0, to: 1.0, tween: :swing_to) diff --git a/lib/states/editor.rb b/lib/states/editor.rb index eb6b40d..8856f2e 100644 --- a/lib/states/editor.rb +++ b/lib/states/editor.rb @@ -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 @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) 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) 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 end end @@ -57,27 +57,27 @@ class Editor < CyberarmEngine::GuiState @navigation = stack(width: 64, height: 1.0, scroll: true) do 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) 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) 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) 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) 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) 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) end @@ -86,23 +86,23 @@ class Editor < CyberarmEngine::GuiState para "Tools", width: 1.0, text_align: :center 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) 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) 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) 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) 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 end end diff --git a/lib/tac.rb b/lib/tac.rb index e36fef4..e47c527 100644 --- a/lib/tac.rb +++ b/lib/tac.rb @@ -1,7 +1,13 @@ 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" SETTINGS_PATH = "#{ROOT_PATH}/data/settings.json" + MEDIA_PATH = "#{File.expand_path("../..", __FILE__)}/media" + CONFIG_SPEC_VERSION = 2 end \ No newline at end of file diff --git a/lib/theme.rb b/lib/theme.rb index 419b0f8..fef11ed 100644 --- a/lib/theme.rb +++ b/lib/theme.rb @@ -1,6 +1,6 @@ module TAC - THEME_FONT = "#{TAC::ROOT_PATH}/media/fonts/NotoSans-Bold.ttf" - THEME_BOLD_FONT = "#{TAC::ROOT_PATH}/media/fonts/NotoSans-Black.ttf" + THEME_FONT = "#{TAC::MEDIA_PATH}/fonts/NotoSans-Bold.ttf" + THEME_BOLD_FONT = "#{TAC::MEDIA_PATH}/fonts/NotoSans-Black.ttf" THEME = { TextBlock: { text_static: true, @@ -27,7 +27,7 @@ module TAC }, ToggleButton: { width: 18, - checkmark_image: "#{TAC::ROOT_PATH}/media/icons/checkmark.png", + checkmark_image: "#{TAC::MEDIA_PATH}/icons/checkmark.png", }, }