refactor(DD2Switcher): simplify sequence index handling and settings loading

This commit is contained in:
2025-08-31 21:43:04 +02:00
parent 274a75b93d
commit 0b7aaa2f99
2 changed files with 34 additions and 24 deletions

View File

@@ -151,10 +151,18 @@ namespace DD2Switcher {
windowPanelForm.UpdateDisplay();
windowPanelForm.PickClicked += (sender, index) => {
if (Program.FirstIndex == -1) {
// If clicking on a window that's already first or last, remove that setting
if (index == Program.FirstIndex) {
Program.FirstIndex = -1;
Console.WriteLine($"Removed first index: {index}");
} else if (index == Program.LastIndex) {
Program.LastIndex = -1;
Console.WriteLine($"Removed last index: {index}");
} else if (Program.FirstIndex == -1) {
// First pick - set both first and last
Program.FirstIndex = index;
Program.LastIndex = index;
Console.WriteLine($"Set first and last index: {index}");
} else if (Program.LastIndex == -1) {
// Second pick - set last (must be >= first)
if (index >= Program.FirstIndex) {
@@ -163,6 +171,7 @@ namespace DD2Switcher {
Program.LastIndex = Program.FirstIndex;
Program.FirstIndex = index;
}
Console.WriteLine($"Set last index: {Program.LastIndex}");
} else {
// Subsequent picks - determine which becomes first
int distanceToFirst = Math.Abs(index - Program.FirstIndex);
@@ -185,6 +194,7 @@ namespace DD2Switcher {
Program.LastIndex = index;
}
}
Console.WriteLine($"Updated indices: First={Program.FirstIndex}, Last={Program.LastIndex}");
}
// Ensure last >= first