This commit is contained in:
2025-08-31 22:11:04 +02:00
parent df936e187d
commit 88005c2125
3 changed files with 34 additions and 37 deletions

View File

@@ -7,6 +7,7 @@ using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
using System.Text.Json;
using System.Threading.Tasks;
namespace DD2Switcher {
public class Settings {
@@ -71,8 +72,6 @@ namespace DD2Switcher {
}
}
public static void ExitSequenceMode() {
CurrentState = SequenceState.INACTIVE;
CurrentSequenceIndex = -1;
@@ -203,12 +202,11 @@ namespace DD2Switcher {
private static bool AltPressed = false;
// State handlers
private static readonly Dictionary<SequenceState, Action> stateHandlers = new Dictionary<SequenceState, Action> {
{ SequenceState.INACTIVE, HandleInactive },
private static readonly Dictionary<SequenceState, Action> stateHandlers =
new Dictionary<SequenceState, Action> { { SequenceState.INACTIVE, HandleInactive },
{ SequenceState.WAITING_FOR_EVENT, HandleWaitingForEvent },
{ SequenceState.WAITING_TO_ADVANCE, HandleWaitingToAdvance },
{ SequenceState.ADVANCE, HandleAdvance }
};
{ SequenceState.ADVANCE, HandleAdvance } };
private static void HandleInactive() {
// Inactive state - do nothing
@@ -224,13 +222,12 @@ namespace DD2Switcher {
private static void HandleWaitingToAdvance() {
// Start timer to advance after N milliseconds
Console.WriteLine($"Starting 500ms timer in WAITING_TO_ADVANCE state");
Task.Delay(500).ContinueWith(_ => {
System.Threading.Thread.Sleep(500);
if (CurrentState == SequenceState.WAITING_TO_ADVANCE) {
CurrentState = SequenceState.ADVANCE;
Console.WriteLine($"Timer expired, transitioning to ADVANCE state");
HandleSequenceEvent();
}
});
}
private static void HandleAdvance() {