mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-15 21:32:35 +00:00
Added basic dialogs, added 'blindman' implementation of TACNET networking code, added font
This commit is contained in:
49
lib/backend.rb
Normal file
49
lib/backend.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
module TAC
|
||||
class Backend
|
||||
attr_reader :config, :tacnet
|
||||
def initialize
|
||||
@config = load_config
|
||||
@tacnet = TACNET.new
|
||||
end
|
||||
|
||||
def load_config
|
||||
if File.exist?(TAC::CONFIG_PATH)
|
||||
JSON.parse(File.read( TAC::CONFIG_PATH ))
|
||||
else
|
||||
write_default_config
|
||||
load_config
|
||||
end
|
||||
end
|
||||
|
||||
def write_default_config
|
||||
File.open(TAC::CONFIG_PATH, "w") do |f|
|
||||
f.write JSON.dump(
|
||||
{
|
||||
config: {
|
||||
spec_version: TAC::CONFIG_SPEC_VERSION,
|
||||
hostname: TACNET::DEFAULT_HOSTNAME,
|
||||
port: TACNET::DEFAULT_PORT,
|
||||
presets: [],
|
||||
},
|
||||
data: {
|
||||
groups: [],
|
||||
actions: [],
|
||||
values: [],
|
||||
},
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def refresh_config
|
||||
load_config
|
||||
|
||||
$window.states.clear
|
||||
$window.push_state(Editor)
|
||||
end
|
||||
|
||||
def refresh_tacnet_status
|
||||
$window.current_state.refresh_tacnet_status
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user