mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Merge pull request #9791 from Joehuu/toolbar-keybinding-tooltips
This commit is contained in:
commit
c68fb92d00
@ -67,8 +67,6 @@ namespace osu.Game
|
||||
[NotNull]
|
||||
private readonly NotificationOverlay notifications = new NotificationOverlay();
|
||||
|
||||
private NowPlayingOverlay nowPlaying;
|
||||
|
||||
private BeatmapListingOverlay beatmapListing;
|
||||
|
||||
private DashboardOverlay dashboard;
|
||||
@ -650,7 +648,7 @@ namespace osu.Game
|
||||
Origin = Anchor.TopRight,
|
||||
}, rightFloatingOverlayContent.Add, true);
|
||||
|
||||
loadComponentSingleFile(nowPlaying = new NowPlayingOverlay
|
||||
loadComponentSingleFile(new NowPlayingOverlay
|
||||
{
|
||||
GetToolbarHeight = () => ToolbarOffset,
|
||||
Anchor = Anchor.TopRight,
|
||||
@ -862,18 +860,6 @@ namespace osu.Game
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case GlobalAction.ToggleNowPlaying:
|
||||
nowPlaying.ToggleVisibility();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ToggleChat:
|
||||
chatOverlay.ToggleVisibility();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ToggleSocial:
|
||||
dashboard.ToggleVisibility();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ResetInputSettings:
|
||||
var sensitivity = frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity);
|
||||
|
||||
@ -889,18 +875,6 @@ namespace osu.Game
|
||||
Toolbar.ToggleVisibility();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ToggleSettings:
|
||||
Settings.ToggleVisibility();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ToggleDirect:
|
||||
beatmapListing.ToggleVisibility();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ToggleNotifications:
|
||||
notifications.ToggleVisibility();
|
||||
return true;
|
||||
|
||||
case GlobalAction.ToggleGameplayMouseButtons:
|
||||
LocalConfig.Set(OsuSetting.MouseDisableButtons, !LocalConfig.Get<bool>(OsuSetting.MouseDisableButtons));
|
||||
return true;
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
@ -13,6 +14,8 @@ namespace osu.Game.Overlays.Toolbar
|
||||
SetIcon(OsuIcon.ChevronDownCircle);
|
||||
TooltipMain = "Beatmap listing";
|
||||
TooltipSub = "Browse for new beatmaps";
|
||||
|
||||
Hotkey = GlobalAction.ToggleDirect;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
|
@ -1,27 +1,34 @@
|
||||
// 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.Caching;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
public class ToolbarButton : OsuClickableContainer
|
||||
public abstract class ToolbarButton : OsuClickableContainer, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public const float WIDTH = Toolbar.HEIGHT * 1.4f;
|
||||
|
||||
protected GlobalAction? Hotkey { get; set; }
|
||||
|
||||
public void SetIcon(Drawable icon)
|
||||
{
|
||||
IconContainer.Icon = icon;
|
||||
@ -66,9 +73,13 @@ namespace osu.Game.Overlays.Toolbar
|
||||
private readonly FillFlowContainer tooltipContainer;
|
||||
private readonly SpriteText tooltip1;
|
||||
private readonly SpriteText tooltip2;
|
||||
private readonly SpriteText keyBindingTooltip;
|
||||
protected FillFlowContainer Flow;
|
||||
|
||||
public ToolbarButton()
|
||||
[Resolved]
|
||||
private KeyBindingStore keyBindings { get; set; }
|
||||
|
||||
protected ToolbarButton()
|
||||
: base(HoverSampleSet.Loud)
|
||||
{
|
||||
Width = WIDTH;
|
||||
@ -123,7 +134,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Origin = TooltipAnchor,
|
||||
Position = new Vector2(TooltipAnchor.HasFlag(Anchor.x0) ? 5 : -5, 5),
|
||||
Alpha = 0,
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
tooltip1 = new OsuSpriteText
|
||||
{
|
||||
@ -132,17 +143,44 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Shadow = true,
|
||||
Font = OsuFont.GetFont(size: 22, weight: FontWeight.Bold),
|
||||
},
|
||||
tooltip2 = new OsuSpriteText
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = TooltipAnchor,
|
||||
Origin = TooltipAnchor,
|
||||
Shadow = true,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
tooltip2 = new OsuSpriteText { Shadow = true },
|
||||
keyBindingTooltip = new OsuSpriteText { Shadow = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private readonly Cached tooltipKeyBinding = new Cached();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
keyBindings.KeyBindingChanged += () => tooltipKeyBinding.Invalidate();
|
||||
updateKeyBindingTooltip();
|
||||
}
|
||||
|
||||
private void updateKeyBindingTooltip()
|
||||
{
|
||||
if (tooltipKeyBinding.IsValid)
|
||||
return;
|
||||
|
||||
var binding = keyBindings.Query().Find(b => (GlobalAction)b.Action == Hotkey);
|
||||
var keyBindingString = binding?.KeyCombination.ReadableString();
|
||||
keyBindingTooltip.Text = !string.IsNullOrEmpty(keyBindingString) ? $" ({keyBindingString})" : string.Empty;
|
||||
|
||||
tooltipKeyBinding.Validate();
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
@ -154,6 +192,8 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
updateKeyBindingTooltip();
|
||||
|
||||
HoverBackground.FadeIn(200);
|
||||
tooltipContainer.FadeIn(100);
|
||||
return base.OnHover(e);
|
||||
@ -164,6 +204,21 @@ namespace osu.Game.Overlays.Toolbar
|
||||
HoverBackground.FadeOut(200);
|
||||
tooltipContainer.FadeOut(100);
|
||||
}
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (action == Hotkey)
|
||||
{
|
||||
Click();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnReleased(GlobalAction action)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class OpaqueBackground : Container
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
@ -13,6 +14,8 @@ namespace osu.Game.Overlays.Toolbar
|
||||
SetIcon(FontAwesome.Solid.Comments);
|
||||
TooltipMain = "Chat";
|
||||
TooltipSub = "Join the real-time discussion";
|
||||
|
||||
Hotkey = GlobalAction.ToggleChat;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
|
@ -2,33 +2,19 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
public class ToolbarHomeButton : ToolbarButton, IKeyBindingHandler<GlobalAction>
|
||||
public class ToolbarHomeButton : ToolbarButton
|
||||
{
|
||||
public ToolbarHomeButton()
|
||||
{
|
||||
Icon = FontAwesome.Solid.Home;
|
||||
TooltipMain = "Home";
|
||||
TooltipSub = "Return to the main menu";
|
||||
}
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (action == GlobalAction.Home)
|
||||
{
|
||||
Click();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnReleased(GlobalAction action)
|
||||
{
|
||||
Hotkey = GlobalAction.Home;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,23 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
public class ToolbarMusicButton : ToolbarOverlayToggleButton
|
||||
{
|
||||
protected override Anchor TooltipAnchor => Anchor.TopRight;
|
||||
|
||||
public ToolbarMusicButton()
|
||||
{
|
||||
Icon = FontAwesome.Solid.Music;
|
||||
TooltipMain = "Now playing";
|
||||
TooltipSub = "Manage the currently playing track";
|
||||
|
||||
Hotkey = GlobalAction.ToggleNowPlaying;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -28,6 +29,8 @@ namespace osu.Game.Overlays.Toolbar
|
||||
TooltipMain = "Notifications";
|
||||
TooltipSub = "Waiting for 'ya";
|
||||
|
||||
Hotkey = GlobalAction.ToggleNotifications;
|
||||
|
||||
Add(countDisplay = new CountCircle
|
||||
{
|
||||
Alpha = 0,
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
@ -13,6 +14,8 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Icon = FontAwesome.Solid.Cog;
|
||||
TooltipMain = "Settings";
|
||||
TooltipSub = "Change your settings";
|
||||
|
||||
Hotkey = GlobalAction.ToggleSettings;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
@ -13,6 +14,8 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Icon = FontAwesome.Solid.Users;
|
||||
TooltipMain = "Friends";
|
||||
TooltipSub = "Interact with those close to you";
|
||||
|
||||
Hotkey = GlobalAction.ToggleSocial;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
|
Loading…
Reference in New Issue
Block a user