1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 03:02:54 +08:00

Move transitions inside ScreenFooterButton and re-use Content from base implementation instead

The point is to apply the transitions against a container that's inside of `ScreenFooterButton`, because the `ScreenFooterButton` drawable's position is being controlled by the flow container it's contained within, and we cannot apply the transitions on it directly.
This commit is contained in:
Salman Ahmed 2024-06-07 22:07:37 +03:00
parent 8c4931eeec
commit f59d94bba4
3 changed files with 115 additions and 114 deletions

View File

@ -97,11 +97,9 @@ namespace osu.Game.Screens.Footer
removedButtonsContainer.Add(oldButton); removedButtonsContainer.Add(oldButton);
if (buttons.Count > 0) if (buttons.Count > 0)
fadeButtonToLeft(oldButton, i, oldButtons.Length); makeButtonDisappearToRightAndExpire(oldButton, i, oldButtons.Length);
else else
fadeButtonToBottom(oldButton, i, oldButtons.Length); makeButtonDisappearToBottomAndExpire(oldButton, i, oldButtons.Length);
Scheduler.AddDelayed(() => oldButton.Expire(), oldButton.TopLevelContent.LatestTransformEndTime - Time.Current);
} }
for (int i = 0; i < buttons.Count; i++) for (int i = 0; i < buttons.Count; i++)
@ -123,52 +121,24 @@ namespace osu.Game.Screens.Footer
newButton.OnLoadComplete += _ => newButton.OnLoadComplete += _ =>
{ {
if (oldButtons.Length > 0) if (oldButtons.Length > 0)
fadeButtonFromRight(newButton, index, buttons.Count, 240); makeButtonAppearFromLeft(newButton, index, buttons.Count, 240);
else else
fadeButtonFromBottom(newButton, index); makeButtonAppearFromBottom(newButton, index);
}; };
} }
} }
private void fadeButtonFromRight(ScreenFooterButton button, int index, int count, float startDelay) private void makeButtonAppearFromLeft(ScreenFooterButton button, int index, int count, float startDelay)
{ => button.AppearFromLeft(startDelay + (count - index) * delay_per_button);
button.TopLevelContent
.MoveToX(-300f)
.FadeOut();
button.TopLevelContent private void makeButtonAppearFromBottom(ScreenFooterButton button, int index)
.Delay(startDelay + (count - index) * delay_per_button) => button.AppearFromBottom(index * delay_per_button);
.MoveToX(0f, 240, Easing.OutCubic)
.FadeIn(240, Easing.OutCubic);
}
private void fadeButtonFromBottom(ScreenFooterButton button, int index) private void makeButtonDisappearToRightAndExpire(ScreenFooterButton button, int index, int count)
{ => button.DisappearToRightAndExpire((count - index) * delay_per_button);
button.TopLevelContent
.MoveToY(100f)
.FadeOut();
button.TopLevelContent private void makeButtonDisappearToBottomAndExpire(ScreenFooterButton button, int index, int count)
.Delay(index * delay_per_button) => button.DisappearToBottomAndExpire((count - index) * delay_per_button);
.MoveToY(0f, 240, Easing.OutCubic)
.FadeIn(240, Easing.OutCubic);
}
private void fadeButtonToLeft(ScreenFooterButton button, int index, int count)
{
button.TopLevelContent
.Delay((count - index) * delay_per_button)
.FadeOut(240, Easing.InOutCubic)
.MoveToX(300f, 360, Easing.InOutCubic);
}
private void fadeButtonToBottom(ScreenFooterButton button, int index, int count)
{
button.TopLevelContent
.Delay((count - index) * delay_per_button)
.FadeOut(240, Easing.InOutCubic)
.MoveToY(100f, 240, Easing.InOutCubic);
}
private void showOverlay(OverlayContainer overlay) private void showOverlay(OverlayContainer overlay)
{ {

View File

@ -69,7 +69,6 @@ namespace osu.Game.Screens.Footer
private readonly Box glowBox; private readonly Box glowBox;
private readonly Box flashLayer; private readonly Box flashLayer;
public readonly Container TopLevelContent;
public readonly OverlayContainer? Overlay; public readonly OverlayContainer? Overlay;
public ScreenFooterButton(OverlayContainer? overlay = null) public ScreenFooterButton(OverlayContainer? overlay = null)
@ -78,9 +77,6 @@ namespace osu.Game.Screens.Footer
Size = new Vector2(BUTTON_WIDTH, BUTTON_HEIGHT); Size = new Vector2(BUTTON_WIDTH, BUTTON_HEIGHT);
Child = TopLevelContent = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
new Container new Container
@ -161,7 +157,6 @@ namespace osu.Game.Screens.Footer
}, },
}, },
} }
}
}; };
} }
@ -230,5 +225,41 @@ namespace osu.Game.Screens.Footer
glowBox.FadeColour(ColourInfo.GradientVertical(buttonAccentColour.Opacity(0f), buttonAccentColour.Opacity(0.2f)), 150, Easing.OutQuint); glowBox.FadeColour(ColourInfo.GradientVertical(buttonAccentColour.Opacity(0f), buttonAccentColour.Opacity(0.2f)), 150, Easing.OutQuint);
} }
public void AppearFromLeft(double delay)
{
Content.MoveToX(-300f)
.FadeOut()
.Delay(delay)
.MoveToX(0f, 240, Easing.OutCubic)
.FadeIn(240, Easing.OutCubic);
}
public void AppearFromBottom(double delay)
{
Content.MoveToY(100f)
.FadeOut()
.Delay(delay)
.MoveToY(0f, 240, Easing.OutCubic)
.FadeIn(240, Easing.OutCubic);
}
public void DisappearToRightAndExpire(double delay)
{
Content.Delay(delay)
.FadeOut(240, Easing.InOutCubic)
.MoveToX(300f, 360, Easing.InOutCubic);
this.Delay(Content.LatestTransformEndTime - Time.Current).Expire();
}
public void DisappearToBottomAndExpire(double delay)
{
Content.Delay(delay)
.FadeOut(240, Easing.InOutCubic)
.MoveToY(100f, 240, Easing.InOutCubic);
this.Delay(Content.LatestTransformEndTime - Time.Current).Expire();
}
} }
} }

View File

@ -72,7 +72,7 @@ namespace osu.Game.Screens.SelectV2.Footer
Icon = FontAwesome.Solid.ExchangeAlt; Icon = FontAwesome.Solid.ExchangeAlt;
AccentColour = colours.Lime1; AccentColour = colours.Lime1;
TopLevelContent.AddRange(new[] AddRange(new[]
{ {
unrankedBadge = new UnrankedBadge(), unrankedBadge = new UnrankedBadge(),
modDisplayBar = new Container modDisplayBar = new Container