Erste Version

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 17:26:23 +01:00
co-authored by Claude Opus 5.5
commit 35f2d1330d
23 changed files with 1981 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
using System;
using System.IO;
using System.Text.Json;
namespace BSO
{
/// <summary>Einstellungen in &lt;Spiel&gt;\BSO\BSO.json - wird beim ersten Start mit Standardwerten angelegt.</summary>
public class Config
{
/// <summary>Name, den die anderen sehen.</summary>
public string Name { get; set; } = Environment.UserName;
/// <summary>Server als host oder host:port.</summary>
public string Server { get; set; } = "127.0.0.1:7777";
/// <summary>Beim Spielstart automatisch verbinden (sonst F8).</summary>
public bool AutoConnect { get; set; }
public static Config Current { get; private set; } = new();
static readonly JsonSerializerOptions Options = new() { WriteIndented = true };
static string ConfigFile => Path.Combine(Bootstrap.Folder, "BSO.json");
public static void Load()
{
try
{
if (File.Exists(ConfigFile)) Current = JsonSerializer.Deserialize<Config>(File.ReadAllText(ConfigFile), Options) ?? new Config();
// Immer zurueckschreiben: neue Einstellungen erscheinen so auch in alten Dateien
File.WriteAllText(ConfigFile, JsonSerializer.Serialize(Current, Options));
Bootstrap.Log($"Einstellungen: Name \"{Current.Name}\", Server {Current.Server}, AutoConnect {Current.AutoConnect}");
}
catch (Exception e)
{
Bootstrap.Log("BSO.json nicht lesbar, nehme Standardwerte: " + e.Message);
}
}
}
}