Add support for select and delete config packet emission

This commit is contained in:
2021-02-10 13:08:21 -06:00
parent e27f1d1dca
commit 8934462c46
4 changed files with 24 additions and 4 deletions

View File

@@ -41,6 +41,10 @@ module TAC
button "#{name}", width: 0.94 do
change_config(name)
if window.backend.tacnet.connected?
window.backend.tacnet.puts(TAC::TACNET::PacketHandler.packet_select_config(name))
end
end
button get_image("#{TAC::ROOT_PATH}/media/icons/gear.png"), image_width: THEME_ICON_SIZE, tip: "Rename configuration" do
@@ -67,7 +71,11 @@ module TAC
File.delete("#{TAC::CONFIGS_PATH}/#{name}.json")
if window.backend.settings.config == name
change_config(nil)
change_config("")
end
if window.backend.tacnet.connected?
window.backend.tacnet.puts(TAC::TACNET::PacketHandler.packet_delete_config(name))
end
populate_configs

View File

@@ -218,6 +218,14 @@ module TAC
list
)
end
def self.packet_select_config(config_name)
Packet.create(Packet::PACKET_TYPES[:select_config], config_name)
end
def self.packet_delete_config(config_name)
Packet.create(Packet::PACKET_TYPES[:delete_config], config_name)
end
end
end
end

View File

@@ -63,9 +63,9 @@ module TAC
def close
if @backend.config_changed?
push_state(Dialog::ConfirmDialog, title: "Unsaved Config", message: "Config has unsaved changes\nthat will be lost if you continue!", callback_method: proc { cleanup_and_close })
push_state(Dialog::ConfirmDialog, title: "Unsaved Config", message: "Config has unsaved changes that will be lost if you continue!", callback_method: proc { cleanup_and_close })
elsif @backend.settings_changed?
push_state(Dialog::ConfirmDialog, title: "Unsaved Settings", message: "Settings has unsaved changes\nthat will be lost if you continue!", callback_method: proc { cleanup_and_close })
push_state(Dialog::ConfirmDialog, title: "Unsaved Settings", message: "Settings has unsaved changes that will be lost if you continue!", callback_method: proc { cleanup_and_close })
else
cleanup_and_close
end

View File

@@ -1,4 +1,8 @@
require_relative "../cyberarm_engine/lib/cyberarm_engine"
begin
require_relative "../cyberarm_engine/lib/cyberarm_engine"
rescue LoadError
require "cyberarm_engine"
end
require "gosu_notifications"
require "socket"
require "securerandom"