2019-02-15 15:17:01 +08: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-22 13:43:05 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2019-02-27 13:15:45 +08:00
|
|
|
using System.Linq;
|
2019-02-21 14:24:26 +08:00
|
|
|
using System.Threading;
|
2019-02-15 15:38:27 +08:00
|
|
|
using NUnit.Framework;
|
2019-02-21 14:24:26 +08:00
|
|
|
using osu.Framework.Allocation;
|
2019-02-22 19:44:02 +08:00
|
|
|
using osu.Framework.Bindables;
|
2019-02-21 14:24:26 +08:00
|
|
|
using osu.Framework.Graphics;
|
2019-02-26 16:31:21 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-02-28 13:33:29 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2019-02-27 13:15:45 +08:00
|
|
|
using osu.Framework.Platform;
|
2019-02-19 18:44:26 +08:00
|
|
|
using osu.Framework.Screens;
|
|
|
|
using osu.Game.Beatmaps;
|
2019-02-22 10:41:28 +08:00
|
|
|
using osu.Game.Configuration;
|
2019-02-27 13:15:45 +08:00
|
|
|
using osu.Game.Database;
|
2019-02-15 15:17:01 +08:00
|
|
|
using osu.Game.Graphics;
|
2019-02-22 19:34:51 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2019-02-27 13:15:45 +08:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2019-02-18 17:58:34 +08:00
|
|
|
using osu.Game.Scoring;
|
2019-02-15 15:17:01 +08:00
|
|
|
using osu.Game.Screens;
|
|
|
|
using osu.Game.Screens.Backgrounds;
|
|
|
|
using osu.Game.Screens.Play;
|
2019-02-21 14:24:26 +08:00
|
|
|
using osu.Game.Screens.Play.PlayerSettings;
|
2019-02-27 13:15:45 +08:00
|
|
|
using osu.Game.Screens.Select;
|
|
|
|
using osu.Game.Tests.Resources;
|
2019-02-18 18:53:55 +08:00
|
|
|
using osu.Game.Users;
|
|
|
|
using osuTK.Graphics;
|
2019-02-15 15:17:01 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
{
|
2019-02-15 15:38:27 +08:00
|
|
|
[TestFixture]
|
2019-02-21 14:24:26 +08:00
|
|
|
public class TestCaseBackgroundScreenBeatmap : ManualInputManagerTestCase
|
2019-02-15 15:17:01 +08:00
|
|
|
{
|
2019-02-22 13:43:05 +08:00
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
{
|
|
|
|
typeof(ScreenWithBeatmapBackground),
|
|
|
|
typeof(PlayerLoader),
|
2019-02-22 19:34:51 +08:00
|
|
|
typeof(Player),
|
2019-02-26 16:31:21 +08:00
|
|
|
typeof(UserDimContainer),
|
|
|
|
typeof(OsuScreen)
|
2019-02-22 13:43:05 +08:00
|
|
|
};
|
|
|
|
|
2019-02-19 18:44:26 +08:00
|
|
|
private DummySongSelect songSelect;
|
2019-02-21 14:24:26 +08:00
|
|
|
private DimAccessiblePlayerLoader playerLoader;
|
|
|
|
private DimAccessiblePlayer player;
|
2019-02-27 13:15:45 +08:00
|
|
|
private DatabaseContextFactory factory;
|
|
|
|
private BeatmapManager manager;
|
|
|
|
private RulesetStore rulesets;
|
2019-02-21 14:24:26 +08:00
|
|
|
|
2019-02-26 16:31:21 +08:00
|
|
|
private ScreenStackCacheContainer screenStackContainer;
|
2019-02-21 14:24:26 +08:00
|
|
|
|
2019-02-27 13:15:45 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(GameHost host)
|
|
|
|
{
|
|
|
|
factory = new DatabaseContextFactory(LocalStorage);
|
|
|
|
factory.ResetDatabase();
|
|
|
|
|
|
|
|
using (var usage = factory.Get())
|
|
|
|
usage.Migrate();
|
|
|
|
|
|
|
|
factory.ResetDatabase();
|
|
|
|
|
|
|
|
using (var usage = factory.Get())
|
|
|
|
usage.Migrate();
|
|
|
|
|
|
|
|
Dependencies.Cache(rulesets = new RulesetStore(factory));
|
|
|
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, Beatmap.Default));
|
2019-02-27 16:02:04 +08:00
|
|
|
Dependencies.Cache(new OsuConfigManager(LocalStorage));
|
2019-02-27 13:15:45 +08:00
|
|
|
|
|
|
|
Beatmap.SetDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
[SetUp]
|
2019-02-27 16:02:04 +08:00
|
|
|
public virtual void SetUp()
|
|
|
|
{
|
|
|
|
Schedule(() =>
|
|
|
|
{
|
|
|
|
manager.Delete(manager.GetAllUsableBeatmapSets());
|
|
|
|
var temp = TestResources.GetTestBeatmapForImport();
|
|
|
|
manager.Import(temp);
|
|
|
|
});
|
|
|
|
}
|
2019-02-27 13:15:45 +08:00
|
|
|
|
2019-02-24 17:10:59 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Check if PlayerLoader properly triggers background dim previews when a user hovers over the visual settings panel.
|
|
|
|
/// </summary>
|
|
|
|
[Test]
|
|
|
|
public void PlayerLoaderSettingsHoverTest()
|
|
|
|
{
|
|
|
|
createSongSelect();
|
2019-02-21 14:24:26 +08:00
|
|
|
AddStep("Start player loader", () => songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer())));
|
|
|
|
AddUntilStep(() => playerLoader?.IsLoaded ?? false, "Wait for Player Loader to load");
|
2019-02-26 08:54:28 +08:00
|
|
|
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
2019-02-21 14:24:26 +08:00
|
|
|
AddStep("Trigger background preview", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(playerLoader.ScreenPos);
|
|
|
|
InputManager.MoveMouseTo(playerLoader.VisualSettingsPos);
|
|
|
|
});
|
|
|
|
|
2019-02-26 09:11:36 +08:00
|
|
|
waitForDim();
|
2019-02-26 08:54:28 +08:00
|
|
|
AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed());
|
2019-02-24 17:10:59 +08:00
|
|
|
}
|
2019-02-21 14:24:26 +08:00
|
|
|
|
2019-02-24 17:10:59 +08: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:
|
|
|
|
/// The OnHover of PlayerLoader will trigger, which could potentially trigger an undim unless checked for in PlayerLoader.
|
|
|
|
/// We need to check that in this scenario, the dim is still properly applied after entering player.
|
|
|
|
/// </summary>
|
|
|
|
[Test]
|
|
|
|
public void PlayerLoaderTransitionTest()
|
|
|
|
{
|
|
|
|
createSongSelect();
|
2019-02-26 16:31:21 +08:00
|
|
|
AddStep("Start player loader", () => { songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer())); });
|
2019-02-24 17:10:59 +08:00
|
|
|
AddUntilStep(() => playerLoader?.IsLoaded ?? false, "Wait for Player Loader to load");
|
2019-02-21 14:24:26 +08:00
|
|
|
AddStep("Allow beatmap to load", () =>
|
2019-02-19 18:44:26 +08:00
|
|
|
{
|
2019-02-21 14:24:26 +08:00
|
|
|
player.Ready = true;
|
|
|
|
InputManager.MoveMouseTo(playerLoader.ScreenPos);
|
2019-02-19 18:44:26 +08:00
|
|
|
});
|
2019-02-21 14:24:26 +08:00
|
|
|
AddUntilStep(() => player?.IsLoaded ?? false, "Wait for player to load");
|
2019-02-26 08:54:28 +08:00
|
|
|
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
2019-02-22 10:41:28 +08:00
|
|
|
AddStep("Trigger background preview when loaded", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(playerLoader.VisualSettingsPos);
|
|
|
|
InputManager.MoveMouseTo(playerLoader.ScreenPos);
|
|
|
|
});
|
2019-02-26 09:11:36 +08:00
|
|
|
waitForDim();
|
2019-02-26 08:54:28 +08:00
|
|
|
AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed());
|
2019-02-24 17:10:59 +08:00
|
|
|
}
|
2019-02-22 10:41:28 +08:00
|
|
|
|
2019-02-24 17:10:59 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Make sure the background is fully invisible (Alpha == 0) when the background should be disabled by the storyboard.
|
|
|
|
/// </summary>
|
|
|
|
[Test]
|
|
|
|
public void StoryboardBackgroundVisibilityTest()
|
|
|
|
{
|
|
|
|
performSetup();
|
2019-02-27 16:56:44 +08:00
|
|
|
createFakeStoryboard();
|
|
|
|
waitForDim();
|
|
|
|
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible());
|
|
|
|
AddStep("Disable storyboard", () =>
|
2019-02-22 10:41:28 +08:00
|
|
|
{
|
2019-02-27 16:56:44 +08:00
|
|
|
player.ReplacesBackground.Value = false;
|
|
|
|
player.StoryboardEnabled.Value = false;
|
2019-02-22 10:41:28 +08:00
|
|
|
});
|
2019-02-26 09:11:36 +08:00
|
|
|
waitForDim();
|
2019-02-27 16:56:44 +08:00
|
|
|
AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && player.IsStoryboardInvisible());
|
2019-02-18 17:58:34 +08:00
|
|
|
}
|
|
|
|
|
2019-02-25 11:35:01 +08:00
|
|
|
/// <summary>
|
|
|
|
/// When exiting player, the screen that it suspends/exits to needs to have a fully visible (Alpha == 1) background.
|
|
|
|
/// </summary>
|
|
|
|
[Test]
|
|
|
|
public void StoryboardTransitionTest()
|
|
|
|
{
|
|
|
|
performSetup();
|
2019-02-27 16:56:44 +08:00
|
|
|
createFakeStoryboard();
|
2019-02-25 11:35:01 +08:00
|
|
|
AddUntilStep(() =>
|
|
|
|
{
|
2019-02-26 16:31:21 +08:00
|
|
|
if (songSelect.IsCurrentScreen()) return true;
|
|
|
|
songSelect.MakeCurrent();
|
|
|
|
return false;
|
2019-02-25 11:35:01 +08:00
|
|
|
}, "Wait for song select is current");
|
2019-02-26 09:11:36 +08:00
|
|
|
waitForDim();
|
2019-02-26 08:54:28 +08:00
|
|
|
AddAssert("Background is visible", () => songSelect.IsBackgroundVisible());
|
2019-02-25 11:35:01 +08:00
|
|
|
}
|
|
|
|
|
2019-02-18 18:53:55 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Check if the fade container is properly being reset when screen dim is disabled.
|
|
|
|
/// </summary>
|
|
|
|
[Test]
|
|
|
|
public void DisableUserDimTest()
|
|
|
|
{
|
2019-02-22 15:56:03 +08:00
|
|
|
performSetup();
|
|
|
|
AddStep("Test User Undimming", () => songSelect.DimEnabled.Value = false);
|
2019-02-26 09:11:36 +08:00
|
|
|
waitForDim();
|
2019-02-26 08:54:28 +08:00
|
|
|
AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed());
|
2019-02-18 18:53:55 +08:00
|
|
|
}
|
|
|
|
|
2019-02-15 15:50:37 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Check if the fade container is properly being faded when screen dim is enabled.
|
|
|
|
/// </summary>
|
2019-02-15 15:17:01 +08:00
|
|
|
[Test]
|
|
|
|
public void EnableUserDimTest()
|
|
|
|
{
|
2019-02-22 15:56:03 +08:00
|
|
|
performSetup();
|
|
|
|
AddStep("Test User Dimming", () => songSelect.DimEnabled.Value = true);
|
2019-02-26 09:11:36 +08:00
|
|
|
waitForDim();
|
2019-02-26 08:54:28 +08:00
|
|
|
AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed());
|
2019-02-15 15:17:01 +08:00
|
|
|
}
|
|
|
|
|
2019-02-15 15:50:37 +08:00
|
|
|
/// <summary>
|
2019-02-18 18:53:55 +08:00
|
|
|
/// Check if the fade container retains dim when pausing
|
2019-02-15 15:50:37 +08:00
|
|
|
/// </summary>
|
2019-02-15 15:38:27 +08:00
|
|
|
[Test]
|
2019-02-18 18:53:55 +08:00
|
|
|
public void PauseTest()
|
2019-02-15 15:38:27 +08:00
|
|
|
{
|
2019-02-27 16:02:04 +08:00
|
|
|
performSetup(true);
|
2019-02-22 13:43:05 +08:00
|
|
|
AddStep("Transition to Pause", () =>
|
|
|
|
{
|
2019-02-24 17:10:59 +08:00
|
|
|
if (!player.IsPaused.Value)
|
2019-02-22 13:43:05 +08:00
|
|
|
player.Exit();
|
|
|
|
});
|
2019-02-26 09:11:36 +08:00
|
|
|
waitForDim();
|
2019-02-26 08:54:28 +08:00
|
|
|
AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed());
|
2019-02-18 18:53:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2019-02-19 18:44:26 +08:00
|
|
|
/// Check if the fade container removes user dim when suspending player for results
|
2019-02-18 18:53:55 +08:00
|
|
|
/// </summary>
|
|
|
|
[Test]
|
|
|
|
public void TransitionTest()
|
|
|
|
{
|
2019-02-22 15:56:03 +08:00
|
|
|
performSetup();
|
2019-02-26 08:56:22 +08:00
|
|
|
AddStep("Transition to Results", () => player.Push(new FadeAccesibleResults(new ScoreInfo { User = new User { Username = "osu!" } })));
|
2019-02-26 09:11:36 +08:00
|
|
|
waitForDim();
|
2019-02-26 08:54:28 +08:00
|
|
|
AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed());
|
|
|
|
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
2019-02-19 18:44:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Check if background gets undimmed when leaving the player for the previous screen
|
|
|
|
/// </summary>
|
|
|
|
[Test]
|
|
|
|
public void TransitionOutTest()
|
|
|
|
{
|
2019-02-22 15:56:03 +08:00
|
|
|
performSetup();
|
2019-02-22 16:15:05 +08:00
|
|
|
AddUntilStep(() =>
|
|
|
|
{
|
|
|
|
if (!songSelect.IsCurrentScreen())
|
|
|
|
{
|
|
|
|
songSelect.MakeCurrent();
|
|
|
|
return false;
|
|
|
|
}
|
2019-02-26 08:56:22 +08:00
|
|
|
|
2019-02-22 16:15:05 +08:00
|
|
|
return true;
|
|
|
|
}, "Wait for song select is current");
|
2019-02-26 09:11:36 +08:00
|
|
|
waitForDim();
|
2019-02-26 08:54:28 +08:00
|
|
|
AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed());
|
2019-02-15 15:38:27 +08:00
|
|
|
}
|
|
|
|
|
2019-02-26 09:27:54 +08:00
|
|
|
private void waitForDim() => AddWaitStep(5, "Wait for dim");
|
2019-02-26 09:11:36 +08:00
|
|
|
|
2019-02-27 16:56:44 +08:00
|
|
|
private void createFakeStoryboard() => AddStep("Enable storyboard", () =>
|
|
|
|
{
|
|
|
|
player.ReplacesBackground.Value = true;
|
|
|
|
player.StoryboardEnabled.Value = true;
|
2019-02-28 13:33:29 +08:00
|
|
|
player.CurrentStoryboardContainer.Add(new SpriteText
|
2019-02-27 16:56:44 +08:00
|
|
|
{
|
2019-02-28 13:33:29 +08:00
|
|
|
Size = new Vector2(250, 50),
|
2019-02-27 16:56:44 +08:00
|
|
|
Alpha = 1,
|
2019-02-28 13:33:29 +08:00
|
|
|
Colour = Color4.White,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Text = "THIS IS A STORYBOARD",
|
2019-02-27 16:56:44 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-02-27 16:02:04 +08:00
|
|
|
private void performSetup(bool allowPause = false)
|
2019-02-26 08:56:22 +08:00
|
|
|
{
|
|
|
|
createSongSelect();
|
|
|
|
|
2019-02-27 13:15:45 +08:00
|
|
|
AddStep("Start player loader", () => { songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer
|
2019-02-26 16:31:21 +08:00
|
|
|
{
|
|
|
|
AllowLeadIn = false,
|
|
|
|
AllowResults = false,
|
2019-02-27 16:02:04 +08:00
|
|
|
AllowPause = allowPause,
|
2019-02-27 13:15:45 +08:00
|
|
|
Ready = true,
|
|
|
|
})); });
|
|
|
|
AddUntilStep(() => playerLoader.IsLoaded, "Wait for Player Loader to load");
|
|
|
|
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
2019-02-26 16:56:42 +08:00
|
|
|
AddUntilStep(() => player.IsLoaded, "Wait for player to load");
|
2019-02-26 08:56:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void createSongSelect()
|
|
|
|
{
|
2019-02-27 13:15:45 +08:00
|
|
|
AddStep("Create new screen stack", () => Child = screenStackContainer = new ScreenStackCacheContainer { RelativeSizeAxes = Axes.Both });
|
|
|
|
AddUntilStep(() => screenStackContainer.IsLoaded,"Wait for screen stack creation");
|
2019-02-27 16:02:04 +08:00
|
|
|
AddStep("Create new song select", () => screenStackContainer.ScreenStack.Push(songSelect = new DummySongSelect()));
|
2019-02-26 16:56:42 +08:00
|
|
|
AddUntilStep(() => songSelect.IsLoaded, "Wait for song select to load");
|
2019-02-27 16:02:04 +08:00
|
|
|
AddStep("Set user settings", () =>
|
2019-02-26 16:31:21 +08:00
|
|
|
{
|
2019-02-27 13:15:45 +08:00
|
|
|
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { new OsuModNoFail() });
|
2019-02-27 16:02:04 +08:00
|
|
|
songSelect.DimLevel.Value = 0.7f;
|
2019-02-26 16:31:21 +08:00
|
|
|
});
|
2019-02-27 16:02:04 +08:00
|
|
|
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap != null, "Song select has selection");
|
2019-02-26 08:56:22 +08:00
|
|
|
}
|
|
|
|
|
2019-02-27 13:15:45 +08:00
|
|
|
private class DummySongSelect : PlaySongSelect
|
2019-02-19 18:44:26 +08:00
|
|
|
{
|
2019-02-26 16:31:21 +08:00
|
|
|
protected override BackgroundScreen CreateBackground()
|
|
|
|
{
|
2019-02-27 13:15:45 +08:00
|
|
|
FadeAccessibleBackground background = new FadeAccessibleBackground(Beatmap.Value);
|
2019-02-26 16:31:21 +08:00
|
|
|
DimEnabled.BindTo(background.EnableUserDim);
|
|
|
|
return background;
|
|
|
|
}
|
|
|
|
|
2019-02-22 15:56:03 +08:00
|
|
|
public readonly Bindable<bool> DimEnabled = new Bindable<bool>();
|
2019-02-27 16:02:04 +08:00
|
|
|
public readonly Bindable<double> DimLevel = new Bindable<double>();
|
2019-02-24 17:10:59 +08:00
|
|
|
|
2019-02-27 13:15:45 +08:00
|
|
|
public new BeatmapCarousel Carousel => base.Carousel;
|
|
|
|
|
2019-02-24 17:10:59 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuConfigManager config)
|
|
|
|
{
|
2019-02-27 16:02:04 +08:00
|
|
|
config.BindWith(OsuSetting.DimLevel, DimLevel);
|
2019-02-22 15:56:03 +08:00
|
|
|
}
|
2019-02-21 14:24:26 +08:00
|
|
|
|
2019-02-27 16:02:04 +08:00
|
|
|
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value);
|
2019-02-21 14:24:26 +08:00
|
|
|
|
2019-02-26 08:54:28 +08:00
|
|
|
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White;
|
2019-02-22 10:41:28 +08:00
|
|
|
|
2019-02-26 08:54:28 +08:00
|
|
|
public bool IsBackgroundInvisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 0;
|
2019-02-22 10:41:28 +08:00
|
|
|
|
2019-02-26 08:54:28 +08:00
|
|
|
public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1;
|
2019-02-22 13:43:05 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Make sure every time a screen gets pushed, the background doesn't get replaced
|
|
|
|
/// </summary>
|
2019-02-24 19:03:24 +08:00
|
|
|
/// <returns>Whether or not the original background (The one created in DummySongSelect) is still the current background</returns>
|
2019-02-26 08:54:28 +08:00
|
|
|
public bool IsBackgroundCurrent() => ((FadeAccessibleBackground)Background).IsCurrentScreen();
|
2019-02-19 18:44:26 +08:00
|
|
|
}
|
2019-02-15 15:17:01 +08:00
|
|
|
|
2019-02-18 18:53:55 +08:00
|
|
|
private class FadeAccesibleResults : SoloResults
|
|
|
|
{
|
2019-02-26 08:56:22 +08:00
|
|
|
public FadeAccesibleResults(ScoreInfo score)
|
|
|
|
: base(score)
|
2019-02-18 18:53:55 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-27 13:15:45 +08:00
|
|
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
2019-02-18 18:53:55 +08:00
|
|
|
}
|
|
|
|
|
2019-02-15 15:17:01 +08:00
|
|
|
private class DimAccessiblePlayer : Player
|
|
|
|
{
|
2019-02-27 13:15:45 +08:00
|
|
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
2019-02-15 15:17:01 +08:00
|
|
|
|
2019-02-27 16:56:44 +08:00
|
|
|
protected override UserDimContainer CreateStoryboardContainer()
|
|
|
|
{
|
|
|
|
return new TestUserDimContainer(true)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 1,
|
|
|
|
EnableUserDim = { Value = true }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-02-27 16:02:04 +08:00
|
|
|
public UserDimContainer CurrentStoryboardContainer => StoryboardContainer;
|
2019-02-24 17:10:59 +08:00
|
|
|
// Whether or not the player should be allowed to load.
|
2019-02-21 14:24:26 +08:00
|
|
|
public bool Ready;
|
|
|
|
|
2019-02-22 10:41:28 +08:00
|
|
|
public Bindable<bool> StoryboardEnabled;
|
|
|
|
public readonly Bindable<bool> ReplacesBackground = new Bindable<bool>();
|
2019-02-24 17:10:59 +08:00
|
|
|
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
2019-02-22 13:43:05 +08:00
|
|
|
|
2019-02-27 16:56:44 +08:00
|
|
|
public bool IsStoryboardVisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha == 1;
|
|
|
|
|
|
|
|
public bool IsStoryboardInvisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha <= 1;
|
|
|
|
|
2019-02-21 14:24:26 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2019-02-22 10:41:28 +08:00
|
|
|
private void load(OsuConfigManager config)
|
2019-02-15 15:17:01 +08:00
|
|
|
{
|
2019-02-21 14:24:26 +08:00
|
|
|
while (!Ready)
|
|
|
|
Thread.Sleep(1);
|
2019-02-22 10:41:28 +08:00
|
|
|
StoryboardEnabled = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
|
|
|
ReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
2019-02-24 17:10:59 +08:00
|
|
|
RulesetContainer.IsPaused.BindTo(IsPaused);
|
2019-02-15 15:17:01 +08:00
|
|
|
}
|
2019-02-21 14:24:26 +08:00
|
|
|
}
|
2019-02-15 15:17:01 +08:00
|
|
|
|
2019-02-26 16:31:21 +08:00
|
|
|
private class ScreenStackCacheContainer : Container
|
|
|
|
{
|
|
|
|
[Cached]
|
|
|
|
private BackgroundScreenStack backgroundScreenStack;
|
|
|
|
|
|
|
|
public readonly ScreenStack ScreenStack;
|
|
|
|
|
|
|
|
public ScreenStackCacheContainer()
|
|
|
|
{
|
|
|
|
Add(backgroundScreenStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both });
|
|
|
|
Add(ScreenStack = new ScreenStack { RelativeSizeAxes = Axes.Both });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-21 14:24:26 +08:00
|
|
|
private class DimAccessiblePlayerLoader : PlayerLoader
|
|
|
|
{
|
|
|
|
public VisualSettings VisualSettingsPos => VisualSettings;
|
2019-02-22 10:41:28 +08:00
|
|
|
public BackgroundScreen ScreenPos => Background;
|
2019-02-21 14:24:26 +08:00
|
|
|
|
2019-02-26 08:56:22 +08:00
|
|
|
public DimAccessiblePlayerLoader(Player player)
|
|
|
|
: base(() => player)
|
2019-02-15 15:38:27 +08:00
|
|
|
{
|
|
|
|
}
|
2019-02-21 17:19:50 +08:00
|
|
|
|
2019-02-27 13:15:45 +08:00
|
|
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
2019-02-18 18:53:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
|
|
|
{
|
2019-02-22 19:34:51 +08:00
|
|
|
protected override UserDimContainer CreateFadeContainer() => new TestUserDimContainer { RelativeSizeAxes = Axes.Both };
|
2019-02-22 17:01:50 +08:00
|
|
|
|
2019-02-24 17:10:59 +08:00
|
|
|
public Color4 CurrentColour => ((TestUserDimContainer)FadeContainer).CurrentColour;
|
|
|
|
public float CurrentAlpha => ((TestUserDimContainer)FadeContainer).CurrentAlpha;
|
2019-02-22 19:34:51 +08:00
|
|
|
|
2019-02-27 13:15:45 +08:00
|
|
|
public FadeAccessibleBackground(WorkingBeatmap beatmap)
|
|
|
|
: base(beatmap)
|
|
|
|
{
|
|
|
|
}
|
2019-02-27 16:56:44 +08:00
|
|
|
}
|
2019-02-27 13:15:45 +08:00
|
|
|
|
2019-02-27 16:56:44 +08:00
|
|
|
private class TestUserDimContainer : UserDimContainer
|
|
|
|
{
|
|
|
|
public TestUserDimContainer(bool isStoryboard = false)
|
|
|
|
: base(isStoryboard)
|
2019-02-22 19:34:51 +08:00
|
|
|
{
|
2019-02-22 10:41:28 +08:00
|
|
|
}
|
2019-02-27 16:56:44 +08:00
|
|
|
public Color4 CurrentColour => DimContainer.Colour;
|
|
|
|
public float CurrentAlpha => DimContainer.Alpha;
|
2019-02-15 15:17:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|