refactor: decompose LauncherApp, centralize magic strings/constants, configurable colors

- Extract InputController from AppHost (key handling + ReloadGameEntries)
- Centralize hardcoded values as code constants (non-configurable):
  FavoritesRootName, DefaultFileName, DefaultTitle, scroll fractions,
  AvailableLines helper, removed redundant ArgsTemplate fallback
- Make color scheme configurable via 'Colors' section in launcher.config.json
  with Enum.TryParse + default fallback; MenuRenderer uses constructor injection
- Clean up MenuRenderer: remove dead maxRow logic, unify cache sizing via EnsureCache
- Document intentional error swallowing in FavoritesService.Save/UIErrorService
- Update README + AGENTS.md with configurable color docs
- Remove redundant ArgsTemplate fallback (config is single source of truth)
This commit is contained in:
2026-08-11 01:33:33 +02:00
parent 7dca82baa8
commit 62968dbcd1
13 changed files with 551 additions and 319 deletions
@@ -4,6 +4,25 @@
namespace MarcerGameDvdLauncher
{
// Configuration POCOs separated into their own file for clarity
/// <summary>
/// Color configuration for the menu renderer.
/// All properties have default values matching the original hardcoded scheme,
/// so omitting any value (or the entire "Colors" section) preserves existing behaviour.
/// </summary>
public class AppColorConfig
{
public ConsoleColor FolderBoth { get; set; } = ConsoleColor.Yellow;
public ConsoleColor FolderPatchOnly { get; set; } = ConsoleColor.DarkYellow;
public ConsoleColor FolderRootOnly { get; set; } = ConsoleColor.Gray;
public ConsoleColor ZipBoth { get; set; } = ConsoleColor.Green;
public ConsoleColor ZipRootOnly { get; set; } = ConsoleColor.DarkGreen;
public ConsoleColor ZipPatchOnly { get; set; } = ConsoleColor.Magenta;
public ConsoleColor SelectedForeground { get; set; } = ConsoleColor.Black;
public ConsoleColor SelectedBackground { get; set; } = ConsoleColor.DarkCyan;
public ConsoleColor VirtualEntry { get; set; } = ConsoleColor.White;
}
public class AppHatariConfig
{
public string? Executable { get; set; }
@@ -16,5 +35,9 @@ namespace MarcerGameDvdLauncher
public string? RootDirectory { get; set; }
public string? PatchDirectory { get; set; }
public AppHatariConfig? Hatari { get; set; }
// Ignored during JSON deserialization — parsed manually in LoadConfiguration so that
// invalid color strings fall back to defaults instead of throwing.
[System.Text.Json.Serialization.JsonIgnore]
public AppColorConfig? Colors { get; set; }
}
}