Auto-generate configuration dialog, fix logger names, prepare for async initialization

This commit is contained in:
John Gross
2018-01-05 20:16:17 -08:00
parent 3f6f077833
commit ba8fa01ce5
50 changed files with 1953 additions and 590 deletions

View File

@@ -29,32 +29,10 @@ namespace Torch.Server.ViewModels
_config = configDedicated;
_config.IgnoreLastSession = true;
SessionSettings = new SessionSettingsViewModel(_config.SessionSettings);
Administrators = string.Join(Environment.NewLine, _config.Administrators);
Banned = string.Join(Environment.NewLine, _config.Banned);
Mods = string.Join(Environment.NewLine, _config.Mods);
}
public void Save(string path = null)
{
var newline = new [] {Environment.NewLine};
_config.Administrators.Clear();
foreach (var admin in Administrators.Split(newline, StringSplitOptions.RemoveEmptyEntries))
_config.Administrators.Add(admin);
_config.Banned.Clear();
foreach (var banned in Banned.Split(newline, StringSplitOptions.RemoveEmptyEntries))
_config.Banned.Add(ulong.Parse(banned));
_config.Mods.Clear();
foreach (var mod in Mods.Split(newline, StringSplitOptions.RemoveEmptyEntries))
{
if (ulong.TryParse(mod, out ulong modId))
_config.Mods.Add(modId);
else
Log.Warn($"'{mod}' is not a valid mod ID.");
}
// Never ever
_config.IgnoreLastSession = true;
_config.Save(path);
@@ -75,71 +53,30 @@ namespace Torch.Server.ViewModels
}
}
private string _administrators;
public string Administrators { get => _administrators; set { _administrators = value; OnPropertyChanged(); } }
private string _banned;
public string Banned { get => _banned; set { _banned = value; OnPropertyChanged(); } }
private string _mods;
public string Mods { get => _mods; set { _mods = value; OnPropertyChanged(); } }
public List<string> Administrators { get => _config.Administrators; set => SetValue(x => _config.Administrators = x, value); }
public int AsteroidAmount
{
get { return _config.AsteroidAmount; }
set { _config.AsteroidAmount = value; OnPropertyChanged(); }
}
public List<ulong> Banned { get => _config.Banned; set => SetValue(x => _config.Banned = x, value); }
public ulong GroupId
{
get { return _config.GroupID; }
set { _config.GroupID = value; OnPropertyChanged(); }
}
public List<ulong> Mods { get => _config.Mods; set => SetValue(x => _config.Mods = x, value); }
public string IP
{
get { return _config.IP; }
set { _config.IP = value; OnPropertyChanged(); }
}
public int AsteroidAmount { get => _config.AsteroidAmount; set => SetValue(x => _config.AsteroidAmount = x, value); }
public int Port
{
get { return _config.ServerPort; }
set { _config.ServerPort = value; OnPropertyChanged(); }
}
public ulong GroupId { get => _config.GroupID; set => SetValue(x => _config.GroupID = x, value); }
public string ServerName
{
get { return _config.ServerName; }
set { _config.ServerName = value; OnPropertyChanged(); }
}
public string IP { get => _config.IP; set => SetValue(x => _config.IP = x, value); }
public bool PauseGameWhenEmpty
{
get { return _config.PauseGameWhenEmpty; }
set { _config.PauseGameWhenEmpty = value; OnPropertyChanged(); }
}
public int Port { get => _config.ServerPort; set => SetValue(x => _config.ServerPort = x, value); }
public string PremadeCheckpointPath
{
get { return _config.PremadeCheckpointPath; }
set { _config.PremadeCheckpointPath = value; OnPropertyChanged(); }
}
public string ServerName { get => _config.ServerName; set => SetValue(x => _config.ServerName = x, value); }
public string LoadWorld
{
get { return _config.LoadWorld; }
set { _config.LoadWorld = value; OnPropertyChanged(); }
}
public bool PauseGameWhenEmpty { get => _config.PauseGameWhenEmpty; set => SetValue(x => _config.PauseGameWhenEmpty = x, value); }
public int SteamPort
{
get { return _config.SteamPort; }
set { _config.SteamPort = value; OnPropertyChanged(); }
}
public string PremadeCheckpointPath { get => _config.PremadeCheckpointPath; set => SetValue(x => _config.PremadeCheckpointPath = x, value); }
public string WorldName
{
get { return _config.WorldName; }
set { _config.WorldName = value; OnPropertyChanged(); }
}
public string LoadWorld { get => _config.LoadWorld; set => SetValue(x => _config.LoadWorld = x, value); }
public int SteamPort { get => _config.SteamPort; set => SetValue(x => _config.SteamPort = x, value); }
public string WorldName { get => _config.WorldName; set => SetValue(x => _config.WorldName = x, value); }
}
}