mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-06 06:43:49 +00:00
PowerControl: Simplify Next, Select and SelectNext
This commit is contained in:
parent
130a6fb745
commit
06f2d9a702
5 changed files with 41 additions and 93 deletions
|
|
@ -160,26 +160,22 @@ namespace PowerControl.Menu
|
|||
scheduleApply();
|
||||
}
|
||||
|
||||
public override void SelectNext()
|
||||
public override void SelectNext(int change)
|
||||
{
|
||||
int index = Options.IndexOf(SelectedOption ?? ActiveOption);
|
||||
if (index < 0)
|
||||
SelectIndex(0); // select first
|
||||
else if (CycleOptions)
|
||||
SelectIndex((index + 1) % Options.Count);
|
||||
else
|
||||
SelectIndex(index + 1);
|
||||
}
|
||||
{
|
||||
if (change > 0)
|
||||
SelectIndex(0); // select first
|
||||
else
|
||||
SelectIndex(Options.Count); // select last
|
||||
return;
|
||||
}
|
||||
|
||||
public override void SelectPrev()
|
||||
{
|
||||
int index = Options.IndexOf(SelectedOption ?? ActiveOption);
|
||||
if (index < 0)
|
||||
SelectIndex(Options.Count - 1); // select last
|
||||
else if (CycleOptions)
|
||||
SelectIndex((index - 1 + Options.Count) % Options.Count);
|
||||
if (CycleOptions)
|
||||
SelectIndex((index + change + Options.Count) % Options.Count);
|
||||
else
|
||||
SelectIndex(index - 1);
|
||||
SelectIndex(index + change);
|
||||
}
|
||||
|
||||
private String optionText(Object option)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue