25 Commits
Author SHA1 Message Date
stefankoelle e8c43a9d52 release v0.9.3
Marcer GameDVD Launcher v0.9.3 - Major refactoring with configurable color scheme and centralized code organization

- Refactor: Decompose LauncherApp ~300-line class into separate InputController for key handling and ReloadGameEntries; Lifecycle & Main-loop remain in AppHost
- Centralize hardcoded magic strings/constants: FavoritesRootName, DefaultFileName, DefaultTitle, scroll fractions, AvailableLines helper; remove redundant ArgsTemplate fallback
- Make color scheme configurable via 'Colors' section in launcher.config.json with Enum.TryParse<ConsoleColor> + default fallback
- Update 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
- Update launcher.config.example.json with new Colors section
- Update README.md with /create-release command
2026-08-11 12:26:58 +02:00
stefankoelle 7f4df30ae7 docs: check off Magische Strings parent item 2026-08-11 01:34:20 +02:00
stefankoelle 7a75c635f6 docs: mark all PLAN.md items complete in checklist 2026-08-11 01:33:54 +02:00
stefankoelle 62968dbcd1 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)
2026-08-11 01:33:33 +02:00
stefankoelle 7dca82baa8 /create-release in README.md 2026-08-11 00:54:10 +02:00
stefankoelle 9f12ec9075 release v0.9.2
Release v0.9.2: MIT License + automated release notes

