mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-15 21:32:35 +00:00
Config is now saved and synced when updated
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user