2019-02-15 07:17:01 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2019-02-27 05:15:45 +00:00
using System.Linq ;
2019-02-21 06:24:26 +00:00
using System.Threading ;
2019-02-15 07:38:27 +00:00
using NUnit.Framework ;
2019-02-21 06:24:26 +00:00
using osu.Framework.Allocation ;
2019-05-31 05:40:53 +00:00
using osu.Framework.Audio ;
2019-02-22 11:44:02 +00:00
using osu.Framework.Bindables ;
2019-02-21 06:24:26 +00:00
using osu.Framework.Graphics ;
2019-07-10 03:36:58 +00:00
using osu.Framework.Graphics.Sprites ;
2019-02-28 07:18:46 +00:00
using osu.Framework.Input.Events ;
using osu.Framework.Input.States ;
2019-02-27 05:15:45 +00:00
using osu.Framework.Platform ;
2019-02-19 10:44:26 +00:00
using osu.Framework.Screens ;
using osu.Game.Beatmaps ;
2019-02-22 02:41:28 +00:00
using osu.Game.Configuration ;
2019-02-15 07:17:01 +00:00
using osu.Game.Graphics ;
2019-02-22 11:34:51 +00:00
using osu.Game.Graphics.Containers ;
2019-05-21 05:13:52 +00:00
using osu.Game.Graphics.Sprites ;
2019-02-27 05:15:45 +00:00
using osu.Game.Rulesets ;
using osu.Game.Rulesets.Osu.Mods ;
2019-02-18 09:58:34 +00:00
using osu.Game.Scoring ;
2019-02-15 07:17:01 +00:00
using osu.Game.Screens ;
using osu.Game.Screens.Backgrounds ;
using osu.Game.Screens.Play ;
2019-02-21 06:24:26 +00:00
using osu.Game.Screens.Play.PlayerSettings ;
2020-03-17 08:43:16 +00:00
using osu.Game.Screens.Ranking ;
2019-02-27 05:15:45 +00:00
using osu.Game.Screens.Select ;
2020-06-11 05:55:49 +00:00
using osu.Game.Tests.Beatmaps ;
2019-02-27 05:15:45 +00:00
using osu.Game.Tests.Resources ;
2019-02-18 10:53:55 +00:00
using osu.Game.Users ;
2019-02-28 05:40:31 +00:00
using osuTK ;
2019-02-18 10:53:55 +00:00
using osuTK.Graphics ;
2019-02-15 07:17:01 +00:00
2019-03-24 16:02:36 +00:00
namespace osu.Game.Tests.Visual.Background
2019-02-15 07:17:01 +00:00
{
2019-02-15 07:38:27 +00:00
[TestFixture]
2020-03-23 01:01:33 +00:00
public class TestSceneUserDimBackgrounds : OsuManualInputManagerTestScene
2019-02-15 07:17:01 +00:00
{
2019-02-19 10:44:26 +00:00
private DummySongSelect songSelect ;
2019-03-13 07:47:03 +00:00
private TestPlayerLoader playerLoader ;
2020-03-05 02:25:07 +00:00
private LoadBlockingTestPlayer player ;
2019-02-27 05:15:45 +00:00
private BeatmapManager manager ;
private RulesetStore rulesets ;
2019-02-21 06:24:26 +00:00
2019-02-27 05:15:45 +00:00
[BackgroundDependencyLoader]
2019-05-31 05:40:53 +00:00
private void load ( GameHost host , AudioManager audio )
2019-02-27 05:15:45 +00:00
{
2019-07-29 07:55:19 +00:00
Dependencies . Cache ( rulesets = new RulesetStore ( ContextFactory ) ) ;
2021-05-31 09:37:32 +00:00
Dependencies . Cache ( manager = new BeatmapManager ( LocalStorage , ContextFactory , rulesets , null , audio , Resources , host , Beatmap . Default ) ) ;
2019-02-27 08:02:04 +00:00
Dependencies . Cache ( new OsuConfigManager ( LocalStorage ) ) ;
2019-02-27 05:15:45 +00:00
2021-02-22 05:53:32 +00:00
manager . Import ( TestResources . GetQuickTestBeatmapForImport ( ) ) . Wait ( ) ;
2019-03-20 11:47:25 +00:00
2019-02-27 05:15:45 +00:00
Beatmap . SetDefault ( ) ;
}
[SetUp]
2019-03-20 11:47:25 +00:00
public virtual void SetUp ( ) = > Schedule ( ( ) = >
2019-02-27 08:02:04 +00:00
{
2020-01-31 10:10:44 +00:00
var stack = new OsuScreenStack { RelativeSizeAxes = Axes . Both } ;
Child = stack ;
stack . Push ( songSelect = new DummySongSelect ( ) ) ;
2019-03-20 11:47:25 +00:00
} ) ;
2019-02-27 05:15:45 +00:00
2021-04-14 20:22:38 +00:00
/// <summary>
/// User settings should always be ignored on song select screen.
/// </summary>
[Test]
public void TestUserSettingsIgnoredOnSongSelect ( )
{
setupUserSettings ( ) ;
2021-04-14 21:48:15 +00:00
AddUntilStep ( "Screen is undimmed" , ( ) = > songSelect . IsBackgroundUndimmed ( ) ) ;
AddUntilStep ( "Screen using background blur" , ( ) = > songSelect . IsBackgroundBlur ( ) ) ;
2021-04-14 20:22:38 +00:00
performFullSetup ( ) ;
AddStep ( "Exit to song select" , ( ) = > player . Exit ( ) ) ;
AddUntilStep ( "Screen is undimmed" , ( ) = > songSelect . IsBackgroundUndimmed ( ) ) ;
AddUntilStep ( "Screen using background blur" , ( ) = > songSelect . IsBackgroundBlur ( ) ) ;
}
2019-02-24 09:10:59 +00:00
/// <summary>
2019-03-13 07:47:03 +00:00
/// Check if <see cref="PlayerLoader"/> properly triggers the visual settings preview when a user hovers over the visual settings panel.
2019-02-24 09:10:59 +00:00
/// </summary>
[Test]
2020-05-26 02:30:36 +00:00
public void TestPlayerLoaderSettingsHover ( )
2019-02-24 09:10:59 +00:00
{
2019-02-28 09:26:41 +00:00
setupUserSettings ( ) ;
2020-03-05 02:25:07 +00:00
AddStep ( "Start player loader" , ( ) = > songSelect . Push ( playerLoader = new TestPlayerLoader ( player = new LoadBlockingTestPlayer { BlockLoad = true } ) ) ) ;
2019-03-19 08:24:26 +00:00
AddUntilStep ( "Wait for Player Loader to load" , ( ) = > playerLoader ? . IsLoaded ? ? false ) ;
2019-02-26 00:54:28 +00:00
AddAssert ( "Background retained from song select" , ( ) = > songSelect . IsBackgroundCurrent ( ) ) ;
2019-02-21 06:24:26 +00:00
AddStep ( "Trigger background preview" , ( ) = >
{
InputManager . MoveMouseTo ( playerLoader . ScreenPos ) ;
InputManager . MoveMouseTo ( playerLoader . VisualSettingsPos ) ;
} ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Screen is dimmed and blur applied" , ( ) = > songSelect . IsBackgroundDimmed ( ) & & songSelect . IsUserBlurApplied ( ) ) ;
2019-02-28 11:01:15 +00:00
AddStep ( "Stop background preview" , ( ) = > InputManager . MoveMouseTo ( playerLoader . ScreenPos ) ) ;
2021-01-04 09:32:23 +00:00
AddUntilStep ( "Screen is undimmed and user blur removed" , ( ) = > songSelect . IsBackgroundUndimmed ( ) & & songSelect . CheckBackgroundBlur ( playerLoader . ExpectedBackgroundBlur ) ) ;
2019-02-24 09:10:59 +00:00
}
2019-02-21 06:24:26 +00:00
2019-02-24 09:10:59 +00:00
/// <summary>
/// In the case of a user triggering the dim preview the instant player gets loaded, then moving the cursor off of the visual settings:
2019-03-13 07:47:03 +00:00
/// The OnHover of PlayerLoader will trigger, which could potentially cause visual settings to be unapplied unless checked for in PlayerLoader.
/// We need to check that in this scenario, the dim and blur is still properly applied after entering player.
2019-02-24 09:10:59 +00:00
/// </summary>
[Test]
2020-05-26 02:30:36 +00:00
public void TestPlayerLoaderTransition ( )
2019-02-24 09:10:59 +00:00
{
2019-02-28 11:01:15 +00:00
performFullSetup ( ) ;
2019-02-28 07:18:46 +00:00
AddStep ( "Trigger hover event" , ( ) = > playerLoader . TriggerOnHover ( ) ) ;
2019-02-26 00:54:28 +00:00
AddAssert ( "Background retained from song select" , ( ) = > songSelect . IsBackgroundCurrent ( ) ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Screen is dimmed and blur applied" , ( ) = > songSelect . IsBackgroundDimmed ( ) & & songSelect . IsUserBlurApplied ( ) ) ;
2019-02-24 09:10:59 +00:00
}
2019-02-22 02:41:28 +00:00
2019-02-24 09:10:59 +00:00
/// <summary>
/// Make sure the background is fully invisible (Alpha == 0) when the background should be disabled by the storyboard.
/// </summary>
[Test]
2020-05-26 02:30:36 +00:00
public void TestStoryboardBackgroundVisibility ( )
2019-02-24 09:10:59 +00:00
{
2019-02-28 09:26:41 +00:00
performFullSetup ( ) ;
2021-01-04 09:32:23 +00:00
AddAssert ( "Background retained from song select" , ( ) = > songSelect . IsBackgroundCurrent ( ) ) ;
2019-02-27 08:56:44 +00:00
createFakeStoryboard ( ) ;
2019-08-11 20:19:22 +00:00
AddStep ( "Enable Storyboard" , ( ) = >
2019-02-28 11:01:15 +00:00
{
player . ReplacesBackground . Value = true ;
player . StoryboardEnabled . Value = true ;
} ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Background is invisible, storyboard is visible" , ( ) = > songSelect . IsBackgroundInvisible ( ) & & player . IsStoryboardVisible ) ;
2019-08-11 20:19:22 +00:00
AddStep ( "Disable Storyboard" , ( ) = >
2019-02-22 02:41:28 +00:00
{
2019-02-27 08:56:44 +00:00
player . ReplacesBackground . Value = false ;
player . StoryboardEnabled . Value = false ;
2019-02-22 02:41:28 +00:00
} ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Background is visible, storyboard is invisible" , ( ) = > songSelect . IsBackgroundVisible ( ) & & ! player . IsStoryboardVisible ) ;
2019-02-18 09:58:34 +00:00
}
2019-02-25 03:35:01 +00:00
/// <summary>
/// When exiting player, the screen that it suspends/exits to needs to have a fully visible (Alpha == 1) background.
/// </summary>
[Test]
2020-05-26 02:30:36 +00:00
public void TestStoryboardTransition ( )
2019-02-25 03:35:01 +00:00
{
2019-02-28 09:26:41 +00:00
performFullSetup ( ) ;
2019-02-27 08:56:44 +00:00
createFakeStoryboard ( ) ;
2019-02-28 11:01:15 +00:00
AddStep ( "Exit to song select" , ( ) = > player . Exit ( ) ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Background is visible" , ( ) = > songSelect . IsBackgroundVisible ( ) ) ;
2019-02-25 03:35:01 +00:00
}
2019-02-18 10:53:55 +00:00
/// <summary>
2019-08-11 20:08:14 +00:00
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a background.
2019-02-18 10:53:55 +00:00
/// </summary>
[Test]
2020-05-26 02:30:36 +00:00
public void TestDisableUserDimBackground ( )
2019-02-18 10:53:55 +00:00
{
2019-02-28 09:26:41 +00:00
performFullSetup ( ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Screen is dimmed and blur applied" , ( ) = > songSelect . IsBackgroundDimmed ( ) & & songSelect . IsUserBlurApplied ( ) ) ;
2021-04-15 05:02:12 +00:00
AddStep ( "Disable user dim" , ( ) = > songSelect . IgnoreUserSettings . Value = true ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Screen is undimmed and user blur removed" , ( ) = > songSelect . IsBackgroundUndimmed ( ) & & songSelect . IsUserBlurDisabled ( ) ) ;
2021-04-15 05:02:12 +00:00
AddStep ( "Enable user dim" , ( ) = > songSelect . IgnoreUserSettings . Value = false ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Screen is dimmed and blur applied" , ( ) = > songSelect . IsBackgroundDimmed ( ) & & songSelect . IsUserBlurApplied ( ) ) ;
2019-02-15 07:17:01 +00:00
}
2019-08-08 12:59:29 +00:00
/// <summary>
2019-08-11 20:08:14 +00:00
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a storyboard.
2019-08-08 12:59:29 +00:00
/// </summary>
[Test]
2020-05-26 02:30:36 +00:00
public void TestDisableUserDimStoryboard ( )
2019-08-08 12:59:29 +00:00
{
performFullSetup ( ) ;
createFakeStoryboard ( ) ;
2019-08-11 20:19:22 +00:00
AddStep ( "Enable Storyboard" , ( ) = >
2019-08-08 12:59:29 +00:00
{
player . ReplacesBackground . Value = true ;
player . StoryboardEnabled . Value = true ;
} ) ;
2021-04-15 05:02:12 +00:00
AddStep ( "Enable user dim" , ( ) = > player . DimmableStoryboard . IgnoreUserSettings . Value = false ) ;
2019-08-08 12:59:29 +00:00
AddStep ( "Set dim level to 1" , ( ) = > songSelect . DimLevel . Value = 1f ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Storyboard is invisible" , ( ) = > ! player . IsStoryboardVisible ) ;
2021-04-15 05:02:12 +00:00
AddStep ( "Disable user dim" , ( ) = > player . DimmableStoryboard . IgnoreUserSettings . Value = true ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Storyboard is visible" , ( ) = > player . IsStoryboardVisible ) ;
2019-08-08 12:59:29 +00:00
}
2021-04-13 06:56:43 +00:00
[Test]
public void TestStoryboardIgnoreUserSettings ( )
{
performFullSetup ( ) ;
createFakeStoryboard ( ) ;
AddStep ( "Enable replacing background" , ( ) = > player . ReplacesBackground . Value = true ) ;
AddUntilStep ( "Storyboard is invisible" , ( ) = > ! player . IsStoryboardVisible ) ;
AddUntilStep ( "Background is visible" , ( ) = > songSelect . IsBackgroundVisible ( ) ) ;
AddStep ( "Ignore user settings" , ( ) = >
{
2021-04-15 05:02:12 +00:00
player . ApplyToBackground ( b = > b . IgnoreUserSettings . Value = true ) ;
player . DimmableStoryboard . IgnoreUserSettings . Value = true ;
2021-04-13 06:56:43 +00:00
} ) ;
AddUntilStep ( "Storyboard is visible" , ( ) = > player . IsStoryboardVisible ) ;
AddUntilStep ( "Background is invisible" , ( ) = > songSelect . IsBackgroundInvisible ( ) ) ;
AddStep ( "Disable background replacement" , ( ) = > player . ReplacesBackground . Value = false ) ;
AddUntilStep ( "Storyboard is visible" , ( ) = > player . IsStoryboardVisible ) ;
AddUntilStep ( "Background is visible" , ( ) = > songSelect . IsBackgroundVisible ( ) ) ;
}
2019-02-15 07:50:37 +00:00
/// <summary>
2019-03-13 07:47:03 +00:00
/// Check if the visual settings container retains dim and blur when pausing
2019-02-15 07:50:37 +00:00
/// </summary>
2019-02-15 07:38:27 +00:00
[Test]
2020-05-26 02:30:36 +00:00
public void TestPause ( )
2019-02-15 07:38:27 +00:00
{
2019-02-28 09:26:41 +00:00
performFullSetup ( true ) ;
2019-03-18 02:48:11 +00:00
AddStep ( "Pause" , ( ) = > player . Pause ( ) ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Screen is dimmed and blur applied" , ( ) = > songSelect . IsBackgroundDimmed ( ) & & songSelect . IsUserBlurApplied ( ) ) ;
2019-03-18 02:48:11 +00:00
AddStep ( "Unpause" , ( ) = > player . Resume ( ) ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Screen is dimmed and blur applied" , ( ) = > songSelect . IsBackgroundDimmed ( ) & & songSelect . IsUserBlurApplied ( ) ) ;
2019-02-18 10:53:55 +00:00
}
/// <summary>
2020-03-17 08:43:16 +00:00
/// Check if the visual settings container removes user dim when suspending <see cref="Player"/> for <see cref="ResultsScreen"/>
2019-02-18 10:53:55 +00:00
/// </summary>
[Test]
2020-05-26 02:30:36 +00:00
public void TestTransition ( )
2019-02-18 10:53:55 +00:00
{
2019-02-28 09:26:41 +00:00
performFullSetup ( ) ;
2020-06-11 05:55:49 +00:00
2019-11-29 06:51:00 +00:00
FadeAccessibleResults results = null ;
2020-06-11 05:55:49 +00:00
AddStep ( "Transition to Results" , ( ) = > player . Push ( results = new FadeAccessibleResults ( new ScoreInfo
{
User = new User { Username = "osu!" } ,
2021-10-04 08:35:53 +00:00
BeatmapInfo = new TestBeatmap ( Ruleset . Value ) . BeatmapInfo ,
2020-10-12 21:26:14 +00:00
Ruleset = Ruleset . Value ,
2020-06-11 05:55:49 +00:00
} ) ) ) ;
2019-11-29 06:51:00 +00:00
AddUntilStep ( "Wait for results is current" , ( ) = > results . IsCurrentScreen ( ) ) ;
2021-01-04 09:32:23 +00:00
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Screen is undimmed, original background retained" , ( ) = >
2021-01-04 09:32:23 +00:00
songSelect . IsBackgroundUndimmed ( ) & & songSelect . IsBackgroundCurrent ( ) & & songSelect . CheckBackgroundBlur ( results . ExpectedBackgroundBlur ) ) ;
2019-02-19 10:44:26 +00:00
}
2019-03-20 08:18:42 +00:00
/// <summary>
/// Check if hovering on the visual settings dialogue after resuming from player still previews the background dim.
/// </summary>
[Test]
2020-05-26 02:30:36 +00:00
public void TestResumeFromPlayer ( )
2019-03-20 08:18:42 +00:00
{
performFullSetup ( ) ;
AddStep ( "Move mouse to Visual Settings" , ( ) = > InputManager . MoveMouseTo ( playerLoader . VisualSettingsPos ) ) ;
2019-03-20 10:45:04 +00:00
AddStep ( "Resume PlayerLoader" , ( ) = > player . Restart ( ) ) ;
2020-05-26 02:29:56 +00:00
AddUntilStep ( "Screen is dimmed and blur applied" , ( ) = > songSelect . IsBackgroundDimmed ( ) & & songSelect . IsUserBlurApplied ( ) ) ;
2019-03-20 08:18:42 +00:00
AddStep ( "Move mouse to center of screen" , ( ) = > InputManager . MoveMouseTo ( playerLoader . ScreenPos ) ) ;
2021-01-04 09:32:23 +00:00
AddUntilStep ( "Screen is undimmed and user blur removed" , ( ) = > songSelect . IsBackgroundUndimmed ( ) & & songSelect . CheckBackgroundBlur ( playerLoader . ExpectedBackgroundBlur ) ) ;
2019-02-15 07:38:27 +00:00
}
2019-02-28 11:01:15 +00:00
private void createFakeStoryboard ( ) = > AddStep ( "Create storyboard" , ( ) = >
2019-02-27 08:56:44 +00:00
{
2019-02-28 11:01:15 +00:00
player . StoryboardEnabled . Value = false ;
player . ReplacesBackground . Value = false ;
2019-07-12 02:50:06 +00:00
player . DimmableStoryboard . Add ( new OsuSpriteText
2019-02-27 08:56:44 +00:00
{
2019-07-10 03:36:58 +00:00
Size = new Vector2 ( 500 , 50 ) ,
2019-02-27 08:56:44 +00:00
Alpha = 1 ,
2019-07-10 03:36:58 +00:00
Colour = Color4 . White ,
2019-02-28 05:33:29 +00:00
Anchor = Anchor . Centre ,
Origin = Anchor . Centre ,
Text = "THIS IS A STORYBOARD" ,
2019-07-10 03:36:58 +00:00
Font = new FontUsage ( size : 50 )
2019-02-27 08:56:44 +00:00
} ) ;
} ) ;
2019-02-28 09:26:41 +00:00
private void performFullSetup ( bool allowPause = false )
2019-02-26 00:56:22 +00:00
{
2019-02-28 09:26:41 +00:00
setupUserSettings ( ) ;
2019-02-26 00:56:22 +00:00
2020-03-05 02:25:07 +00:00
AddStep ( "Start player loader" , ( ) = > songSelect . Push ( playerLoader = new TestPlayerLoader ( player = new LoadBlockingTestPlayer ( allowPause ) ) ) ) ;
2019-03-28 02:18:54 +00:00
2019-03-19 08:24:26 +00:00
AddUntilStep ( "Wait for Player Loader to load" , ( ) = > playerLoader . IsLoaded ) ;
2019-02-27 05:15:45 +00:00
AddStep ( "Move mouse to center of screen" , ( ) = > InputManager . MoveMouseTo ( playerLoader . ScreenPos ) ) ;
2019-03-19 08:24:26 +00:00
AddUntilStep ( "Wait for player to load" , ( ) = > player . IsLoaded ) ;
2019-02-26 00:56:22 +00:00
}
2019-02-28 09:26:41 +00:00
private void setupUserSettings ( )
2019-02-26 00:56:22 +00:00
{
2020-03-20 06:02:13 +00:00
AddUntilStep ( "Song select is current" , ( ) = > songSelect . IsCurrentScreen ( ) ) ;
2021-10-02 03:44:22 +00:00
AddUntilStep ( "Song select has selection" , ( ) = > songSelect . Carousel ? . SelectedBeatmapInfo ! = null ) ;
2019-02-28 09:26:41 +00:00
AddStep ( "Set default user settings" , ( ) = >
2019-02-26 08:31:21 +00:00
{
2019-12-13 12:45:38 +00:00
SelectedMods . Value = SelectedMods . Value . Concat ( new [ ] { new OsuModNoFail ( ) } ) . ToArray ( ) ;
2019-02-27 08:02:04 +00:00
songSelect . DimLevel . Value = 0.7f ;
2019-03-13 07:47:03 +00:00
songSelect . BlurLevel . Value = 0.4f ;
2019-02-26 08:31:21 +00:00
} ) ;
2019-02-26 00:56:22 +00:00
}
2019-10-15 07:14:06 +00:00
protected override void Dispose ( bool isDisposing )
{
base . Dispose ( isDisposing ) ;
rulesets ? . Dispose ( ) ;
}
2019-02-27 05:15:45 +00:00
private class DummySongSelect : PlaySongSelect
2019-02-19 10:44:26 +00:00
{
2021-01-04 09:32:23 +00:00
private FadeAccessibleBackground background ;
2019-02-26 08:31:21 +00:00
protected override BackgroundScreen CreateBackground ( )
{
2021-01-04 09:32:23 +00:00
background = new FadeAccessibleBackground ( Beatmap . Value ) ;
2021-04-15 05:02:12 +00:00
IgnoreUserSettings . BindTo ( background . IgnoreUserSettings ) ;
2019-02-26 08:31:21 +00:00
return background ;
}
2021-04-15 05:02:12 +00:00
public readonly Bindable < bool > IgnoreUserSettings = new Bindable < bool > ( ) ;
2020-02-01 21:50:29 +00:00
public readonly Bindable < double > DimLevel = new BindableDouble ( ) ;
public readonly Bindable < double > BlurLevel = new BindableDouble ( ) ;
2019-02-24 09:10:59 +00:00
2019-02-27 05:15:45 +00:00
public new BeatmapCarousel Carousel = > base . Carousel ;
2019-02-24 09:10:59 +00:00
[BackgroundDependencyLoader]
private void load ( OsuConfigManager config )
{
2019-02-27 08:02:04 +00:00
config . BindWith ( OsuSetting . DimLevel , DimLevel ) ;
2019-02-28 07:18:46 +00:00
config . BindWith ( OsuSetting . BlurLevel , BlurLevel ) ;
2019-02-22 07:56:03 +00:00
}
2019-02-21 06:24:26 +00:00
2021-01-04 09:32:23 +00:00
public bool IsBackgroundDimmed ( ) = > background . CurrentColour = = OsuColour . Gray ( 1f - background . CurrentDim ) ;
2019-02-21 06:24:26 +00:00
2021-01-04 09:32:23 +00:00
public bool IsBackgroundUndimmed ( ) = > background . CurrentColour = = Color4 . White ;
2019-02-22 02:41:28 +00:00
2021-01-04 09:32:23 +00:00
public bool IsUserBlurApplied ( ) = > background . CurrentBlur = = new Vector2 ( ( float ) BlurLevel . Value * BackgroundScreenBeatmap . USER_BLUR_FACTOR ) ;
2019-03-13 07:47:03 +00:00
2021-01-04 09:32:23 +00:00
public bool IsUserBlurDisabled ( ) = > background . CurrentBlur = = new Vector2 ( 0 ) ;
2019-03-13 07:47:03 +00:00
2021-01-04 09:32:23 +00:00
public bool IsBackgroundInvisible ( ) = > background . CurrentAlpha = = 0 ;
2019-02-22 02:41:28 +00:00
2021-01-04 09:32:23 +00:00
public bool IsBackgroundVisible ( ) = > background . CurrentAlpha = = 1 ;
2019-02-22 05:43:05 +00:00
2021-04-14 20:22:38 +00:00
public bool IsBackgroundBlur ( ) = > background . CurrentBlur = = new Vector2 ( BACKGROUND_BLUR ) ;
2021-01-04 09:32:23 +00:00
public bool CheckBackgroundBlur ( Vector2 expected ) = > background . CurrentBlur = = expected ;
2019-03-14 07:09:17 +00:00
2019-02-22 05:43:05 +00:00
/// <summary>
/// Make sure every time a screen gets pushed, the background doesn't get replaced
/// </summary>
2019-02-24 11:03:24 +00:00
/// <returns>Whether or not the original background (The one created in DummySongSelect) is still the current background</returns>
2021-01-04 09:32:23 +00:00
public bool IsBackgroundCurrent ( ) = > background ? . IsCurrentScreen ( ) = = true ;
2019-02-19 10:44:26 +00:00
}
2019-02-15 07:17:01 +00:00
2020-03-17 08:43:16 +00:00
private class FadeAccessibleResults : ResultsScreen
2019-02-18 10:53:55 +00:00
{
2019-02-28 11:01:15 +00:00
public FadeAccessibleResults ( ScoreInfo score )
2020-11-21 13:38:38 +00:00
: base ( score , true )
2019-02-18 10:53:55 +00:00
{
}
2021-01-05 07:00:25 +00:00
protected override BackgroundScreen CreateBackground ( ) = > new FadeAccessibleBackground ( Beatmap . Value ) ;
2019-03-14 07:09:17 +00:00
2021-01-04 09:32:23 +00:00
public Vector2 ExpectedBackgroundBlur = > new Vector2 ( BACKGROUND_BLUR ) ;
2019-02-18 10:53:55 +00:00
}
2020-03-05 02:25:07 +00:00
private class LoadBlockingTestPlayer : TestPlayer
2019-02-15 07:17:01 +00:00
{
2021-01-04 09:32:23 +00:00
protected override BackgroundScreen CreateBackground ( ) = >
new FadeAccessibleBackground ( Beatmap . Value ) ;
public override void OnEntering ( IScreen last )
{
base . OnEntering ( last ) ;
ApplyToBackground ( b = > ReplacesBackground . BindTo ( b . StoryboardReplacesBackground ) ) ;
}
2019-02-15 07:17:01 +00:00
2019-07-12 03:04:45 +00:00
public new DimmableStoryboard DimmableStoryboard = > base . DimmableStoryboard ;
2019-02-28 07:51:17 +00:00
2019-02-24 09:10:59 +00:00
// Whether or not the player should be allowed to load.
2019-03-27 08:34:58 +00:00
public bool BlockLoad ;
2019-02-21 06:24:26 +00:00
2019-02-22 02:41:28 +00:00
public Bindable < bool > StoryboardEnabled ;
public readonly Bindable < bool > ReplacesBackground = new Bindable < bool > ( ) ;
2019-02-24 09:10:59 +00:00
public readonly Bindable < bool > IsPaused = new Bindable < bool > ( ) ;
2019-02-22 05:43:05 +00:00
2020-03-05 02:25:07 +00:00
public LoadBlockingTestPlayer ( bool allowPause = true )
2019-03-26 07:53:44 +00:00
: base ( allowPause )
{
}
2019-07-12 03:04:45 +00:00
public bool IsStoryboardVisible = > DimmableStoryboard . ContentDisplayed ;
2019-02-27 08:56:44 +00:00
2019-02-21 06:24:26 +00:00
[BackgroundDependencyLoader]
2019-03-27 05:33:50 +00:00
private void load ( OsuConfigManager config , CancellationToken token )
2019-02-15 07:17:01 +00:00
{
2019-03-27 08:34:58 +00:00
while ( BlockLoad & & ! token . IsCancellationRequested )
2019-02-21 06:24:26 +00:00
Thread . Sleep ( 1 ) ;
2019-03-27 05:33:50 +00:00
2019-02-22 02:41:28 +00:00
StoryboardEnabled = config . GetBindable < bool > ( OsuSetting . ShowStoryboard ) ;
2019-03-19 14:44:15 +00:00
DrawableRuleset . IsPaused . BindTo ( IsPaused ) ;
2019-02-15 07:17:01 +00:00
}
2019-02-21 06:24:26 +00:00
}
2019-02-15 07:17:01 +00:00
2019-03-13 07:47:03 +00:00
private class TestPlayerLoader : PlayerLoader
2019-02-21 06:24:26 +00:00
{
2021-01-04 09:32:23 +00:00
private FadeAccessibleBackground background ;
2019-02-21 06:24:26 +00:00
public VisualSettings VisualSettingsPos = > VisualSettings ;
2021-01-04 09:32:23 +00:00
public BackgroundScreen ScreenPos = > background ;
2019-02-21 06:24:26 +00:00
2019-03-13 07:47:03 +00:00
public TestPlayerLoader ( Player player )
2019-02-26 00:56:22 +00:00
: base ( ( ) = > player )
2019-02-15 07:38:27 +00:00
{
}
2019-02-21 09:19:50 +00:00
2019-02-28 11:01:15 +00:00
public void TriggerOnHover ( ) = > OnHover ( new HoverEvent ( new InputState ( ) ) ) ;
2019-02-28 07:18:46 +00:00
2021-01-04 09:32:23 +00:00
public Vector2 ExpectedBackgroundBlur = > new Vector2 ( BACKGROUND_BLUR ) ;
2019-03-14 07:09:17 +00:00
2021-01-04 09:32:23 +00:00
protected override BackgroundScreen CreateBackground ( ) = > background = new FadeAccessibleBackground ( Beatmap . Value ) ;
2019-02-18 10:53:55 +00:00
}
private class FadeAccessibleBackground : BackgroundScreenBeatmap
{
2019-07-12 02:50:06 +00:00
protected override DimmableBackground CreateFadeContainer ( ) = > dimmable = new TestDimmableBackground { RelativeSizeAxes = Axes . Both } ;
2019-02-22 09:01:50 +00:00
2019-07-12 02:50:06 +00:00
public Color4 CurrentColour = > dimmable . CurrentColour ;
2019-03-13 07:47:03 +00:00
2019-07-12 02:50:06 +00:00
public float CurrentAlpha = > dimmable . CurrentAlpha ;
2019-02-22 11:34:51 +00:00
2019-12-10 12:25:03 +00:00
public float CurrentDim = > dimmable . DimLevel ;
2019-02-28 07:18:46 +00:00
public Vector2 CurrentBlur = > Background . BlurSigma ;
2019-07-12 02:50:06 +00:00
private TestDimmableBackground dimmable ;
2019-02-28 11:01:15 +00:00
2019-02-27 05:15:45 +00:00
public FadeAccessibleBackground ( WorkingBeatmap beatmap )
: base ( beatmap )
{
}
2019-02-27 08:56:44 +00:00
}
2019-02-27 05:15:45 +00:00
2019-07-12 02:50:06 +00:00
private class TestDimmableBackground : BackgroundScreenBeatmap . DimmableBackground
2019-07-09 07:23:59 +00:00
{
2019-07-12 02:38:15 +00:00
public Color4 CurrentColour = > Content . Colour ;
public float CurrentAlpha = > Content . Alpha ;
2019-12-10 12:25:03 +00:00
public new float DimLevel = > base . DimLevel ;
2019-07-09 07:23:59 +00:00
}
2019-02-15 07:17:01 +00:00
}
}