mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 05:52:55 +08:00
Add key bindings everywhere
This commit is contained in:
parent
a175defefd
commit
3fc8ac0ec7
@ -20,7 +20,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class OsuButton : Button
|
public class OsuButton : Button
|
||||||
{
|
{
|
||||||
public LocalisableString Text
|
public virtual LocalisableString Text
|
||||||
{
|
{
|
||||||
get => SpriteText?.Text ?? default;
|
get => SpriteText?.Text ?? default;
|
||||||
set
|
set
|
||||||
|
@ -14,8 +14,10 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -170,13 +172,13 @@ Do whatever you need to try and perceive the difference in latency, then choose
|
|||||||
|
|
||||||
int betterSide = RNG.Next(0, 2);
|
int betterSide = RNG.Next(0, 2);
|
||||||
|
|
||||||
mainArea.Add(new LatencyArea(betterSide == 1 ? induced_latency / difficulty : 0)
|
mainArea.Add(new LatencyArea(Key.Number1, betterSide == 1 ? induced_latency / difficulty : 0)
|
||||||
{
|
{
|
||||||
Width = 0.5f,
|
Width = 0.5f,
|
||||||
ReportBetter = () => recordResult(betterSide == 0)
|
ReportBetter = () => recordResult(betterSide == 0)
|
||||||
});
|
});
|
||||||
|
|
||||||
mainArea.Add(new LatencyArea(betterSide == 0 ? induced_latency / difficulty : 0)
|
mainArea.Add(new LatencyArea(Key.Number2, betterSide == 0 ? induced_latency / difficulty : 0)
|
||||||
{
|
{
|
||||||
Width = 0.5f,
|
Width = 0.5f,
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
@ -198,7 +200,7 @@ Do whatever you need to try and perceive the difference in latency, then choose
|
|||||||
Spacing = new Vector2(20),
|
Spacing = new Vector2(20),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Button
|
new Button(Key.R)
|
||||||
{
|
{
|
||||||
Text = "Increase confidence at current level",
|
Text = "Increase confidence at current level",
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -210,32 +212,22 @@ Do whatever you need to try and perceive the difference in latency, then choose
|
|||||||
loadNextRound();
|
loadNextRound();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Button
|
new Button(Key.I)
|
||||||
{
|
{
|
||||||
Text = "Increase difficulty",
|
Text = "Increase difficulty",
|
||||||
BackgroundColour = colours.Red2,
|
BackgroundColour = colours.Red2,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Action = () =>
|
Action = () => changeDifficulty(difficulty + 1)
|
||||||
{
|
|
||||||
changeDifficulty(difficulty + 1);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
new Button
|
new Button(Key.D)
|
||||||
{
|
{
|
||||||
Text = "Decrease difficulty",
|
Text = "Decrease difficulty",
|
||||||
BackgroundColour = colours.Green,
|
BackgroundColour = colours.Green,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
|
Action = () => changeDifficulty(difficulty - 1),
|
||||||
Enabled = { Value = difficulty > 1 },
|
Enabled = { Value = difficulty > 1 },
|
||||||
Action = () =>
|
|
||||||
{
|
|
||||||
resultsArea.Clear();
|
|
||||||
correctCount = 0;
|
|
||||||
targetRoundCount = rounds_to_complete;
|
|
||||||
difficulty--;
|
|
||||||
loadNextRound();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -264,12 +256,14 @@ Do whatever you need to try and perceive the difference in latency, then choose
|
|||||||
|
|
||||||
private Drawable? background;
|
private Drawable? background;
|
||||||
|
|
||||||
|
private readonly Key key;
|
||||||
private readonly int inducedLatency;
|
private readonly int inducedLatency;
|
||||||
|
|
||||||
private long frameCount;
|
private long frameCount;
|
||||||
|
|
||||||
public LatencyArea(int inducedLatency)
|
public LatencyArea(Key key, int inducedLatency)
|
||||||
{
|
{
|
||||||
|
this.key = key;
|
||||||
this.inducedLatency = inducedLatency;
|
this.inducedLatency = inducedLatency;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
@ -302,7 +296,7 @@ Do whatever you need to try and perceive the difference in latency, then choose
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Button
|
new Button(key)
|
||||||
{
|
{
|
||||||
Text = "Feels better",
|
Text = "Feels better",
|
||||||
Y = 20,
|
Y = 20,
|
||||||
@ -459,6 +453,30 @@ Do whatever you need to try and perceive the difference in latency, then choose
|
|||||||
|
|
||||||
public class Button : SettingsButton
|
public class Button : SettingsButton
|
||||||
{
|
{
|
||||||
|
private readonly Key key;
|
||||||
|
|
||||||
|
public Button(Key key)
|
||||||
|
{
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override LocalisableString Text
|
||||||
|
{
|
||||||
|
get => base.Text;
|
||||||
|
set => base.Text = $"{value} (Press {key.ToString().Replace("Number", string.Empty)})";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
|
{
|
||||||
|
if (!e.Repeat && e.Key == key)
|
||||||
|
{
|
||||||
|
TriggerClick();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnKeyDown(e);
|
||||||
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider overlayColourProvider { get; set; } = null!;
|
private OverlayColourProvider overlayColourProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user