Remove need for tracking bool and backing logo

This commit is contained in:
David Zhao 2019-04-08 16:14:41 +09:00
parent 376bed3a30
commit 8a01995668
2 changed files with 13 additions and 16 deletions

View File

@ -17,14 +17,12 @@ public class LogoTrackingContainer : Container
{
public Facade LogoFacade { get; }
protected OsuLogo Logo => logo;
protected OsuLogo Logo { get; private set; }
private OsuLogo logo;
private Easing easing;
private Vector2? startPosition;
private double? startTime;
private double duration;
private bool tracking;
public LogoTrackingContainer()
{
@ -43,33 +41,32 @@ public void StartTracking(OsuLogo logo, double duration = 0, Easing easing = Eas
if (logo == null)
throw new ArgumentNullException(nameof(logo));
if (logo.IsTracking && tracking == false)
if (logo.IsTracking && Logo == null)
throw new InvalidOperationException($"Cannot track an instance of {typeof(OsuLogo)} to multiple {typeof(LogoTrackingContainer)}s");
if (this.logo != logo && this.logo != null)
if (Logo != logo && Logo != null)
{
// If we're replacing the logo to be tracked, the old one no longer has a tracking container
this.logo.IsTracking = false;
Logo.IsTracking = false;
}
this.logo = logo;
this.logo.IsTracking = true;
Logo = logo;
Logo.IsTracking = true;
this.duration = duration;
this.easing = easing;
startTime = null;
startPosition = null;
tracking = true;
}
public void StopTracking()
{
if (logo != null)
logo.IsTracking = false;
tracking = false;
if (Logo != null)
{
Logo.IsTracking = false;
Logo = null;
}
}
/// <summary>
@ -89,7 +86,7 @@ protected override void Update()
{
base.Update();
if (Logo == null || !tracking)
if (Logo == null)
return;
// Account for the scale of the actual OsuLogo, as SizeForFlow only accounts for the sprite scale.

View File

@ -63,7 +63,6 @@ public void SetOsuLogo(OsuLogo logo)
// 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();
}
@ -106,6 +105,7 @@ public ButtonSystem()
});
buttonArea.Flow.CentreTarget = logoTrackingContainer.LogoFacade;
logoTrackingContainer.LogoFacade.Scale = new Vector2(0.74f);
}
[Resolved(CanBeNull = true)]