From 2ffc479411ab1edc093aa5416a5ec3e62eacf6a6 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Sat, 23 Dec 2017 14:56:23 +0100 Subject: [PATCH 1/3] let NotificationOverlay move the background --- osu.Game/OsuGame.cs | 21 +++++++++++++++++++-- osu.Game/Overlays/SettingsOverlay.cs | 6 +++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 4745733bd9..121e9360ce 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -75,6 +75,8 @@ namespace osu.Game private SettingsOverlay settings; + private float backgroundOffset; + public OsuGame(string[] args = null) { this.args = args; @@ -276,12 +278,27 @@ namespace osu.Game switch (settings.State) { case Visibility.Hidden: - intro.MoveToX(0, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint); + backgroundOffset -= ToolbarButton.WIDTH / 2; break; case Visibility.Visible: - intro.MoveToX(SettingsOverlay.SIDEBAR_WIDTH / 2, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint); + backgroundOffset += ToolbarButton.WIDTH / 2; break; } + intro.MoveToX(backgroundOffset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint); + }; + + notificationOverlay.StateChanged += delegate + { + switch (notificationOverlay.State) + { + case Visibility.Hidden: + backgroundOffset += ToolbarButton.WIDTH / 2; + break; + case Visibility.Visible: + backgroundOffset -= ToolbarButton.WIDTH / 2; + break; + } + intro.MoveToX(backgroundOffset, NotificationOverlay.TRANSITION_LENGTH, Easing.OutQuint); }; Cursor.State = Visibility.Hidden; diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 798fa00032..a80f6d4da8 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -24,7 +24,7 @@ namespace osu.Game.Overlays public const float TRANSITION_LENGTH = 600; - public const float SIDEBAR_WIDTH = Sidebar.DEFAULT_WIDTH; + private const float sidebar_width = Sidebar.DEFAULT_WIDTH; protected const float WIDTH = 400; @@ -102,7 +102,7 @@ namespace osu.Game.Overlays if (showSidebar) { - AddInternal(Sidebar = new Sidebar { Width = SIDEBAR_WIDTH }); + AddInternal(Sidebar = new Sidebar { Width = sidebar_width }); SectionsContainer.SelectedSection.ValueChanged += section => { @@ -167,7 +167,7 @@ namespace osu.Game.Overlays ContentContainer.MoveToX(-WIDTH, TRANSITION_LENGTH, Easing.OutQuint); - Sidebar?.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, Easing.OutQuint); + Sidebar?.MoveToX(-sidebar_width, TRANSITION_LENGTH, Easing.OutQuint); this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint); searchTextBox.HoldFocus = false; From 5b22c5a45371e671b155f11bbcc6e4d94c95eff5 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Sun, 24 Dec 2017 10:28:37 +0100 Subject: [PATCH 2/3] reduce code duplication to move intro background --- osu.Game/OsuGame.cs | 51 ++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 121e9360ce..f91df9b6ba 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -37,7 +37,7 @@ namespace osu.Game private MusicController musicController; - private NotificationOverlay notificationOverlay; + private NotificationOverlay notifications; private DialogOverlay dialogOverlay; @@ -75,8 +75,6 @@ namespace osu.Game private SettingsOverlay settings; - private float backgroundOffset; - public OsuGame(string[] args = null) { this.args = args; @@ -138,7 +136,7 @@ namespace osu.Game if (s.Beatmap == null) { - notificationOverlay.Post(new SimpleNotification + notifications.Post(new SimpleNotification { Text = @"Tried to load a score for a beatmap we don't have!", Icon = FontAwesome.fa_life_saver, @@ -156,7 +154,7 @@ namespace osu.Game base.LoadComplete(); // hook up notifications to components. - BeatmapManager.PostNotification = n => notificationOverlay?.Post(n); + BeatmapManager.PostNotification = n => notifications?.Post(n); BeatmapManager.GetStableStorage = GetStorageForStableInstall; AddRange(new Drawable[] @@ -209,7 +207,7 @@ namespace osu.Game Origin = Anchor.TopRight, }, overlayContent.Add); - loadComponentSingleFile(notificationOverlay = new NotificationOverlay + loadComponentSingleFile(notifications = new NotificationOverlay { Depth = -4, Anchor = Anchor.TopRight, @@ -225,7 +223,7 @@ namespace osu.Game { if (entry.Level < LogLevel.Important) return; - notificationOverlay.Post(new SimpleNotification + notifications.Post(new SimpleNotification { Text = $@"{entry.Level}: {entry.Message}" }); @@ -238,7 +236,7 @@ namespace osu.Game dependencies.Cache(userProfile); dependencies.Cache(musicController); dependencies.Cache(beatmapSetOverlay); - dependencies.Cache(notificationOverlay); + dependencies.Cache(notifications); dependencies.Cache(dialogOverlay); // ensure only one of these overlays are open at once. @@ -273,33 +271,20 @@ namespace osu.Game }; } - settings.StateChanged += delegate + Action stateChanged = delegate { - switch (settings.State) - { - case Visibility.Hidden: - backgroundOffset -= ToolbarButton.WIDTH / 2; - break; - case Visibility.Visible: - backgroundOffset += ToolbarButton.WIDTH / 2; - break; - } - intro.MoveToX(backgroundOffset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint); + float offset = intro.X; + + if (settings.State == Visibility.Hidden || notifications.State == Visibility.Visible) + offset -= ToolbarButton.WIDTH / 2; + else if (settings.State == Visibility.Visible || notifications.State == Visibility.Hidden) + offset += ToolbarButton.WIDTH / 2; + + intro.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint); }; - notificationOverlay.StateChanged += delegate - { - switch (notificationOverlay.State) - { - case Visibility.Hidden: - backgroundOffset += ToolbarButton.WIDTH / 2; - break; - case Visibility.Visible: - backgroundOffset -= ToolbarButton.WIDTH / 2; - break; - } - intro.MoveToX(backgroundOffset, NotificationOverlay.TRANSITION_LENGTH, Easing.OutQuint); - }; + settings.StateChanged += stateChanged; + notifications.StateChanged += stateChanged; Cursor.State = Visibility.Hidden; } @@ -368,7 +353,7 @@ namespace osu.Game direct.State = Visibility.Hidden; social.State = Visibility.Hidden; userProfile.State = Visibility.Hidden; - notificationOverlay.State = Visibility.Hidden; + notifications.State = Visibility.Hidden; } private void screenChanged(Screen newScreen) From 68a00235b92fc87d54f88c432892ed8a63e06464 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Sun, 24 Dec 2017 14:32:56 +0100 Subject: [PATCH 3/3] simplify offset calculation for background --- osu.Game/OsuGame.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index f757d16c85..67f6e6f4e2 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -274,12 +274,12 @@ namespace osu.Game Action stateChanged = delegate { - float offset = intro.X; + float offset = 0; - if (settings.State == Visibility.Hidden || notifications.State == Visibility.Visible) - offset -= ToolbarButton.WIDTH / 2; - else if (settings.State == Visibility.Visible || notifications.State == Visibility.Hidden) + if (settings.State == Visibility.Visible) offset += ToolbarButton.WIDTH / 2; + if (notifications.State == Visibility.Visible) + offset -= ToolbarButton.WIDTH / 2; intro.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint); };