Config is now saved and synced when updated

This commit is contained in:
2020-06-07 22:47:53 -05:00
parent ab6edb7a58
commit 151df4ca57
14 changed files with 162 additions and 59 deletions

View File

@@ -8,13 +8,28 @@ module TAC
def load_config
if File.exist?(TAC::CONFIG_PATH)
JSON.parse(File.read( TAC::CONFIG_PATH ))
return JSON.parse(File.read( TAC::CONFIG_PATH ), symbolize_names: true)
else
write_default_config
load_config
end
end
def update_config
@config = load_config
$window.current_state.populate_groups_list
end
def save_config
json = JSON.dump(@config)
File.open(TAC::CONFIG_PATH, "w") { |f| f.write json }
if @tacnet.connected?
@tacnet.puts(TAC::TACNET::PacketHandler.packet_dump_config(json))
end
end
def write_default_config
File.open(TAC::CONFIG_PATH, "w") do |f|
f.write JSON.dump(