From 30323876a8b0209f9da63f8e9d7bcdf7ca004eaa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Nov 2016 18:49:20 +0900 Subject: [PATCH 01/10] Use preload for options (fix icons). --- osu.Game/OsuGameBase.cs | 5 +++-- osu.Game/Overlays/OptionsOverlay.cs | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index ae13b20f4a..d731115c91 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -44,8 +44,7 @@ namespace osu.Game Children = new Drawable[] { - Options = new OptionsOverlay(), - Cursor = new OsuCursorContainer() + Cursor = new OsuCursorContainer { Depth = float.MaxValue } }; Beatmap.ValueChanged += Beatmap_ValueChanged; @@ -81,6 +80,8 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); + (Options = new OptionsOverlay { Depth = float.MaxValue / 2}).Preload(game, Add); + API = new APIAccess() { Username = Config.Get(OsuConfig.Username), diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index c8d0dbac31..40c586b7f8 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -34,7 +34,6 @@ namespace osu.Game.Overlays public OptionsOverlay() { - Depth = float.MaxValue; RelativeSizeAxes = Axes.Y; Size = new Vector2(width, 1); Position = new Vector2(-width, 0); From 3b0114671e097f6c07f5ce83bc604e93a9f7ecf6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Nov 2016 19:16:39 +0900 Subject: [PATCH 02/10] Max sidebar draggable. --- osu.Game/OsuGameBase.cs | 2 +- osu.Game/Overlays/Options/OptionsSideNav.cs | 37 +++++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index d731115c91..5f1bf5aafd 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -80,7 +80,7 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); - (Options = new OptionsOverlay { Depth = float.MaxValue / 2}).Preload(game, Add); + (Options = new OptionsOverlay { Depth = float.MaxValue / 2 }).Preload(game, Add); API = new APIAccess() { diff --git a/osu.Game/Overlays/Options/OptionsSideNav.cs b/osu.Game/Overlays/Options/OptionsSideNav.cs index c578d138a6..94c599fe68 100644 --- a/osu.Game/Overlays/Options/OptionsSideNav.cs +++ b/osu.Game/Overlays/Options/OptionsSideNav.cs @@ -19,13 +19,19 @@ namespace osu.Game.Overlays.Options RelativeSizeAxes = Axes.Y; InternalChildren = new Drawable[] { - content = new FlowContainer + new SidebarScrollContainer { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Origin = Anchor.CentreLeft, - Anchor = Anchor.CentreLeft, - Direction = FlowDirection.VerticalOnly + Children = new [] + { + content = new FlowContainer + { + Origin = Anchor.CentreLeft, + Anchor = Anchor.CentreLeft, + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FlowDirection.VerticalOnly + } + } }, new Box { @@ -38,18 +44,27 @@ namespace osu.Game.Overlays.Options }; } + private class SidebarScrollContainer : ScrollContainer + { + public SidebarScrollContainer() + { + Content.Anchor = Anchor.CentreLeft; + Content.Origin = Anchor.CentreLeft; + } + } + public class SidebarButton : Container { private TextAwesome drawableIcon; private Box backgroundBox; public Action Action; - + public FontAwesome Icon { get { return drawableIcon.Icon; } set { drawableIcon.Icon = value; } } - + public SidebarButton() { Size = new Vector2(60); @@ -69,20 +84,20 @@ namespace osu.Game.Overlays.Options }, }; } - + protected override bool OnMouseDown(InputState state, MouseDownEventArgs e) { Action?.Invoke(); backgroundBox.FlashColour(Color4.White, 400); return true; } - + protected override bool OnHover(InputState state) { backgroundBox.FadeTo(0.4f, 200); return true; } - + protected override void OnHoverLost(InputState state) { backgroundBox.FadeTo(0, 200); From 8c68f9ba93305048ec341f9d78d8def8d6cfee10 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Nov 2016 19:17:09 +0900 Subject: [PATCH 03/10] OptionsSideNav -> OptionsSidebar. --- .../{OptionsSideNav.cs => OptionsSidebar.cs} | 4 ++-- osu.Game/Overlays/OptionsOverlay.cs | 4 ++-- osu.Game/osu.Game.csproj | 14 +++----------- 3 files changed, 7 insertions(+), 15 deletions(-) rename osu.Game/Overlays/Options/{OptionsSideNav.cs => OptionsSidebar.cs} (94%) diff --git a/osu.Game/Overlays/Options/OptionsSideNav.cs b/osu.Game/Overlays/Options/OptionsSidebar.cs similarity index 94% rename from osu.Game/Overlays/Options/OptionsSideNav.cs rename to osu.Game/Overlays/Options/OptionsSidebar.cs index 94c599fe68..6fa6a7f978 100644 --- a/osu.Game/Overlays/Options/OptionsSideNav.cs +++ b/osu.Game/Overlays/Options/OptionsSidebar.cs @@ -9,12 +9,12 @@ using osu.Game.Graphics; namespace osu.Game.Overlays.Options { - public class OptionsSideNav : Container + public class OptionsSidebar : Container { private FlowContainer content; protected override Container Content => content; - public OptionsSideNav() + public OptionsSidebar() { RelativeSizeAxes = Axes.Y; InternalChildren = new Drawable[] diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 40c586b7f8..e855cc0c89 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -97,12 +97,12 @@ namespace osu.Game.Overlays } } }, - new OptionsSideNav + new OptionsSidebar { Padding = new MarginPadding { Left = sideNavPadding, Right = sideNavPadding }, Width = sideNavWidth + sideNavPadding * 2, Children = sections.Select(section => - new OptionsSideNav.SidebarButton + new OptionsSidebar.SidebarButton { Icon = section.Icon, Action = () => scrollContainer.ScrollIntoView(section) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 18bf9c1b34..3b5ea8de73 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -202,7 +202,7 @@ - + @@ -251,15 +251,7 @@ - - - - - - - - - + - + \ No newline at end of file From 89b11ed099d0182bd55be1ab27d70c7c6cdab438 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Nov 2016 19:18:31 +0900 Subject: [PATCH 04/10] Handle sidebar buttons onClick not onMouseDown. --- osu.Game/Overlays/Options/OptionsSidebar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Options/OptionsSidebar.cs b/osu.Game/Overlays/Options/OptionsSidebar.cs index 6fa6a7f978..810265cf5d 100644 --- a/osu.Game/Overlays/Options/OptionsSidebar.cs +++ b/osu.Game/Overlays/Options/OptionsSidebar.cs @@ -85,7 +85,7 @@ namespace osu.Game.Overlays.Options }; } - protected override bool OnMouseDown(InputState state, MouseDownEventArgs e) + protected override bool OnClick(InputState state) { Action?.Invoke(); backgroundBox.FlashColour(Color4.White, 400); From 4426a683ed4d8b0b630de85aba73447f08e0be26 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Nov 2016 19:26:12 +0900 Subject: [PATCH 05/10] Move OptionsOverlay to OsuGame. --- osu.Game/OsuGame.cs | 4 ++++ osu.Game/OsuGameBase.cs | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7f14c6c942..7f488c43be 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -35,6 +35,8 @@ namespace osu.Game string[] args; + public OptionsOverlay Options; + public OsuGame(string[] args = null) { this.args = args; @@ -89,6 +91,8 @@ namespace osu.Game } }); + (Options = new OptionsOverlay { Depth = float.MaxValue / 2 }).Preload(game, Add); + (intro = new Intro { Beatmap = Beatmap diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 5f1bf5aafd..0ac808d1ff 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -27,7 +27,6 @@ namespace osu.Game protected override string MainResourceFile => @"osu.Game.Resources.dll"; - public OptionsOverlay Options; public APIAccess API; protected override Container Content => ratioContainer; @@ -80,8 +79,6 @@ namespace osu.Game Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic")); - (Options = new OptionsOverlay { Depth = float.MaxValue / 2 }).Preload(game, Add); - API = new APIAccess() { Username = Config.Get(OsuConfig.Username), From 97f3023cd9f4b1eef9a0f48e41e54a9801425f59 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Nov 2016 19:27:37 +0900 Subject: [PATCH 06/10] Ctrl+O for options. --- osu.Game/OsuGame.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7f488c43be..8a72cef0c4 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -131,6 +131,16 @@ namespace osu.Game return true; } + if (state.Keyboard.ControlPressed) + { + switch (args.Key) + { + case Key.O: + Options.ToggleVisibility(); + return true; + } + } + return base.OnKeyDown(state, args); } From 3ef26a6bf0ccde8e45cf59dba96879004c1a672f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Nov 2016 20:07:28 +0900 Subject: [PATCH 07/10] Fix paddings, transitions, const variable names. --- osu.Game/Overlays/Options/OptionsSection.cs | 4 +- osu.Game/Overlays/Options/OptionsSidebar.cs | 13 ++---- osu.Game/Overlays/OptionsOverlay.cs | 52 ++++++++++++--------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/osu.Game/Overlays/Options/OptionsSection.cs b/osu.Game/Overlays/Options/OptionsSection.cs index 57b48c17b5..b6d2f4634c 100644 --- a/osu.Game/Overlays/Options/OptionsSection.cs +++ b/osu.Game/Overlays/Options/OptionsSection.cs @@ -35,8 +35,8 @@ namespace osu.Game.Overlays.Options Padding = new MarginPadding { Top = 10 + borderSize, - Left = OptionsOverlay.SideMargins, - Right = OptionsOverlay.SideMargins, + Left = OptionsOverlay.CONTENT_MARGINS, + Right = OptionsOverlay.CONTENT_MARGINS, Bottom = 10, }, RelativeSizeAxes = Axes.X, diff --git a/osu.Game/Overlays/Options/OptionsSidebar.cs b/osu.Game/Overlays/Options/OptionsSidebar.cs index 810265cf5d..aba1c050af 100644 --- a/osu.Game/Overlays/Options/OptionsSidebar.cs +++ b/osu.Game/Overlays/Options/OptionsSidebar.cs @@ -19,6 +19,11 @@ namespace osu.Game.Overlays.Options RelativeSizeAxes = Axes.Y; InternalChildren = new Drawable[] { + new Box + { + Colour = Color4.Black, + RelativeSizeAxes = Axes.Both, + }, new SidebarScrollContainer { Children = new [] @@ -33,14 +38,6 @@ namespace osu.Game.Overlays.Options } } }, - new Box - { - Colour = new Color4(30, 30, 30, 255), - RelativeSizeAxes = Axes.Y, - Width = 2, - Origin = Anchor.TopRight, - Anchor = Anchor.TopRight, - } }; } diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index e855cc0c89..66e41ccf51 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -24,20 +24,18 @@ namespace osu.Game.Overlays { public class OptionsOverlay : OverlayContainer { - internal const float SideMargins = 10; + internal const float CONTENT_MARGINS = 10; + private const float width = 400; - private const float sideNavWidth = 60; - private const float sideNavPadding = 0; + private const float sidebar_width = 60; + private const float sidebar_padding = 10; + private const float sidebar_total = sidebar_width + sidebar_padding; private ScrollContainer scrollContainer; - private FlowContainer flowContainer; + private OptionsSidebar sidebar; public OptionsOverlay() { - RelativeSizeAxes = Axes.Y; - Size = new Vector2(width, 1); - Position = new Vector2(-width, 0); - var sections = new OptionsSection[] { new GeneralSection(), @@ -51,20 +49,23 @@ namespace osu.Game.Overlays new MaintenanceSection(), }; + RelativeSizeAxes = Axes.Y; + AutoSizeAxes = Axes.X; + Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.Black, - Alpha = 0.8f, + Alpha = 0.6f, }, - scrollContainer = new ScrollContainer + scrollContainer = new PaddedScrollContainer { ScrollDraggerAnchor = Anchor.TopLeft, RelativeSizeAxes = Axes.Y, - Width = width - (sideNavWidth + sideNavPadding * 2), - Position = new Vector2(sideNavWidth + sideNavPadding * 2, 0), + Width = width, + Padding = new MarginPadding { Left = sidebar_width }, Children = new[] { new FlowContainer @@ -78,29 +79,29 @@ namespace osu.Game.Overlays { Text = "settings", TextSize = 40, - Margin = new MarginPadding { Left = SideMargins, Top = 30 }, + Margin = new MarginPadding { Left = CONTENT_MARGINS, Top = 30 }, }, new SpriteText { Colour = new Color4(235, 117, 139, 255), Text = "Change the way osu! behaves", TextSize = 18, - Margin = new MarginPadding { Left = SideMargins, Bottom = 30 }, + Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 }, }, - flowContainer = new FlowContainer + new FlowContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Direction = FlowDirection.VerticalOnly, + Children = sections, } } } } }, - new OptionsSidebar + sidebar = new OptionsSidebar { - Padding = new MarginPadding { Left = sideNavPadding, Right = sideNavPadding }, - Width = sideNavWidth + sideNavPadding * 2, + Width = sidebar_width, Children = sections.Select(section => new OptionsSidebar.SidebarButton { @@ -110,7 +111,6 @@ namespace osu.Game.Overlays ) } }; - flowContainer.Add(sections); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; @@ -129,14 +129,24 @@ namespace osu.Game.Overlays protected override void PopIn() { - MoveToX(0, 300, EasingTypes.Out); + scrollContainer.MoveToX(0, 600, EasingTypes.OutQuint); + sidebar.MoveToX(0, 800, EasingTypes.OutQuint); FadeTo(1, 300); } protected override void PopOut() { - MoveToX(-width, 300, EasingTypes.Out); + scrollContainer.MoveToX(-width, 600, EasingTypes.OutQuint); + sidebar.MoveToX(-sidebar_width, 600, EasingTypes.OutQuint); FadeTo(0, 300); } + + private class PaddedScrollContainer : ScrollContainer + { + public PaddedScrollContainer() + { + Content.Padding = new MarginPadding { Left = sidebar_padding }; + } + } } } From 28a94e2df123d076a3f16c229596e73aaced873c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 8 Nov 2016 20:35:21 +0900 Subject: [PATCH 08/10] Remove unused constant. --- osu.Game/Overlays/OptionsOverlay.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 66e41ccf51..be5261d28f 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -29,7 +29,6 @@ namespace osu.Game.Overlays private const float width = 400; private const float sidebar_width = 60; private const float sidebar_padding = 10; - private const float sidebar_total = sidebar_width + sidebar_padding; private ScrollContainer scrollContainer; private OptionsSidebar sidebar; From d41d7b8e9ab99156b2722fc2078d9a295d441384 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 9 Nov 2016 12:10:22 +0900 Subject: [PATCH 09/10] Don't derive ScrollContainer unnecessarily. --- osu.Game/Overlays/OptionsOverlay.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index be5261d28f..e0f7af9f3a 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -59,8 +59,9 @@ namespace osu.Game.Overlays Colour = Color4.Black, Alpha = 0.6f, }, - scrollContainer = new PaddedScrollContainer + scrollContainer = new ScrollContainer { + ScrollbarOverlapsContent = false, ScrollDraggerAnchor = Anchor.TopLeft, RelativeSizeAxes = Axes.Y, Width = width, @@ -139,13 +140,5 @@ namespace osu.Game.Overlays sidebar.MoveToX(-sidebar_width, 600, EasingTypes.OutQuint); FadeTo(0, 300); } - - private class PaddedScrollContainer : ScrollContainer - { - public PaddedScrollContainer() - { - Content.Padding = new MarginPadding { Left = sidebar_padding }; - } - } } } From b2291ed615880226e0eab6f4df845abcbc60e589 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 9 Nov 2016 12:15:15 +0900 Subject: [PATCH 10/10] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index b8d0a0050b..25b8c3c6cf 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit b8d0a0050be25aec4333134ca18497340e1154a7 +Subproject commit 25b8c3c6cfead49acf5659a750c7e604289d5b81