From d437c1d7ec386e8ca72ab8ffb6f5e3a6f143e463 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Thu, 8 Feb 2018 23:28:42 +0300 Subject: [PATCH 1/9] Introduce PlayerBase class --- osu.Game/Screens/Play/Player.cs | 96 ++++----------------------- osu.Game/Screens/Play/PlayerBase.cs | 84 +++++++++++++++++++++++ osu.Game/Screens/Play/PlayerLoader.cs | 7 +- osu.Game/osu.Game.csproj | 1 + 4 files changed, 99 insertions(+), 89 deletions(-) create mode 100644 osu.Game/Screens/Play/PlayerBase.cs diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 72864482d5..0f15592b72 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -5,9 +5,6 @@ using System; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -18,31 +15,23 @@ using osu.Framework.Threading; using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Configuration; -using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Online.API; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; -using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Play.BreaksOverlay; using osu.Game.Screens.Ranking; -using osu.Game.Storyboards.Drawables; -using OpenTK; namespace osu.Game.Screens.Play { - public class Player : OsuScreen, IProvideCursor + public class Player : PlayerBase, IProvideCursor { - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); - public override bool ShowOverlaysOnEnter => false; public Action RestartRequested; - public override bool AllowBeatmapRulesetChange => false; - public bool HasFailed { get; private set; } public bool AllowPause { get; set; } = true; @@ -67,39 +56,16 @@ namespace osu.Game.Screens.Play private ScoreProcessor scoreProcessor; protected RulesetContainer RulesetContainer; - #region User Settings - - private Bindable dimLevel; - private Bindable blurLevel; - private Bindable showStoryboard; - private Bindable mouseWheelDisabled; - private Bindable userAudioOffset; - - private SampleChannel sampleRestart; - - #endregion - - private Container storyboardContainer; - private DrawableStoryboard storyboard; - private HUDOverlay hudOverlay; private FailOverlay failOverlay; private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true; [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuConfigManager config, APIAccess api) + private void load(OsuConfigManager config, APIAccess api) { this.api = api; - dimLevel = config.GetBindable(OsuSetting.DimLevel); - blurLevel = config.GetBindable(OsuSetting.BlurLevel); - showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - - mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); - - sampleRestart = audio.Sample.Get(@"Gameplay/restart"); - WorkingBeatmap working = Beatmap.Value; Beatmap beatmap; @@ -150,15 +116,14 @@ namespace osu.Game.Screens.Play offsetClock = new FramedOffsetClock(decoupledClock); - userAudioOffset = config.GetBindable(OsuSetting.AudioOffset); - userAudioOffset.ValueChanged += v => offsetClock.Offset = v; - userAudioOffset.TriggerChange(); + UserAudioOffset.ValueChanged += v => offsetClock.Offset = v; + UserAudioOffset.TriggerChange(); scoreProcessor = RulesetContainer.CreateScoreProcessor(); Children = new Drawable[] { - storyboardContainer = new Container + StoryboardContainer = new Container { RelativeSizeAxes = Axes.Both, Clock = offsetClock, @@ -219,8 +184,8 @@ namespace osu.Game.Screens.Play } }; - if (showStoryboard) - initializeStoryboard(false); + if (ShowStoryboard) + InitializeStoryboard(false); // Bind ScoreProcessor to ourselves scoreProcessor.AllJudged += onCompletion; @@ -239,22 +204,9 @@ namespace osu.Game.Screens.Play mod.ApplyToClock(adjustableSourceClock); } - private void initializeStoryboard(bool asyncLoad) - { - var beatmap = Beatmap.Value; - - storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value); - storyboard.Masking = true; - - if (asyncLoad) - LoadComponentAsync(storyboard, storyboardContainer.Add); - else - storyboardContainer.Add(storyboard); - } - public void Restart() { - sampleRestart?.Play(); + SampleRestart?.Play(); ValidForResume = false; RestartRequested?.Invoke(); Exit(); @@ -310,10 +262,10 @@ namespace osu.Game.Screens.Play if (!loadedSuccessfully) return; - dimLevel.ValueChanged += _ => updateBackgroundElements(); - blurLevel.ValueChanged += _ => updateBackgroundElements(); - showStoryboard.ValueChanged += _ => updateBackgroundElements(); - updateBackgroundElements(); + DimLevel.ValueChanged += _ => UpdateBackgroundElements(); + BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); + ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); + UpdateBackgroundElements(); Content.Alpha = 0; Content @@ -368,28 +320,6 @@ namespace osu.Game.Screens.Play return true; } - private void updateBackgroundElements() - { - if (!IsCurrentScreen) return; - - const float duration = 800; - - var opacity = 1 - (float)dimLevel; - - if (showStoryboard && storyboard == null) - initializeStoryboard(true); - - var beatmap = Beatmap.Value; - var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable; - - storyboardContainer - .FadeColour(OsuColour.Gray(opacity), duration, Easing.OutQuint) - .FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, duration, Easing.OutQuint); - - (Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)blurLevel.Value * 25), duration, Easing.OutQuint); - Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, duration, Easing.OutQuint); - } - private void fadeOut() { const float fade_out_duration = 250; @@ -402,6 +332,6 @@ namespace osu.Game.Screens.Play Background?.FadeTo(1f, fade_out_duration); } - protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !pauseContainer.IsPaused; + protected override bool OnWheel(InputState state) => MouseWheelDisabled.Value && !pauseContainer.IsPaused; } } diff --git a/osu.Game/Screens/Play/PlayerBase.cs b/osu.Game/Screens/Play/PlayerBase.cs new file mode 100644 index 0000000000..c5a7e52de7 --- /dev/null +++ b/osu.Game/Screens/Play/PlayerBase.cs @@ -0,0 +1,84 @@ +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Configuration; +using osu.Game.Graphics; +using osu.Game.Screens.Backgrounds; +using osu.Game.Storyboards.Drawables; +using OpenTK; + +namespace osu.Game.Screens.Play +{ + public abstract class PlayerBase : OsuScreen + { + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); + public override bool AllowBeatmapRulesetChange => false; + + #region User Settings + + protected Bindable DimLevel; + protected Bindable BlurLevel; + protected Bindable ShowStoryboard; + protected Bindable MouseWheelDisabled; + protected Bindable UserAudioOffset; + + protected SampleChannel SampleRestart; + + #endregion + + protected DrawableStoryboard Storyboard; + protected Container StoryboardContainer; + + [BackgroundDependencyLoader] + private void load(AudioManager audio, OsuConfigManager config) + { + DimLevel = config.GetBindable(OsuSetting.DimLevel); + BlurLevel = config.GetBindable(OsuSetting.BlurLevel); + ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); + + MouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); + + SampleRestart = audio.Sample.Get(@"Gameplay/restart"); + + UserAudioOffset = config.GetBindable(OsuSetting.AudioOffset); + } + + protected void UpdateBackgroundElements() + { + if (!IsCurrentScreen) return; + + const float duration = 800; + + var opacity = 1 - (float)DimLevel; + + if (ShowStoryboard && Storyboard == null) + InitializeStoryboard(true); + + var beatmap = Beatmap.Value; + var storyboardVisible = ShowStoryboard && beatmap.Storyboard.HasDrawable; + + StoryboardContainer + .FadeColour(OsuColour.Gray(opacity), duration, Easing.OutQuint) + .FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, duration, Easing.OutQuint); + + (Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)BlurLevel.Value * 25), duration, Easing.OutQuint); + Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, duration, Easing.OutQuint); + } + + protected void InitializeStoryboard(bool asyncLoad) + { + var beatmap = Beatmap.Value; + + Storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value); + Storyboard.Masking = true; + + if (asyncLoad) + LoadComponentAsync(Storyboard, StoryboardContainer.Add); + else + StoryboardContainer.Add(Storyboard); + } + } +} diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 2950990779..0c6368c714 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -9,7 +9,6 @@ using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Backgrounds; using OpenTK; using osu.Framework.Localisation; using osu.Game.Screens.Menu; @@ -17,7 +16,7 @@ using osu.Game.Screens.Play.PlayerSettings; namespace osu.Game.Screens.Play { - public class PlayerLoader : OsuScreen + public class PlayerLoader : PlayerBase { private Player player; @@ -27,10 +26,6 @@ namespace osu.Game.Screens.Play private bool showOverlays = true; public override bool ShowOverlaysOnEnter => showOverlays; - public override bool AllowBeatmapRulesetChange => false; - - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); - public PlayerLoader(Player player) { this.player = player; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 6542160b97..cc5f5b92da 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -340,6 +340,7 @@ + From a860dd720893bf9f2eb950c64ef2d720477e7536 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Fri, 9 Feb 2018 00:06:24 +0300 Subject: [PATCH 2/9] =?UTF-8?q?Preview=20visual=20settings=20at=20the=20?= =?UTF-8?q?=E2=80=9Cloading=E2=80=9D=20screen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- osu.Game/Screens/Play/Player.cs | 5 +---- osu.Game/Screens/Play/PlayerBase.cs | 13 ++++++++++++- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 0f15592b72..8ebee96bae 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -262,10 +262,7 @@ namespace osu.Game.Screens.Play if (!loadedSuccessfully) return; - DimLevel.ValueChanged += _ => UpdateBackgroundElements(); - BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); - ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); - UpdateBackgroundElements(); + ConfigureBackgroundUpdate(); Content.Alpha = 0; Content diff --git a/osu.Game/Screens/Play/PlayerBase.cs b/osu.Game/Screens/Play/PlayerBase.cs index c5a7e52de7..b725b739c9 100644 --- a/osu.Game/Screens/Play/PlayerBase.cs +++ b/osu.Game/Screens/Play/PlayerBase.cs @@ -46,6 +46,14 @@ namespace osu.Game.Screens.Play UserAudioOffset = config.GetBindable(OsuSetting.AudioOffset); } + protected void ConfigureBackgroundUpdate() + { + DimLevel.ValueChanged += _ => UpdateBackgroundElements(); + BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); + ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); + UpdateBackgroundElements(); + } + protected void UpdateBackgroundElements() { if (!IsCurrentScreen) return; @@ -60,7 +68,7 @@ namespace osu.Game.Screens.Play var beatmap = Beatmap.Value; var storyboardVisible = ShowStoryboard && beatmap.Storyboard.HasDrawable; - StoryboardContainer + StoryboardContainer? .FadeColour(OsuColour.Gray(opacity), duration, Easing.OutQuint) .FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, duration, Easing.OutQuint); @@ -70,6 +78,9 @@ namespace osu.Game.Screens.Play protected void InitializeStoryboard(bool asyncLoad) { + if (StoryboardContainer == null) + return; + var beatmap = Beatmap.Value; Storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value); diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 0c6368c714..a4284efddb 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -88,7 +88,7 @@ namespace osu.Game.Screens.Play { base.OnEntering(last); - Background.FadeTo(0.4f, 250); + ConfigureBackgroundUpdate(); Content.ScaleTo(0.7f); From 4535e09607cda38faad7f4c146819b01de75a593 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Fri, 9 Feb 2018 00:36:31 +0300 Subject: [PATCH 3/9] Add missing license header --- osu.Game/Screens/Play/PlayerBase.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PlayerBase.cs b/osu.Game/Screens/Play/PlayerBase.cs index b725b739c9..5f22645361 100644 --- a/osu.Game/Screens/Play/PlayerBase.cs +++ b/osu.Game/Screens/Play/PlayerBase.cs @@ -1,4 +1,7 @@ -using osu.Framework.Allocation; +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Configuration; From c57e8785e23a01145b395da7fea09854bdb10f4e Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Thu, 15 Feb 2018 23:57:53 +0300 Subject: [PATCH 4/9] Move all storyboard loading to Player itself --- osu.Game/Screens/Play/Player.cs | 56 +++++++++-- osu.Game/Screens/Play/PlayerBase.cs | 98 ------------------- osu.Game/Screens/Play/PlayerLoader.cs | 10 +- .../Play/ScreenWithBeatmapBackground.cs | 58 +++++++++++ osu.Game/osu.Game.csproj | 2 +- 5 files changed, 118 insertions(+), 106 deletions(-) delete mode 100644 osu.Game/Screens/Play/PlayerBase.cs create mode 100644 osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 8ebee96bae..38525b18b9 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -5,6 +5,8 @@ using System; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -14,7 +16,7 @@ using osu.Framework.Screens; using osu.Framework.Threading; using osu.Framework.Timing; using osu.Game.Beatmaps; -using osu.Game.Configuration; +using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Online.API; using osu.Game.Rulesets; @@ -23,10 +25,11 @@ using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Screens.Play.BreaksOverlay; using osu.Game.Screens.Ranking; +using osu.Game.Storyboards.Drawables; namespace osu.Game.Screens.Play { - public class Player : PlayerBase, IProvideCursor + public class Player : ScreenWithBeatmapBackground, IProvideCursor { public override bool ShowOverlaysOnEnter => false; @@ -53,18 +56,24 @@ namespace osu.Game.Screens.Play private APIAccess api; + private SampleChannel sampleRestart; + private ScoreProcessor scoreProcessor; protected RulesetContainer RulesetContainer; private HUDOverlay hudOverlay; private FailOverlay failOverlay; + private DrawableStoryboard storyboard; + private Container storyboardContainer; + private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true; [BackgroundDependencyLoader] - private void load(OsuConfigManager config, APIAccess api) + private void load(AudioManager audio, APIAccess api) { this.api = api; + sampleRestart = audio.Sample.Get(@"Gameplay/restart"); WorkingBeatmap working = Beatmap.Value; Beatmap beatmap; @@ -123,7 +132,7 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { - StoryboardContainer = new Container + storyboardContainer = new Container { RelativeSizeAxes = Axes.Both, Clock = offsetClock, @@ -185,7 +194,7 @@ namespace osu.Game.Screens.Play }; if (ShowStoryboard) - InitializeStoryboard(false); + initializeStoryboard(false); // Bind ScoreProcessor to ourselves scoreProcessor.AllJudged += onCompletion; @@ -206,7 +215,7 @@ namespace osu.Game.Screens.Play public void Restart() { - SampleRestart?.Play(); + sampleRestart?.Play(); ValidForResume = false; RestartRequested?.Invoke(); Exit(); @@ -330,5 +339,40 @@ namespace osu.Game.Screens.Play } protected override bool OnWheel(InputState state) => MouseWheelDisabled.Value && !pauseContainer.IsPaused; + + private void initializeStoryboard(bool asyncLoad) + { + if (storyboardContainer == null) + return; + + var beatmap = Beatmap.Value; + + storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value); + storyboard.Masking = true; + + if (asyncLoad) + LoadComponentAsync(storyboard, storyboardContainer.Add); + else + storyboardContainer.Add(storyboard); + } + + protected override void UpdateBackgroundElements() + { + if (!IsCurrentScreen) return; + + base.UpdateBackgroundElements(); + + if (ShowStoryboard && storyboard == null) + initializeStoryboard(true); + + var beatmap = Beatmap.Value; + var storyboardVisible = ShowStoryboard && beatmap.Storyboard.HasDrawable; + + storyboardContainer? + .FadeColour(OsuColour.Gray(Opacity), Duration, Easing.OutQuint) + .FadeTo(storyboardVisible && Opacity > 0 ? 1 : 0, Duration, Easing.OutQuint); + + Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? Opacity : 0, Duration, Easing.OutQuint); + } } } diff --git a/osu.Game/Screens/Play/PlayerBase.cs b/osu.Game/Screens/Play/PlayerBase.cs deleted file mode 100644 index 5f22645361..0000000000 --- a/osu.Game/Screens/Play/PlayerBase.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Sample; -using osu.Framework.Configuration; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Configuration; -using osu.Game.Graphics; -using osu.Game.Screens.Backgrounds; -using osu.Game.Storyboards.Drawables; -using OpenTK; - -namespace osu.Game.Screens.Play -{ - public abstract class PlayerBase : OsuScreen - { - protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); - public override bool AllowBeatmapRulesetChange => false; - - #region User Settings - - protected Bindable DimLevel; - protected Bindable BlurLevel; - protected Bindable ShowStoryboard; - protected Bindable MouseWheelDisabled; - protected Bindable UserAudioOffset; - - protected SampleChannel SampleRestart; - - #endregion - - protected DrawableStoryboard Storyboard; - protected Container StoryboardContainer; - - [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuConfigManager config) - { - DimLevel = config.GetBindable(OsuSetting.DimLevel); - BlurLevel = config.GetBindable(OsuSetting.BlurLevel); - ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - - MouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); - - SampleRestart = audio.Sample.Get(@"Gameplay/restart"); - - UserAudioOffset = config.GetBindable(OsuSetting.AudioOffset); - } - - protected void ConfigureBackgroundUpdate() - { - DimLevel.ValueChanged += _ => UpdateBackgroundElements(); - BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); - ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); - UpdateBackgroundElements(); - } - - protected void UpdateBackgroundElements() - { - if (!IsCurrentScreen) return; - - const float duration = 800; - - var opacity = 1 - (float)DimLevel; - - if (ShowStoryboard && Storyboard == null) - InitializeStoryboard(true); - - var beatmap = Beatmap.Value; - var storyboardVisible = ShowStoryboard && beatmap.Storyboard.HasDrawable; - - StoryboardContainer? - .FadeColour(OsuColour.Gray(opacity), duration, Easing.OutQuint) - .FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, duration, Easing.OutQuint); - - (Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)BlurLevel.Value * 25), duration, Easing.OutQuint); - Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, duration, Easing.OutQuint); - } - - protected void InitializeStoryboard(bool asyncLoad) - { - if (StoryboardContainer == null) - return; - - var beatmap = Beatmap.Value; - - Storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value); - Storyboard.Masking = true; - - if (asyncLoad) - LoadComponentAsync(Storyboard, StoryboardContainer.Add); - else - StoryboardContainer.Add(Storyboard); - } - } -} diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index a4284efddb..fa5ed6365f 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -16,7 +16,7 @@ using osu.Game.Screens.Play.PlayerSettings; namespace osu.Game.Screens.Play { - public class PlayerLoader : PlayerBase + public class PlayerLoader : ScreenWithBeatmapBackground { private Player player; @@ -263,5 +263,13 @@ namespace osu.Game.Screens.Play }; } } + + protected override void UpdateBackgroundElements() + { + if (!IsCurrentScreen) return; + + base.UpdateBackgroundElements(); + Background?.FadeTo(Opacity, Duration, Easing.OutQuint); + } } } diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs new file mode 100644 index 0000000000..83346d677c --- /dev/null +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -0,0 +1,58 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Game.Configuration; +using osu.Game.Screens.Backgrounds; +using OpenTK; + +namespace osu.Game.Screens.Play +{ + public abstract class ScreenWithBeatmapBackground : OsuScreen + { + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); + public override bool AllowBeatmapRulesetChange => false; + + protected float Duration => 800; + protected float Opacity => 1 - (float)DimLevel; + + #region User Settings + + protected Bindable DimLevel; + protected Bindable BlurLevel; + protected Bindable ShowStoryboard; + protected Bindable MouseWheelDisabled; + protected Bindable UserAudioOffset; + + #endregion + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + DimLevel = config.GetBindable(OsuSetting.DimLevel); + BlurLevel = config.GetBindable(OsuSetting.BlurLevel); + ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); + + MouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); + + UserAudioOffset = config.GetBindable(OsuSetting.AudioOffset); + } + + protected void ConfigureBackgroundUpdate() + { + DimLevel.ValueChanged += _ => UpdateBackgroundElements(); + BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); + ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); + UpdateBackgroundElements(); + } + + protected virtual void UpdateBackgroundElements() + { + if (!IsCurrentScreen) return; + + (Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)BlurLevel.Value * 25), Duration, Easing.OutQuint); + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index cc5f5b92da..b9ab6e7c59 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -340,7 +340,7 @@ - + From 9760f30ce97637256b963cac3267c9ef3d8542b5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 16 Feb 2018 12:08:21 +0900 Subject: [PATCH 5/9] Tidy things up to make more sense --- osu.Game/Screens/Play/Player.cs | 9 +++++---- osu.Game/Screens/Play/PlayerLoader.cs | 8 -------- osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs | 9 ++++++--- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 96ae4c7872..467332dbb9 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -347,7 +347,7 @@ namespace osu.Game.Screens.Play var beatmap = Beatmap.Value; - storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value); + storyboard = beatmap.Storyboard.CreateDrawable(); storyboard.Masking = true; if (asyncLoad) @@ -369,10 +369,11 @@ namespace osu.Game.Screens.Play var storyboardVisible = ShowStoryboard && beatmap.Storyboard.HasDrawable; storyboardContainer? - .FadeColour(OsuColour.Gray(Opacity), Duration, Easing.OutQuint) - .FadeTo(storyboardVisible && Opacity > 0 ? 1 : 0, Duration, Easing.OutQuint); + .FadeColour(OsuColour.Gray(BackgroundOpacity), BACKGROUND_FADE_DURATION, Easing.OutQuint) + .FadeTo(storyboardVisible && BackgroundOpacity > 0 ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint); - Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? Opacity : 0, Duration, Easing.OutQuint); + if (storyboardVisible && beatmap.Storyboard.ReplacesBackground) + Background?.FadeTo(0, BACKGROUND_FADE_DURATION, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index fa5ed6365f..042b4fc744 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -263,13 +263,5 @@ namespace osu.Game.Screens.Play }; } } - - protected override void UpdateBackgroundElements() - { - if (!IsCurrentScreen) return; - - base.UpdateBackgroundElements(); - Background?.FadeTo(Opacity, Duration, Easing.OutQuint); - } } } diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 83346d677c..d83f7e087d 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -13,10 +13,12 @@ namespace osu.Game.Screens.Play public abstract class ScreenWithBeatmapBackground : OsuScreen { protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); + public override bool AllowBeatmapRulesetChange => false; - protected float Duration => 800; - protected float Opacity => 1 - (float)DimLevel; + protected const float BACKGROUND_FADE_DURATION = 800; + + protected float BackgroundOpacity => 1 - (float)DimLevel; #region User Settings @@ -52,7 +54,8 @@ namespace osu.Game.Screens.Play { if (!IsCurrentScreen) return; - (Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)BlurLevel.Value * 25), Duration, Easing.OutQuint); + Background?.FadeTo(BackgroundOpacity, BACKGROUND_FADE_DURATION, Easing.OutQuint); + (Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)BlurLevel.Value * 25), BACKGROUND_FADE_DURATION, Easing.OutQuint); } } } From 2cb197d0c452d27139eb3dd6e29d3193c40a6f62 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Thu, 8 Mar 2018 11:35:00 +0300 Subject: [PATCH 6/9] Replace ConfigureBackgroundUpdate with OnEntering --- osu.Game/Screens/Play/Player.cs | 2 -- osu.Game/Screens/Play/PlayerLoader.cs | 2 -- osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs | 4 +++- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 7ec72a0e0e..9b341fbfe5 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -277,8 +277,6 @@ namespace osu.Game.Screens.Play if (!loadedSuccessfully) return; - ConfigureBackgroundUpdate(); - Content.Alpha = 0; Content .ScaleTo(0.7f) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 042b4fc744..784dcf7657 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -88,8 +88,6 @@ namespace osu.Game.Screens.Play { base.OnEntering(last); - ConfigureBackgroundUpdate(); - Content.ScaleTo(0.7f); contentIn(); diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index d83f7e087d..9942bf4ef5 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Screens; using osu.Game.Configuration; using osu.Game.Screens.Backgrounds; using OpenTK; @@ -42,8 +43,9 @@ namespace osu.Game.Screens.Play UserAudioOffset = config.GetBindable(OsuSetting.AudioOffset); } - protected void ConfigureBackgroundUpdate() + protected override void OnEntering(Screen last) { + base.OnEntering(last); DimLevel.ValueChanged += _ => UpdateBackgroundElements(); BlurLevel.ValueChanged += _ => UpdateBackgroundElements(); ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); From 6d91889ca641258a9706c932d16d2aa836a8ba80 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 8 Mar 2018 22:16:47 +0900 Subject: [PATCH 7/9] Move player-specific configuration bindables back to player --- osu.Game/Screens/Play/Player.cs | 16 ++++++++++++---- .../Screens/Play/ScreenWithBeatmapBackground.cs | 6 ------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 9b341fbfe5..d24ed53518 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -16,6 +17,7 @@ using osu.Framework.Screens; using osu.Framework.Threading; using osu.Framework.Timing; using osu.Game.Beatmaps; +using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Online.API; @@ -43,6 +45,9 @@ namespace osu.Game.Screens.Play public bool AllowLeadIn { get; set; } = true; public bool AllowResults { get; set; } = true; + private Bindable mouseWheelDisabled; + private Bindable userAudioOffset; + public int RestartCount; public CursorContainer Cursor => RulesetContainer.Cursor; @@ -75,11 +80,14 @@ namespace osu.Game.Screens.Play private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true; [BackgroundDependencyLoader] - private void load(AudioManager audio, APIAccess api) + private void load(AudioManager audio, APIAccess api, OsuConfigManager config) { this.api = api; sampleRestart = audio.Sample.Get(@"Gameplay/restart"); + mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); + userAudioOffset = config.GetBindable(OsuSetting.AudioOffset); + WorkingBeatmap working = Beatmap.Value; Beatmap beatmap; @@ -131,8 +139,8 @@ namespace osu.Game.Screens.Play // the final usable gameplay clock with user-set offsets applied. var offsetClock = new FramedOffsetClock(adjustableClock); - UserAudioOffset.ValueChanged += v => offsetClock.Offset = v; - UserAudioOffset.TriggerChange(); + userAudioOffset.ValueChanged += v => offsetClock.Offset = v; + userAudioOffset.TriggerChange(); scoreProcessor = RulesetContainer.CreateScoreProcessor(); @@ -342,7 +350,7 @@ namespace osu.Game.Screens.Play Background?.FadeTo(1f, fade_out_duration); } - protected override bool OnWheel(InputState state) => MouseWheelDisabled.Value && !pauseContainer.IsPaused; + protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !pauseContainer.IsPaused; private void initializeStoryboard(bool asyncLoad) { diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 9942bf4ef5..8e963a94a8 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -26,8 +26,6 @@ namespace osu.Game.Screens.Play protected Bindable DimLevel; protected Bindable BlurLevel; protected Bindable ShowStoryboard; - protected Bindable MouseWheelDisabled; - protected Bindable UserAudioOffset; #endregion @@ -37,10 +35,6 @@ namespace osu.Game.Screens.Play DimLevel = config.GetBindable(OsuSetting.DimLevel); BlurLevel = config.GetBindable(OsuSetting.BlurLevel); ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - - MouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); - - UserAudioOffset = config.GetBindable(OsuSetting.AudioOffset); } protected override void OnEntering(Screen last) From 2b0309b26d905a2c5a1448d6bdf4f74863374e15 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 9 Mar 2018 21:29:13 +0900 Subject: [PATCH 8/9] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 6372fb22c1..214035c3d4 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 6372fb22c1c85f600921a139849b8dedf71026d5 +Subproject commit 214035c3d4974a9507fef8670000cef8326f1f5e From 7cabc54f646094964bc8220e6d7cd094cf37cfaf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 10 Mar 2018 00:48:48 +0900 Subject: [PATCH 9/9] Fix major regression (framework revert) --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 214035c3d4..6915954abd 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 214035c3d4974a9507fef8670000cef8326f1f5e +Subproject commit 6915954abdba64e72f698aa58698b00159f3678d