-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor key binding panel leveraging new helper methods
- Loading branch information
Showing
6 changed files
with
98 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
osu.Game/Overlays/Settings/Sections/Input/GlobalKeyBindingsSubsection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using osu.Framework.Localisation; | ||
using osu.Game.Database; | ||
using osu.Game.Input.Bindings; | ||
using Realms; | ||
|
||
namespace osu.Game.Overlays.Settings.Sections.Input | ||
{ | ||
public partial class GlobalKeyBindingsSubsection : KeyBindingsSubsection | ||
{ | ||
protected override LocalisableString Header { get; } | ||
|
||
private readonly GlobalActionCategory category; | ||
|
||
public GlobalKeyBindingsSubsection(LocalisableString header, GlobalActionCategory category) | ||
{ | ||
Header = header; | ||
this.category = category; | ||
Defaults = GlobalActionContainer.GetDefaultBindingsFor(category); | ||
} | ||
|
||
protected override IEnumerable<RealmKeyBinding> GetKeyBindings(Realm realm) | ||
{ | ||
var bindings = realm.All<RealmKeyBinding>() | ||
.Where(b => b.RulesetName == null && b.Variant == null) | ||
.Detach(); | ||
|
||
var actionsInSection = GlobalActionContainer.GetGlobalActionsFor(category).Cast<int>().ToHashSet(); | ||
return bindings.Where(kb => actionsInSection.Contains(kb.ActionInt)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters