mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Make KeyBindingOverlay support variants as settings sub sections.
This commit is contained in:
44
osu.Game/Overlays/KeyBinding/KeyBindingsSubsection.cs
Normal file
44
osu.Game/Overlays/KeyBinding/KeyBindingsSubsection.cs
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Input;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Overlays.KeyBinding
|
||||
{
|
||||
public abstract class KeyBindingsSubsection : SettingsSubsection
|
||||
{
|
||||
protected IEnumerable<Framework.Input.Bindings.KeyBinding> Defaults;
|
||||
|
||||
protected RulesetInfo Ruleset;
|
||||
|
||||
private readonly int variant;
|
||||
|
||||
protected KeyBindingsSubsection(int variant)
|
||||
{
|
||||
this.variant = variant;
|
||||
|
||||
FlowContent.Spacing = new Vector2(0, 1);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(KeyBindingStore store)
|
||||
{
|
||||
var bindings = store.Query(Ruleset?.ID, variant);
|
||||
|
||||
foreach (var defaultBinding in Defaults)
|
||||
{
|
||||
// one row per valid action.
|
||||
Add(new KeyBindingRow(defaultBinding.Action, bindings.Where(b => b.Action.Equals((int)defaultBinding.Action)))
|
||||
{
|
||||
AllowMainMouseButtons = Ruleset != null
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user