Format
This commit is contained in:
@@ -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 },
|
||||
{ SequenceState.WAITING_FOR_EVENT, HandleWaitingForEvent },
|
||||
{ SequenceState.WAITING_TO_ADVANCE, HandleWaitingToAdvance },
|
||||
{ SequenceState.ADVANCE, HandleAdvance }
|
||||
};
|
||||
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 } };
|
||||
|
||||
private static void HandleInactive() {
|
||||
// Inactive state - do nothing
|
||||
@@ -224,18 +222,17 @@ 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(_ => {
|
||||
if (CurrentState == SequenceState.WAITING_TO_ADVANCE) {
|
||||
CurrentState = SequenceState.ADVANCE;
|
||||
Console.WriteLine($"Timer expired, transitioning to ADVANCE state");
|
||||
HandleSequenceEvent();
|
||||
}
|
||||
});
|
||||
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() {
|
||||
Console.WriteLine($"Advancing sequence from ADVANCE state");
|
||||
|
||||
|
||||
CurrentSequenceIndex++;
|
||||
Console.WriteLine($"Advanced to index {CurrentSequenceIndex}");
|
||||
|
||||
|
Reference in New Issue
Block a user