refactor(DD2Switcher): simplify sequence index handling and settings loading
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user