mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 16:12:57 +08:00
Put user dim logic in yet another container inside UserDimContainer
This commit is contained in:
parent
a4162a69fb
commit
76de39a344
@ -12,6 +12,7 @@ using osu.Framework.Screens;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
@ -32,18 +33,38 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
typeof(ScreenWithBeatmapBackground),
|
typeof(ScreenWithBeatmapBackground),
|
||||||
typeof(PlayerLoader),
|
typeof(PlayerLoader),
|
||||||
typeof(Player)
|
typeof(Player),
|
||||||
|
typeof(UserDimContainer)
|
||||||
};
|
};
|
||||||
|
|
||||||
private DummySongSelect songSelect;
|
private DummySongSelect songSelect;
|
||||||
private DimAccessiblePlayerLoader playerLoader;
|
private DimAccessiblePlayerLoader playerLoader;
|
||||||
private DimAccessiblePlayer player;
|
private DimAccessiblePlayer player;
|
||||||
|
private readonly ScreenStack screen;
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private BackgroundScreenStack backgroundStack;
|
private BackgroundScreenStack backgroundStack;
|
||||||
|
|
||||||
|
private void createSongSelect()
|
||||||
|
{
|
||||||
|
AddStep("Create song select if required", () =>
|
||||||
|
{
|
||||||
|
if (songSelect == null)
|
||||||
|
{
|
||||||
|
LoadComponentAsync(new DummySongSelect(), p =>
|
||||||
|
{
|
||||||
|
songSelect = p;
|
||||||
|
screen.Push(p);
|
||||||
|
songSelect.UpdateBindables();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AddUntilStep(() => songSelect?.IsLoaded ?? false, "Wait for song select to load");
|
||||||
|
}
|
||||||
|
|
||||||
private void performSetup()
|
private void performSetup()
|
||||||
{
|
{
|
||||||
|
createSongSelect();
|
||||||
AddUntilStep(() =>
|
AddUntilStep(() =>
|
||||||
{
|
{
|
||||||
if (!songSelect.IsCurrentScreen())
|
if (!songSelect.IsCurrentScreen())
|
||||||
@ -53,31 +74,17 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, "Wait for song select is current");
|
}, "Wait for song select is current");
|
||||||
|
|
||||||
AddStep("Load new player to song select", () => songSelect.Push(player = new DimAccessiblePlayer { Ready = true }));
|
AddStep("Load new player to song select", () => songSelect.Push(player = new DimAccessiblePlayer { Ready = true }));
|
||||||
AddUntilStep(() => player?.IsLoaded ?? false, "Wait for player to load");
|
AddUntilStep(() => player?.IsLoaded ?? false, "Wait for player to load");
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestCaseBackgroundScreenBeatmap()
|
public TestCaseBackgroundScreenBeatmap()
|
||||||
{
|
{
|
||||||
ScreenStack screen;
|
|
||||||
|
|
||||||
InputManager.Add(backgroundStack = new BackgroundScreenStack {RelativeSizeAxes = Axes.Both});
|
InputManager.Add(backgroundStack = new BackgroundScreenStack {RelativeSizeAxes = Axes.Both});
|
||||||
InputManager.Add(screen = new ScreenStack { RelativeSizeAxes = Axes.Both });
|
InputManager.Add(screen = new ScreenStack { RelativeSizeAxes = Axes.Both });
|
||||||
|
|
||||||
AddStep("Load Song Select", () =>
|
createSongSelect();
|
||||||
{
|
|
||||||
songSelect?.MakeCurrent();
|
|
||||||
songSelect?.Exit();
|
|
||||||
|
|
||||||
LoadComponentAsync(new DummySongSelect(), p =>
|
|
||||||
{
|
|
||||||
songSelect = p;
|
|
||||||
screen.Push(p);
|
|
||||||
songSelect.UpdateBindables();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
AddUntilStep(() => songSelect?.IsLoaded ?? false, "Wait for song select to load");
|
|
||||||
AddStep("Create beatmap", () =>
|
AddStep("Create beatmap", () =>
|
||||||
{
|
{
|
||||||
Beatmap.Value = new TestWorkingBeatmap(new Beatmap<OsuHitObject>
|
Beatmap.Value = new TestWorkingBeatmap(new Beatmap<OsuHitObject>
|
||||||
@ -301,32 +308,40 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
||||||
{
|
{
|
||||||
private Bindable<float> dimLevel;
|
private readonly Bindable<double> dimLevel = new Bindable<double>();
|
||||||
|
|
||||||
|
protected override UserDimContainer CreateFadeContainer() => new TestUserDimContainer { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
dimLevel = config.GetBindable<float>(OsuSetting.DimLevel);
|
config.BindWith(OsuSetting.DimLevel, dimLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AssertDimmed()
|
public bool AssertDimmed()
|
||||||
{
|
{
|
||||||
return FadeContainer.Colour == OsuColour.Gray(1 - dimLevel);
|
return ((TestUserDimContainer)FadeContainer).CurrentColour == OsuColour.Gray(1 - (float)dimLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AssertUndimmed()
|
public bool AssertUndimmed()
|
||||||
{
|
{
|
||||||
return FadeContainer.Colour == Color4.White;
|
return ((TestUserDimContainer)FadeContainer).CurrentColour == Color4.White;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AssertInvisible()
|
public bool AssertInvisible()
|
||||||
{
|
{
|
||||||
return FadeContainer.Alpha == 0;
|
return ((TestUserDimContainer)FadeContainer).CurrentAlpha == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AssertVisible()
|
public bool AssertVisible()
|
||||||
{
|
{
|
||||||
return FadeContainer.Alpha == 1;
|
return ((TestUserDimContainer)FadeContainer).CurrentAlpha == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestUserDimContainer : UserDimContainer
|
||||||
|
{
|
||||||
|
public Color4 CurrentColour => DimContainer.Colour;
|
||||||
|
public float CurrentAlpha => DimContainer.Alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ namespace osu.Game.Graphics.Containers
|
|||||||
protected Bindable<bool> ShowStoryboard;
|
protected Bindable<bool> ShowStoryboard;
|
||||||
public Bindable<bool> EnableUserDim = new Bindable<bool>();
|
public Bindable<bool> EnableUserDim = new Bindable<bool>();
|
||||||
public Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
public Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||||
|
protected Container DimContainer;
|
||||||
|
protected override Container<Drawable> Content => DimContainer;
|
||||||
|
|
||||||
private readonly bool isStoryboard;
|
private readonly bool isStoryboard;
|
||||||
|
|
||||||
@ -23,7 +25,9 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
public UserDimContainer(bool isStoryboard = false)
|
public UserDimContainer(bool isStoryboard = false)
|
||||||
{
|
{
|
||||||
|
DimContainer = new Container { RelativeSizeAxes = Axes.Both };
|
||||||
this.isStoryboard = isStoryboard;
|
this.isStoryboard = isStoryboard;
|
||||||
|
AddInternal(DimContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -41,15 +45,15 @@ namespace osu.Game.Graphics.Containers
|
|||||||
{
|
{
|
||||||
if (isStoryboard)
|
if (isStoryboard)
|
||||||
{
|
{
|
||||||
this.FadeTo(!ShowStoryboard || DimLevel == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
DimContainer.FadeTo(!ShowStoryboard || DimLevel == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The background needs to be hidden in the case of it being replaced
|
// The background needs to be hidden in the case of it being replaced
|
||||||
this.FadeTo(ShowStoryboard && StoryboardReplacesBackground ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
DimContainer.FadeTo(ShowStoryboard && StoryboardReplacesBackground ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.FadeColour(EnableUserDim ? OsuColour.Gray(1 - (float)DimLevel) : Color4.White, background_fade_duration, Easing.OutQuint);
|
DimContainer.FadeColour(EnableUserDim ? OsuColour.Gray(1 - (float)DimLevel) : Color4.White, background_fade_duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
public Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
public Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||||
|
|
||||||
protected UserDimContainer FadeContainer;
|
protected UserDimContainer FadeContainer;
|
||||||
|
protected virtual UserDimContainer CreateFadeContainer() => new UserDimContainer { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
public virtual WorkingBeatmap Beatmap
|
public virtual WorkingBeatmap Beatmap
|
||||||
{
|
{
|
||||||
@ -29,7 +30,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
|
|
||||||
beatmap = value;
|
beatmap = value;
|
||||||
|
|
||||||
FadeContainer = new UserDimContainer { RelativeSizeAxes = Axes.Both };
|
FadeContainer = CreateFadeContainer();
|
||||||
InternalChild = FadeContainer;
|
InternalChild = FadeContainer;
|
||||||
EnableUserDim.BindTo(FadeContainer.EnableUserDim);
|
EnableUserDim.BindTo(FadeContainer.EnableUserDim);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user