public void WriteGameConfig(string gameDirPath, ShikiGameConfig gameConfig) { string gameConfigPath = Path.Combine(gameDirPath, gameConfigFileName); Directory.CreateDirectory(gameDirPath); string jsonString = JsonSerializer.Serialize <ShikiGameConfig>(gameConfig, jsonSerializerOptions); File.WriteAllText(gameConfigPath, jsonString); }
public ShikiGameConfig ReadGameConfig(string gameDirPath) { ShikiGameConfig gameConfig; string gameConfigPath = Path.Combine(gameDirPath, gameConfigFileName); if (File.Exists(gameConfigPath)) { string jsonString = File.ReadAllText(gameConfigPath); gameConfig = JsonSerializer.Deserialize <ShikiGameConfig>(jsonString, jsonSerializerOptions); } else { gameConfig = new ShikiGameConfig(); } return(gameConfig); }