using System.Numerics; namespace GamePort.Game; /// EXE404523..404D1E keyboard and pointer selection for PracticeYesNo. public sealed class PracticePrompt { public bool Active { get; private set; } public int Mode { get; private set; } public event Action? Chosen; public void Show(int mode) { if (mode is < 0 or > 3) throw new NotSupportedException("Practice mode is outside recovered VR04..VR01 mapping"); if (Active) return; Mode = mode; Active = true; } public void Key(uint scancode, Vector2 pointer) { if (!Active) return; if (scancode == 28) Choose(true); // Y. else if (scancode == 17) Choose(false); // N. else if (scancode is 40 or 88) Choose(Yes(pointer)); // Enter / keypad Enter. } public void Click(Vector2 pointer) { if (!Active) return; if (Yes(pointer)) Choose(true); else if (pointer.X > 315 && pointer.X < 395 && pointer.Y > 240 && pointer.Y < 300) Choose(false); } public static string Destination(int mode) => mode switch { 0 => "VR04.gam", 1 => "VR03.gam", 2 => "VR02.gam", 3 => "VR01.gam", _ => throw new NotSupportedException("Unrecovered practice destination") }; private void Choose(bool accepted) { Active = false; Chosen?.Invoke(Mode, accepted); } private static bool Yes(Vector2 p) => p.X > 225 && p.X < 305 && p.Y > 240 && p.Y < 300; }