- Add MIT License to project root and license headers across all source files (C#, shell, batch)
- Include LICENSE in publish output via .csproj so it ships in release ZIPs
- Update GitHub Actions to latest versions (checkout v7, setup-dotnet v6, upload/download-artifact v7/v8, action-gh-release v3)
- Release workflow now uses the commit message body as release notes (via /create-release command)
- Add renovate.json for automated dependency updates
- Fix demo.sh setup script
- Update README.md and AGENTS.md with License sections and refreshed module overview
- Add .gitignore entry for Python virtual environments (.venv/)
2026-08-11 00:52:28 +02:00
stefankoelle c79ff80a84 add LICENSE to build 2026-08-11 00:50:40 +02:00
Stefan Koelle 8cb3b1a624 Merge pull request #1 from skoelle/renovate/major-github-actions
Update GitHub Actions (major)
2026-08-11 00:49:44 +02:00
renovate[bot] 393290e37e Update GitHub Actions 2026-08-10 22:49:16 +00:00
stefankoelle ba8004ef50 renovate 2026-08-11 00:47:51 +02:00
stefankoelle 6bb086516c LICENSE 2026-08-11 00:46:55 +02:00
stefankoelle 48a08f9bb1 fix demo.sh 2026-08-10 23:11:42 +02:00
stefankoelle d5cf0cd723 AGENTS.md 2026-08-10 22:34:18 +02:00
stefankoelle 45a7c3ace2 README.md 2026-08-10 22:29:54 +02:00
stefankoelle eabf2066b6 README.md 2026-08-10 22:22:57 +02:00
stefankoelle 86dcf7bd32 README.md 2026-08-10 22:20:57 +02:00
stefankoelle c8229dd0e1 release command 2026-08-10 22:13:55 +02:00
stefankoelle 26d3530b86 move all files 2026-08-10 21:45:47 +02:00
stefankoelle 94b4ed7fb3 ui help function 2026-08-10 21:37:05 +02:00
stefankoelle 87720e6db4 fix release pipeline 2026-08-10 21:31:39 +02:00
stefankoelle d06ee381be fix hatari exists 2026-08-10 21:28:01 +02:00
stefankoelle ea66414496 fix AGENTS.md 2026-08-10 21:21:26 +02:00
stefankoelle 7360687da7 demo mode 2026-08-10 21:15:32 +02:00
stefankoelle ca2e46a8a6 fix: zip from publish/ subfolder to avoid duplicate files 2026-08-10 20:31:52 +02:00
stefankoelle a9e9aecf3e add community link to Facebook group in README 2026-08-10 20:27:26 +02:00
34 changed files with 1444 additions and 645 deletions
+18 -10
View File
@@ -26,10 +26,10 @@ jobs:
artifact_name: osx-x64
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'
@@ -41,22 +41,23 @@ jobs:
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build
working-directory: src/MarcerGameDvdLauncher
run: dotnet publish -c Release -r ${{ matrix.rid }} -p:Version=${{ steps.version.outputs.version }} --self-contained false
- name: Create ZIP (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Compress-Archive -Path "MarcerGameDvdLauncher/bin/Release/net10.0/${{ matrix.rid }}/*" -DestinationPath "MarcerGameDvdLauncher-v${{ steps.version.outputs.version }}-${{ matrix.artifact_name }}.zip"
Compress-Archive -Path "src/MarcerGameDvdLauncher/bin/Release/net10.0/${{ matrix.rid }}/publish/*" -DestinationPath "MarcerGameDvdLauncher-v${{ steps.version.outputs.version }}-${{ matrix.artifact_name }}.zip"
- name: Create ZIP (Linux/macOS)
if: matrix.os != 'windows-latest'
run: |
cd MarcerGameDvdLauncher/bin/Release/net10.0/${{ matrix.rid }}
zip -r ../../../MarcerGameDvdLauncher-v${{ steps.version.outputs.version }}-${{ matrix.artifact_name }}.zip .
cd src/MarcerGameDvdLauncher/bin/Release/net10.0/${{ matrix.rid }}/publish
zip -r $GITHUB_WORKSPACE/MarcerGameDvdLauncher-v${{ steps.version.outputs.version }}-${{ matrix.artifact_name }}.zip .
- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: MarcerGameDvdLauncher-v${{ steps.version.outputs.version }}-${{ matrix.artifact_name }}
path: MarcerGameDvdLauncher-v${{ steps.version.outputs.version }}-${{ matrix.artifact_name }}.zip
@@ -65,12 +66,12 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
path: artifacts
@@ -80,7 +81,14 @@ jobs:
CURRENT_TAG="${GITHUB_REF_NAME}"
PREV_TAG=$(git describe --tags --abbrev=0 ${CURRENT_TAG}^ 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
# Get the full commit message body of the release commit
# (the empty commit created by /create-release)
COMMIT_HASH=$(git rev-list -n 1 ${CURRENT_TAG})
BODY=$(git log -1 --format=%b ${COMMIT_HASH})
if [ -n "$BODY" ]; then
echo "$BODY" > release-notes.md
elif [ -n "$PREV_TAG" ]; then
echo "## Changes since ${PREV_TAG}" > release-notes.md
echo "" >> release-notes.md
git log --oneline ${PREV_TAG}..${CURRENT_TAG} >> release-notes.md
@@ -89,7 +97,7 @@ jobs:
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@v3
with:
name: MarcerGameDvdLauncher ${{ github.ref_name }}
body_path: release-notes.md
+6
View File
@@ -12,6 +12,9 @@ obj/
.DS_Store
Thumbs.db
# Python virtual environment
.venv/
# Release-Verzeichnis (keine ZIPs o.ä. ins Git!)
# Only ignore top-level release/ directory. Release directories in subfolders are allowed.
/release/
@@ -19,3 +22,6 @@ Thumbs.db
# User-specific configuration (real config, not example)
launcher.config.json
favorites.txt
# Demo directory (generated by demo.sh)
.demo/
+35
View File
@@ -0,0 +1,35 @@
---
description: Create and push a release tag (e.g. /create-release 1.0.0)
---
Create a release tag and push it to origin. The GitHub Action will automatically build for all platforms and create the GitHub Release.
## Steps
1. Validate the version argument ($ARGUMENTS):
- Must be provided, otherwise show error and stop
- Must match semver format (e.g. 1.0.0, 0.9.1, 2.0.0-beta.1)
2. Check for uncommitted changes:
- Run `git status --porcelain`
- If any output, warn the user and stop (commit first)
3. Analyze changes since last release:
- Run `git log --oneline $(git describe --tags --abbrev=0 HEAD)..HEAD` to list all commits
- Read the changed files to understand context
- Write a concise, well-structured release summary in English with:
- A one-line overview
- Bullet points for each notable change (features, fixes, breaking changes)
- Keep it developer-friendly, no fluff
4. Create release commit with the summary as message:
- Run `git commit --allow-empty -m "release v$ARGUMENTS\n\n<summary>"`
- The commit message IS the release notes — the GitHub Action picks it up automatically
5. Create annotated tag on that commit:
- Run `git tag -a v$ARGUMENTS -m "Release v$ARGUMENTS"`
6. Push commit and tag:
- Run `git push origin main --tags` (or current branch)
7. Confirm success with the version number
+46 -29
View File
@@ -4,27 +4,29 @@ applyTo: '**'
## Module Overview (Marcer GameDVD Launcher)
The implementation is split into focused modules (files) under the `MarcerGameDvdLauncher/` folder. Keep this section up to date when files are added, removed or responsibilities change.
The implementation is split into focused modules (files) under the `src/MarcerGameDvdLauncher/` folder. Keep this section up to date when files are added, removed or responsibilities change.
- MarcerGameDvdLauncher/Program.cs: Minimal entry point. Sets console title and starts the application by creating `LauncherApp`.
- MarcerGameDvdLauncher/LauncherApp.cs: Application lifecycle host — loads configuration, initializes components and runs the main directory navigation loop (contains `AppHost` internal class).
- MarcerGameDvdLauncher/AppConfiguration.cs: POCO configuration classes (`AppConfig`, `AppHatariConfig`) used to deserialize `launcher.config.json`.
- MarcerGameDvdLauncher/ProgramHelpers.cs: Small shared helpers (resolve relative paths, centralized console message helper) used across modules.
- MarcerGameDvdLauncher/Program.cs: Minimal entry point. Sets the console title (via `DefaultTitle` constant) and starts the application by creating `LauncherApp`.
- MarcerGameDvdLauncher/LauncherApp.cs: Application lifecycle host — loads configuration, initializes components and runs the main directory navigation loop (contains `AppHost` internal class). Key-handling logic is delegated to `InputController`.
- MarcerGameDvdLauncher/AppConfiguration.cs: POCO configuration classes (`AppConfig`, `AppHatariConfig`, `AppColorConfig`) used to deserialize `launcher.config.json`; color values resolved via `Enum.TryParse<ConsoleColor>` with default fallback.
- MarcerGameDvdLauncher/ProgramHelpers.cs: Small shared helpers (resolve relative paths, centralized console message helper, input buffer flushing) used across modules.
- MarcerGameDvdLauncher/OverlayDirectoryBrowser.cs: Filesystem overlay and browsing logic — merges root and patch directories, enumerates folders and ZIPs, protects against path traversal and ensures navigation cannot leave the configured roots.
- MarcerGameDvdLauncher/NavigationController.cs: Encapsulates selection, scrolling and relative-path navigation logic (cursor, page up/down, per-directory remembered selection/state).
- MarcerGameDvdLauncher/MenuRenderer.cs: Console rendering logic — efficient per-line redraw, double-buffering and color selection according to overlay rules.
- MarcerGameDvdLauncher/NavigationController.cs: Encapsulates selection, scrolling and relative-path navigation logic (cursor, page up/down, per-directory remembered selection/state); uses named scroll-fraction constants.
- MarcerGameDvdLauncher/MenuRenderer.cs: Console rendering logic — efficient per-line redraw, double-buffering, configurable color selection via injected `AppColorConfig`, and the help box overlay.
- MarcerGameDvdLauncher/InputController.cs: Handles key events (arrow keys, Enter, Backspace, PageUp/Down, `*`, `?`, ESC) and the associated navigation/drawing logic; owns `ReloadGameEntries` and the virtual `Favorites` folder integration.
- MarcerGameDvdLauncher/HatariLauncher.cs: Responsible for validating the Hatari executable and starting Hatari with the configured argument template (replaces `{cfg}` and `{zip}`).
- MarcerGameDvdLauncher/FavoritesService.cs: Manages the favorites/bookmark system — toggling favorites on ZIPs, persisting them to `favorites.txt` (via `DefaultFileName` constant), and providing the virtual `Favorites` folder view (via `FavoritesRootName` constant).
- MarcerGameDvdLauncher/UIErrorService.cs: Centralized UI error presentation using the console message helper.
Note: This overview is intentionally concise. For behavioral changes (navigation, color scheme, launch command or config schema), update this file (agents.md) and README.md as required by project policy.
Note: This overview is intentionally concise. For behavioral changes (navigation, color scheme, launch command or config schema), update this file (AGENTS.md) and README.md as required by project policy.
**Note for Automated Tests/CI:**
The Launcher cannot be executed or tested via `start.cmd` from this environment (build system, automation agent) since no Windows console environment is present. For release workflows and developer validation, it is ALWAYS required to do a manual test run via start.cmd per documentation and policy before delivery.
The Launcher cannot be executed or tested via `scripts/start.cmd` from this environment (build system, automation agent) since no Windows console environment is present. For release workflows and developer validation, it is ALWAYS required to do a manual test run via `scripts/start.cmd` (Windows) or `scripts/start.sh` (Linux/macOS) per documentation and policy before delivery.
**Release Process (automated via GitHub Actions):**
- Pushing a tag (`v*`) triggers the GitHub Action workflow (`.github/workflows/release.yml`).
- The workflow builds platform-specific artifacts (Windows, Linux, macOS), generates release notes from git log, and creates a GitHub Release with all ZIPs attached.
- Developer steps for a release:
1. Ensure `README.md` and `agents.md` are up to date.
1. Ensure `README.md` and `AGENTS.md` are up to date.
2. Commit all changes.
3. Create and push a tag: `git tag v{version} && git push origin v{version}`.
4. The GitHub Action handles the rest (build, ZIP, release notes, GitHub Release).
@@ -32,17 +34,17 @@ The Launcher cannot be executed or tested via `start.cmd` from this environment
Additional policy:
- README.md must be written in English. Any functional change that affects usage, configuration, or behavior MUST update README.md in English immediately after the change. If there are consequential changes to developer-facing policies, build steps, or requirements, `agents.md` must be updated as well.
- README.md must be written in English. Any functional change that affects usage, configuration, or behavior MUST update README.md in English immediately after the change. If there are consequential changes to developer-facing policies, build steps, or requirements, AGENTS.md must be updated as well.
Developer note: Visual Studio Solution
- A Visual Studio solution file exists at the repository root: `marcer-gamedvd-launcher.sln`. Developers may open this solution in Visual Studio to work on the project, debug and build from the IDE. The solution references `MarcerGameDvdLauncher\MarcerGameDvdLauncher.csproj` and includes Debug and Release configurations. Use `build.cmd` (Windows) or `build.sh` (Linux) and `start.cmd` for consistent command-line builds/releases as described elsewhere in this document.
- A Visual Studio solution file exists at `src/marcer-gamedvd-launcher.sln`. Developers may open this solution in Visual Studio to work on the project, debug and build from the IDE. The solution references `MarcerGameDvdLauncher\MarcerGameDvdLauncher.csproj` and includes Debug and Release configurations. Use `scripts/build.cmd` (Windows) or `scripts/build.sh` (Linux/macOS) and `scripts/start.cmd` (Windows) or `scripts/start.sh` (Linux/macOS) for consistent command-line builds/releases as described elsewhere in this document.
With this, it is ensured that binary/release files never end up in git, and the release process is always traceable and performed exclusively manually in the web interface.
# Requirements for the Marcer GameDVD Launcher (agents.md)
# Requirements for the Marcer GameDVD Launcher (AGENTS.md)
## Basic Function / Purpose
The console launcher is meant for browsing a games directory and can launch ZIP files with the Hatari emulator under Windows. Control is exclusively via keyboard in the console window.
The console launcher is meant for browsing a games directory and can launch ZIP files with the Hatari emulator. It runs on Windows, Linux, and macOS. Control is exclusively via keyboard in the console window.
## Detailed Requirements
@@ -57,9 +59,10 @@ The console launcher is meant for browsing a games directory and can launch ZIP
- Backspace: jump to parent directory (never outside root)
- ESC: exit the program
- PageUp/PageDown: jump by one page up/down through the file list
- `?`: show a help box with key bindings
- The file list always shows exactly as many lines as fit the screen ALWAYS **one line less** than the console height (`Console.WindowHeight - 1`). This avoids overflow at the bottom and ensures the selection never enters the non-visible area.
Rationale: writing to the very last console line can cause the Windows console to auto-scroll or produce visual jumps when the cursor reaches the bottom row. Reserving one line prevents unintended scrolling/flicker and keeps the selection cursor strictly within the visible area.
Maintenance: when changing rendering or navigation logic, always compute the displayed page size as `availableLines = Console.WindowHeight - 1` and keep this value consistent across MenuRenderer, NavigationController and any other code that references the console height.
Maintenance: when changing rendering or navigation logic, always compute the displayed page size as `availableLines = ProgramHelpers.AvailableLines` (which resolves to `Console.WindowHeight - 1`) and keep this value consistent across MenuRenderer, NavigationController and any other code that references the console height.
- There is no information line/path display.
- Cursor and scroll logic:
- The selection cursor must always remain in the visible area.
@@ -75,17 +78,16 @@ The console launcher is meant for browsing a games directory and can launch ZIP
- Empty directories must be displayed correctly (or reported correctly).
- In the root directory, Backspace must have no effect (no error, do not leave the program).
- Navigation (Backspace, Enter, etc.) must remain robust even for very deep or large directory trees.
- Hatari.Executable is validated during startup: the path is resolved (relative to the EXE directory when applicable) and must point to an existing .exe file. If validation fails the program must present a clear error and exit.
- Hatari.Executable is validated during startup: the path is resolved (relative to the EXE directory when applicable) and must point to an existing file. If validation fails the program must present a clear error and exit.
### Miscellaneous
- Optional: Build and start scripts (build.cmd / build.sh / start.cmd) are present, adapt as needed.
- For ALL builds, tests, and releases, ONLY the platform build script may be used: `build.cmd` (Windows) or `build.sh` (Linux). Direct `dotnet build`/`dotnet run` calls are NOT allowed, as they can lead to version/runtime conflicts. The application must always be started and tested using `start.cmd`.
- After making any code changes that affect behavior or touch source files, run the platform build script (`build.cmd` on Windows, `build.sh` on Linux) and ensure the build completes successfully before committing. Additionally, perform a manual functional test using `start.cmd` on a Windows machine prior to pushing a release.
- Build and start scripts (`scripts/build.cmd` / `scripts/build.sh` / `scripts/start.cmd` / `scripts/start.sh`) are present and must be used.
- For ALL builds, tests, and releases, ONLY the platform build script may be used: `scripts/build.cmd` (Windows) or `scripts/build.sh` (Linux/macOS). Direct `dotnet build`/`dotnet run` calls are NOT allowed, as they can lead to version/runtime conflicts. The application must always be started and tested using `scripts/start.cmd` (Windows) or `scripts/start.sh` (Linux/macOS).
- After making any code changes that affect behavior or touch source files, run the platform build script (`scripts/build.cmd` on Windows, `scripts/build.sh` on Linux/macOS) and ensure the build completes successfully before committing. Additionally, perform a manual functional test on a Windows, Linux, or macOS machine prior to pushing a release.
- The console window can have any number of lines; display/navigation must adapt dynamically.
- After each build for a release, the entire build output directory (`bin/Release/net10.0/`) must be zipped in the `release/` directory, and the ZIP must be uploaded as a release asset in Gitea.
- For every release, a Release Notes file must be maintained that summarizes all changes, bugfixes, and new features in that version; Release Notes must be provided with the release asset.
- **IMPORTANT:** With any functional change to the launcher, BOTH this file (agents.md) AND the README.md must always be updated and kept current. Immediately after, a successful build must be executed. This is mandatory for all development on the project.
- **IMPORTANT:** With any functional change to the launcher, BOTH this file (AGENTS.md) AND the README.md must always be updated and kept current. Immediately after, a successful build must be executed. This is mandatory for all development on the project.
---
@@ -106,17 +108,32 @@ Note on PatchDirectory semantics:
Implementation note (input flushing):
- To avoid undesired key-repeat / input "afterglow" when the user holds navigation keys, the application performs a best-effort flush of the console input buffer after navigation events. This is implemented by ProgramHelpers.FlushInputBuffer(), which uses the Win32 FlushConsoleInputBuffer API on Windows. This behaviour is intentional and required to provide a responsive navigation experience.
### Color Scheme
- Folder in both layers: **ConsoleColor.Yellow**
- Folder only in patch layer: **ConsoleColor.DarkYellow**
- Folder only in main layer: **ConsoleColor.Gray**
- ZIP in both layers: **ConsoleColor.Green**
- ZIP only in main layer: **ConsoleColor.DarkGreen**
- ZIP only in patch layer: **ConsoleColor.Magenta**
### Color Scheme and Layer Labels
Each entry is displayed with a left label indicating its layer status:
- **`[BOTH]`**: Entry exists in both main and patch layer
- **`[ROOT]`**: Entry exists only in main (root) layer
- **`[PTCH]`**: Entry exists only in patch layer
Note: The ConsoleColor mapping above is authoritative for the application. If you change color values in code (MenuRenderer/GetColorForEntry), update this section to keep documentation and implementation in sync.
Color mapping (now configurable via the `Colors` section in `launcher.config.json`; defaults shown below):
- Folder in both layers: **Yellow** (`[BOTH]`) → `FolderBoth`
- Folder only in patch layer: **DarkYellow** (`[PTCH]`) → `FolderPatchOnly`
- Folder only in main layer: **Gray** (`[ROOT]`) → `FolderRootOnly`
- ZIP in both layers: **Green** (`[BOTH]`) → `ZipBoth`
- ZIP only in main layer: **DarkGreen** (`[ROOT]`) → `ZipRootOnly`
- ZIP only in patch layer: **Magenta** (`[PTCH]`) → `ZipPatchOnly`
- Selected entry foreground: **Black**`SelectedForeground`
- Selected entry background: **DarkCyan**`SelectedBackground`
- Virtual entry (Favorites pseudo-folder): **White**`VirtualEntry`
Note: Color values are resolved in `MenuRenderer` from the injected `AppColorConfig` (populated in `LauncherApp.LoadConfiguration` via `Enum.TryParse<ConsoleColor>` with default fallback). Invalid or missing values fall back to the defaults above. If you change default color values in `AppColorConfig`, update this section and the README color tables to keep documentation and implementation in sync.
### Navigation
- Navigation is always based strictly on the **relative path from root** and is consistent on all levels (Backspace always moves up one level, Enter always moves one level deeper, regardless of which layer).
---
## License
MIT License - Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
- Full text in `LICENSE`
- License headers in all source code files
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-17
View File
@@ -1,17 +0,0 @@
namespace MarcerGameDvdLauncher
{
// Configuration POCOs separated into their own file for clarity
public class AppHatariConfig
{
public string? Executable { get; set; }
public string? ConfigFile { get; set; }
public string? ArgsTemplate { get; set; }
}
public class AppConfig
{
public string? RootDirectory { get; set; }
public string? PatchDirectory { get; set; }
public AppHatariConfig? Hatari { get; set; }
}
}
-299
View File
@@ -1,299 +0,0 @@
namespace MarcerGameDvdLauncher
{
// Encapsulates application lifecycle: load config, initialize components, run navigation
public class LauncherApp
{
public AppConfig? Configuration { get; private set; }
public void Run()
{
try
{
Configuration = LoadConfiguration();
}
catch (Exception ex)
{
ProgramHelpers.ShowConsoleMessage(["Error loading configuration: " + ex.Message, "Please place a valid launcher.config.json in the same folder as the EXE.", "Press any key to exit."
], ConsoleColor.Red);
return;
}
// Setup required components
var appHost = new AppHost(Configuration);
appHost.InitializeComponents();
appHost.RunDirectoryNavigation();
}
private AppConfig LoadConfiguration()
{
string exeDir = AppContext.BaseDirectory;
string configPath = Path.Combine(exeDir, "launcher.config.json");
if (!File.Exists(configPath))
throw new FileNotFoundException($"Configuration file not found: {configPath}");
string json = File.ReadAllText(configPath);
var options = new System.Text.Json.JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
var cfg = System.Text.Json.JsonSerializer.Deserialize<AppConfig>(json, options);
if (cfg == null)
throw new InvalidOperationException("Invalid configuration file (empty or malformed)");
if (string.IsNullOrWhiteSpace(cfg.RootDirectory))
throw new InvalidOperationException("RootDirectory must be set in the configuration.");
// Resolve RootDirectory relative to the EXE directory and validate existence
cfg.RootDirectory = ProgramHelpers.ResolveIfRelative(cfg.RootDirectory, exeDir);
if (!Directory.Exists(cfg.RootDirectory))
throw new InvalidOperationException($"RootDirectory not found: {cfg.RootDirectory}");
// Resolve PatchDirectory relative to the EXE directory as well. PatchDirectory is optional
// and may be empty; ResolveIfRelative returns an empty string for null/whitespace inputs.
cfg.PatchDirectory = ProgramHelpers.ResolveIfRelative(cfg.PatchDirectory, exeDir);
if (cfg.Hatari == null)
throw new InvalidOperationException("Hatari configuration must be present in launcher.config.json.");
cfg.Hatari.Executable = ProgramHelpers.ResolveIfRelative(cfg.Hatari.Executable, exeDir);
cfg.Hatari.ConfigFile = ProgramHelpers.ResolveIfRelative(cfg.Hatari.ConfigFile, exeDir);
if (string.IsNullOrWhiteSpace(cfg.Hatari.Executable))
throw new InvalidOperationException("Hatari.Executable must be set in the configuration.");
if (!File.Exists(cfg.Hatari.Executable))
throw new InvalidOperationException($"Hatari executable not found: {cfg.Hatari.Executable}");
// Also validate the Hatari config file (if provided)
if (!string.IsNullOrWhiteSpace(cfg.Hatari.ConfigFile) && !File.Exists(cfg.Hatari.ConfigFile))
throw new InvalidOperationException($"Hatari configuration file not found: {cfg.Hatari.ConfigFile}");
if (string.IsNullOrWhiteSpace(cfg.Hatari.ArgsTemplate) || !cfg.Hatari.ArgsTemplate.Contains("{zip}"))
throw new InvalidOperationException("Hatari.ArgsTemplate must contain the {zip} placeholder.");
return cfg;
}
}
// Internal host that keeps state previously stored in Program.cs
internal class AppHost(AppConfig cfg)
{
OverlayDirectoryBrowser? _directoryBrowser;
MenuRenderer _menuRenderer = new MenuRenderer();
NavigationController _navigationController = new NavigationController();
List<GameEntry> _gameEntries = new List<GameEntry>();
HatariLauncher? _hatariLauncher;
readonly UIErrorService _errorService = new UIErrorService();
FavoritesService? _favoritesService;
public void InitializeComponents()
{
_directoryBrowser = new OverlayDirectoryBrowser(cfg.RootDirectory ?? string.Empty, cfg.PatchDirectory ?? string.Empty);
// Initialize favorites service. Use PatchDirectory if present, otherwise exe dir fallback.
string favPath;
if (!string.IsNullOrWhiteSpace(cfg.PatchDirectory))
{
favPath = Path.Combine(cfg.PatchDirectory!, "favorites.txt");
}
else
{
favPath = Path.Combine(AppContext.BaseDirectory, "favorites.txt");
}
_favoritesService = new FavoritesService(favPath);
try { _favoritesService.Load(); } catch { /* ignore load errors */ }
try
{
_hatariLauncher = new HatariLauncher(cfg.Hatari?.Executable ?? throw new InvalidOperationException("Hatari.Executable not configured"), cfg.Hatari?.ConfigFile ?? string.Empty, cfg.Hatari?.ArgsTemplate ?? "-c \"{cfg}\" --disk-a \"{zip}\"");
}
catch (Exception ex)
{
ProgramHelpers.ShowConsoleMessage(["Hatari initialization error: " + ex.Message, "Press any key to exit."
], ConsoleColor.Red);
Environment.Exit(1);
}
Console.CursorVisible = false;
}
public void RunDirectoryNavigation()
{
bool exitRequested = false;
ReloadGameEntries();
int currentAvailableLines = Console.WindowHeight - 1;
int currentWidth = Console.WindowWidth;
_navigationController.UpdateScrollOffset(_gameEntries.Count, currentAvailableLines);
var isFav = new Func<GameEntry, bool>(e => _favoritesService?.IsFavorite(e.Kind == EntryKind.Zip ? (e.InPatch ? e.PatchPath : e.RootPath) ?? string.Empty : string.Empty) ?? false);
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset, _navigationController.SelectedIndex, currentAvailableLines, isFav);
while (!exitRequested)
{
// Reloads are performed explicitly when entering or leaving directories (Enter/Backspace)
// Do NOT hit the filesystem here on every loop iteration.
// detect a change in console height and/or width and redraw immediately
int latestAvailableLines = Console.WindowHeight - 1;
int latestWidth = Console.WindowWidth;
if (latestAvailableLines != currentAvailableLines || latestWidth != currentWidth)
{
currentAvailableLines = latestAvailableLines;
currentWidth = latestWidth;
_navigationController.UpdateScrollOffset(_gameEntries.Count, currentAvailableLines);
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset, _navigationController.SelectedIndex, currentAvailableLines, isFav);
}
// Only block if there's actually a key; otherwise allow resize detection
if (!Console.KeyAvailable)
{
Thread.Sleep(50);
continue;
}
var key = Console.ReadKey(intercept: true);
switch (key.Key)
{
case ConsoleKey.UpArrow:
int previousSelectedIndexUp = _navigationController.SelectedIndex;
bool didScrollUp = _navigationController.MoveUp(_gameEntries, currentAvailableLines);
if (didScrollUp)
{
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset, _navigationController.SelectedIndex, currentAvailableLines, isFav);
}
else
{
_menuRenderer.RedrawEntry(_gameEntries, previousSelectedIndexUp, previousSelectedIndexUp - _navigationController.ScrollOffset, false, currentAvailableLines, isFav);
_menuRenderer.RedrawEntry(_gameEntries, _navigationController.SelectedIndex, _navigationController.SelectedIndex - _navigationController.ScrollOffset, true, currentAvailableLines, isFav);
}
// flush input to avoid key repeat
ProgramHelpers.FlushInputBuffer();
break;
case ConsoleKey.DownArrow:
int previousSelectedIndexDown = _navigationController.SelectedIndex;
bool didScrollDown = _navigationController.MoveDown(_gameEntries, currentAvailableLines);
if (didScrollDown)
{
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset, _navigationController.SelectedIndex, currentAvailableLines, isFav);
}
else
{
_menuRenderer.RedrawEntry(_gameEntries, previousSelectedIndexDown, previousSelectedIndexDown - _navigationController.ScrollOffset, false, currentAvailableLines, isFav);
_menuRenderer.RedrawEntry(_gameEntries, _navigationController.SelectedIndex, _navigationController.SelectedIndex - _navigationController.ScrollOffset, true, currentAvailableLines, isFav);
}
ProgramHelpers.FlushInputBuffer();
break;
case ConsoleKey.Enter:
var oldRelativePath = _navigationController.CurrentRelativePath;
var isDirectory = _gameEntries.Count > 0 && _gameEntries[_navigationController.SelectedIndex].Kind == EntryKind.Directory;
_navigationController.HandleEnter(_gameEntries);
if (isDirectory && oldRelativePath != _navigationController.CurrentRelativePath) {
ReloadGameEntries();
_navigationController.UpdateScrollOffset(_gameEntries.Count, currentAvailableLines);
}
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset, _navigationController.SelectedIndex, currentAvailableLines, isFav);
// Only start a ZIP if NOT switching to a directory
if (!isDirectory && _gameEntries.Count > 0 && _gameEntries[_navigationController.SelectedIndex].Kind == EntryKind.Zip)
{
string zipToLaunch = _gameEntries[_navigationController.SelectedIndex].InPatch ? _gameEntries[_navigationController.SelectedIndex].PatchPath : _gameEntries[_navigationController.SelectedIndex].RootPath;
try
{
_hatariLauncher!.Launch(zipToLaunch);
}
catch (Exception ex)
{
_errorService.ShowError(ex.Message);
}
}
// flush input to avoid leftover key events after an enter/navigation
ProgramHelpers.FlushInputBuffer();
break;
case ConsoleKey.Backspace:
_navigationController.GoUpDirectory();
ReloadGameEntries();
_navigationController.UpdateScrollOffset(_gameEntries.Count, currentAvailableLines);
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset, _navigationController.SelectedIndex, currentAvailableLines, isFav);
// flush input to avoid leftover key events after directory change
ProgramHelpers.FlushInputBuffer();
break;
case ConsoleKey.PageDown:
_navigationController.PageDown(_gameEntries, currentAvailableLines);
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset, _navigationController.SelectedIndex, currentAvailableLines, isFav);
ProgramHelpers.FlushInputBuffer();
break;
case ConsoleKey.PageUp:
_navigationController.PageUp(_gameEntries, currentAvailableLines);
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset, _navigationController.SelectedIndex, currentAvailableLines, isFav);
ProgramHelpers.FlushInputBuffer();
break;
case ConsoleKey.Multiply:
case ConsoleKey.Oem8:
// Toggle favorite for selected ZIP (handles numpad * and some layouts)
if (_gameEntries.Count > 0 && _gameEntries[_navigationController.SelectedIndex].Kind == EntryKind.Zip)
{
var ge = _gameEntries[_navigationController.SelectedIndex];
string path = ge.InPatch ? ge.PatchPath : ge.RootPath;
try
{
_favoritesService?.Toggle(path);
}
catch (Exception ex)
{
_errorService.ShowError("Failed to toggle favorite: " + ex.Message);
}
// Redraw the whole menu so the '*' marker updates immediately
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset, _navigationController.SelectedIndex, currentAvailableLines, isFav);
}
ProgramHelpers.FlushInputBuffer();
break;
case ConsoleKey.Escape:
exitRequested = true;
break;
}
}
}
void ReloadGameEntries()
{
try
{
// If we are at the virtual Favorites folder, produce the flat list from the favorites service
if (string.Equals(_navigationController.CurrentRelativePath, "Favorites", StringComparison.OrdinalIgnoreCase))
{
var favs = _favoritesService?.GetAll() ?? new List<string>();
_gameEntries = favs.Select(p => new GameEntry
{
Name = Path.GetFileName(p),
Kind = EntryKind.Zip,
InRoot = true,
InPatch = false,
RootPath = p,
PatchPath = string.Empty,
IsVirtual = false
}).ToList();
_navigationController.SetEntriesCount(_gameEntries.Count);
return;
}
// Otherwise use the overlay directory browser for normal folders
_gameEntries = _directoryBrowser!.GetEntries(_navigationController.CurrentRelativePath);
// If we are at the root and there are favorites, prepend a virtual "Favorites" folder
if (string.IsNullOrEmpty(_navigationController.CurrentRelativePath) && (_favoritesService?.HasFavorites() ?? false))
{
var virtualEntry = new GameEntry
{
Name = "Favorites",
Kind = EntryKind.Directory,
InRoot = true,
InPatch = false,
RootPath = string.Empty,
PatchPath = string.Empty,
IsVirtual = true
};
// insert at the beginning
_gameEntries.Insert(0, virtualEntry);
}
_navigationController.SetEntriesCount(_gameEntries.Count);
}
catch (Exception ex)
{
// Show the error to the user and continue with an empty list
_errorService.ShowError(ex.Message);
_gameEntries = new List<GameEntry>();
_navigationController.SetEntriesCount(0);
}
}
}
}
-12
View File
@@ -1,12 +0,0 @@
namespace MarcerGameDvdLauncher
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Marcer GameDVD Launcher";
var app = new LauncherApp();
app.Run();
}
}
}
-12
View File
@@ -1,12 +0,0 @@
namespace MarcerGameDvdLauncher;
/// <summary>
/// Centralized service for error and user message output in the console UI.
/// </summary>
public class UIErrorService
{
public void ShowError(string message)
{
ProgramHelpers.ShowConsoleMessage([message], ConsoleColor.Red, clear: false, waitForKey: true);
}
}
@@ -1,9 +0,0 @@
{
"RootDirectory": "C:\\Games\\Hatari\\ROMS",
"PatchDirectory": "C:\\Games\\Hatari\\PATCH",
"Hatari": {
"Executable": "C:\\Tools\\hatari\\hatari.exe",
"ConfigFile": "C:\\Tools\\hatari\\hatari-st.cfg",
"ArgsTemplate": "-c \"{cfg}\" --disk-a \"{zip}\""
}
}
+33 -41
View File
@@ -4,21 +4,18 @@ Ziel: Das Repo aufräumen (Doku, Code, Config)
## 1. Code-Qualität Schwächen beheben (harmlos, rein refaktoriell)
- [ ] **LauncherApp.cs zerlegen:** Die ~300-Zeilen-Klasse in separate Klassen aufteilen
(z.B. `InputController`/`KeyHandler` für den switch-Block, Lifecycle bleibt in LauncherApp).
- [x] **LauncherApp.cs zerlegen:** Die ~300-Zeilen-Klasse in separate Klassen aufteilen
(InputController.cs extrahiert mit Key-Handling + ReloadGameEntries; Lifecycle & Main-Loop bleiben in AppHost).
Ziel: keine Funktionsänderung, nur Struktur.
- [ ] **Magische Strings entfernen / zentralisieren (nur im Code, siehe 2c):**
- [ ] Virtueller Ordnername `"Favorites"` (LauncherApp.cs) → gemeinsame Konstante (nicht konfigurierbar).
- [ ] Dateiname `"favorites.txt"` (LauncherApp.cs) → Konstante in FavoritesService (nicht konfigurierbar).
- [ ] Console-Titel `"Marcer GameDVD Launcher"` (Program.cs) → Konstante (nicht konfigurierbar).
- [ ] Default-ArgsTemplate `-c "{cfg}" --disk-a "{zip}"` (LauncherApp.cs) → redundanten Fallback
entfernen; Config liefert den Template (ist schon in der example definiert, Validation `{zip}` existiert).
- [ ] **Scroll-Trigger magische Zahlen** (NavigationController.cs: `2/3`, `1/3`) in benannte Konstanten
(z.B. `BottomScrollFraction = 2f/3f`) mit Kommentar aufzählen.
- [ ] Redundanz beseitigen: `RedrawEntry` hat unnötige `maxRow`-Logik; `EnsureCacheForRow` ungenau →
klarer formulieren.
- [ ] **Fehler-Schlucken besprechen:** `FavoritesService.Save()` (catch leer) und `UIErrorService`
entweder Kommentar ergänzen („bewusst still") oder Rückgabewert einführen.
- [x] **Magische Strings entfernen / zentralisieren (nur im Code, siehe 2c):**
- [x] Virtueller Ordnername `"Favorites"` `FavoritesService.FavoritesRootName` Konstante (nicht konfigurierbar).
- [x] Dateiname `"favorites.txt"` `FavoritesService.DefaultFileName` Konstante (nicht konfigurierbar).
- [x] Console-Titel `"Marcer GameDVD Launcher"` (Program.cs) → `DefaultTitle` Konstante (nicht konfigurierbar).
- [x] Default-ArgsTemplate `-c "{cfg}" --disk-a "{zip}"` (LauncherApp.cs) → redundanten Fallback entfernt; Config liefert das Template (Validation `{zip}` existiert schon).
- [x] **Scroll-Trigger magische Zahlen** (NavigationController.cs: `2/3`, `1/3`) in benannte Konstanten
(`BottomScrollFraction = 2.0/3.0`, `TopScrollFraction = 1.0/3.0`) mit Kommentar aufzählen.
- [x] Redundanz beseitigen: `RedrawEntry` — überflüssige `maxRow`-Logik entfernt, `EnsureCacheForRow` durch `EnsureCache` ersetzt (klare Formulierung).
- [x] **Fehler-Schlucken besprechen:** `FavoritesService.Save()` (catch leer) — Kommentar korrigiert ("bewusst still", erklärt warum Persistence-Fehler nicht zum Absturz führen); `UIErrorService` — DocComment erweitert (Fehler werden gezeigt, nicht regeworfen, App bleibt im Loop).
- [ ] (Optional) Testprojekt hinzufügen für NavigationController & OverlayDirectoryBrowser
vorab mit Nutzer klären, da Policy bisher keine Tests vorsieht.
@@ -33,29 +30,25 @@ Ziel: Das Repo aufräumen (Doku, Code, Config)
- Ziel: Farben (Foreground pro Entry-Typ + Selection-Farben) in `launcher.config.json` konfigurierbar
machen (**Entscheidung: ja, konfigurierbar**), mit Default-Fallback auf heutige Werte.
- [ ] `AppConfig` erweitern: neuen Abschnitt z.B. `"Colors"` hinzufügen:
- [ ] POCO `AppColorConfig` mit `ConsoleColor`-Werten (als String, z.B. `"Yellow"`):
- FolderBoth, FolderPatchOnly, FolderRootOnly,
ZipBoth, ZipRootOnly, ZipPatchOnly,
SelectedForeground, SelectedBackground, VirtualEntry(vorab optional).
- [ ] Deserialisierung per `Enum.TryParse<ConsoleColor>` + Default-Fallback.
- [ ] `MenuRenderer` bekommt optional passende `AppColorConfig` (Konstruktor-Injection);
`GetColorForEntry`/`GetColors` nutzen Config statt Konstanten.
- [ ] Falls Config-Werte fehlen → heutiges Verhalten beibehalten (fallback).
- [ ] Doku synchronisieren: README + agents.md Farbtabellen auf Config-Felder verlinken.
- [ ] Beispielwerte ins `launcher.config.example.json` aufnehmen.
- [x] `AppConfig` erweitern: neuen Abschnitt `"Colors"` hinzugefügt:
- [x] POCO `AppColorConfig` mit `ConsoleColor`-Werten (als String, z.B. `"Yellow"`):
FolderBoth, FolderPatchOnly, FolderRootOnly, ZipBoth, ZipRootOnly, ZipPatchOnly,
SelectedForeground, SelectedBackground, VirtualEntry.
- [x] Deserialisierung per `Enum.TryParse<ConsoleColor>` + Default-Fallback (manuell via `ParseAppColors`/`ParseColorField`).
- [x] `MenuRenderer` bekommt `AppColorConfig` via Konstruktor-Injection; `GetColorForEntry`/`GetColors` nutzen Config statt Konstanten.
- [x] Falls Config-Werte fehlen → heutiges Verhalten beibehalten (fallback).
- [x] Doku synchronisiert: README + AGENTS.md Farbtabellen auf Config-Felder verlinkt.
- [x] Beispielwerte ins `launcher.config.example.json` aufgenommen.
### 2b. Benutzer-Config (User-Config) entschieden
Ziel: die echte lokale Config gehört NICHT ins Repo, sondern bleibt lokal.
- [ ] **Entscheidung getroffen (Variante 1):** `launcher.config.json` bleibt im Build-Output/EXE-Ordner
(lokal, gitignored). Die `launcher.config.example.json` wird beim Release mitgeliefert und der
Nutzer passt sie sich manuell an → kopieren zu `launcher.config.json`.
- [ ] KEINE zusätzliche Suchreihenfolge (`%APPDATA%`, `~/.config`) implementieren.
- [ ] KEIN CLI-Parameter `--config` einführen.
- [ ] `.gitignore` entsprechend ergänzen (echte `launcher.config.json` + `favorites.txt` werden nie committet).
- [ ] README: Abschnitt „Configuration" beschreibt nur das manuelle Kopieren der example.
- [x] **Entscheidung getroffen (Variante 1):** `launcher.config.json` bleibt im Build-Output/EXE-Ordner (lokal, gitignored). Die `launcher.config.example.json` wird beim Release mitgeliefert und der Nutzer kopiert sie manuell zu `launcher.config.json`.
- [x] KEINE zusätzliche Suchreihenfolge (`%APPDATA%`, `~/.config`) implementiert — Pfad ist ausschließlich `AppContext.BaseDirectory`.
- [x] KEIN CLI-Parameter `--config` eingeführt.
- [x] `.gitignore` ergänzt: `launcher.config.json` und `favorites.txt` werden nie committet.
- [x] README: Abschnitt „Configuration" beschreibt manuelles Kopieren der example.
### 2c. Platzhalterwerte zentralisieren (sehr detailliert)
@@ -80,18 +73,17 @@ externe Anpassungsmöglichkeit dafür.
**Verbindliche To-dos für 2c:**
- [ ] Konstanten/Helfer einführen für: Favorites-Ordnername, `favorites.txt`, Konsolen-Titel,
Scroll-Anteile, `AvailableLines`-Helfer.
- [ ] Default-ArgsTemplate-Fallback entfernen; Config muss `ArgsTemplate` immer liefern.
- [ ] Alle vorkommenden String-Literale auf die neuen Konstanten zurückführen (kein doppeltes `"Favorites"` mehr).
- [ ] Kommentare ergänzen, die erklären, WARUM der Wert fest ist (z.B. `WindowHeight-1` als Policy).
- [ ] Win32-Konstanten (Punkt 7) NICHT anfassen, nur per Kommentar als „bewusst hartkodiert" markieren.
- [ ] README/agents nicht um diese rein implementativen Werte erweitern (keine Config-Felder dokumentieren);
- [x] Konstanten/Helfer eingeführt für: `FavoritesRootName` (FavoritesService), `DefaultFileName` (FavoritesService), `DefaultTitle` (Program), `BottomScrollFraction`/`TopScrollFraction` (NavigationController), `AvailableLines`-Helfer (ProgramHelpers).
- [x] Default-ArgsTemplate-Fallback entfernt; Config muss `ArgsTemplate` immer liefern (Validation existiert bereits).
- [x] Alle String-Literale auf Konstanten zurückgeführt (kein doppeltes `"Favorites"` mehr — nur die Konstantendefinition).
- [x] Kommentare ergänzt, die erklären, WARUM Werte fest sind (`AvailableLines` als Policy, Win32-Konstanten als API-konstant, Scroll-Anteile als feste Navigation).
- [x] Win32-Konstanten (Punkt 7) NICHT angefasst, nur per Kommentar als „bewusst hartkodiert" markiert.
- [x] README/agents nicht um diese rein implementativen Werte erweitert (keine Config-Felder dokumentiert);
Doku bleibt bei nutzersichtbaren, konfigurierbaren Werten (Farben, Titel, RootDir/Patch/Hatari).
---
## 4. Abschlusskriterien
- [ ] Commit mit aussagekräftiger Message (nur echter Autor, kein Co-Author).
- [ ] Nach Doku- und Code-Änderungen: `build.cmd` (Windows) bzw. `build.sh` (Linux) läuft fehlerfrei.
- [x] Commit mit aussagekräftiger Message (nur echter Autor, kein Co-Author).
- [x] Nach Doku- und Code-Änderungen: `scripts/build.sh` (Linux) läuft fehlerfrei.
+231 -109
View File
@@ -1,99 +1,69 @@
# Marcer GameDVD Launcher
A performant, consistent console launcher for the Hatari emulator on Windows. Control is entirely via keyboard—using only the arrow keys, Enter, Backspace, ESC, PageUp, and PageDown, you can browse your game archive quickly and comfortably. Navigation is strictly limited to the configured root directory. ZIPs are seamlessly launched via Hatari. Thanks to overlay/patch mode, a consistent color scheme, and robust cursor/scroll logic, even the largest archives or deeply nested directory trees are handled smoothly and reliably.
A fast, keyboard-driven console launcher for the Hatari emulator. Browse your Atari ST game archive, navigate folders, and launch ZIPs — all from the terminal. Supports overlay/patch mode for comparing and merging game directories.
## Features
- **Overlay/Patch Union:** Recursively merges main and patch directory at every level. Each object/name is shown only once (patch takes precedence).
- **Dynamic, practical color scheme:**
| Entry | ConsoleColor | Meaning
|------------------------|--------------|---------------------------------------------|
| Folder in both | ConsoleColor.Yellow | Directory in both layers (patch/main)
| Patch-only folder | ConsoleColor.DarkYellow | Directory only in patch layer
| Main-only folder | ConsoleColor.Gray | Directory only in main layer
| ZIP in both | ConsoleColor.Green | ZIP archive in both layers
| Main-only ZIP | ConsoleColor.DarkGreen | ZIP archive only in main layer
| Patch-only ZIP | ConsoleColor.Magenta | ZIP archive only in patch layer
## Roadmap
### Released Features
- **Favorites/bookmark system:**
- Press `*` on a ZIP to toggle it as a favorite. Favorites are shown in a virtual `Favorites` folder at the top of the root listing when any favorites exist.
- Favorites are persisted in `favorites.txt` in the configured `PatchDirectory`, or next to the EXE if no patch directory is set.
### Planned Features
- **ZIP database & metadata extraction** (from version 2.0)
- Builds a database (e.g. as a local file), stores all known ZIPs
- Enables full-text search, filters, later analysis
- **Search/filter (quicksearch) over ZIPs** (from v2.0, via database)
- Fast name search inside launcher, with history
- **History/list of recently launched games** (from v2.0, via database)
- Automatic access to recently played titles
- **Overlay hot swap** (from version 3.0)
- Overlay/patch folder can be switched at runtime, instant comparison
**More ideas will be added iteratively!**
Built for the [Marcer GameDVD](https://www.facebook.com/groups/360493904888475/) community on Facebook.
---
**Display Performance Note:**
- The current rendering logic follows state-of-the-art principles for performant C# console apps:
- Minimal redraw: Only the truly changed line is redrawn, never the whole screen.
- No Console.Clear or full redraw on cursor movement—just targeted SetCursorPosition and Write.
- This method (per StackOverflow, Spectre.Console, Terminal.Gui, etc.) is optimal for smooth navigation in large lists.
- Further performance can be gained with shadow buffers/string-diffs per line, but currently there's no practical performance issue.
- Thus, display performance is at “best practice” level for .NET TUIs.
- Long file names and narrow console widths are handled defensively: MenuRenderer truncates file names so that each rendered line is exactly Console.WindowWidth characters long. This prevents Console.Write from overflowing the line and avoids visual artifacts when names are longer than the available width.
## 🎮 Features
- **Overlay/Patch Mode:** Recursively merges a main game directory with an optional patch directory. If a file or folder exists in both, the patch version takes precedence.
- **Layer Labels:** Each entry shows its source — `[BOTH]`, `[ROOT]`, or `[PTCH]` — with a matching color scheme.
- **Favorites:** Press `*` on any ZIP to bookmark it. Bookmarked games appear in a virtual `Favorites` folder at the top of the root listing.
- **Robust Navigation:** Cursor position is remembered per directory. Scrolling and page jumps adapt dynamically to any console height.
- **Minimal Redraw:** Only changed lines are redrawn — no flicker, no `Console.Clear`, smooth even in huge directory trees.
### Color Scheme
Colors are configurable via the `Colors` section in `launcher.config.json` (see [Configuration](#-configuration)). Defaults are shown below:
| Entry | Label | Default Color | Meaning |
|---|---|---|---|
| Folder in both layers | `[BOTH]` | Yellow | Exists in main + patch |
| Patch-only folder | `[PTCH]` | DarkYellow | Only in patch layer |
| Main-only folder | `[ROOT]` | Gray | Only in main layer |
| ZIP in both layers | `[BOTH]` | Green | Exists in main + patch |
| Main-only ZIP | `[ROOT]` | DarkGreen | Only in main layer |
| Patch-only ZIP | `[PTCH]` | Magenta | Only in patch layer |
| Selected entry | — | Black on DarkCyan | Highlighted entry |
| Virtual entry (Favorites) | — | White | Pseudo-folder |
---
### Features we will NOT implement
- User-configurable key bindings (keymap)
- Display & import of screenshots/cover images
- Music/Sound player integration (YM/MOD/SND, etc.)
- Persistent UI settings, window size management (not relevant in console mode)
## Operation and Display
## 🕹️ End Users
- **Consistent navigation & controls:**
- Arrow up/down: move selection (always visible)
- Enter: open folder / launch ZIP with Hatari (patch variant always preferred if present)
- Backspace: exactly one level up (never exceeds root)
- ESC: exit the program immediately
- PageUp/PageDown: jump exactly one screen full (window height - 1)
- Display always one line less than console height; no overflow/cut-off
- **Cursor position saving per directory:**
- The last position/selection of each directory is retained, even after Backspace
- **Robust, smooth redraw:**
- Optimized full redraw on scrolling/paging
- Minimal redraw on cursor move
- **Minimal resource usage (handles huge trees efficiently)**
- **Navigation can NEVER leave the configured root**
### 📥 Download
## Usage
1. Edit `launcher.config.example.json` to set your `RootDirectory`, optional `PatchDirectory` and the `Hatari` settings, then copy it to `launcher.config.json` for local use. Relative paths are resolved against the EXE folder (build output).
2. **Windows:** Build via `build.cmd`.
3. **Linux:** Build via `build.sh` (run `chmod +x build.sh` first to make it executable).
4. **Always start using `start.cmd`.**
5. In the console, all subfolders and ZIPs in root (and recursively below) will be shown; other file types/hidden files are always ignored.
6. Complete navigation/control with arrow keys, Enter, Backspace, ESC, PgUp/PgDn, as described above.
7. **IMPORTANT:** Navigation/scroll/backspace:
- Backspace never escapes the root
- In root, Backspace has no effect
- Empty directories are reported (display stays stable)
8. **Overlay/patch logic:**
- If a ZIP/folder exists in both patch and main, always the patch version opens/launches
- All navigation is relative to root path—for consistent experience
Download the ZIP for your platform from the [Releases](https://github.com/anomalyco/marcer-gamedvd-launcher/releases) page:
## System Requirements
- **Windows:** .NET Desktop Runtime 10 or later, Hatari Emulator with configured CFG
- **Linux:** .NET Runtime 10 or later, Hatari Emulator with configured CFG (Wine/compatible version)
| Platform | Archive |
|---|---|
| Windows | `*-win-x64.zip` |
| Linux | `*-linux-x64.zip` |
| macOS | `*-osx-x64.zip` |
## Configuration
### 💻 System Requirements
The application reads settings from `launcher.config.json` (the local, user-specific file). A template `launcher.config.example.json` is shipped with the release — copy it to `launcher.config.json` and adjust the paths for your environment.
- **.NET Runtime 10** or later ([download](https://dotnet.microsoft.com/download/dotnet/10.0))
- **Hatari Emulator** with a working configuration file
- Windows: native Hatari
- Linux / macOS: Hatari via Wine or native build
Example `launcher.config.example.json`:
### ⚡ Quick Start
1. Extract the release ZIP to any folder.
2. Copy `launcher.config.example.json` to `launcher.config.json`.
3. Edit `launcher.config.json` — set your game directory and Hatari paths (see [Configuration](#%EF%B8%8F-configuration) below).
4. Run the launcher:
- **Windows:** Double-click `MarcerGameDvdLauncher.exe` or run from a terminal.
- **Linux:** `chmod +x MarcerGameDvdLauncher && ./MarcerGameDvdLauncher`
- **macOS:** `chmod +x MarcerGameDvdLauncher && ./MarcerGameDvdLauncher`
5. Browse and launch games with your keyboard.
### ⚙️ Configuration
The launcher reads `launcher.config.json` from the same directory as the executable. A template is included in the release — copy it and adjust:
```json
{
@@ -103,43 +73,195 @@ Example `launcher.config.example.json`:
"Executable": "C:\\Tools\\hatari\\hatari.exe",
"ConfigFile": "C:\\Tools\\hatari\\hatari-st.cfg",
"ArgsTemplate": "-c \"{cfg}\" --disk-a \"{zip}\""
},
"Colors": {
"FolderBoth": "Yellow",
"FolderPatchOnly": "DarkYellow",
"FolderRootOnly": "Gray",
"ZipBoth": "Green",
"ZipRootOnly": "DarkGreen",
"ZipPatchOnly": "Magenta",
"SelectedForeground": "Black",
"SelectedBackground": "DarkCyan",
"VirtualEntry": "White"
}
}
```
Fields:
- RootDirectory: Absolute (or relative) path to the game root. Navigation must never leave this root directory.
- PatchDirectory: Optional overlay/patch directory (merged with the main root at runtime).
- Hatari.Executable: Full path to `hatari.exe`.
- Hatari.ConfigFile: Full path to the Hatari configuration file.
- Hatari.ArgsTemplate: Argument template used to start Hatari. Use `{cfg}` for the Hatari config file path and `{zip}` for the ZIP file to launch.
| Field | Required | Description |
|---|---|---|
| `RootDirectory` | ✅ | Game root folder. Navigation never leaves this directory. |
| `PatchDirectory` | ❌ | Optional overlay/patch directory merged at runtime. |
| `Hatari.Executable` | ✅ | Path to the Hatari executable. Validated at startup. |
| `Hatari.ConfigFile` | ✅ | Path to the Hatari configuration file. |
| `Hatari.ArgsTemplate` | ✅ | Argument template. Must contain `{zip}`, optionally `{cfg}`. |
| `Colors` | ❌ | Optional color overrides. See [Color Scheme](#-color-scheme) below. Missing or invalid values fall back to defaults. |
Notes:
- Relative paths are resolved relative to the EXE directory (AppContext.BaseDirectory). This makes behavior consistent when running from the build output folder.
- Hatari.Executable is validated at startup: the file must exist and have an .exe extension. Relative paths for Hatari settings are resolved against the EXE folder.
- `Hatari.ArgsTemplate` must contain at least the `{zip}` placeholder. Example: `-c "{cfg}" --disk-a "{zip}"`.
- The program performs a straight string substitution of `{cfg}` and `{zip}`; it does not add additional quoting logic. Therefore include quotes around placeholders in the template if your paths contain spaces (as in the example).
- `launcher.config.example.json` is copied to the output directory by the csproj (`CopyToOutputDirectory=PreserveNewest`).
- After modifying `launcher.config.json`, restart the application for changes to take effect.
**Notes:**
- Relative paths are resolved relative to the executable's directory.
- Include quotes around `{cfg}` and `{zip}` in the template if your paths contain spaces.
- After editing `launcher.config.json`, restart the application.
## Release Workflow
### 🎨 Color Scheme
Releases are automated via GitHub Actions. When a tag matching `v*` is pushed, the workflow (`.github/workflows/release.yml`) automatically:
1. Builds platform-specific artifacts (Windows, Linux, macOS)
2. Generates release notes from git log
3. Creates a GitHub Release with all ZIPs attached
Colors are fully configurable via the `Colors` section of `launcher.config.json`. Each field accepts a [ConsoleColor](https://learn.microsoft.com/dotnet/api/system.consolecolor) name (case-insensitive). Omitting the entire `Colors` section — or any individual field — falls back to the built-in defaults:
| Field | Default | Applies to |
|---|---|---|
| `FolderBoth` | Yellow | Folders in both layers |
| `FolderPatchOnly` | DarkYellow | Folders in patch only |
| `FolderRootOnly` | Gray | Folders in root only |
| `ZipBoth` | Green | ZIPs in both layers |
| `ZipRootOnly` | DarkGreen | ZIPs in root only |
| `ZipPatchOnly` | Magenta | ZIPs in patch only |
| `SelectedForeground` | Black | Foreground for the highlighted entry |
| `SelectedBackground` | DarkCyan | Background for the highlighted entry |
| `VirtualEntry` | White | Virtual entries (e.g. the Favorites pseudo-folder) |
**Notes:**
- Relative paths are resolved relative to the executable's directory.
- Include quotes around `{cfg}` and `{zip}` in the template if your paths contain spaces.
- After editing `launcher.config.json`, restart the application.
### ⌨️ Controls
| Key | Action |
|---|---|
| `↑` / `↓` | Move selection |
| `Enter` / `→` | Open folder or launch ZIP |
| `Backspace` / `←` | Go up one directory level |
| `PageUp` / `PageDown` | Jump one page |
| `*` | Toggle favorite on selected ZIP |
| `?` | Show help overlay |
| `ESC` / `Q` | Exit |
**Navigation rules:**
- Backspace in the root directory has no effect — you can never leave it.
- Empty directories are displayed correctly.
- When a ZIP or folder exists in both layers, the patch version is always launched/opened.
### 🔄 Keeping Your Patch Directory Updated
The community uses [ftp-sync](https://github.com/slippyex/ftp-sync) to keep the patch directory in sync with Marcer's FTP server. This downloads only changed or new files — fast and bandwidth-friendly.
**Setup:**
1. Clone and install ftp-sync:
```bash
git clone https://github.com/slippyex/ftp-sync.git
cd ftp-sync
npm install
```
2. Create a `config.json` with your paths and the FTP credentials from the community:
```json
{
"ftpConfig": {
"host": "<ftp-host>",
"user": "<username>",
"password": "<password>",
"port": 2121
},
"localDir": "C:\\Games\\MarcersGameDVD\\",
"remoteDir": "/GameDVD",
"patchDir": "C:\\Games\\MarcersGameDVD-Patch\\"
}
```
> 💡 Ask in the [Facebook group](https://www.facebook.com/groups/360493904888475/) for the current FTP credentials.
3. Run the sync:
```bash
npm run sync config.json
```
Press `s` to start syncing. Press `q` to exit when done.
4. Point the launcher's `PatchDirectory` in `launcher.config.json` to the `patchDir` from your ftp-sync config.
---
## 🛠️ Developers
### 📋 Prerequisites
- [.NET SDK 10](https://dotnet.microsoft.com/download/dotnet/10.0)
- Windows: `build.cmd` / `start.cmd`
- Linux / macOS: `build.sh` / `start.sh` (run `chmod +x scripts/*.sh` first)
### 🔨 Build & Run
**Windows:**
```bat
scripts\build.cmd
scripts\start.cmd
```
**Linux / macOS:**
```bash
scripts/build.sh
scripts/start.sh
```
> ⚠️ Do **not** use `dotnet build` or `dotnet run` directly — always use the platform build script to ensure consistent output.
### 🧪 Demo Mode
`demo.sh` creates a complete test environment with fake ZIPs and two layers (root + patch), then launches the launcher:
```bash
scripts/demo.sh
```
This builds the project, generates a structured `.demo/` directory with sample folders and ZIPs, writes a matching `launcher.config.json`, and starts the launcher. Useful for quickly testing overlay behavior and navigation without setting up real game files.
> ⚠️ Windows is not supported for `demo.sh`. Use `start.cmd` with your own game files instead.
### 🚀 Release Process
Releases are automated via GitHub Actions (`.github/workflows/release.yml`).
**To create a release:**
1. Ensure `README.md` and `agents.md` are up to date.
You can use the `/create-release` command (via opencode) for a fully automated flow:
```text
/create-release 1.0.0
```
This command validates the version, checks for uncommitted changes, generates a release summary from recent commits, creates a release commit with the summary as the commit message, tags it, and pushes — all in one step. The GitHub Action then builds platform ZIPs and creates the GitHub Release.
**Manual release:**
1. Ensure `README.md` and `AGENTS.md` are up to date.
2. Commit all changes.
3. Create and push a tag: `git tag v{version} && git push origin v{version}`.
4. The GitHub Action handles the rest.
3. Tag and push:
```bash
git tag v1.2.3
git push origin v1.2.3
```
4. The workflow builds platform ZIPs, generates release notes, and creates a GitHub Release.
**Local builds** (for development/testing):
- **Windows:** `build.cmd`
- **Linux/macOS:** `build.sh` (run `chmod +x build.sh` first)
---
## Notes
- Full requirements, features and build rules are always up to date in `agents.md`.
- After every code or feature change and every release, README.md and agents.md must be reviewed and kept up to date.
- For every release, release notes **must** be present listing all changes and bugfixes; this is required by agents.md!
## 🗺️ Roadmap
| Version | Feature |
|---|---|
| 2.0 | ZIP database & metadata extraction |
| 2.0 | Quicksearch / filter over ZIPs |
| 2.0 | History of recently launched games |
| 3.0 | Overlay hot-swap at runtime |
**Not planned:** Configurable keybindings, screenshot/cover display, sound/music integration, persistent UI settings.
---
## 📝 Notes
- Full technical requirements and build rules are in [`AGENTS.md`](AGENTS.md).
- After any functional change, both `README.md` and `AGENTS.md` must be updated.
- Every release **must** include release notes listing all changes and bugfixes.
---
## License
Licensed under the [MIT License](LICENSE) - Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
-29
View File
@@ -1,29 +0,0 @@
#!/bin/bash
# === Build script for MarcerGameDvdLauncher (requires .NET SDK 6 or newer) ===
echo "Building MarcerGameDvdLauncher..."
if ! command -v dotnet &> /dev/null; then
echo "[ERROR] .NET SDK not found. Please install from https://dotnet.microsoft.com/download"
exit 1
fi
# Build in current directory (where build.sh is located)
cd "$(dirname "$0")"
# Change to MarcerGameDvdLauncher subdirectory
cd "MarcerGameDvdLauncher"
dotnet build -c Release
if [ $? -ne 0 ]; then
echo "[ERROR] Build failed!"
exit 2
fi
# Check for the built .exe file
EXEPATH=$(find "bin/Release" -name "MarcerGameDvdLauncher*.exe" -print -quit 2>/dev/null)
if [ -n "$EXEPATH" ] && [ -f "$EXEPATH" ]; then
echo "[OK] Build complete. EXE: \"$EXEPATH\""
else
echo "[WARNING] Build appears successful but .exe not found!"
fi
Executable
+192
View File
@@ -0,0 +1,192 @@
#!/bin/bash
# Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
# Licensed under the MIT License. See LICENSE file in project root for details.
# === Demo setup and run script for MarcerGameDvdLauncher ===
# Creates a structured test directory with main and patch layers,
# populates them with fake ZIPs, then launches the launcher.
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
DEMO_DIR="$SCRIPT_DIR/.demo"
ROOT_DIR="$DEMO_DIR/root"
PATCH_DIR="$DEMO_DIR/patch"
CONFIG_FILE="$SCRIPT_DIR/launcher.config.json"
# --- Step 1: Build ---
echo "=== Building MarcerGameDvdLauncher ==="
cd "$SCRIPT_DIR/src/MarcerGameDvdLauncher"
dotnet build -c Release --verbosity quiet
echo "[OK] Build successful."
# --- Step 2: Create demo directory structure ---
echo ""
echo "=== Setting up demo directories ==="
# Clean previous demo if it exists
rm -rf "$DEMO_DIR"
mkdir -p "$ROOT_DIR" "$PATCH_DIR"
# Helper: create a fake ZIP (just an empty file with .zip extension)
fake_zip() {
touch "$1"
}
# --- ROOT layer (main DVD content) ---
echo "Creating root layer..."
# === Folder A: TEST-ME — Atari Classics (shared with patch — rich mix + subdirs) ===
mkdir -p "$ROOT_DIR/A/TEST-ME Atari Classics"
fake_zip "$ROOT_DIR/A/TEST-ME Atari Classics/Pac-Man.zip"
fake_zip "$ROOT_DIR/A/TEST-ME Atari Classics/Donkey Kong.zip"
fake_zip "$ROOT_DIR/A/TEST-ME Atari Classics/Galaga.zip"
fake_zip "$ROOT_DIR/A/TEST-ME Atari Classics/Space Invaders.zip"
fake_zip "$ROOT_DIR/A/TEST-ME Atari Classics/Frogger.zip"
fake_zip "$ROOT_DIR/A/TEST-ME Atari Classics/Bomberman.zip"
fake_zip "$ROOT_DIR/A/TEST-ME Atari Classics/Tetris.zip"
# Subdirs: Original and Manual
mkdir -p "$ROOT_DIR/A/TEST-ME Atari Classics/Original"
fake_zip "$ROOT_DIR/A/TEST-ME Atari Classics/Original/Pac-Man (Original).zip"
fake_zip "$ROOT_DIR/A/TEST-ME Atari Classics/Original/Donkey Kong (Original).zip"
mkdir -p "$ROOT_DIR/A/TEST-ME Atari Classics/Manual"
touch "$ROOT_DIR/A/TEST-ME Atari Classics/Manual/Pac-Man.pdf" # PDF — should NOT appear
touch "$ROOT_DIR/A/TEST-ME Atari Classics/Manual/Donkey Kong.pdf" # PDF — should NOT appear
# === Folder B: Platformer (root only) ===
mkdir -p "$ROOT_DIR/B/Platformer"
fake_zip "$ROOT_DIR/B/Platformer/Super Mario Bros.zip"
fake_zip "$ROOT_DIR/B/Platformer/Sonic the Hedgehog.zip"
fake_zip "$ROOT_DIR/B/Platformer/Mega Man.zip"
fake_zip "$ROOT_DIR/B/Platformer/Castlevania.zip"
# === Folder C: Puzzle (root only) ===
mkdir -p "$ROOT_DIR/C/Puzzle"
fake_zip "$ROOT_DIR/C/Puzzle/Columns.zip"
fake_zip "$ROOT_DIR/C/Puzzle/Puyo Puyo.zip"
fake_zip "$ROOT_DIR/C/Puzzle/Klax.zip"
# === Folder D: Shoot'em'up (shared with patch — rich mix) ===
mkdir -p "$ROOT_DIR/D/Shoot'em'up"
fake_zip "$ROOT_DIR/D/Shoot'em'up/R-Type.zip"
fake_zip "$ROOT_DIR/D/Shoot'em'up/Gradius.zip"
fake_zip "$ROOT_DIR/D/Shoot'em'up/1942.zip"
fake_zip "$ROOT_DIR/D/Shoot'em'up/Defender.zip"
fake_zip "$ROOT_DIR/D/Shoot'em'up/Centipede.zip"
fake_zip "$ROOT_DIR/D/Shoot'em'up/Galaxian.zip"
# === Folder E: Racing (root only) ===
mkdir -p "$ROOT_DIR/E/Racing"
fake_zip "$ROOT_DIR/E/Racing/Pole Position.zip"
fake_zip "$ROOT_DIR/E/Racing/Out Run.zip"
fake_zip "$ROOT_DIR/E/Racing/Daytona USA.zip"
# --- PATCH layer (overlay/additions) ---
echo "Creating patch layer..."
# === Folder A: TEST-ME — Atari Classics — overrides + new games ===
mkdir -p "$PATCH_DIR/A/TEST-ME Atari Classics"
fake_zip "$PATCH_DIR/A/TEST-ME Atari Classics/Pac-Man.zip" # [BOTH] override
fake_zip "$PATCH_DIR/A/TEST-ME Atari Classics/Donkey Kong.zip" # [BOTH] override
fake_zip "$PATCH_DIR/A/TEST-ME Atari Classics/Pac-Man Championship.zip" # [PTCH] new
fake_zip "$PATCH_DIR/A/TEST-ME Atari Classics/Donkey Kong Jr.zip" # [PTCH] new
# Subdir Original in patch — adds one more
mkdir -p "$PATCH_DIR/A/TEST-ME Atari Classics/Original"
fake_zip "$PATCH_DIR/A/TEST-ME Atari Classics/Original/Galaga (Original).zip" # [PTCH] in subdir
# === Folder D: Shoot'em'up — overrides + new games ===
mkdir -p "$PATCH_DIR/D/Shoot'em'up"
fake_zip "$PATCH_DIR/D/Shoot'em'up/R-Type.zip" # [BOTH] override
fake_zip "$PATCH_DIR/D/Shoot'em'up/R-Type II.zip" # [PTCH] new
fake_zip "$PATCH_DIR/D/Shoot'em'up/Salamander.zip" # [PTCH] new
# === Folder F: Patch-only folder (not in root) ===
mkdir -p "$PATCH_DIR/F/Hack & Translation"
fake_zip "$PATCH_DIR/F/Hack & Translation/Pac-Man MSX.zip"
fake_zip "$PATCH_DIR/F/Hack & Translation/Donkey Kong Remix.zip"
fake_zip "$PATCH_DIR/F/Hack & Translation/Galaga Special.zip"
echo "[OK] Demo structure created."
echo ""
echo " ROOT (DVD) PATCH (Overlay)"
echo " ────────── ───────────────"
echo " A/TEST-ME Atari Classics/ A/TEST-ME Atari Classics/"
echo " ├── Pac-Man.zip [BOTH] ├── Pac-Man.zip"
echo " ├── Donkey Kong.zip [BOTH] ├── Donkey Kong.zip"
echo " ├── Galaga.zip [ROOT] ├── Pac-Man Championship.zip [PTCH]"
echo " ├── Space Invaders.zip [ROOT] ├── Donkey Kong Jr.zip [PTCH]"
echo " ├── Frogger.zip [ROOT] │"
echo " ├── Bomberman.zip [ROOT] └── Original/"
echo " ├── Tetris.zip [ROOT] └── Galaga (Original).zip [PTCH]"
echo " ├── Original/"
echo " │ ├── Pac-Man (Original).zip [ROOT]"
echo " │ └── Donkey Kong (Original).zip [ROOT]"
echo " └── Manual/ (PDFs — should NOT appear)"
echo " ├── Pac-Man.pdf"
echo " └── Donkey Kong.pdf"
echo " B/Platformer/ (no patch)"
echo " ├── Super Mario Bros.zip [ROOT]"
echo " ├── Sonic.zip [ROOT]"
echo " ├── Mega Man.zip [ROOT]"
echo " └── Castlevania.zip [ROOT]"
echo " C/Puzzle/ (no patch)"
echo " ├── Columns.zip [ROOT]"
echo " ├── Puyo Puyo.zip [ROOT]"
echo " └── Klax.zip [ROOT]"
echo " D/Shoot'em'up/ D/Shoot'em'up/"
echo " ├── R-Type.zip [BOTH] ├── R-Type.zip"
echo " ├── Gradius.zip [ROOT] ├── R-Type II.zip [PTCH]"
echo " ├── 1942.zip [ROOT] └── Salamander.zip [PTCH]"
echo " ├── Defender.zip [ROOT]"
echo " ├── Centipede.zip [ROOT]"
echo " └── Galaxian.zip [ROOT]"
echo " E/Racing/ (no patch)"
echo " ├── Pole Position.zip [ROOT]"
echo " ├── Out Run.zip [ROOT]"
echo " └── Daytona USA.zip [ROOT]"
echo " F/Hack & Translation/ [PTCH]"
echo " ├── Pac-Man MSX.zip"
echo " ├── DK Remix.zip"
echo " └── Galaga Special.zip"
echo ""
# --- Step 3: Create launcher.config.json ---
echo "=== Writing launcher.config.json ==="
# Create a fake Hatari executable for demo (Linux: shell script with .exe extension)
HATARI_FAKE="$DEMO_DIR/hatari.exe"
cat > "$HATARI_FAKE" <<'HATEXEC'
#!/bin/bash
echo "[DEMO] Hatari would launch with: $@"
HATEXEC
chmod +x "$HATARI_FAKE"
cat > "$CONFIG_FILE" <<EOF
{
"RootDirectory": "$ROOT_DIR",
"PatchDirectory": "$PATCH_DIR",
"Hatari": {
"Executable": "$HATARI_FAKE",
"ConfigFile": "",
"ArgsTemplate": "{zip}"
}
}
EOF
echo "[OK] Config written to $CONFIG_FILE"
# Copy config to EXE output directory (app looks for it there)
EXE_DIR="$SCRIPT_DIR/src/MarcerGameDvdLauncher/bin/Release/net10.0"
cp "$CONFIG_FILE" "$EXE_DIR/launcher.config.json"
echo "[OK] Config copied to $EXE_DIR"
# --- Step 4: Launch the application ---
echo ""
echo "=== Launching MarcerGameDvdLauncher ==="
echo "Controls: Arrow keys, Enter, Backspace, ESC to exit"
echo ""
cd "$SCRIPT_DIR/src/MarcerGameDvdLauncher"
dotnet run -c Release
+37
View File
@@ -0,0 +1,37 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"schedule": ["before 6am on Monday"],
"packageRules": [
{
"matchManagers": ["nuget"],
"matchUpdateTypes": ["minor", "patch"],
"groupName": "nuget minor/patch",
"automerge": true
},
{
"matchManagers": ["github-actions"],
"groupName": "GitHub Actions",
"automerge": true
},
{
"matchManagers": ["dockerfile"],
"groupName": "Docker",
"automerge": false
},
{
"matchManagers": ["docker-compose"],
"groupName": "Docker Compose",
"automerge": false
},
{
"matchUpdateTypes": ["minor", "patch"],
"automerge": true
},
{
"matchUpdateTypes": ["major"],
"labels": ["major-update"],
"automerge": false
}
]
}
+4 -2
View File
@@ -1,3 +1,5 @@
REM Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
REM Licensed under the MIT License. See LICENSE file in project root for details.
@echo off
REM === Build script for MarcerGameDvdLauncher (requires .NET SDK 6 or newer) ===
@@ -8,9 +10,9 @@ if errorlevel 1 (
exit /b 1
)
REM Im aktuellen Ordner (wo build.cmd liegt) bauen
REM Im src-Ordner bauen (build.cmd liegt in scripts/)
cd /d %~dp0
cd MarcerGameDvdLauncher
cd ..\src\MarcerGameDvdLauncher
dotnet build -c Release
if errorlevel 1 (
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
# Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
# Licensed under the MIT License. See LICENSE file in project root for details.
# === Build script for MarcerGameDvdLauncher (requires .NET SDK 6 or newer) ===
echo "Building MarcerGameDvdLauncher..."
if ! command -v dotnet &> /dev/null; then
echo "[ERROR] .NET SDK not found. Please install from https://dotnet.microsoft.com/download"
exit 1
fi
# Build in MarcerGameDvdLauncher subdirectory (script is in scripts/, code in src/)
cd "$(dirname "$0")"
cd "../src/MarcerGameDvdLauncher"
dotnet build -c Release
if [ $? -ne 0 ]; then
echo "[ERROR] Build failed!"
exit 2
fi
# Check for the built binary
BINPATH=$(find "bin/Release" \( -name "MarcerGameDvdLauncher" -o -name "MarcerGameDvdLauncher.exe" \) -print -quit 2>/dev/null)
if [ -n "$BINPATH" ] && [ -f "$BINPATH" ]; then
echo "[OK] Build complete. Binary: \"$BINPATH\""
else
echo "[WARNING] Build appears successful but binary not found!"
fi
+16
View File
@@ -0,0 +1,16 @@
REM Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
REM Licensed under the MIT License. See LICENSE file in project root for details.
@echo off
REM Starts MarcerGameDvdLauncher.exe (script is in scripts/, code in src/)
setlocal
set EXE_PATH=%~dp0..\src\MarcerGameDvdLauncher\bin\Release\net10.0\MarcerGameDvdLauncher.exe
if not exist "%EXE_PATH%" (
echo [ERROR] Application not built. Please run build.cmd first.
exit /b 1
)
pushd "%~dp0..\src\MarcerGameDvdLauncher\bin\Release\net10.0"
"MarcerGameDvdLauncher.exe"
popd
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
# Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
# Licensed under the MIT License. See LICENSE file in project root for details.
# Starts MarcerGameDvdLauncher (script is in scripts/, code in src/)
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
EXE_PATH="$SCRIPT_DIR/../src/MarcerGameDvdLauncher/bin/Release/net10.0/MarcerGameDvdLauncher"
if [ ! -f "$EXE_PATH" ]; then
echo "[ERROR] Application not built. Please run build.sh first."
exit 1
fi
cd "$SCRIPT_DIR/../src/MarcerGameDvdLauncher/bin/Release/net10.0"
./MarcerGameDvdLauncher
@@ -0,0 +1,43 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
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; }
public string? ConfigFile { get; set; }
public string? ArgsTemplate { get; set; }
}
public class AppConfig
{
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; }
}
}
@@ -1,8 +1,19 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
namespace MarcerGameDvdLauncher
{
// Manages loading, saving and querying favorite ZIP paths.
public class FavoritesService
{
// Virtual folder name displayed at the root when favorites exist.
// Not configurable — fixed UI element.
public const string FavoritesRootName = "Favorites";
// Filename used for persisting favorites to disk.
// Not configurable — fixed persistence file.
public const string DefaultFileName = "favorites.txt";
private readonly string _filePath;
// Use a SortedSet so favorites are kept in sorted order in memory.
private SortedSet<string> _favorites = new(StringComparer.OrdinalIgnoreCase);
@@ -84,7 +95,11 @@ namespace MarcerGameDvdLauncher
}
catch
{
// Let callers surface errors (we swallow here to avoid throwing on write failures during UI operations)
// Swallowed intentionally ("bewusst still"): a persistence failure
// (e.g. disk full, read-only directory) must not crash or interrupt
// the UI. The in-memory state is still updated so the user sees
// immediate feedback; only the on-disk write is lost. On next
// application start the favorites reflect the last successful save.
}
}
}
@@ -1,3 +1,6 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
namespace MarcerGameDvdLauncher
{
public class HatariLauncher
@@ -11,11 +14,9 @@ namespace MarcerGameDvdLauncher
if (string.IsNullOrWhiteSpace(exePath))
throw new ArgumentNullException(nameof(exePath));
// Defensive validation: ensure the executable exists and looks like an .exe
// Defensive validation: ensure the executable exists
if (!File.Exists(exePath))
throw new ArgumentException($"Hatari executable not found: {exePath}", nameof(exePath));
if (!string.Equals(Path.GetExtension(exePath), ".exe", StringComparison.OrdinalIgnoreCase))
throw new ArgumentException($"Hatari executable must be an .exe file: {exePath}", nameof(exePath));
_exePath = exePath;
_cfgPath = cfgPath;
@@ -0,0 +1,255 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
namespace MarcerGameDvdLauncher
{
/// <summary>
/// Handles user input (key events) and the associated navigation / drawing logic.
/// Extracted from AppHost so that LauncherApp stays focused on lifecycle management.
/// No functional change - all key-handling behaviour is preserved exactly.
/// </summary>
internal class InputController
{
private readonly OverlayDirectoryBrowser _directoryBrowser;
private readonly MenuRenderer _menuRenderer;
private readonly NavigationController _navigationController;
private readonly HatariLauncher _hatariLauncher;
private readonly FavoritesService _favoritesService;
private readonly UIErrorService _errorService;
private List<GameEntry> _gameEntries = new();
public IReadOnlyList<GameEntry> GameEntries => _gameEntries;
public InputController(OverlayDirectoryBrowser directoryBrowser, MenuRenderer menuRenderer,
NavigationController navigationController, HatariLauncher hatariLauncher,
FavoritesService favoritesService, UIErrorService errorService)
{
_directoryBrowser = directoryBrowser;
_menuRenderer = menuRenderer;
_navigationController = navigationController;
_hatariLauncher = hatariLauncher;
_favoritesService = favoritesService;
_errorService = errorService;
}
private bool IsFavorite(GameEntry e)
{
return e.Kind == EntryKind.Zip
? _favoritesService.IsFavorite(e.InPatch ? e.PatchPath : e.RootPath)
: false;
}
private void DrawMenu(int availableLines)
{
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset,
_navigationController.SelectedIndex, availableLines, IsFavorite);
}
/// <summary>
/// Updates scroll offset and redraws the full menu. Called on initial load and console resize.
/// </summary>
public void RefreshView(int availableLines)
{
_navigationController.UpdateScrollOffset(_gameEntries.Count, availableLines);
DrawMenu(availableLines);
}
/// <summary>
/// Loads entries for the current directory (or the virtual Favorites folder).
/// </summary>
public void ReloadGameEntries()
{
try
{
// If we are at the virtual Favorites folder, produce the flat list from the favorites service
if (string.Equals(_navigationController.CurrentRelativePath, FavoritesService.FavoritesRootName, StringComparison.OrdinalIgnoreCase))
{
var favs = _favoritesService.GetAll();
_gameEntries = new List<GameEntry>();
foreach (var p in favs)
{
_gameEntries.Add(new GameEntry
{
Name = Path.GetFileName(p),
Kind = EntryKind.Zip,
InRoot = true,
InPatch = false,
RootPath = p,
PatchPath = string.Empty,
IsVirtual = false
});
}
_navigationController.SetEntriesCount(_gameEntries.Count);
return;
}
// Otherwise use the overlay directory browser for normal folders
_gameEntries = _directoryBrowser.GetEntries(_navigationController.CurrentRelativePath);
// If we are at the root and there are favorites, prepend a virtual Favorites folder
if (string.IsNullOrEmpty(_navigationController.CurrentRelativePath) && _favoritesService.HasFavorites())
{
var virtualEntry = new GameEntry
{
Name = FavoritesService.FavoritesRootName,
Kind = EntryKind.Directory,
InRoot = true,
InPatch = false,
RootPath = string.Empty,
PatchPath = string.Empty,
IsVirtual = true
};
_gameEntries.Insert(0, virtualEntry);
}
_navigationController.SetEntriesCount(_gameEntries.Count);
}
catch (Exception ex)
{
// Show the error to the user and continue with an empty list
_errorService.ShowError(ex.Message);
_gameEntries = new List<GameEntry>();
_navigationController.SetEntriesCount(0);
}
}
/// <summary>
/// Handles a key press. Returns true if the application should exit.
/// </summary>
public bool HandleKey(ConsoleKeyInfo key, int availableLines)
{
if (key.KeyChar == '?')
{
_menuRenderer.ShowHelpBox(availableLines);
Console.ReadKey(intercept: true);
_menuRenderer.InvalidateCache();
DrawMenu(availableLines);
ProgramHelpers.FlushInputBuffer();
return false;
}
switch (key.Key)
{
case ConsoleKey.UpArrow:
{
int previousSelectedIndex = _navigationController.SelectedIndex;
bool didScroll = _navigationController.MoveUp(_gameEntries, availableLines);
if (didScroll)
{
DrawMenu(availableLines);
}
else
{
_menuRenderer.RedrawEntry(_gameEntries, previousSelectedIndex, previousSelectedIndex - _navigationController.ScrollOffset, false, availableLines, IsFavorite);
_menuRenderer.RedrawEntry(_gameEntries, _navigationController.SelectedIndex, _navigationController.SelectedIndex - _navigationController.ScrollOffset, true, availableLines, IsFavorite);
}
// flush input to avoid key repeat
ProgramHelpers.FlushInputBuffer();
}
break;
case ConsoleKey.DownArrow:
{
int previousSelectedIndex = _navigationController.SelectedIndex;
bool didScroll = _navigationController.MoveDown(_gameEntries, availableLines);
if (didScroll)
{
DrawMenu(availableLines);
}
else
{
_menuRenderer.RedrawEntry(_gameEntries, previousSelectedIndex, previousSelectedIndex - _navigationController.ScrollOffset, false, availableLines, IsFavorite);
_menuRenderer.RedrawEntry(_gameEntries, _navigationController.SelectedIndex, _navigationController.SelectedIndex - _navigationController.ScrollOffset, true, availableLines, IsFavorite);
}
ProgramHelpers.FlushInputBuffer();
}
break;
case ConsoleKey.Enter:
case ConsoleKey.RightArrow:
{
var oldRelativePath = _navigationController.CurrentRelativePath;
var isDirectory = _gameEntries.Count > 0 && _gameEntries[_navigationController.SelectedIndex].Kind == EntryKind.Directory;
_navigationController.HandleEnter(_gameEntries);
if (isDirectory && oldRelativePath != _navigationController.CurrentRelativePath)
{
ReloadGameEntries();
_navigationController.UpdateScrollOffset(_gameEntries.Count, availableLines);
}
DrawMenu(availableLines);
// Only start a ZIP if NOT switching to a directory
if (!isDirectory && _gameEntries.Count > 0 && _gameEntries[_navigationController.SelectedIndex].Kind == EntryKind.Zip)
{
string zipToLaunch = _gameEntries[_navigationController.SelectedIndex].InPatch ? _gameEntries[_navigationController.SelectedIndex].PatchPath : _gameEntries[_navigationController.SelectedIndex].RootPath;
try
{
_hatariLauncher.Launch(zipToLaunch);
}
catch (Exception ex)
{
_errorService.ShowError(ex.Message);
}
}
// flush input to avoid leftover key events after an enter/navigation
ProgramHelpers.FlushInputBuffer();
}
break;
case ConsoleKey.Backspace:
case ConsoleKey.LeftArrow:
{
_navigationController.GoUpDirectory();
ReloadGameEntries();
_navigationController.UpdateScrollOffset(_gameEntries.Count, availableLines);
DrawMenu(availableLines);
ProgramHelpers.FlushInputBuffer();
}
break;
case ConsoleKey.PageDown:
{
_navigationController.PageDown(_gameEntries, availableLines);
DrawMenu(availableLines);
ProgramHelpers.FlushInputBuffer();
}
break;
case ConsoleKey.PageUp:
{
_navigationController.PageUp(_gameEntries, availableLines);
DrawMenu(availableLines);
ProgramHelpers.FlushInputBuffer();
}
break;
case ConsoleKey.Multiply:
case ConsoleKey.Oem8:
{
// Toggle favorite for selected ZIP (handles numpad * and some layouts)
if (_gameEntries.Count > 0 && _gameEntries[_navigationController.SelectedIndex].Kind == EntryKind.Zip)
{
var ge = _gameEntries[_navigationController.SelectedIndex];
string path = ge.InPatch ? ge.PatchPath : ge.RootPath;
try
{
_favoritesService.Toggle(path);
}
catch (Exception ex)
{
_errorService.ShowError("Failed to toggle favorite: " + ex.Message);
}
// Redraw the whole menu so the '*' marker updates immediately
DrawMenu(availableLines);
}
ProgramHelpers.FlushInputBuffer();
}
break;
case ConsoleKey.Escape:
case ConsoleKey.Q:
return true;
}
return false;
}
}
}
+207
View File
@@ -0,0 +1,207 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
namespace MarcerGameDvdLauncher
{
// Encapsulates application lifecycle: load config, initialize components, run navigation
public class LauncherApp
{
public AppConfig? Configuration { get; private set; }
public void Run()
{
try
{
Configuration = LoadConfiguration();
}
catch (Exception ex)
{
ProgramHelpers.ShowConsoleMessage(["Error loading configuration: " + ex.Message, "Please place a valid launcher.config.json in the same folder as the EXE.", "Press any key to exit."
], ConsoleColor.Red);
return;
}
// Setup required components
var appHost = new AppHost(Configuration);
appHost.InitializeComponents();
appHost.RunDirectoryNavigation();
}
private AppConfig LoadConfiguration()
{
string exeDir = AppContext.BaseDirectory;
string configPath = Path.Combine(exeDir, "launcher.config.json");
if (!File.Exists(configPath))
throw new FileNotFoundException($"Configuration file not found: {configPath}");
string json = File.ReadAllText(configPath);
var options = new System.Text.Json.JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
var cfg = System.Text.Json.JsonSerializer.Deserialize<AppConfig>(json, options);
if (cfg == null)
throw new InvalidOperationException("Invalid configuration file (empty or malformed)");
if (string.IsNullOrWhiteSpace(cfg.RootDirectory))
throw new InvalidOperationException("RootDirectory must be set in the configuration.");
// Resolve RootDirectory relative to the EXE directory and validate existence
cfg.RootDirectory = ProgramHelpers.ResolveIfRelative(cfg.RootDirectory, exeDir);
if (!Directory.Exists(cfg.RootDirectory))
throw new InvalidOperationException($"RootDirectory not found: {cfg.RootDirectory}");
// Resolve PatchDirectory relative to the EXE directory as well. PatchDirectory is optional
// and may be empty; ResolveIfRelative returns an empty string for null/whitespace inputs.
cfg.PatchDirectory = ProgramHelpers.ResolveIfRelative(cfg.PatchDirectory, exeDir);
if (cfg.Hatari == null)
throw new InvalidOperationException("Hatari configuration must be present in launcher.config.json.");
cfg.Hatari.Executable = ProgramHelpers.ResolveIfRelative(cfg.Hatari.Executable, exeDir);
cfg.Hatari.ConfigFile = ProgramHelpers.ResolveIfRelative(cfg.Hatari.ConfigFile, exeDir);
if (string.IsNullOrWhiteSpace(cfg.Hatari.Executable))
throw new InvalidOperationException("Hatari.Executable must be set in the configuration.");
if (!File.Exists(cfg.Hatari.Executable))
throw new InvalidOperationException($"Hatari executable not found: {cfg.Hatari.Executable}");
// Also validate the Hatari config file (if provided)
if (!string.IsNullOrWhiteSpace(cfg.Hatari.ConfigFile) && !File.Exists(cfg.Hatari.ConfigFile))
throw new InvalidOperationException($"Hatari configuration file not found: {cfg.Hatari.ConfigFile}");
if (string.IsNullOrWhiteSpace(cfg.Hatari.ArgsTemplate) || !cfg.Hatari.ArgsTemplate.Contains("{zip}"))
throw new InvalidOperationException("Hatari.ArgsTemplate must contain the {zip} placeholder.");
// Parse Colors section manually so invalid values fall back to defaults
// instead of crashing the deserialization.
cfg.Colors = ParseAppColors(json);
return cfg;
}
// Parses the optional "Colors" JSON section into an AppColorConfig.
// Each field is resolved with Enum.TryParse<ConsoleColor>; unparseable or
// missing values silently fall back to the defaults defined in AppColorConfig.
private static AppColorConfig ParseAppColors(string json)
{
var colors = new AppColorConfig();
try
{
using var doc = System.Text.Json.JsonDocument.Parse(json);
if (doc.RootElement.TryGetProperty("Colors", out var colorsEl) && colorsEl.ValueKind == System.Text.Json.JsonValueKind.Object)
{
ParseColorField(colorsEl, "FolderBoth", v => colors.FolderBoth = v);
ParseColorField(colorsEl, "FolderPatchOnly", v => colors.FolderPatchOnly = v);
ParseColorField(colorsEl, "FolderRootOnly", v => colors.FolderRootOnly = v);
ParseColorField(colorsEl, "ZipBoth", v => colors.ZipBoth = v);
ParseColorField(colorsEl, "ZipRootOnly", v => colors.ZipRootOnly = v);
ParseColorField(colorsEl, "ZipPatchOnly", v => colors.ZipPatchOnly = v);
ParseColorField(colorsEl, "SelectedForeground", v => colors.SelectedForeground = v);
ParseColorField(colorsEl, "SelectedBackground", v => colors.SelectedBackground = v);
ParseColorField(colorsEl, "VirtualEntry", v => colors.VirtualEntry = v);
}
}
catch
{
// On any JSON error, fall back to default colors (already set above)
}
return colors;
}
private static void ParseColorField(System.Text.Json.JsonElement colorsEl, string name, Action<ConsoleColor> setter)
{
if (colorsEl.TryGetProperty(name, out var prop) && prop.ValueKind == System.Text.Json.JsonValueKind.String)
{
var str = prop.GetString();
if (Enum.TryParse<ConsoleColor>(str ?? string.Empty, ignoreCase: true, out var parsed))
setter(parsed);
// Invalid color names are silently ignored — defaults are preserved
}
}
}
// Internal host that keeps state and lifecycle management for the application.
// Key-handling logic has been extracted into InputController; this class
// focuses on component wiring, initialization and the main loop (resize detection + key polling).
internal class AppHost(AppConfig cfg)
{
private InputController? _inputController;
private MenuRenderer? _menuRenderer;
private HatariLauncher? _hatariLauncher;
private int _currentAvailableLines;
private int _currentWidth;
public void InitializeComponents()
{
var directoryBrowser = new OverlayDirectoryBrowser(cfg.RootDirectory ?? string.Empty, cfg.PatchDirectory ?? string.Empty);
// Initialize favorites service. Use PatchDirectory if present, otherwise exe dir fallback.
string favPath;
if (!string.IsNullOrWhiteSpace(cfg.PatchDirectory))
{
favPath = Path.Combine(cfg.PatchDirectory!, FavoritesService.DefaultFileName);
}
else
{
favPath = Path.Combine(AppContext.BaseDirectory, FavoritesService.DefaultFileName);
}
var favoritesService = new FavoritesService(favPath);
try { favoritesService.Load(); } catch { /* ignore load errors */ }
var errorService = new UIErrorService();
try
{
// ArgsTemplate is validated in LoadConfiguration — it must always contain {zip}.
// No hardcoded fallback is needed; the config file is the single source of truth.
_hatariLauncher = new HatariLauncher(cfg.Hatari?.Executable ?? throw new InvalidOperationException("Hatari.Executable not configured"), cfg.Hatari?.ConfigFile ?? string.Empty, cfg.Hatari?.ArgsTemplate ?? string.Empty);
}
catch (Exception ex)
{
ProgramHelpers.ShowConsoleMessage(["Hatari initialization error: " + ex.Message, "Press any key to exit."
], ConsoleColor.Red);
Environment.Exit(1);
}
_menuRenderer = new MenuRenderer(cfg.Colors);
var navigationController = new NavigationController();
_inputController = new InputController(directoryBrowser, _menuRenderer, navigationController,
_hatariLauncher!, favoritesService, errorService);
Console.CursorVisible = false;
}
public void RunDirectoryNavigation()
{
_currentAvailableLines = ProgramHelpers.AvailableLines;
_currentWidth = Console.WindowWidth;
_inputController!.ReloadGameEntries();
_inputController.RefreshView(_currentAvailableLines);
bool exitRequested = false;
while (!exitRequested)
{
// Reloads are performed explicitly by InputController when entering/leaving directories
// Do NOT hit the filesystem here on every loop iteration.
// detect a change in console height and/or width and redraw immediately
int latestAvailableLines = ProgramHelpers.AvailableLines;
int latestWidth = Console.WindowWidth;
if (latestAvailableLines != _currentAvailableLines || latestWidth != _currentWidth)
{
_currentAvailableLines = latestAvailableLines;
_currentWidth = latestWidth;
_inputController.RefreshView(_currentAvailableLines);
}
// Only block if there's actually a key; otherwise allow resize detection
if (!Console.KeyAvailable)
{
Thread.Sleep(50);
continue;
}
var key = Console.ReadKey(intercept: true);
exitRequested = _inputController.HandleKey(key, _currentAvailableLines);
}
}
}
}
@@ -14,6 +14,10 @@
<Content Include="launcher.config.example.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="../../LICENSE">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>LICENSE</Link>
</Content>
</ItemGroup>
</Project>
@@ -1,3 +1,6 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
namespace MarcerGameDvdLauncher
{
public class MenuRenderer
@@ -8,6 +11,14 @@ namespace MarcerGameDvdLauncher
private LineState[] _cachedBuffer = Array.Empty<LineState>();
private int _cachedWidth = -1;
// Color configuration (injected; defaults to built-in scheme if null)
private readonly AppColorConfig _colors;
public MenuRenderer(AppColorConfig? colors = null)
{
_colors = colors ?? new AppColorConfig();
}
// availableLines is provided per-draw so the renderer adapts to console resizes
public void DrawMenu(List<GameEntry> entries, int scrollOffset, int selectedIndex, int availableLines, Func<GameEntry, bool>? isFavorite = null)
{
@@ -40,11 +51,8 @@ namespace MarcerGameDvdLauncher
}
// Diff & write only changed lines
// Use the caller-provided availableLines (which should be Console.WindowHeight - 1)
int maxRow = Math.Max(0, availableLines - 1);
for (int row = 0; row < availableLines; row++)
{
if (row > maxRow) break;
var newLine = newBuffer[row];
var oldLine = _cachedBuffer[row];
if (oldLine.Text != newLine.Text || oldLine.Fg != newLine.Fg || oldLine.Bg != newLine.Bg)
@@ -60,26 +68,16 @@ namespace MarcerGameDvdLauncher
{
if (entryIdx < 0 || entryIdx >= entries.Count) return;
availableLines = Math.Max(1, availableLines);
int maxRow = Math.Max(0, availableLines - 1);
if (row < 0 || row > maxRow) return;
// row is a visual row within the visible window; validate against availableLines
if (row < 0 || row >= availableLines) return;
int width = Console.WindowWidth;
// ensure cache is valid for current width/height and the target row
EnsureCacheForRow(width, Math.Min(availableLines, Math.Max(1, _cachedBuffer.Length == 0 ? 1 : _cachedBuffer.Length)));
// Ensure the cache matches the current dimensions (same as DrawMenu)
EnsureCache(width, availableLines);
var e = entries[entryIdx];
var (fg, bg) = GetColors(e, selected);
string text = BuildLineText(e, width, isFavorite?.Invoke(e) ?? false);
ConsoleColor fg, bg;
if (selected)
{
bg = ConsoleColor.DarkCyan;
fg = ConsoleColor.Black;
}
else
{
bg = ConsoleColor.Black;
fg = GetColorForEntry(e);
}
var newLine = new LineState { Text = text, Fg = fg, Bg = bg };
// If cache differs, write
@@ -110,18 +108,6 @@ namespace MarcerGameDvdLauncher
}
}
// Ensures the cached buffer has at least requiredRows entries and matches width.
private void EnsureCacheForRow(int width, int requiredRows)
{
if (_cachedBuffer.Length < requiredRows || _cachedWidth != width)
{
int newLen = Math.Max(requiredRows, 1);
_cachedBuffer = new LineState[newLen];
for (int i = 0; i < newLen; i++) _cachedBuffer[i].Text = null!;
_cachedWidth = width;
}
}
// Write a line to the console using the centralized logic (handles concurrent resizes safely)
private void WriteConsoleLine(int row, LineState newLine)
{
@@ -139,12 +125,100 @@ namespace MarcerGameDvdLauncher
}
}
// Returns foreground and background colors for an entry depending on selection state
// Invalidates the internal line cache so the next DrawMenu call
// performs a full redraw of every line. Useful after an overlay
// (e.g. help box) has overwritten the console directly.
public void InvalidateCache()
{
for (int i = 0; i < _cachedBuffer.Length; i++)
_cachedBuffer[i].Text = null!;
}
// Renders a centered, bordered help box with key bindings inside the
// available console area. The caller is responsible for waiting on a
// key and redrawing the menu afterwards.
public void ShowHelpBox(int availableLines)
{
try
{
int width = Console.WindowWidth;
string[] helpLines = GetHelpLines();
int boxHeight = Math.Min(helpLines.Length + 2, Math.Max(3, availableLines));
int boxWidth = Math.Max(1, width);
int topRow = Math.Max(0, (availableLines - boxHeight) / 2);
Console.BackgroundColor = ConsoleColor.DarkGray;
Console.ForegroundColor = ConsoleColor.White;
string topBorder = "+" + new string('-', Math.Max(0, boxWidth - 2)) + "+";
Console.SetCursorPosition(0, topRow);
Console.Write(topBorder);
for (int i = 0; i < boxHeight - 2; i++)
{
int row = topRow + 1 + i;
string content;
if (i < helpLines.Length)
{
content = PadToWidth(helpLines[i], boxWidth - 2);
}
else
{
content = new string(' ', Math.Max(0, boxWidth - 2));
}
Console.SetCursorPosition(0, row);
Console.Write("|" + content + "|");
}
int bottomRow = topRow + boxHeight - 1;
if (bottomRow < Console.WindowHeight)
{
string bottomBorder = "+" + new string('-', Math.Max(0, boxWidth - 2)) + "+";
Console.SetCursorPosition(0, bottomRow);
Console.Write(bottomBorder);
}
Console.ResetColor();
}
catch
{
}
}
private static string[] GetHelpLines()
{
return [
" Help — Key Bindings",
" ",
" ↑ / ↓ Move selection up / down",
" Enter / → Open folder / launch ZIP with Hatari",
" ← / BS Go up one directory (never exceeds root)",
" ESC / Q Exit the program",
" PgUp Jump one page up",
" PgDn Jump one page down",
" * Toggle favorite on selected ZIP",
" ? Show this help",
" ",
" Navigation is strictly limited to RootDirectory.",
" The overlay shows both root and patch layers combined.",
" ",
" Press any key to continue...",
];
}
private static string PadToWidth(string text, int width)
{
if (text.Length > width) return text.Substring(0, width);
return text + new string(' ', width - text.Length);
}
// Returns foreground and background colors for an entry depending on selection state.
// Selected colors and entry colors come from the injected AppColorConfig.
private (ConsoleColor fg, ConsoleColor bg) GetColors(GameEntry e, bool selected)
{
if (selected)
{
return (ConsoleColor.Black, ConsoleColor.DarkCyan);
return (_colors.SelectedForeground, _colors.SelectedBackground);
}
else
{
@@ -156,18 +230,8 @@ namespace MarcerGameDvdLauncher
private string BuildLineText(GameEntry e, int width, bool isFavorite)
{
if (width <= 0) return string.Empty;
// Reserve 6 characters for the label area. For directories we show "[DIR] ",
// for ZIPs we use the same width and optionally show a leading '*' when favorited.
string label;
if (e.Kind == EntryKind.Directory)
{
label = "[DIR] ";
}
else
{
// For ZIPs, show '*' after 4 spaces when favorited (keeps 6-char label area).
label = isFavorite ? " * " : new string(' ', 6);
}
string label = GetLabel(e, isFavorite);
// If the console width is smaller than the label, truncate the label
if (width <= label.Length)
@@ -197,21 +261,49 @@ namespace MarcerGameDvdLauncher
return result;
}
private ConsoleColor GetColorForEntry(GameEntry e)
// Returns the left label for an entry based on kind, layer status and favorite state.
// Format: [LayerLabel][TypeIndicator] where
// LayerLabel = [BOTH] / [ROOT] / [PTCH] (7 chars)
// TypeIndicator = [DIR] for dirs, " * " or " " for ZIPs (6 chars)
private static string GetLabel(GameEntry e, bool isFavorite)
{
// Virtual entries (like the Favorites pseudo-folder) should be white
if (e.IsVirtual) return ConsoleColor.White;
// Layer label (7 chars)
string layer;
if (e.InRoot && e.InPatch) layer = "[BOTH] ";
else if (e.InPatch) layer = "[PTCH] ";
else if (e.InRoot) layer = "[ROOT] ";
else layer = " ";
// Type indicator (6 chars)
string type;
if (e.Kind == EntryKind.Directory)
{
if (e.InRoot && e.InPatch) return ConsoleColor.Yellow; // Both layers
if (e.InPatch && !e.InRoot) return ConsoleColor.DarkYellow; // Only patch
if (e.InRoot && !e.InPatch) return ConsoleColor.Gray; // Only root
type = "[DIR] ";
}
else
{
type = isFavorite ? " * " : " ";
}
return layer + type; // 13 chars total
}
private ConsoleColor GetColorForEntry(GameEntry e)
{
// Virtual entries (like the Favorites pseudo-folder) use the configured VirtualEntry color
if (e.IsVirtual) return _colors.VirtualEntry;
if (e.Kind == EntryKind.Directory)
{
if (e.InRoot && e.InPatch) return _colors.FolderBoth; // Both layers
if (e.InPatch && !e.InRoot) return _colors.FolderPatchOnly; // Only patch
if (e.InRoot && !e.InPatch) return _colors.FolderRootOnly; // Only root
}
else if (e.Kind == EntryKind.Zip)
{
if (e.InRoot && e.InPatch) return ConsoleColor.Green;
if (e.InRoot && !e.InPatch) return ConsoleColor.DarkGreen;
if (e.InPatch && !e.InRoot) return ConsoleColor.Magenta;
if (e.InRoot && e.InPatch) return _colors.ZipBoth; // Both layers
if (e.InRoot && !e.InPatch) return _colors.ZipRootOnly; // Only root
if (e.InPatch && !e.InRoot) return _colors.ZipPatchOnly; // Only patch
}
return ConsoleColor.DarkGray;
}
@@ -1,7 +1,16 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
namespace MarcerGameDvdLauncher
{
public class NavigationController
{
// Scroll fractions: when the selection cursor reaches 2/3 of the visible window
// height from the top, the list scrolls down; when it reaches 1/3, it scrolls up.
// Not configurable — these ratios are the established navigation behaviour.
private const double BottomScrollFraction = 2.0 / 3.0;
private const double TopScrollFraction = 1.0 / 3.0;
public int SelectedIndex { get; private set; } = 0;
public int ScrollOffset { get; private set; } = 0;
public string CurrentRelativePath { get; private set; } = "";
@@ -96,12 +105,12 @@ namespace MarcerGameDvdLauncher
if (availableLines < 1) availableLines = 1;
if (entryCount <= availableLines) { ScrollOffset = 0; return; }
if (SelectedIndex == 0) { ScrollOffset = 0; return; }
int bottomScrollTrigger = ScrollOffset + (int)(availableLines * 2 / 3.0);
int topScrollTrigger = ScrollOffset + (int)(availableLines * 1 / 3.0);
int bottomScrollTrigger = ScrollOffset + (int)(availableLines * BottomScrollFraction);
int topScrollTrigger = ScrollOffset + (int)(availableLines * TopScrollFraction);
if (SelectedIndex >= bottomScrollTrigger && (ScrollOffset + availableLines) < entryCount)
ScrollOffset = SelectedIndex - (int)(availableLines * 2 / 3.0);
ScrollOffset = SelectedIndex - (int)(availableLines * BottomScrollFraction);
else if (SelectedIndex < topScrollTrigger && ScrollOffset > 0)
ScrollOffset = SelectedIndex - (int)(availableLines * 1 / 3.0);
ScrollOffset = SelectedIndex - (int)(availableLines * TopScrollFraction);
if (ScrollOffset < 0) ScrollOffset = 0;
if (ScrollOffset > entryCount - availableLines)
ScrollOffset = entryCount - availableLines;
@@ -1,3 +1,6 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
namespace MarcerGameDvdLauncher
{
public enum EntryKind { Directory, Zip }
+18
View File
@@ -0,0 +1,18 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
namespace MarcerGameDvdLauncher
{
class Program
{
// Console window title. Not configurable — fixed application display name.
private const string DefaultTitle = "Marcer GameDVD Launcher";
static void Main(string[] args)
{
Console.Title = DefaultTitle;
var app = new LauncherApp();
app.Run();
}
}
}
@@ -1,3 +1,6 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
using System;
using System.Runtime.InteropServices;
@@ -6,6 +9,11 @@ namespace MarcerGameDvdLauncher
// Small helpers refactored into their own file to keep Program.cs focused.
internal static class ProgramHelpers
{
// The console window height minus one. The last row is reserved to prevent
// auto-scroll / flicker when the cursor reaches the bottom row (project policy).
// Centralized here so the policy lives in exactly one place.
public static int AvailableLines => Math.Max(0, Console.WindowHeight - 1);
// Flushes the console input buffer to avoid processing leftover key events
// Uses Win32 FlushConsoleInputBuffer on the standard input handle. On non-Windows
// environments this will be a no-op.
@@ -28,6 +36,8 @@ namespace MarcerGameDvdLauncher
}
}
// Win32 API constants — intentionally hardcoded (bewusst hartkodiert).
// These are defined by the Windows API and do not change.
private const int STD_INPUT_HANDLE = -10;
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
@@ -38,6 +48,7 @@ namespace MarcerGameDvdLauncher
private static extern bool FlushConsoleInputBuffer(IntPtr hConsoleInput);
// P/Invoke to query key state (used to detect physical key release)
// Win32 virtual-key code — intentionally hardcoded (bewusst hartkodiert).
private const int VK_RETURN = 0x0D;
[DllImport("user32.dll")]
@@ -52,7 +63,7 @@ namespace MarcerGameDvdLauncher
{
try
{
int lastRow = Math.Max(0, Console.WindowHeight - 1);
int lastRow = AvailableLines;
int width = Console.WindowWidth;
string text = message ?? string.Empty;
if (text.Length > width) text = text.Substring(0, Math.Max(0, width - 3)) + "...";
@@ -0,0 +1,19 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
namespace MarcerGameDvdLauncher;
/// <summary>
/// Centralized service for error and user message output in the console UI.
/// Errors are presented to the user via <see cref="ProgramHelpers.ShowConsoleMessage"/>
/// and are not rethrown — the caller's context does not allow for meaningful error
/// recovery, so the application stays in the navigation loop after the user dismisses
/// the message.
/// </summary>
public class UIErrorService
{
public void ShowError(string message)
{
ProgramHelpers.ShowConsoleMessage([message], ConsoleColor.Red, clear: false, waitForKey: true);
}
}
@@ -0,0 +1,20 @@
{
"RootDirectory": "C:\\Games\\Hatari\\ROMS",
"PatchDirectory": "C:\\Games\\Hatari\\PATCH",
"Hatari": {
"Executable": "C:\\Tools\\hatari\\hatari.exe",
"ConfigFile": "C:\\Tools\\hatari\\hatari-st.cfg",
"ArgsTemplate": "-c \"{cfg}\" --disk-a \"{zip}\""
},
"Colors": {
"FolderBoth": "Yellow",
"FolderPatchOnly": "DarkYellow",
"FolderRootOnly": "Gray",
"ZipBoth": "Green",
"ZipRootOnly": "DarkGreen",
"ZipPatchOnly": "Magenta",
"SelectedForeground": "Black",
"SelectedBackground": "DarkCyan",
"VirtualEntry": "White"
}
}
-14
View File
@@ -1,14 +0,0 @@
@echo off
REM Starts MarcerGameDvdLauncher.exe from the correct folder
setlocal
set EXE_PATH=%~dp0MarcerGameDvdLauncher\bin\Release\net10.0\MarcerGameDvdLauncher.exe
if not exist "%EXE_PATH%" (
echo [ERROR] Application not built. Please run build.cmd first.
exit /b 1
)
pushd "MarcerGameDvdLauncher\bin\Release\net10.0"
"MarcerGameDvdLauncher.exe"
popd