Skip to content

Commit

Permalink
Merge branch 'master' into results-screen-quick-retry-transition
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte authored Dec 4, 2024
2 parents a4d5864 + e555131 commit a7586c5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class BindingSettings : SettingsSubsection
{
protected override LocalisableString Header => BindingSettingsStrings.ShortcutAndGameplayBindings;

public override IEnumerable<LocalisableString> FilterTerms => base.FilterTerms.Concat(new LocalisableString[] { @"keybindings", @"controls", @"keyboard", @"keys" });
public override IEnumerable<LocalisableString> FilterTerms => base.FilterTerms.Concat(new LocalisableString[] { @"keybindings", @"controls", @"keyboard", @"keys", @"buttons" });

public BindingSettings(KeyBindingPanel keyConfig)
{
Expand Down
30 changes: 23 additions & 7 deletions osu.Game/Screens/OnlinePlay/Lounge/Components/RoomsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
Expand Down Expand Up @@ -80,19 +81,34 @@ private void applyFilterCriteria(FilterCriteria? criteria)
bool matchingFilter = true;

matchingFilter &= criteria.Ruleset == null || r.Room.PlaylistItemStats?.RulesetIDs.Any(id => id == criteria.Ruleset.OnlineID) != false;

if (!string.IsNullOrEmpty(criteria.SearchString))
{
// Room name isn't translatable, so ToString() is used here for simplicity.
matchingFilter &= r.FilterTerms.Any(term => term.ToString().Contains(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase));
}

matchingFilter &= matchPermissions(r, criteria.Permissions);

// Room name isn't translatable, so ToString() is used here for simplicity.
string[] filterTerms = r.FilterTerms.Select(t => t.ToString()).ToArray();
string[] searchTerms = criteria.SearchString.Split(' ', StringSplitOptions.RemoveEmptyEntries);
matchingFilter &= searchTerms.All(searchTerm => filterTerms.Any(filterTerm => checkTerm(filterTerm, searchTerm)));

r.MatchingFilter = matchingFilter;
}
});

// Lifted from SearchContainer.
static bool checkTerm(string haystack, string needle)
{
int index = 0;

for (int i = 0; i < needle.Length; i++)
{
int found = CultureInfo.InvariantCulture.CompareInfo.IndexOf(haystack, needle[i], index, CompareOptions.OrdinalIgnoreCase);
if (found < 0)
return false;

index = found + 1;
}

return true;
}

static bool matchPermissions(DrawableLoungeRoom room, RoomPermissionsFilter accessType)
{
switch (accessType)
Expand Down

0 comments on commit a7586c5

Please sign in to comment.