Skip to content

Commit a472a2c

Browse files
committed
fix(real this time): power plan combo now actually populated from ListAvailablePlans
1 parent d3dd3dc commit a472a2c

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/GamerGuardian/UI/SettingsWindow.xaml.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,18 @@ private void LoadGlobals()
192192
PowerPlanCurrentText.Text = $"Current: {activeName}";
193193
PowerPlanMonitorCheck.IsChecked = g.PowerPlan.Monitor;
194194
PowerPlanAutoApplyCheck.IsChecked = g.PowerPlan.AutoApply;
195-
var availableChoices = Enum.GetValues<PowerPlanChoice>()
196-
.Where(c => planNames.ContainsKey(PowerPlanMonitor.ToGuid(c)))
195+
196+
var planItems = planNames
197+
.OrderBy(kv => kv.Value, StringComparer.OrdinalIgnoreCase)
198+
.Select(kv => new PowerPlanItem(kv.Key, kv.Value))
197199
.ToList();
198-
if (availableChoices.Count == 0) availableChoices = Enum.GetValues<PowerPlanChoice>().ToList();
199-
PowerPlanCombo.ItemsSource = availableChoices;
200-
PowerPlanCombo.SelectedItem = availableChoices.Contains(g.PowerPlan.Desired)
201-
? g.PowerPlan.Desired
202-
: availableChoices[0];
200+
PowerPlanCombo.ItemsSource = planItems;
201+
PowerPlanCombo.DisplayMemberPath = nameof(PowerPlanItem.Name);
202+
203+
var savedGuid = PowerPlanMonitor.ResolveDesiredGuid(g.PowerPlan);
204+
PowerPlanCombo.SelectedItem = planItems.FirstOrDefault(p => p.Guid == savedGuid)
205+
?? (active is Guid a ? planItems.FirstOrDefault(p => p.Guid == a) : null)
206+
?? planItems.FirstOrDefault();
203207
}
204208

205209
private static bool? SafeRead(Func<bool?> f)

0 commit comments

Comments
 (0)