mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Apply reviews
This commit is contained in:
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
buttons = new ButtonSystem(),
|
buttons = new ButtonSystem(),
|
||||||
logo = new OsuLogo()
|
logo = new OsuLogo { RelativePositionAxes = Axes.Both }
|
||||||
};
|
};
|
||||||
|
|
||||||
buttons.SetOsuLogo(logo);
|
buttons.SetOsuLogo(logo);
|
||||||
|
@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
AddToggleStep("Toggle move continuously", b => randomPositions = b);
|
AddToggleStep("Toggle move continuously", b => randomPositions = b);
|
||||||
AddStep("Add tracking containers", addFacadeContainers);
|
AddStep("Add tracking containers", addFacadeContainers);
|
||||||
AddStep("Move facade to random position", startTrackingRandom);
|
AddStep("Move facade to random position", moveLogoFacade);
|
||||||
waitForMove();
|
waitForMove();
|
||||||
AddAssert("Logo is tracking", () => trackingContainer.IsLogoTracking);
|
AddAssert("Logo is tracking", () => trackingContainer.IsLogoTracking);
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
public void RemoveFacadeTest()
|
public void RemoveFacadeTest()
|
||||||
{
|
{
|
||||||
AddStep("Add tracking containers", addFacadeContainers);
|
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("Remove facade from FacadeContainer", removeFacade);
|
||||||
waitForMove();
|
waitForMove();
|
||||||
AddAssert("Logo is not tracking", () => !trackingContainer.IsLogoTracking);
|
AddAssert("Logo is not tracking", () => !trackingContainer.IsLogoTracking);
|
||||||
@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
public void TransferFacadeTest()
|
public void TransferFacadeTest()
|
||||||
{
|
{
|
||||||
AddStep("Add tracking containers", addFacadeContainers);
|
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("Remove facade from FacadeContainer", removeFacade);
|
||||||
AddStep("Transfer facade to a new container", () =>
|
AddStep("Transfer facade to a new container", () =>
|
||||||
{
|
{
|
||||||
@ -171,14 +171,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
AddStep("Perform logo movements", () =>
|
AddStep("Perform logo movements", () =>
|
||||||
{
|
{
|
||||||
trackingContainer.Tracking = false;
|
trackingContainer.StopTracking();
|
||||||
logo.MoveTo(new Vector2(0.5f), 500, Easing.InOutExpo);
|
logo.MoveTo(new Vector2(0.5f), 500, Easing.InOutExpo);
|
||||||
trackingContainer.SetLogo(logo, 1.0f, 1000, Easing.InOutExpo);
|
|
||||||
visualBox.Colour = Color4.White;
|
visualBox.Colour = Color4.White;
|
||||||
|
|
||||||
Scheduler.AddDelayed(() =>
|
Scheduler.AddDelayed(() =>
|
||||||
{
|
{
|
||||||
trackingContainer.Tracking = true;
|
trackingContainer.StartTracking(logo, 1000, Easing.InOutExpo);
|
||||||
visualBox.Colour = Color4.Tomato;
|
visualBox.Colour = Color4.Tomato;
|
||||||
}, 700);
|
}, 700);
|
||||||
});
|
});
|
||||||
@ -221,14 +221,13 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
failed = false;
|
failed = false;
|
||||||
newContainer = new LogoTrackingContainer();
|
newContainer = new LogoTrackingContainer();
|
||||||
addFacadeContainers();
|
addFacadeContainers();
|
||||||
startTrackingRandom();
|
moveLogoFacade();
|
||||||
newContainer.SetLogo(logo);
|
|
||||||
});
|
});
|
||||||
AddStep("Try tracking new container", () =>
|
AddStep("Try tracking new container", () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
newContainer.Tracking = true;
|
newContainer.StartTracking(logo);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -268,7 +267,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
trackingContainer.Add(logoFacade = trackingContainer.LogoFacade);
|
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);
|
private void waitForMove(int count = 5) => AddWaitStep("Wait for transforms to finish", count);
|
||||||
@ -280,12 +279,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
moveLogoFacade();
|
moveLogoFacade();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startTrackingRandom()
|
|
||||||
{
|
|
||||||
trackingContainer.Tracking = true;
|
|
||||||
moveLogoFacade();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveLogoFacade()
|
private void moveLogoFacade()
|
||||||
{
|
{
|
||||||
if (logoFacade?.Transforms.Count == 0 && transferContainer?.Transforms.Count == 0)
|
if (logoFacade?.Transforms.Count == 0 && transferContainer?.Transforms.Count == 0)
|
||||||
@ -304,7 +297,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check that the logo is tracking the position of the facade, with an acceptable precision lenience.
|
/// Check that the logo is tracking the position of the facade, with an acceptable precision lenience.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsLogoTracking => Precision.AlmostEquals(Logo.Position, LogoTrackingPosition);
|
public bool IsLogoTracking => Precision.AlmostEquals(Logo.Position, ComputeLogoTrackingPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,29 +17,9 @@ namespace osu.Game.Graphics.Containers
|
|||||||
{
|
{
|
||||||
public Facade LogoFacade { get; }
|
public Facade LogoFacade { get; }
|
||||||
|
|
||||||
/// <summary>
|
protected OsuLogo Logo => logo;
|
||||||
/// Whether or not the logo assigned to this FacadeContainer should be tracking the position of its facade.
|
|
||||||
/// </summary>
|
|
||||||
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");
|
|
||||||
|
|
||||||
Logo.IsTracking = value;
|
private OsuLogo logo;
|
||||||
}
|
|
||||||
|
|
||||||
tracking = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected OsuLogo Logo;
|
|
||||||
|
|
||||||
private float facadeScale;
|
|
||||||
private Easing easing;
|
private Easing easing;
|
||||||
private Vector2? startPosition;
|
private Vector2? startPosition;
|
||||||
private double? startTime;
|
private double? startTime;
|
||||||
@ -58,27 +38,38 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// <param name="facadeScale">The scale of the facade. Does not actually affect the logo itself.</param>
|
/// <param name="facadeScale">The scale of the facade. Does not actually affect the logo itself.</param>
|
||||||
/// <param name="duration">The duration of the initial transform. Default is instant.</param>
|
/// <param name="duration">The duration of the initial transform. Default is instant.</param>
|
||||||
/// <param name="easing">The easing type of the initial transform.</param>
|
/// <param name="easing">The easing type of the initial transform.</param>
|
||||||
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
|
// 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.duration = duration;
|
||||||
this.easing = easing;
|
this.easing = easing;
|
||||||
|
|
||||||
startTime = null;
|
startTime = null;
|
||||||
startPosition = null;
|
startPosition = null;
|
||||||
|
|
||||||
|
tracking = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopTracking()
|
||||||
|
{
|
||||||
|
if (logo != null)
|
||||||
|
logo.IsTracking = false;
|
||||||
|
|
||||||
|
tracking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -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.
|
/// Manually performs a conversion of the Facade's position to the Logo's parent's relative space.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>Will only be correct if the logo's <see cref="Drawable.RelativePositionAxes"/> are set to Axes.Both</remarks>
|
/// <remarks>Will only be correct if the logo's <see cref="Drawable.RelativePositionAxes"/> are set to Axes.Both</remarks>
|
||||||
protected Vector2 LogoTrackingPosition => new Vector2(Logo.Parent.ToLocalSpace(LogoFacade.ScreenSpaceDrawQuad.Centre).X / Logo.Parent.RelativeToAbsoluteFactor.X,
|
protected Vector2 ComputeLogoTrackingPosition()
|
||||||
Logo.Parent.ToLocalSpace(LogoFacade.ScreenSpaceDrawQuad.Centre).Y / Logo.Parent.RelativeToAbsoluteFactor.Y);
|
{
|
||||||
|
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()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (Logo == null || !Tracking)
|
if (Logo == null || !tracking)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Account for the scale of the actual OsuLogo, as SizeForFlow only accounts for the sprite scale.
|
// 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 this is our first update since tracking has started, initialize our starting values for interpolation
|
||||||
if (startTime == null || startPosition == null)
|
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));
|
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.
|
// 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
|
else
|
||||||
{
|
{
|
||||||
Logo.Position = LogoTrackingPosition;
|
Logo.Position = localPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,7 +125,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
if (Logo != null)
|
if (Logo != null)
|
||||||
Tracking = false;
|
Logo.IsTracking = false;
|
||||||
|
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
}
|
}
|
||||||
|
@ -60,17 +60,17 @@ namespace osu.Game.Screens.Menu
|
|||||||
if (this.logo != null)
|
if (this.logo != null)
|
||||||
{
|
{
|
||||||
this.logo.Action = onOsuLogo;
|
this.logo.Action = onOsuLogo;
|
||||||
logoTrackingContainer.SetLogo(logo, 0.74f);
|
|
||||||
|
|
||||||
// osuLogo.SizeForFlow relies on loading to be complete.
|
// osuLogo.SizeForFlow relies on loading to be complete.
|
||||||
buttonArea.Flow.Position = new Vector2(WEDGE_WIDTH * 2 - (BUTTON_WIDTH + this.logo.SizeForFlow / 4), 0);
|
buttonArea.Flow.Position = new Vector2(WEDGE_WIDTH * 2 - (BUTTON_WIDTH + this.logo.SizeForFlow / 4), 0);
|
||||||
|
logoTrackingContainer.LogoFacade.Scale = new Vector2(0.74f);
|
||||||
|
|
||||||
updateLogoState();
|
updateLogoState();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We should stop tracking as the facade is now out of scope.
|
// 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?.Cancel();
|
||||||
logoDelayedAction = Scheduler.AddDelayed(() =>
|
logoDelayedAction = Scheduler.AddDelayed(() =>
|
||||||
{
|
{
|
||||||
logoTrackingContainer.Tracking = false;
|
logoTrackingContainer.StopTracking();
|
||||||
|
|
||||||
game?.Toolbar.Hide();
|
game?.Toolbar.Hide();
|
||||||
|
|
||||||
@ -294,8 +294,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
if (lastState == ButtonSystemState.Initial)
|
if (lastState == ButtonSystemState.Initial)
|
||||||
logo.ScaleTo(0.5f, 200, Easing.In);
|
logo.ScaleTo(0.5f, 200, Easing.In);
|
||||||
|
|
||||||
logoTrackingContainer.SetLogo(logo, 0.74f, lastState == ButtonSystemState.EnteringMode ? 0 : 200, Easing.In);
|
logoTrackingContainer.StartTracking(logo, lastState == ButtonSystemState.EnteringMode ? 0 : 200, Easing.In);
|
||||||
logoTrackingContainer.Tracking = true;
|
|
||||||
|
|
||||||
logoDelayedAction?.Cancel();
|
logoDelayedAction?.Cancel();
|
||||||
logoDelayedAction = Scheduler.AddDelayed(() =>
|
logoDelayedAction = Scheduler.AddDelayed(() =>
|
||||||
@ -308,14 +307,14 @@ namespace osu.Game.Screens.Menu
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logo.ClearTransforms(targetMember: nameof(Position));
|
logo.ClearTransforms(targetMember: nameof(Position));
|
||||||
logoTrackingContainer.Tracking = true;
|
logoTrackingContainer.StartTracking(logo, 0, Easing.In);
|
||||||
logo.ScaleTo(0.5f, 200, Easing.OutQuint);
|
logo.ScaleTo(0.5f, 200, Easing.OutQuint);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ButtonSystemState.EnteringMode:
|
case ButtonSystemState.EnteringMode:
|
||||||
logoTrackingContainer.Tracking = true;
|
logoTrackingContainer.StartTracking(logo, 0, Easing.In);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
if (CentreTarget == null)
|
if (CentreTarget == null)
|
||||||
return base.OriginPosition;
|
return base.OriginPosition;
|
||||||
|
|
||||||
return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2;
|
return CentreTarget.DrawPosition + CentreTarget.DrawSize / 2 * CentreTarget.Scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private void contentOut()
|
private void contentOut()
|
||||||
{
|
{
|
||||||
// Ensure the logo is no longer tracking before we scale the content
|
// 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.ScaleTo(0.7f, 300, Easing.InQuint);
|
||||||
content.FadeOut(250);
|
content.FadeOut(250);
|
||||||
@ -161,15 +161,13 @@ namespace osu.Game.Screens.Play
|
|||||||
logo.ScaleTo(new Vector2(0.15f), duration, Easing.In);
|
logo.ScaleTo(new Vector2(0.15f), duration, Easing.In);
|
||||||
logo.FadeIn(350);
|
logo.FadeIn(350);
|
||||||
|
|
||||||
content.SetLogo(logo, 1.0f, resuming ? 0 : 500, Easing.InOutExpo);
|
Scheduler.AddDelayed(() => { content.StartTracking(logo, resuming ? 0 : 500, Easing.InOutExpo); }, resuming ? 0 : 500);
|
||||||
|
|
||||||
Scheduler.AddDelayed(() => { content.Tracking = true; }, resuming ? 0 : 500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LogoExiting(OsuLogo logo)
|
protected override void LogoExiting(OsuLogo logo)
|
||||||
{
|
{
|
||||||
base.LogoExiting(logo);
|
base.LogoExiting(logo);
|
||||||
content.Tracking = false;
|
content.StopTracking();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
Reference in New Issue
Block a user