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

View File

@@ -16,7 +16,7 @@ namespace DD2Switcher {
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
@@ -120,7 +120,7 @@ namespace DD2Switcher {
this.PerformLayout(); this.PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.Label indexLabel; private System.Windows.Forms.Label indexLabel;
private System.Windows.Forms.Label nameLabel; private System.Windows.Forms.Label nameLabel;