mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Set global action as a parameter in toast
This commit is contained in:
@ -1,11 +1,14 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -16,12 +19,22 @@ namespace osu.Game.Overlays.OSD
|
||||
private const int toast_minimum_width = 240;
|
||||
|
||||
private readonly Container content;
|
||||
|
||||
private readonly OsuSpriteText spriteText;
|
||||
|
||||
private readonly string shortcut;
|
||||
|
||||
private readonly GlobalAction? action;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
protected readonly OsuSpriteText ValueText;
|
||||
|
||||
protected Toast(string description, string value, string shortcut)
|
||||
protected Toast(string description, string value, string shortcut = null, GlobalAction? action = null)
|
||||
{
|
||||
this.shortcut = shortcut;
|
||||
this.action = action;
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
@ -68,7 +81,7 @@ namespace osu.Game.Overlays.OSD
|
||||
Origin = Anchor.Centre,
|
||||
Text = value
|
||||
},
|
||||
new OsuSpriteText
|
||||
spriteText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
@ -76,9 +89,23 @@ namespace osu.Game.Overlays.OSD
|
||||
Alpha = 0.3f,
|
||||
Margin = new MarginPadding { Bottom = 15 },
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
||||
Text = string.IsNullOrEmpty(shortcut) ? "NO KEY BOUND" : shortcut.ToUpperInvariant()
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
string text;
|
||||
|
||||
if (action != null)
|
||||
text = config.LookupKeyBindings(action);
|
||||
else if (!string.IsNullOrEmpty(shortcut))
|
||||
text = shortcut;
|
||||
else
|
||||
text = "no key bound";
|
||||
|
||||
spriteText.Text = text.ToUpperInvariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user