diff --git a/osu.Game.Tests/Visual/UserInterface/TestCaseButtonSystem.cs b/osu.Game.Tests/Visual/UserInterface/TestCaseButtonSystem.cs
index 261e87ff07..04aa8bce7e 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestCaseButtonSystem.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestCaseButtonSystem.cs
@@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.UserInterface
RelativeSizeAxes = Axes.Both,
},
buttons = new ButtonSystem(),
- logo = new OsuLogo()
+ logo = new OsuLogo { RelativePositionAxes = Axes.Both }
};
buttons.SetOsuLogo(logo);
diff --git a/osu.Game.Tests/Visual/UserInterface/TestCaseLogoTrackingContainer.cs b/osu.Game.Tests/Visual/UserInterface/TestCaseLogoTrackingContainer.cs
index 01a3113fe1..8b70a34c85 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestCaseLogoTrackingContainer.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestCaseLogoTrackingContainer.cs
@@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual.UserInterface
{
AddToggleStep("Toggle move continuously", b => randomPositions = b);
AddStep("Add tracking containers", addFacadeContainers);
- AddStep("Move facade to random position", startTrackingRandom);
+ AddStep("Move facade to random position", moveLogoFacade);
waitForMove();
AddAssert("Logo is tracking", () => trackingContainer.IsLogoTracking);
}
@@ -85,7 +85,7 @@ namespace osu.Game.Tests.Visual.UserInterface
public void RemoveFacadeTest()
{
AddStep("Add tracking containers", addFacadeContainers);
- AddStep("Move facade to random position", startTrackingRandom);
+ AddStep("Move facade to random position", moveLogoFacade);
AddStep("Remove facade from FacadeContainer", removeFacade);
waitForMove();
AddAssert("Logo is not tracking", () => !trackingContainer.IsLogoTracking);
@@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual.UserInterface
public void TransferFacadeTest()
{
AddStep("Add tracking containers", addFacadeContainers);
- AddStep("Move facade to random position", startTrackingRandom);
+ AddStep("Move facade to random position", moveLogoFacade);
AddStep("Remove facade from FacadeContainer", removeFacade);
AddStep("Transfer facade to a new container", () =>
{
@@ -171,14 +171,14 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("Perform logo movements", () =>
{
- trackingContainer.Tracking = false;
+ trackingContainer.StopTracking();
logo.MoveTo(new Vector2(0.5f), 500, Easing.InOutExpo);
- trackingContainer.SetLogo(logo, 1.0f, 1000, Easing.InOutExpo);
+
visualBox.Colour = Color4.White;
Scheduler.AddDelayed(() =>
{
- trackingContainer.Tracking = true;
+ trackingContainer.StartTracking(logo, 1000, Easing.InOutExpo);
visualBox.Colour = Color4.Tomato;
}, 700);
});
@@ -221,14 +221,13 @@ namespace osu.Game.Tests.Visual.UserInterface
failed = false;
newContainer = new LogoTrackingContainer();
addFacadeContainers();
- startTrackingRandom();
- newContainer.SetLogo(logo);
+ moveLogoFacade();
});
AddStep("Try tracking new container", () =>
{
try
{
- newContainer.Tracking = true;
+ newContainer.StartTracking(logo);
}
catch (Exception e)
{
@@ -268,7 +267,7 @@ namespace osu.Game.Tests.Visual.UserInterface
});
trackingContainer.Add(logoFacade = trackingContainer.LogoFacade);
- trackingContainer.SetLogo(logo, 1.0f, 1000);
+ trackingContainer.StartTracking(logo, 1000);
}
private void waitForMove(int count = 5) => AddWaitStep("Wait for transforms to finish", count);
@@ -280,12 +279,6 @@ namespace osu.Game.Tests.Visual.UserInterface
moveLogoFacade();
}
- private void startTrackingRandom()
- {
- trackingContainer.Tracking = true;
- moveLogoFacade();
- }
-
private void moveLogoFacade()
{
if (logoFacade?.Transforms.Count == 0 && transferContainer?.Transforms.Count == 0)
@@ -304,7 +297,7 @@ namespace osu.Game.Tests.Visual.UserInterface
///
/// Check that the logo is tracking the position of the facade, with an acceptable precision lenience.
///
- public bool IsLogoTracking => Precision.AlmostEquals(Logo.Position, LogoTrackingPosition);
+ public bool IsLogoTracking => Precision.AlmostEquals(Logo.Position, ComputeLogoTrackingPosition());
}
}
}
diff --git a/osu.Game/Graphics/Containers/LogoTrackingContainer.cs b/osu.Game/Graphics/Containers/LogoTrackingContainer.cs
index 746710bcda..ae585a2ba7 100644
--- a/osu.Game/Graphics/Containers/LogoTrackingContainer.cs
+++ b/osu.Game/Graphics/Containers/LogoTrackingContainer.cs
@@ -17,29 +17,9 @@ namespace osu.Game.Graphics.Containers
{
public Facade LogoFacade { get; }
- ///
- /// Whether or not the logo assigned to this FacadeContainer should be tracking the position of its facade.
- ///
- public bool Tracking
- {
- get => tracking;
- set
- {
- if (Logo != null)
- {
- if (value && !tracking && Logo.IsTracking)
- throw new InvalidOperationException($"Cannot track an instance of {typeof(OsuLogo)} to multiple {typeof(LogoTrackingContainer)}s");
+ protected OsuLogo Logo => logo;
- Logo.IsTracking = value;
- }
-
- tracking = value;
- }
- }
-
- protected OsuLogo Logo;
-
- private float facadeScale;
+ private OsuLogo logo;
private Easing easing;
private Vector2? startPosition;
private double? startTime;
@@ -58,27 +38,38 @@ namespace osu.Game.Graphics.Containers
/// The scale of the facade. Does not actually affect the logo itself.
/// The duration of the initial transform. Default is instant.
/// The easing type of the initial transform.
- public void SetLogo(OsuLogo logo, float facadeScale = 1.0f, double duration = 0, Easing easing = Easing.None)
+ public void StartTracking(OsuLogo logo, double duration = 0, Easing easing = Easing.None)
{
- if (Logo != logo && Logo != null)
+ if (logo == null)
+ throw new ArgumentNullException(nameof(logo));
+
+ if (logo.IsTracking && tracking == false)
+ throw new InvalidOperationException($"Cannot track an instance of {typeof(OsuLogo)} to multiple {typeof(LogoTrackingContainer)}s");
+
+ if (this.logo != logo && this.logo != null)
{
// If we're replacing the logo to be tracked, the old one no longer has a tracking container
- Logo.IsTracking = false;
+ this.logo.IsTracking = false;
}
- Logo = logo ?? throw new ArgumentNullException(nameof(logo));
+ this.logo = logo;
+ this.logo.IsTracking = true;
- if (Tracking)
- {
- Logo.IsTracking = true;
- }
-
- this.facadeScale = facadeScale;
this.duration = duration;
this.easing = easing;
startTime = null;
startPosition = null;
+
+ tracking = true;
+ }
+
+ public void StopTracking()
+ {
+ if (logo != null)
+ logo.IsTracking = false;
+
+ tracking = false;
}
///
@@ -86,20 +77,27 @@ namespace osu.Game.Graphics.Containers
/// Manually performs a conversion of the Facade's position to the Logo's parent's relative space.
///
/// Will only be correct if the logo's are set to Axes.Both
- protected Vector2 LogoTrackingPosition => new Vector2(Logo.Parent.ToLocalSpace(LogoFacade.ScreenSpaceDrawQuad.Centre).X / Logo.Parent.RelativeToAbsoluteFactor.X,
- Logo.Parent.ToLocalSpace(LogoFacade.ScreenSpaceDrawQuad.Centre).Y / Logo.Parent.RelativeToAbsoluteFactor.Y);
+ protected Vector2 ComputeLogoTrackingPosition()
+ {
+ var absolutePos = Logo.Parent.ToLocalSpace(LogoFacade.ScreenSpaceDrawQuad.Centre);
+
+ return new Vector2(absolutePos.X / Logo.Parent.RelativeToAbsoluteFactor.X,
+ absolutePos.Y / Logo.Parent.RelativeToAbsoluteFactor.Y);
+ }
protected override void Update()
{
base.Update();
- if (Logo == null || !Tracking)
+ if (Logo == null || !tracking)
return;
// Account for the scale of the actual OsuLogo, as SizeForFlow only accounts for the sprite scale.
- ((ExposedFacade)LogoFacade).SetSize(new Vector2(Logo.SizeForFlow * Logo.Scale.X * facadeScale));
+ ((ExposedFacade)LogoFacade).SetSize(new Vector2(Logo.SizeForFlow * Logo.Scale.X));
- if (LogoFacade.Parent != null && Logo.Position != LogoTrackingPosition && Logo.RelativePositionAxes == Axes.Both)
+ var localPos = ComputeLogoTrackingPosition();
+
+ if (LogoFacade.Parent != null && Logo.Position != localPos && Logo.RelativePositionAxes == Axes.Both)
{
// If this is our first update since tracking has started, initialize our starting values for interpolation
if (startTime == null || startPosition == null)
@@ -115,11 +113,11 @@ namespace osu.Game.Graphics.Containers
var amount = (float)Interpolation.ApplyEasing(easing, Math.Min(elapsedDuration / duration, 1));
// Interpolate the position of the logo, where amount 0 is where the logo was when it first began interpolating, and amount 1 is the target location.
- Logo.Position = Vector2.Lerp((Vector2)startPosition, LogoTrackingPosition, amount);
+ Logo.Position = Vector2.Lerp((Vector2)startPosition, localPos, amount);
}
else
{
- Logo.Position = LogoTrackingPosition;
+ Logo.Position = localPos;
}
}
}
@@ -127,7 +125,7 @@ namespace osu.Game.Graphics.Containers
protected override void Dispose(bool isDisposing)
{
if (Logo != null)
- Tracking = false;
+ Logo.IsTracking = false;
base.Dispose(isDisposing);
}
diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs
index d042e110e9..1d2ee3c284 100644
--- a/osu.Game/Screens/Menu/ButtonSystem.cs
+++ b/osu.Game/Screens/Menu/ButtonSystem.cs
@@ -60,17 +60,17 @@ namespace osu.Game.Screens.Menu
if (this.logo != null)
{
this.logo.Action = onOsuLogo;
- logoTrackingContainer.SetLogo(logo, 0.74f);
// osuLogo.SizeForFlow relies on loading to be complete.
buttonArea.Flow.Position = new Vector2(WEDGE_WIDTH * 2 - (BUTTON_WIDTH + this.logo.SizeForFlow / 4), 0);
+ logoTrackingContainer.LogoFacade.Scale = new Vector2(0.74f);
updateLogoState();
}
else
{
// We should stop tracking as the facade is now out of scope.
- logoTrackingContainer.Tracking = false;
+ logoTrackingContainer.StopTracking();
}
}
@@ -271,7 +271,7 @@ namespace osu.Game.Screens.Menu
logoDelayedAction?.Cancel();
logoDelayedAction = Scheduler.AddDelayed(() =>
{
- logoTrackingContainer.Tracking = false;
+ logoTrackingContainer.StopTracking();
game?.Toolbar.Hide();
@@ -294,8 +294,7 @@ namespace osu.Game.Screens.Menu
if (lastState == ButtonSystemState.Initial)
logo.ScaleTo(0.5f, 200, Easing.In);
- logoTrackingContainer.SetLogo(logo, 0.74f, lastState == ButtonSystemState.EnteringMode ? 0 : 200, Easing.In);
- logoTrackingContainer.Tracking = true;
+ logoTrackingContainer.StartTracking(logo, lastState == ButtonSystemState.EnteringMode ? 0 : 200, Easing.In);
logoDelayedAction?.Cancel();
logoDelayedAction = Scheduler.AddDelayed(() =>
@@ -308,14 +307,14 @@ namespace osu.Game.Screens.Menu
break;
default:
logo.ClearTransforms(targetMember: nameof(Position));
- logoTrackingContainer.Tracking = true;
+ logoTrackingContainer.StartTracking(logo, 0, Easing.In);
logo.ScaleTo(0.5f, 200, Easing.OutQuint);
break;
}
break;
case ButtonSystemState.EnteringMode:
- logoTrackingContainer.Tracking = true;
+ logoTrackingContainer.StartTracking(logo, 0, Easing.In);
break;
}
}
diff --git a/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs b/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs
index ec7333ec02..8310ab06eb 100644
--- a/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs
+++ b/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs
@@ -29,7 +29,7 @@ namespace osu.Game.Screens.Menu
if (CentreTarget == null)
return base.OriginPosition;
- return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2;
+ return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2 * CentreTarget.Scale;
}
}
}
diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs
index f7feb3535d..4c8f9a3539 100644
--- a/osu.Game/Screens/Play/PlayerLoader.cs
+++ b/osu.Game/Screens/Play/PlayerLoader.cs
@@ -128,7 +128,7 @@ namespace osu.Game.Screens.Play
private void contentOut()
{
// Ensure the logo is no longer tracking before we scale the content
- content.Tracking = false;
+ content.StopTracking();
content.ScaleTo(0.7f, 300, Easing.InQuint);
content.FadeOut(250);
@@ -161,15 +161,13 @@ namespace osu.Game.Screens.Play
logo.ScaleTo(new Vector2(0.15f), duration, Easing.In);
logo.FadeIn(350);
- content.SetLogo(logo, 1.0f, resuming ? 0 : 500, Easing.InOutExpo);
-
- Scheduler.AddDelayed(() => { content.Tracking = true; }, resuming ? 0 : 500);
+ Scheduler.AddDelayed(() => { content.StartTracking(logo, resuming ? 0 : 500, Easing.InOutExpo); }, resuming ? 0 : 500);
}
protected override void LogoExiting(OsuLogo logo)
{
base.LogoExiting(logo);
- content.Tracking = false;
+ content.StopTracking();
}
protected override void LoadComplete()