diff options
| author | godosa <godosa@godosa.eu> | 2026-10-06 23:39:36 +0200 |
|---|---|---|
| committer | godosa <godosa@godosa.eu> | 2026-10-06 23:39:36 +0200 |
| commit | 39066900773e7857faf2d02e7ed51b71d219d97d (patch) | |
| tree | ffab8e4ddd971626776c3b1f4ce1da2c186c2187 /src/Godosa.Core/Input/MenuCursor.cs | |
| download | godosa-engine-39066900773e7857faf2d02e7ed51b71d219d97d.tar.gz godosa-engine-39066900773e7857faf2d02e7ed51b71d219d97d.zip | |
godosa-engine: initial public history
Diffstat (limited to 'src/Godosa.Core/Input/MenuCursor.cs')
| -rw-r--r-- | src/Godosa.Core/Input/MenuCursor.cs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Godosa.Core/Input/MenuCursor.cs b/src/Godosa.Core/Input/MenuCursor.cs new file mode 100644 index 0000000..be6cab3 --- /dev/null +++ b/src/Godosa.Core/Input/MenuCursor.cs @@ -0,0 +1,21 @@ +namespace Godosa.Core.Input; + +/// <summary>Which action a gamepad highlights in an open window (hud spec §4): wraps at the +/// ends, stays inside a list that shrinks, −1 when there's nothing to pick.</summary> +public sealed class MenuCursor +{ + public int Index { get; private set; } = -1; + + public void Clamp(int count) + { + if (count <= 0) Index = -1; + else if (Index < 0) Index = 0; + else if (Index >= count) Index = count - 1; + } + + public void Move(int delta, int count) + { + if (count <= 0) return; + Index = ((Index + delta) % count + count) % count; + } +} |
