model center and wait for hatari

This commit is contained in:
2026-08-11 19:55:44 +02:00
parent 9649910df6
commit 0117ba90c3
4 changed files with 28 additions and 23 deletions
+5
View File
@@ -83,6 +83,11 @@ fake_zip "$ROOT_DIR/E/Racing/Pole Position.zip"
fake_zip "$ROOT_DIR/E/Racing/Out Run.zip" fake_zip "$ROOT_DIR/E/Racing/Out Run.zip"
fake_zip "$ROOT_DIR/E/Racing/Daytona USA.zip" fake_zip "$ROOT_DIR/E/Racing/Daytona USA.zip"
# === Folders G-Z: empty placeholder folders ===
for letter in {G..Z}; do
mkdir -p "$ROOT_DIR/$letter"
done
# --- PATCH layer (overlay/additions) --- # --- PATCH layer (overlay/additions) ---
echo "Creating patch layer..." echo "Creating patch layer..."
+4 -5
View File
@@ -55,11 +55,10 @@ namespace MarcerGameDvdLauncher
UseShellExecute = false, UseShellExecute = false,
WorkingDirectory = Directory.GetCurrentDirectory() WorkingDirectory = Directory.GetCurrentDirectory()
}; };
System.Diagnostics.Process.Start(psi); var process = System.Diagnostics.Process.Start(psi);
// Show a modal indicating the emulator was started and wait until // Show a modal indicating the emulator is running and wait until
// the user releases the Return key before clearing the modal. This // the process has exited before clearing the modal.
// prevents accidental key repeats from triggering other actions. ProgramHelpers.ShowModalUntilProcessExited(process, "Hatari is running...");
ProgramHelpers.ShowModalUntilReturnReleased("Hatari started. Release Return to continue...");
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -171,6 +171,8 @@ namespace MarcerGameDvdLauncher
{ {
errorService.ShowError(ex.Message); errorService.ShowError(ex.Message);
} }
// Redraw menu after Hatari has exited
DrawMenu(availableLines);
} }
// flush input to avoid leftover key events after an enter/navigation // flush input to avoid leftover key events after an enter/navigation
ProgramHelpers.FlushInputBuffer(); ProgramHelpers.FlushInputBuffer();
+17 -18
View File
@@ -53,37 +53,36 @@ namespace MarcerGameDvdLauncher
[DllImport("user32.dll")] [DllImport("user32.dll")]
private static extern short GetAsyncKeyState(int vKey); private static extern short GetAsyncKeyState(int vKey);
// Shows a simple modal message on the reserved last console line and // Shows a simple modal message in the center of the console and
// blocks until the Return key is physically released. The message is // blocks until the given process has exited. The message is then
// then removed and the method returns. This is designed to be a // removed and the method returns.
// lightweight modal for the console UI and uses the last console line public static void ShowModalUntilProcessExited(System.Diagnostics.Process? process, string? message)
// which the application reserves for transient messages.
public static void ShowModalUntilReturnReleased(string? message)
{ {
try try
{ {
var lastRow = AvailableLines; int width = Console.WindowWidth;
var width = Console.WindowWidth; int height = Console.WindowHeight;
int centerRow = height / 2;
var text = message ?? string.Empty; var text = message ?? string.Empty;
if (text.Length > width) text = text.Substring(0, Math.Max(0, width - 3)) + "..."; if (text.Length > width - 4) text = text.Substring(0, Math.Max(0, width - 7)) + "...";
var padding = Math.Max(0, width - text.Length); int leftPad = Math.Max(0, (width - text.Length) / 2);
var line = text + new string(' ', padding); var line = new string(' ', leftPad) + text;
Console.BackgroundColor = ConsoleColor.DarkGray; Console.BackgroundColor = ConsoleColor.DarkGray;
Console.ForegroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.White;
try { Console.SetCursorPosition(0, lastRow); } catch { } try { Console.SetCursorPosition(0, centerRow); } catch { }
try { Console.Write(line); } catch { } try { Console.Write(line.PadRight(width)); } catch { }
Console.ResetColor(); Console.ResetColor();
// Wait until Return key is not pressed // Wait until the external process has exited
// GetAsyncKeyState returns a short where the high-order bit is set when key is down while (process != null && !process.HasExited)
while ((GetAsyncKeyState(VK_RETURN) & 0x8000) != 0)
{ {
Thread.Sleep(10); Thread.Sleep(100);
} }
// Clear the line // Clear the line
try { Console.SetCursorPosition(0, lastRow); } catch { } try { Console.SetCursorPosition(0, centerRow); } catch { }
try { Console.Write(new string(' ', width)); } catch { } try { Console.Write(new string(' ', width)); } catch { }
} }
catch catch