1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 18:32:56 +08:00

Privatize ViewTarget

This commit is contained in:
Lucas A 2020-02-11 18:10:46 +01:00
parent 30e0a34e50
commit b9e10cb498
2 changed files with 20 additions and 14 deletions

View File

@ -32,6 +32,8 @@ namespace osu.Game.Tests.Visual.Online
{
public new LoadingAnimation LoadingAnimation => base.LoadingAnimation;
public CompositeDrawable ViewTarget => base.Content.Parent;
public TestOnlineViewContainer()
: base(@"Please sign in to view dummy test content")
{
@ -53,9 +55,9 @@ namespace osu.Game.Tests.Visual.Online
};
}
protected override void FadeContentOut(Drawable content) => content.Hide();
protected override void PopContentOut(Drawable content) => content.Hide();
protected override void FadeContentIn(Drawable content) => content.Show();
protected override void PopContentIn(Drawable content) => content.Show();
}
[Test]
@ -63,7 +65,7 @@ namespace osu.Game.Tests.Visual.Online
{
AddStep("set status to online", () => ((DummyAPIAccess)API).State = APIState.Online);
AddAssert("children are visible", () => onlineView.TransformationTarget.IsPresent);
AddAssert("children are visible", () => onlineView.ViewTarget.IsPresent);
AddAssert("loading animation is not visible", () => !onlineView.LoadingAnimation.IsPresent);
}
@ -72,7 +74,7 @@ namespace osu.Game.Tests.Visual.Online
{
AddStep("set status to offline", () => ((DummyAPIAccess)API).State = APIState.Offline);
AddAssert("children are hidden", () => !onlineView.TransformationTarget.IsPresent);
AddAssert("children are hidden", () => !onlineView.ViewTarget.IsPresent);
AddAssert("loading animation is not visible", () => !onlineView.LoadingAnimation.IsPresent);
}
@ -81,12 +83,16 @@ namespace osu.Game.Tests.Visual.Online
{
AddStep("set status to connecting", () => ((DummyAPIAccess)API).State = APIState.Connecting);
AddAssert("children are hidden", () => !onlineView.TransformationTarget.IsPresent);
AddAssert("children are hidden", () => !onlineView.ViewTarget.IsPresent);
AddAssert("loading animation is visible", () => onlineView.LoadingAnimation.IsPresent);
}
[Test]
public void TestFailingStateVisibility()
{
AddStep("set status to failing", () => ((DummyAPIAccess)API).State = APIState.Failing);
AddAssert("children are hidden", () => !onlineView.TransformationTarget.IsPresent);
AddAssert("children are hidden", () => !onlineView.ViewTarget.IsPresent);
AddAssert("loading animation is visible", () => onlineView.LoadingAnimation.IsPresent);
}
}

View File

@ -11,7 +11,7 @@ using osu.Game.Online.Placeholders;
namespace osu.Game.Online
{
/// <summary>
/// A <see cref="Container"/> for dislaying online content which require a local user to be logged in.
/// A <see cref="Container"/> for displaying online content which require a local user to be logged in.
/// Shows its children only when the local user is logged in and supports displaying a placeholder if not.
/// </summary>
public abstract class OnlineViewContainer : Container, IOnlineComponent
@ -21,7 +21,7 @@ namespace osu.Game.Online
protected const double TRANSFORM_TIME = 300.0;
internal readonly Container TransformationTarget;
private readonly Container viewTarget;
protected override Container<Drawable> Content { get; }
[Resolved]
@ -31,7 +31,7 @@ namespace osu.Game.Online
{
InternalChildren = new Drawable[]
{
TransformationTarget = new Container
viewTarget = new Container
{
RelativeSizeAxes = Axes.Both,
Child = Content = new Container
@ -52,30 +52,30 @@ namespace osu.Game.Online
switch (state)
{
case APIState.Offline:
FadeContentOut(TransformationTarget);
PopContentOut(viewTarget);
placeholder.ScaleTo(0.8f).Then().ScaleTo(1, 3 * TRANSFORM_TIME, Easing.OutQuint);
placeholder.FadeInFromZero(2 * TRANSFORM_TIME, Easing.OutQuint);
LoadingAnimation.Hide();
break;
case APIState.Online:
FadeContentIn(TransformationTarget);
PopContentIn(viewTarget);
placeholder.FadeOut(TRANSFORM_TIME / 2, Easing.OutQuint);
LoadingAnimation.Hide();
break;
case APIState.Failing:
case APIState.Connecting:
FadeContentOut(TransformationTarget);
PopContentOut(viewTarget);
LoadingAnimation.Show();
placeholder.FadeOut(TRANSFORM_TIME / 2, Easing.OutQuint);
break;
}
}
protected abstract void FadeContentOut(Drawable content);
protected abstract void PopContentOut(Drawable content);
protected abstract void FadeContentIn(Drawable content);
protected abstract void PopContentIn(Drawable content);
protected override void LoadComplete()
{