mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 21:32:57 +08:00
Merge pull request #2045 from UselessToucan/PlayerBase
Allow previewing background adjustments at player loading screen
This commit is contained in:
commit
c11f6efab5
@ -25,32 +25,29 @@ using osu.Game.Rulesets;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens.Backgrounds;
|
|
||||||
using osu.Game.Screens.Play.BreaksOverlay;
|
using osu.Game.Screens.Play.BreaksOverlay;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Storyboards.Drawables;
|
using osu.Game.Storyboards.Drawables;
|
||||||
using OpenTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public class Player : OsuScreen, IProvideCursor
|
public class Player : ScreenWithBeatmapBackground, IProvideCursor
|
||||||
{
|
{
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
|
||||||
|
|
||||||
protected override float BackgroundParallaxAmount => 0.1f;
|
protected override float BackgroundParallaxAmount => 0.1f;
|
||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => false;
|
public override bool ShowOverlaysOnEnter => false;
|
||||||
|
|
||||||
public Action RestartRequested;
|
public Action RestartRequested;
|
||||||
|
|
||||||
public override bool AllowBeatmapRulesetChange => false;
|
|
||||||
|
|
||||||
public bool HasFailed { get; private set; }
|
public bool HasFailed { get; private set; }
|
||||||
|
|
||||||
public bool AllowPause { get; set; } = true;
|
public bool AllowPause { get; set; } = true;
|
||||||
public bool AllowLeadIn { get; set; } = true;
|
public bool AllowLeadIn { get; set; } = true;
|
||||||
public bool AllowResults { get; set; } = true;
|
public bool AllowResults { get; set; } = true;
|
||||||
|
|
||||||
|
private Bindable<bool> mouseWheelDisabled;
|
||||||
|
private Bindable<double> userAudioOffset;
|
||||||
|
|
||||||
public int RestartCount;
|
public int RestartCount;
|
||||||
|
|
||||||
public CursorContainer Cursor => RulesetContainer.Cursor;
|
public CursorContainer Cursor => RulesetContainer.Cursor;
|
||||||
@ -69,41 +66,27 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private APIAccess api;
|
private APIAccess api;
|
||||||
|
|
||||||
private ScoreProcessor scoreProcessor;
|
|
||||||
protected RulesetContainer RulesetContainer;
|
|
||||||
|
|
||||||
#region User Settings
|
|
||||||
|
|
||||||
private Bindable<double> dimLevel;
|
|
||||||
private Bindable<double> blurLevel;
|
|
||||||
private Bindable<bool> showStoryboard;
|
|
||||||
private Bindable<bool> mouseWheelDisabled;
|
|
||||||
private Bindable<double> userAudioOffset;
|
|
||||||
|
|
||||||
private SampleChannel sampleRestart;
|
private SampleChannel sampleRestart;
|
||||||
|
|
||||||
#endregion
|
private ScoreProcessor scoreProcessor;
|
||||||
|
protected RulesetContainer RulesetContainer;
|
||||||
private Container storyboardContainer;
|
|
||||||
private DrawableStoryboard storyboard;
|
|
||||||
|
|
||||||
private HUDOverlay hudOverlay;
|
private HUDOverlay hudOverlay;
|
||||||
private FailOverlay failOverlay;
|
private FailOverlay failOverlay;
|
||||||
|
|
||||||
|
private DrawableStoryboard storyboard;
|
||||||
|
private Container storyboardContainer;
|
||||||
|
|
||||||
private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true;
|
private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, OsuConfigManager config, APIAccess api)
|
private void load(AudioManager audio, APIAccess api, OsuConfigManager config)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
sampleRestart = audio.Sample.Get(@"Gameplay/restart");
|
||||||
dimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
|
||||||
blurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
|
|
||||||
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
|
||||||
|
|
||||||
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
||||||
|
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
|
||||||
sampleRestart = audio.Sample.Get(@"Gameplay/restart");
|
|
||||||
|
|
||||||
WorkingBeatmap working = Beatmap.Value;
|
WorkingBeatmap working = Beatmap.Value;
|
||||||
Beatmap beatmap;
|
Beatmap beatmap;
|
||||||
@ -156,7 +139,6 @@ namespace osu.Game.Screens.Play
|
|||||||
// the final usable gameplay clock with user-set offsets applied.
|
// the final usable gameplay clock with user-set offsets applied.
|
||||||
var offsetClock = new FramedOffsetClock(adjustableClock);
|
var offsetClock = new FramedOffsetClock(adjustableClock);
|
||||||
|
|
||||||
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
|
|
||||||
userAudioOffset.ValueChanged += v => offsetClock.Offset = v;
|
userAudioOffset.ValueChanged += v => offsetClock.Offset = v;
|
||||||
userAudioOffset.TriggerChange();
|
userAudioOffset.TriggerChange();
|
||||||
|
|
||||||
@ -225,7 +207,7 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (showStoryboard)
|
if (ShowStoryboard)
|
||||||
initializeStoryboard(false);
|
initializeStoryboard(false);
|
||||||
|
|
||||||
// Bind ScoreProcessor to ourselves
|
// Bind ScoreProcessor to ourselves
|
||||||
@ -245,19 +227,6 @@ namespace osu.Game.Screens.Play
|
|||||||
mod.ApplyToClock(sourceClock);
|
mod.ApplyToClock(sourceClock);
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
public void Restart()
|
||||||
{
|
{
|
||||||
sampleRestart?.Play();
|
sampleRestart?.Play();
|
||||||
@ -316,11 +285,6 @@ namespace osu.Game.Screens.Play
|
|||||||
if (!loadedSuccessfully)
|
if (!loadedSuccessfully)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dimLevel.ValueChanged += _ => updateBackgroundElements();
|
|
||||||
blurLevel.ValueChanged += _ => updateBackgroundElements();
|
|
||||||
showStoryboard.ValueChanged += _ => updateBackgroundElements();
|
|
||||||
updateBackgroundElements();
|
|
||||||
|
|
||||||
Content.Alpha = 0;
|
Content.Alpha = 0;
|
||||||
Content
|
Content
|
||||||
.ScaleTo(0.7f)
|
.ScaleTo(0.7f)
|
||||||
@ -374,28 +338,6 @@ namespace osu.Game.Screens.Play
|
|||||||
return true;
|
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(beatmap.Background != null && (!storyboardVisible || !beatmap.Storyboard.ReplacesBackground) ? opacity : 0, duration, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fadeOut()
|
private void fadeOut()
|
||||||
{
|
{
|
||||||
const float fade_out_duration = 250;
|
const float fade_out_duration = 250;
|
||||||
@ -409,5 +351,41 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
{
|
||||||
|
if (storyboardContainer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var beatmap = Beatmap.Value;
|
||||||
|
|
||||||
|
storyboard = beatmap.Storyboard.CreateDrawable();
|
||||||
|
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(BackgroundOpacity), BACKGROUND_FADE_DURATION, Easing.OutQuint)
|
||||||
|
.FadeTo(storyboardVisible && BackgroundOpacity > 0 ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||||
|
|
||||||
|
if (storyboardVisible && beatmap.Storyboard.ReplacesBackground)
|
||||||
|
Background?.FadeTo(0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ using osu.Framework.Screens;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Screens.Backgrounds;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
@ -17,7 +16,7 @@ using osu.Game.Screens.Play.PlayerSettings;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public class PlayerLoader : OsuScreen
|
public class PlayerLoader : ScreenWithBeatmapBackground
|
||||||
{
|
{
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
@ -27,10 +26,6 @@ namespace osu.Game.Screens.Play
|
|||||||
private bool showOverlays = true;
|
private bool showOverlays = true;
|
||||||
public override bool ShowOverlaysOnEnter => showOverlays;
|
public override bool ShowOverlaysOnEnter => showOverlays;
|
||||||
|
|
||||||
public override bool AllowBeatmapRulesetChange => false;
|
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
|
||||||
|
|
||||||
public PlayerLoader(Player player)
|
public PlayerLoader(Player player)
|
||||||
{
|
{
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@ -93,8 +88,6 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
|
|
||||||
Background.FadeTo(0.4f, 250);
|
|
||||||
|
|
||||||
Content.ScaleTo(0.7f);
|
Content.ScaleTo(0.7f);
|
||||||
|
|
||||||
contentIn();
|
contentIn();
|
||||||
|
57
osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs
Normal file
57
osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// 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.Framework.Screens;
|
||||||
|
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 const float BACKGROUND_FADE_DURATION = 800;
|
||||||
|
|
||||||
|
protected float BackgroundOpacity => 1 - (float)DimLevel;
|
||||||
|
|
||||||
|
#region User Settings
|
||||||
|
|
||||||
|
protected Bindable<double> DimLevel;
|
||||||
|
protected Bindable<double> BlurLevel;
|
||||||
|
protected Bindable<bool> ShowStoryboard;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
DimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||||
|
BlurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
|
||||||
|
ShowStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnEntering(Screen last)
|
||||||
|
{
|
||||||
|
base.OnEntering(last);
|
||||||
|
DimLevel.ValueChanged += _ => UpdateBackgroundElements();
|
||||||
|
BlurLevel.ValueChanged += _ => UpdateBackgroundElements();
|
||||||
|
ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements();
|
||||||
|
UpdateBackgroundElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void UpdateBackgroundElements()
|
||||||
|
{
|
||||||
|
if (!IsCurrentScreen) return;
|
||||||
|
|
||||||
|
Background?.FadeTo(BackgroundOpacity, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||||
|
(Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)BlurLevel.Value * 25), BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -378,10 +378,11 @@
|
|||||||
<Compile Include="Rulesets\Replays\ReplayFrame.cs" />
|
<Compile Include="Rulesets\Replays\ReplayFrame.cs" />
|
||||||
<Compile Include="Rulesets\Replays\Types\IConvertibleReplayFrame.cs" />
|
<Compile Include="Rulesets\Replays\Types\IConvertibleReplayFrame.cs" />
|
||||||
<Compile Include="Rulesets\Scoring\Legacy\LegacyScoreParser.cs" />
|
<Compile Include="Rulesets\Scoring\Legacy\LegacyScoreParser.cs" />
|
||||||
<Compile Include="Rulesets\UI\ScalableContainer.cs" />
|
<Compile Include="Screens\Play\ScreenWithBeatmapBackground.cs" />
|
||||||
<Compile Include="Screens\Play\PlayerSettings\VisualSettings.cs" />
|
<Compile Include="Screens\Play\PlayerSettings\VisualSettings.cs" />
|
||||||
<Compile Include="Rulesets\Objects\CatmullApproximator.cs" />
|
<Compile Include="Rulesets\Objects\CatmullApproximator.cs" />
|
||||||
<Compile Include="Rulesets\UI\HitObjectContainer.cs" />
|
<Compile Include="Rulesets\UI\HitObjectContainer.cs" />
|
||||||
|
<Compile Include="Rulesets\UI\ScalableContainer.cs" />
|
||||||
<Compile Include="Rulesets\UI\Scrolling\Visualisers\SequentialSpeedChangeVisualiser.cs" />
|
<Compile Include="Rulesets\UI\Scrolling\Visualisers\SequentialSpeedChangeVisualiser.cs" />
|
||||||
<Compile Include="Rulesets\UI\Scrolling\Visualisers\ISpeedChangeVisualiser.cs" />
|
<Compile Include="Rulesets\UI\Scrolling\Visualisers\ISpeedChangeVisualiser.cs" />
|
||||||
<Compile Include="Rulesets\UI\Scrolling\Visualisers\OverlappingSpeedChangeVisualiser.cs" />
|
<Compile Include="Rulesets\UI\Scrolling\Visualisers\OverlappingSpeedChangeVisualiser.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user