blob: be6cab3b12bab0e5305b29c033601b3929e30fca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
}
}
|