mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 02:22:59 +08:00
Merge branch 'master' into mania_reversing
This commit is contained in:
commit
7c3ef81d9c
@ -24,6 +24,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private SampleChannel sampleClick;
|
||||
private SampleChannel sampleHover;
|
||||
|
||||
protected Triangles Triangles;
|
||||
|
||||
public OsuButton()
|
||||
{
|
||||
Height = 40;
|
||||
@ -52,7 +54,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new Triangles
|
||||
Triangles = new Triangles
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColourDark = colours.BlueDarker,
|
||||
@ -120,4 +122,4 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,17 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
buttons.Add(new KeyButton(b));
|
||||
}
|
||||
|
||||
public void RestoreDefaults()
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var d in Defaults)
|
||||
{
|
||||
var button = buttons[i++];
|
||||
button.UpdateKeyCombination(d);
|
||||
store.Update(button.KeyBinding);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
this.FadeEdgeEffectTo<Container>(1, transition_time, Easing.OutQuint);
|
||||
@ -129,6 +140,8 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
|
||||
public bool AllowMainMouseButtons;
|
||||
|
||||
public IEnumerable<KeyCombination> Defaults;
|
||||
|
||||
private bool isModifier(Key k) => k < Key.F1;
|
||||
|
||||
protected override bool OnClick(InputState state) => true;
|
||||
|
@ -4,10 +4,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets;
|
||||
using OpenTK;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.KeyBinding
|
||||
{
|
||||
@ -31,14 +35,38 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
{
|
||||
var bindings = store.Query(Ruleset?.ID, variant);
|
||||
|
||||
foreach (var defaultBinding in Defaults)
|
||||
foreach (var defaultGroup in Defaults.GroupBy(d => d.Action))
|
||||
{
|
||||
// one row per valid action.
|
||||
Add(new KeyBindingRow(defaultBinding.Action, bindings.Where(b => b.Action.Equals((int)defaultBinding.Action)))
|
||||
Add(new KeyBindingRow(defaultGroup.Key, bindings.Where(b => b.Action.Equals((int)defaultGroup.Key)))
|
||||
{
|
||||
AllowMainMouseButtons = Ruleset != null
|
||||
AllowMainMouseButtons = Ruleset != null,
|
||||
Defaults = defaultGroup.Select(d => d.KeyCombination)
|
||||
});
|
||||
}
|
||||
|
||||
Add(new ResetButton
|
||||
{
|
||||
Action = () => Children.OfType<KeyBindingRow>().ForEach(k => k.RestoreDefaults())
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class ResetButton : OsuButton
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Text = "Reset";
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Margin = new MarginPadding { Top = 5 };
|
||||
Height = 20;
|
||||
|
||||
Content.CornerRadius = 5;
|
||||
|
||||
BackgroundColour = colours.PinkDark;
|
||||
Triangles.ColourDark = colours.PinkDarker;
|
||||
Triangles.ColourLight = colours.Pink;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user