feat: Implement platform-specific persistence for renderer settings and save games

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-23 16:28:35 +01:00
parent dcfb2e8e02
commit 26c738b702
14 changed files with 291 additions and 28 deletions
@@ -0,0 +1,31 @@
/// Returns the platform-appropriate Wolf3D config directory path.
///
/// This file is only ever imported by native (dart:io) code paths and must
/// never be loaded on web.
library;
import 'dart:io';
/// Returns the Wolf3D config directory for the current platform.
///
/// - Linux: `$XDG_CONFIG_HOME/wolf3d` (defaults to `~/.config/wolf3d`)
/// - macOS: `~/Library/Application Support/wolf3d`
/// - Windows: `%APPDATA%/wolf3d`
/// - Other: `~/.config/wolf3d`
String platformConfigDir() {
if (Platform.isLinux) {
final String xdg = Platform.environment['XDG_CONFIG_HOME'] ?? '';
final String home = Platform.environment['HOME'] ?? '.';
return xdg.isNotEmpty ? '$xdg/wolf3d' : '$home/.config/wolf3d';
}
if (Platform.isMacOS) {
final String home = Platform.environment['HOME'] ?? '.';
return '$home/Library/Application Support/wolf3d';
}
if (Platform.isWindows) {
final String appData = Platform.environment['APPDATA'] ?? '.';
return '$appData/wolf3d';
}
final String home = Platform.environment['HOME'] ?? '.';
return '$home/.config/wolf3d';
}