Handle overlay toggling with toolbar buttons instead

This commit is contained in:
Joehu
2020-08-06 01:17:24 -07:00
parent ad959ce523
commit 7bcb68ffac
9 changed files with 45 additions and 48 deletions

View File

@ -67,8 +67,6 @@ namespace osu.Game
[NotNull] [NotNull]
private readonly NotificationOverlay notifications = new NotificationOverlay(); private readonly NotificationOverlay notifications = new NotificationOverlay();
private NowPlayingOverlay nowPlaying;
private BeatmapListingOverlay beatmapListing; private BeatmapListingOverlay beatmapListing;
private DashboardOverlay dashboard; private DashboardOverlay dashboard;
@ -650,7 +648,7 @@ namespace osu.Game
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}, rightFloatingOverlayContent.Add, true); }, rightFloatingOverlayContent.Add, true);
loadComponentSingleFile(nowPlaying = new NowPlayingOverlay loadComponentSingleFile(new NowPlayingOverlay
{ {
GetToolbarHeight = () => ToolbarOffset, GetToolbarHeight = () => ToolbarOffset,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
@ -862,18 +860,6 @@ namespace osu.Game
switch (action) 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: case GlobalAction.ResetInputSettings:
var sensitivity = frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity); var sensitivity = frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity);
@ -889,18 +875,6 @@ namespace osu.Game
Toolbar.ToggleVisibility(); Toolbar.ToggleVisibility();
return true; 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: case GlobalAction.ToggleGameplayMouseButtons:
LocalConfig.Set(OsuSetting.MouseDisableButtons, !LocalConfig.Get<bool>(OsuSetting.MouseDisableButtons)); LocalConfig.Set(OsuSetting.MouseDisableButtons, !LocalConfig.Get<bool>(OsuSetting.MouseDisableButtons));
return true; return true;

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
@ -13,6 +14,8 @@ namespace osu.Game.Overlays.Toolbar
SetIcon(OsuIcon.ChevronDownCircle); SetIcon(OsuIcon.ChevronDownCircle);
TooltipMain = "Beatmap listing"; TooltipMain = "Beatmap listing";
TooltipSub = "Browse for new beatmaps"; TooltipSub = "Browse for new beatmaps";
Hotkey = GlobalAction.ToggleDirect;
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]

View File

@ -5,23 +5,27 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osuTK; using osuTK;
using osuTK.Graphics; 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 namespace osu.Game.Overlays.Toolbar
{ {
public abstract class ToolbarButton : OsuClickableContainer public abstract class ToolbarButton : OsuClickableContainer, IKeyBindingHandler<GlobalAction>
{ {
public const float WIDTH = Toolbar.HEIGHT * 1.4f; public const float WIDTH = Toolbar.HEIGHT * 1.4f;
protected GlobalAction? Hotkey { get; set; }
public void SetIcon(Drawable icon) public void SetIcon(Drawable icon)
{ {
IconContainer.Icon = icon; IconContainer.Icon = icon;
@ -164,6 +168,21 @@ namespace osu.Game.Overlays.Toolbar
HoverBackground.FadeOut(200); HoverBackground.FadeOut(200);
tooltipContainer.FadeOut(100); 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 public class OpaqueBackground : Container

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
@ -13,6 +14,8 @@ namespace osu.Game.Overlays.Toolbar
SetIcon(FontAwesome.Solid.Comments); SetIcon(FontAwesome.Solid.Comments);
TooltipMain = "Chat"; TooltipMain = "Chat";
TooltipSub = "Join the real-time discussion"; TooltipSub = "Join the real-time discussion";
Hotkey = GlobalAction.ToggleChat;
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]

View File

@ -2,33 +2,19 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
public class ToolbarHomeButton : ToolbarButton, IKeyBindingHandler<GlobalAction> public class ToolbarHomeButton : ToolbarButton
{ {
public ToolbarHomeButton() public ToolbarHomeButton()
{ {
Icon = FontAwesome.Solid.Home; Icon = FontAwesome.Solid.Home;
TooltipMain = "Home"; TooltipMain = "Home";
TooltipSub = "Return to the main menu"; TooltipSub = "Return to the main menu";
}
public bool OnPressed(GlobalAction action) Hotkey = GlobalAction.Home;
{
if (action == GlobalAction.Home)
{
Click();
return true;
}
return false;
}
public void OnReleased(GlobalAction action)
{
} }
} }
} }

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
@ -13,6 +14,8 @@ namespace osu.Game.Overlays.Toolbar
Icon = FontAwesome.Solid.Music; Icon = FontAwesome.Solid.Music;
TooltipMain = "Now playing"; TooltipMain = "Now playing";
TooltipSub = "Manage the currently playing track"; TooltipSub = "Manage the currently playing track";
Hotkey = GlobalAction.ToggleNowPlaying;
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -28,6 +29,8 @@ namespace osu.Game.Overlays.Toolbar
TooltipMain = "Notifications"; TooltipMain = "Notifications";
TooltipSub = "Waiting for 'ya"; TooltipSub = "Waiting for 'ya";
Hotkey = GlobalAction.ToggleNotifications;
Add(countDisplay = new CountCircle Add(countDisplay = new CountCircle
{ {
Alpha = 0, Alpha = 0,

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
@ -13,6 +14,8 @@ namespace osu.Game.Overlays.Toolbar
Icon = FontAwesome.Solid.Cog; Icon = FontAwesome.Solid.Cog;
TooltipMain = "Settings"; TooltipMain = "Settings";
TooltipSub = "Change your settings"; TooltipSub = "Change your settings";
Hotkey = GlobalAction.ToggleSettings;
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
@ -13,6 +14,8 @@ namespace osu.Game.Overlays.Toolbar
Icon = FontAwesome.Solid.Users; Icon = FontAwesome.Solid.Users;
TooltipMain = "Friends"; TooltipMain = "Friends";
TooltipSub = "Interact with those close to you"; TooltipSub = "Interact with those close to you";
Hotkey = GlobalAction.ToggleSocial;
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]