diff --git a/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs index 6ffff680d6..5716d8f89f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs @@ -46,7 +46,7 @@ namespace osu.Desktop.VisualTests.Tests })); } - private class ExampleContainer : SettingsDropdownContainer + private class ExampleContainer : ReplaySettingsGroup { protected override string Title => @"example"; } diff --git a/osu.Game/Graphics/UserInterface/SimpleButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs similarity index 94% rename from osu.Game/Graphics/UserInterface/SimpleButton.cs rename to osu.Game/Graphics/UserInterface/IconButton.cs index e593f7fc05..d2a87d2dd0 100644 --- a/osu.Game/Graphics/UserInterface/SimpleButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -12,7 +12,7 @@ using osu.Framework.Input; namespace osu.Game.Graphics.UserInterface { - public class SimpleButton : ClickableContainer + public class IconButton : ClickableContainer { private readonly TextAwesome icon; private readonly Box hover; @@ -33,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface set { icon.Scale = value; } } - public SimpleButton() + public IconButton() { AutoSizeAxes = Axes.Both; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 208f30137b..bfe10e845e 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -39,8 +39,8 @@ namespace osu.Game.Overlays private Drawable currentBackground; private DragBar progressBar; - private SimpleButton playButton; - private SimpleButton playlistButton; + private IconButton playButton; + private IconButton playlistButton; private SpriteText title, artist; @@ -144,7 +144,7 @@ namespace osu.Game.Overlays Anchor = Anchor.BottomCentre, Children = new Drawable[] { - new FillFlowContainer + new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, @@ -153,26 +153,26 @@ namespace osu.Game.Overlays Anchor = Anchor.Centre, Children = new[] { - new SimpleButton + new IconButton { Action = prev, Icon = FontAwesome.fa_step_backward, }, - playButton = new SimpleButton + playButton = new IconButton { Scale = new Vector2(1.4f), IconScale = new Vector2(1.4f), Action = play, Icon = FontAwesome.fa_play_circle_o, }, - new SimpleButton + new IconButton { Action = next, Icon = FontAwesome.fa_step_forward, }, } }, - playlistButton = new SimpleButton + playlistButton = new IconButton { Origin = Anchor.Centre, Anchor = Anchor.CentreRight, diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 4610cd2d6a..ccbb36fd03 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -33,6 +33,8 @@ namespace osu.Game.Screens.Play public readonly ReplaySettingsOverlay ReplaySettingsOverlay; private Bindable showHud; + private bool replaySettingsIsVisible; + private bool replayLoaded; private static bool hasShownNotificationOnce; @@ -97,8 +99,10 @@ namespace osu.Game.Screens.Play { hitRenderer.InputManager.Add(KeyCounter.GetReceptor()); + replayLoaded = hitRenderer.HasReplayLoaded; + // in the case a replay isn't loaded, we want some elements to only appear briefly. - if (!hitRenderer.HasReplayLoaded) + if (!replayLoaded) { ReplaySettingsOverlay.Hide(); ReplaySettingsOverlay.AlwaysPresent = false; @@ -122,6 +126,18 @@ namespace osu.Game.Screens.Play } } + switch (args.Key) + { + case Key.H: + if (replayLoaded) + { + ReplaySettingsOverlay.FadeTo(replaySettingsIsVisible ? 1 : 0, duration); + replaySettingsIsVisible = !replaySettingsIsVisible; + return true; + } + else return false; + } + return base.OnKeyDown(state, args); } } diff --git a/osu.Game/Screens/Play/ReplaySettings/CollectionSettings.cs b/osu.Game/Screens/Play/ReplaySettings/CollectionSettings.cs index 7b2e313353..defa2a8ded 100644 --- a/osu.Game/Screens/Play/ReplaySettings/CollectionSettings.cs +++ b/osu.Game/Screens/Play/ReplaySettings/CollectionSettings.cs @@ -10,7 +10,7 @@ using osu.Game.Graphics.UserInterface; namespace osu.Game.Screens.Play.ReplaySettings { - public class CollectionSettings : SettingsDropdownContainer + public class CollectionSettings : ReplaySettingsGroup { protected override string Title => @"collections"; diff --git a/osu.Game/Screens/Play/ReplaySettings/DiscussionSettings.cs b/osu.Game/Screens/Play/ReplaySettings/DiscussionSettings.cs index 93dd65cb6d..ac21a11e63 100644 --- a/osu.Game/Screens/Play/ReplaySettings/DiscussionSettings.cs +++ b/osu.Game/Screens/Play/ReplaySettings/DiscussionSettings.cs @@ -8,7 +8,7 @@ using osu.Game.Graphics.UserInterface; namespace osu.Game.Screens.Play.ReplaySettings { - public class DiscussionSettings : SettingsDropdownContainer + public class DiscussionSettings : ReplaySettingsGroup { protected override string Title => @"discussions"; @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Play.ReplaySettings { new ReplaySettingsCheckbox { - LabelText = "Show floating coments", + LabelText = "Show floating comments", Bindable = config.GetBindable(OsuSetting.FloatingComments) }, new FocusedTextBox diff --git a/osu.Game/Screens/Play/ReplaySettings/PlaybackSettings.cs b/osu.Game/Screens/Play/ReplaySettings/PlaybackSettings.cs index 6432c48e38..69b6ed7fe3 100644 --- a/osu.Game/Screens/Play/ReplaySettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/ReplaySettings/PlaybackSettings.cs @@ -8,7 +8,7 @@ using osu.Framework.Graphics; namespace osu.Game.Screens.Play.ReplaySettings { - public class PlaybackSettings : SettingsDropdownContainer + public class PlaybackSettings : ReplaySettingsGroup { protected override string Title => @"playback"; diff --git a/osu.Game/Graphics/UserInterface/SettingsDropdownContainer.cs b/osu.Game/Screens/Play/ReplaySettings/ReplaySettingsGroup.cs similarity index 81% rename from osu.Game/Graphics/UserInterface/SettingsDropdownContainer.cs rename to osu.Game/Screens/Play/ReplaySettings/ReplaySettingsGroup.cs index ccfab53100..5d416ef372 100644 --- a/osu.Game/Graphics/UserInterface/SettingsDropdownContainer.cs +++ b/osu.Game/Screens/Play/ReplaySettings/ReplaySettingsGroup.cs @@ -7,14 +7,16 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; -namespace osu.Game.Graphics.UserInterface +namespace osu.Game.Screens.Play.ReplaySettings { - public abstract class SettingsDropdownContainer : Container + public abstract class ReplaySettingsGroup : Container { /// - /// The title of this container, which will be written in header. + /// The title to be displayed in the header of this group. /// protected abstract string Title { get; } @@ -24,14 +26,13 @@ namespace osu.Game.Graphics.UserInterface private const int header_height = 30; private const int corner_radius = 5; - private FillFlowContainer content; - private SimpleButton button; - private bool buttonIsActive; + private readonly FillFlowContainer content; + private readonly IconButton button; + private bool expanded; private Color4 buttonActiveColour; - [BackgroundDependencyLoader] - private void load(OsuColour colours) + public ReplaySettingsGroup() { AutoSizeAxes = Axes.Y; Width = container_width; @@ -53,7 +54,6 @@ namespace osu.Game.Graphics.UserInterface Direction = FillDirection.Vertical, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Children = new Drawable[] { new Container @@ -63,7 +63,6 @@ namespace osu.Game.Graphics.UserInterface Anchor = Anchor.TopCentre, RelativeSizeAxes = Axes.X, Height = header_height, - Children = new Drawable[] { new OsuSpriteText @@ -75,14 +74,13 @@ namespace osu.Game.Graphics.UserInterface Font = @"Exo2.0-Bold", Margin = new MarginPadding { Left = 10 }, }, - button = new SimpleButton + button = new IconButton { Origin = Anchor.Centre, Anchor = Anchor.CentreRight, Position = new Vector2(-15,0), Icon = FontAwesome.fa_bars, Scale = new Vector2(0.75f), - Colour = buttonActiveColour = colours.Yellow, Action = triggerContentVisibility, }, } @@ -105,19 +103,25 @@ namespace osu.Game.Graphics.UserInterface }; } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + button.Colour = buttonActiveColour = colours.Yellow; + } + protected override Container Content => content; private void triggerContentVisibility() { content.ClearTransforms(); - content.AutoSizeAxes = buttonIsActive ? Axes.Y : Axes.None; + content.AutoSizeAxes = expanded ? Axes.Y : Axes.None; - if (!buttonIsActive) + if (!expanded) content.ResizeHeightTo(0, transition_duration, EasingTypes.OutQuint); - button.FadeColour(buttonIsActive ? buttonActiveColour : Color4.White, 200, EasingTypes.OutQuint); + button.FadeColour(expanded ? buttonActiveColour : Color4.White, 200, EasingTypes.OutQuint); - buttonIsActive = !buttonIsActive; + expanded = !expanded; } } } diff --git a/osu.Game/Screens/Play/ReplaySettings/ReplaySettingsOverlay.cs b/osu.Game/Screens/Play/ReplaySettings/ReplaySettingsOverlay.cs index 9217d54687..925b760a5b 100644 --- a/osu.Game/Screens/Play/ReplaySettings/ReplaySettingsOverlay.cs +++ b/osu.Game/Screens/Play/ReplaySettings/ReplaySettingsOverlay.cs @@ -2,19 +2,13 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using OpenTK.Input; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Input; namespace osu.Game.Screens.Play.ReplaySettings { public class ReplaySettingsOverlay : FillFlowContainer { - private const int fade_duration = 100; - - private bool isVisible; - public ReplaySettingsOverlay() { AlwaysPresent = true; @@ -26,20 +20,5 @@ namespace osu.Game.Screens.Play.ReplaySettings Add(new DiscussionSettings()); Add(new PlaybackSettings()); } - - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - if (args.Repeat) return false; - - switch (args.Key) - { - case Key.H: - FadeTo(isVisible ? 1 : 0, fade_duration); - isVisible = !isVisible; - return true; - } - - return base.OnKeyDown(state, args); - } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3e7741e964..02bcac6778 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -74,7 +74,7 @@ - + @@ -243,7 +243,7 @@ - +