mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 10:42:55 +08:00
Add fake storyboard to visually assess storyboard dim
This commit is contained in:
parent
ebec944bb8
commit
14ffd9efe8
@ -10,6 +10,8 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -27,6 +29,7 @@ using osu.Game.Screens.Play.PlayerSettings;
|
|||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
@ -68,13 +71,21 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
Dependencies.Cache(rulesets = new RulesetStore(factory));
|
Dependencies.Cache(rulesets = new RulesetStore(factory));
|
||||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, Beatmap.Default));
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, Beatmap.Default));
|
||||||
|
Dependencies.Cache(new OsuConfigManager(LocalStorage));
|
||||||
|
|
||||||
Beatmap.SetDefault();
|
Beatmap.SetDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public virtual void SetUp() =>
|
public virtual void SetUp()
|
||||||
Schedule(() => { manager?.Delete(manager.GetAllUsableBeatmapSets()); });
|
{
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
manager.Delete(manager.GetAllUsableBeatmapSets());
|
||||||
|
var temp = TestResources.GetTestBeatmapForImport();
|
||||||
|
manager.Import(temp);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if PlayerLoader properly triggers background dim previews when a user hovers over the visual settings panel.
|
/// Check if PlayerLoader properly triggers background dim previews when a user hovers over the visual settings panel.
|
||||||
@ -134,9 +145,18 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
player.ReplacesBackground.Value = true;
|
player.ReplacesBackground.Value = true;
|
||||||
player.StoryboardEnabled.Value = true;
|
player.StoryboardEnabled.Value = true;
|
||||||
|
player.CurrentStoryboardContainer.Add(new SpriteText
|
||||||
|
{
|
||||||
|
Size = new Vector2(250, 50),
|
||||||
|
Alpha = 1,
|
||||||
|
Colour = Color4.White,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Text = "THIS IS A STORYBOARD",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Background is invisible", () => songSelect.IsBackgroundInvisible());
|
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.CurrentStoryboardContainer.Alpha == 1);
|
||||||
AddStep("Disable storyboard", () => player.ReplacesBackground.Value = false);
|
AddStep("Disable storyboard", () => player.ReplacesBackground.Value = false);
|
||||||
waitForDim();
|
waitForDim();
|
||||||
AddAssert("Background is visible", () => songSelect.IsBackgroundVisible());
|
AddAssert("Background is visible", () => songSelect.IsBackgroundVisible());
|
||||||
@ -153,6 +173,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
player.ReplacesBackground.Value = true;
|
player.ReplacesBackground.Value = true;
|
||||||
player.StoryboardEnabled.Value = true;
|
player.StoryboardEnabled.Value = true;
|
||||||
|
player.CurrentStoryboardContainer.Add(new Box
|
||||||
|
{
|
||||||
|
Alpha = 1,
|
||||||
|
Colour = Color4.Tomato
|
||||||
|
});
|
||||||
});
|
});
|
||||||
AddUntilStep(() =>
|
AddUntilStep(() =>
|
||||||
{
|
{
|
||||||
@ -194,7 +219,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
[Test]
|
[Test]
|
||||||
public void PauseTest()
|
public void PauseTest()
|
||||||
{
|
{
|
||||||
performSetup();
|
performSetup(true);
|
||||||
AddStep("Transition to Pause", () =>
|
AddStep("Transition to Pause", () =>
|
||||||
{
|
{
|
||||||
if (!player.IsPaused.Value)
|
if (!player.IsPaused.Value)
|
||||||
@ -240,7 +265,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
private void waitForDim() => AddWaitStep(5, "Wait for dim");
|
private void waitForDim() => AddWaitStep(5, "Wait for dim");
|
||||||
|
|
||||||
private void performSetup()
|
private void performSetup(bool allowPause = false)
|
||||||
{
|
{
|
||||||
createSongSelect();
|
createSongSelect();
|
||||||
|
|
||||||
@ -248,6 +273,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
AllowLeadIn = false,
|
AllowLeadIn = false,
|
||||||
AllowResults = false,
|
AllowResults = false,
|
||||||
|
AllowPause = allowPause,
|
||||||
Ready = true,
|
Ready = true,
|
||||||
})); });
|
})); });
|
||||||
AddUntilStep(() => playerLoader.IsLoaded, "Wait for Player Loader to load");
|
AddUntilStep(() => playerLoader.IsLoaded, "Wait for Player Loader to load");
|
||||||
@ -259,15 +285,14 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
AddStep("Create new screen stack", () => Child = screenStackContainer = new ScreenStackCacheContainer { RelativeSizeAxes = Axes.Both });
|
AddStep("Create new screen stack", () => Child = screenStackContainer = new ScreenStackCacheContainer { RelativeSizeAxes = Axes.Both });
|
||||||
AddUntilStep(() => screenStackContainer.IsLoaded,"Wait for screen stack creation");
|
AddUntilStep(() => screenStackContainer.IsLoaded,"Wait for screen stack creation");
|
||||||
AddStep("create new song select", () => screenStackContainer.ScreenStack.Push(songSelect = new DummySongSelect()));
|
AddStep("Create new song select", () => screenStackContainer.ScreenStack.Push(songSelect = new DummySongSelect()));
|
||||||
AddUntilStep(() => songSelect.IsLoaded, "Wait for song select to load");
|
AddUntilStep(() => songSelect.IsLoaded, "Wait for song select to load");
|
||||||
AddStep("Add map", () =>
|
AddStep("Set user settings", () =>
|
||||||
{
|
{
|
||||||
var temp = TestResources.GetTestBeatmapForImport();
|
|
||||||
manager.Import(temp);
|
|
||||||
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { new OsuModNoFail() });
|
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { new OsuModNoFail() });
|
||||||
|
songSelect.DimLevel.Value = 0.7f;
|
||||||
});
|
});
|
||||||
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap != null, "has selection");
|
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap != null, "Song select has selection");
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DummySongSelect : PlaySongSelect
|
private class DummySongSelect : PlaySongSelect
|
||||||
@ -280,17 +305,17 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
|
|
||||||
public readonly Bindable<bool> DimEnabled = new Bindable<bool>();
|
public readonly Bindable<bool> DimEnabled = new Bindable<bool>();
|
||||||
private readonly Bindable<double> dimLevel = new Bindable<double>();
|
public readonly Bindable<double> DimLevel = new Bindable<double>();
|
||||||
|
|
||||||
public new BeatmapCarousel Carousel => base.Carousel;
|
public new BeatmapCarousel Carousel => base.Carousel;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
config.BindWith(OsuSetting.DimLevel, dimLevel);
|
config.BindWith(OsuSetting.DimLevel, DimLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)dimLevel.Value);
|
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value);
|
||||||
|
|
||||||
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White;
|
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White;
|
||||||
|
|
||||||
@ -319,6 +344,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||||
|
|
||||||
|
public UserDimContainer CurrentStoryboardContainer => StoryboardContainer;
|
||||||
// Whether or not the player should be allowed to load.
|
// Whether or not the player should be allowed to load.
|
||||||
public bool Ready;
|
public bool Ready;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private FailOverlay failOverlay;
|
private FailOverlay failOverlay;
|
||||||
|
|
||||||
private DrawableStoryboard storyboard;
|
private DrawableStoryboard storyboard;
|
||||||
private UserDimContainer storyboardContainer;
|
protected UserDimContainer StoryboardContainer;
|
||||||
|
|
||||||
public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true;
|
public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true;
|
||||||
|
|
||||||
@ -176,10 +176,10 @@ namespace osu.Game.Screens.Play
|
|||||||
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded.Value,
|
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded.Value,
|
||||||
Children = new Container[]
|
Children = new Container[]
|
||||||
{
|
{
|
||||||
storyboardContainer = new UserDimContainer(true)
|
StoryboardContainer = new UserDimContainer(true)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Alpha = 0,
|
Alpha = 1,
|
||||||
EnableUserDim = { Value = true }
|
EnableUserDim = { Value = true }
|
||||||
},
|
},
|
||||||
new ScalingContainer(ScalingMode.Gameplay)
|
new ScalingContainer(ScalingMode.Gameplay)
|
||||||
@ -355,7 +355,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Background.EnableUserDim.Value = true;
|
Background.EnableUserDim.Value = true;
|
||||||
|
|
||||||
storyboardReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
storyboardReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
||||||
storyboardContainer.StoryboardReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
StoryboardContainer.StoryboardReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
||||||
storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
|
storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
@ -422,7 +422,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private void initializeStoryboard(bool asyncLoad)
|
private void initializeStoryboard(bool asyncLoad)
|
||||||
{
|
{
|
||||||
if (storyboardContainer == null)
|
if (StoryboardContainer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var beatmap = Beatmap.Value;
|
var beatmap = Beatmap.Value;
|
||||||
@ -431,9 +431,9 @@ namespace osu.Game.Screens.Play
|
|||||||
storyboard.Masking = true;
|
storyboard.Masking = true;
|
||||||
|
|
||||||
if (asyncLoad)
|
if (asyncLoad)
|
||||||
LoadComponentAsync(storyboard, storyboardContainer.Add);
|
LoadComponentAsync(storyboard, StoryboardContainer.Add);
|
||||||
else
|
else
|
||||||
storyboardContainer.Add(storyboard);
|
StoryboardContainer.Add(storyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateBackgroundElements()
|
protected override void UpdateBackgroundElements()
|
||||||
|
Loading…
Reference in New Issue
Block a user