From d7c39a00b43100038207f9f75108ecfee4fba6d0 Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Fri, 31 Mar 2017 16:43:31 +0300 Subject: [PATCH] Hud Visibility --- osu.Game/Configuration/OsuConfigManager.cs | 2 +- osu.Game/Modes/UI/HudOverlay.cs | 24 ++++++++++++-- .../Sections/Gameplay/GeneralOptions.cs | 5 +++ osu.Game/Screens/Play/Player.cs | 32 +++++++++++++++++-- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 6190678e1e..61397d2bee 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -36,6 +36,7 @@ namespace osu.Game.Configuration Set(OsuConfig.MenuParallax, true); Set(OsuConfig.KeyOverlay, false); + Set(OsuConfig.ShowInterface, true); //todo: implement all settings below this line (remove the Disabled set when doing so). Set(OsuConfig.MouseSpeed, 1.0).Disabled = true; @@ -89,7 +90,6 @@ namespace osu.Game.Configuration Set(OsuConfig.LastVersionPermissionsFailed, string.Empty).Disabled = true; Set(OsuConfig.LoadSubmittedThread, true).Disabled = true; Set(OsuConfig.LobbyPlayMode, -1).Disabled = true; - Set(OsuConfig.ShowInterface, true).Disabled = true; Set(OsuConfig.ShowInterfaceDuringRelax, false).Disabled = true; Set(OsuConfig.LobbyShowExistingOnly, false).Disabled = true; Set(OsuConfig.LobbyShowFriendsOnly, false).Disabled = true; diff --git a/osu.Game/Modes/UI/HudOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs index a6c54e7f3a..42d789c741 100644 --- a/osu.Game/Modes/UI/HudOverlay.cs +++ b/osu.Game/Modes/UI/HudOverlay.cs @@ -22,6 +22,9 @@ namespace osu.Game.Modes.UI public readonly HealthDisplay HealthDisplay; private Bindable showKeyCounter; + private Bindable showHud; + + public bool IsVisible => showHud; protected abstract KeyCounterCollection CreateKeyCounter(); protected abstract ComboCounter CreateComboCounter(); @@ -47,11 +50,15 @@ namespace osu.Game.Modes.UI private void load(OsuConfigManager config) { showKeyCounter = config.GetBindable(OsuConfig.KeyOverlay); - showKeyCounter.ValueChanged += visibilityChanged; + showKeyCounter.ValueChanged += keyCounterVisibilityChanged; showKeyCounter.TriggerChange(); + + showHud = config.GetBindable(OsuConfig.ShowInterface); + showHud.ValueChanged += hudVisibilityChanged; + showHud.TriggerChange(); } - private void visibilityChanged(object sender, EventArgs e) + private void keyCounterVisibilityChanged(object sender, EventArgs e) { if (showKeyCounter) KeyCounter.Show(); @@ -59,6 +66,19 @@ namespace osu.Game.Modes.UI KeyCounter.Hide(); } + private void hudVisibilityChanged(object sender, EventArgs e) + { + if (showHud) + Show(); + else + Hide(); + } + + public void ChangeVisibility() + { + showHud.Value = !showHud.Value; + } + public void BindProcessor(ScoreProcessor processor) { //bind processor bindables to combocounter, score display etc. diff --git a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs index 70a2c52322..ee6778a47a 100644 --- a/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Gameplay/GeneralOptions.cs @@ -39,6 +39,11 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay Bindable = (BindableDouble)config.GetBindable(OsuConfig.ScoreMeterScale) }, new OsuCheckbox + { + LabelText = "Show score overlay", + Bindable = config.GetBindable(OsuConfig.ShowInterface) + }, + new OsuCheckbox { LabelText = "Always show key overlay", Bindable = config.GetBindable(OsuConfig.KeyOverlay) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 73d397b24b..592d4a9433 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -22,6 +22,9 @@ using osu.Game.Screens.Ranking; using System; using System.Linq; using osu.Game.Modes.Scoring; +using osu.Game.Overlays; +using osu.Game.Overlays.Notifications; +using OpenTK.Input; namespace osu.Game.Screens.Play { @@ -59,8 +62,8 @@ namespace osu.Game.Screens.Play private HudOverlay hudOverlay; private PauseOverlay pauseOverlay; - [BackgroundDependencyLoader] - private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config) + [BackgroundDependencyLoader(true)] + private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, NotificationManager notificationManager) { var beatmap = Beatmap.Beatmap; @@ -158,6 +161,14 @@ namespace osu.Game.Screens.Play hudOverlay, pauseOverlay }; + + if (!hudOverlay.IsVisible) + { + notificationManager?.Post(new SimpleNotification + { + Text = @"The score overlay is currently disabled. You can toogle this by pressing Shift + Tab." + }); + } } private void initializeSkipButton() @@ -333,5 +344,22 @@ namespace osu.Game.Screens.Play private Bindable mouseWheelDisabled; protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused; + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (args.Repeat) return false; + + if (state.Keyboard.ShiftPressed) + { + switch (args.Key) + { + case Key.Tab: + hudOverlay.ChangeVisibility(); + return true; + } + } + + return base.OnKeyDown(state, args); + } } } \ No newline at end of file