Skip to content

Commit

Permalink
Fix index when switching to a quick matched search
Browse files Browse the repository at this point in the history
Also no longer plays a sound when trying to switch to an empty menu.
Thanks to `tobyaaa#7052` for catching it.
  • Loading branch information
PenguinOwl committed Nov 27, 2021
1 parent bf71639 commit 03f1a29
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Celeste.Mod.mm/Mod/UI/OuiMapSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class OuiMapSearch : Oui {
private int itemCount;
private int matchCount;

private bool quickMatched = false;

private TextMenu.SubHeader resultHeader;

private static TextMenuExt.SubHeaderExt perfectMatchHeader;
Expand Down Expand Up @@ -382,6 +384,8 @@ private void ReloadItems() {
menu.rightMenu.Position.Y = menu.rightMenu.ScrollTargetY;
}

quickMatched = matched;

// Don't allow pressing any buttons while searching
foreach (TextMenu.Item item in items)
item.Disabled = Searching;
Expand Down Expand Up @@ -493,7 +497,13 @@ private bool switchMenu() {
menu.leftFocused = nextIsLeft;
Searching = nextIsLeft;
MInput.Disabled = nextIsLeft;
menu.currentMenu.Selection = nextIsLeft ? -1 : 2;
int resultIndex = quickMatched ? 1 : 2;
menu.currentMenu.Selection = nextIsLeft ? -1 : resultIndex;
if (nextIsLeft) {
Audio.Play(SFX.ui_main_button_toggle_off);
} else {
Audio.Play(SFX.ui_main_button_toggle_on);
}
return true;
}
return false;
Expand Down Expand Up @@ -526,14 +536,12 @@ public override void Update() {
if (Input.MenuRight.Pressed) {
if (!menu.leftFocused)
return;
Audio.Play(SFX.ui_main_button_toggle_on);
switchMenu();
}

if (Input.MenuLeft.Pressed) {
if (menu.leftFocused)
return;
Audio.Play(SFX.ui_main_button_toggle_off);
switchMenu();
}

Expand Down

0 comments on commit 03f1a29

Please sign in to comment.