1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 17:52:56 +08:00
This commit is contained in:
HoutarouOreki 2018-07-18 15:17:20 +02:00
parent 6baa761b9c
commit 837747e35f
6 changed files with 56 additions and 28 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual
@ -12,6 +13,7 @@ namespace osu.Game.Tests.Visual
private ChangelogOverlay changelog;
private int releaseStreamCount;
private int index;
private void indexIncrement() => index = (index == releaseStreamCount - 1) ? 0 : index + 1;
protected override void LoadComplete()
{
@ -22,16 +24,46 @@ namespace osu.Game.Tests.Visual
releaseStreamCount = changelog.streams.badgesContainer.Children.Count;
AddStep(@"Show", changelog.Show);
AddRepeatStep(@"Toggle Release Stream", () => {
AddRepeatStep(@"Toggle Release Stream", () =>
{
changelog.streams.badgesContainer.Children[index].Activate();
index = (index == releaseStreamCount - 1) ? 0 : index + 1;
indexIncrement();
}, releaseStreamCount);
AddStep(@"Listing", changelog.header.ActivateListing);
AddStep(@"Listing", changelog.ActivateListing);
AddStep(@"Hide", changelog.Hide);
AddWaitStep(4);
AddStep(@"Show with Release Stream", () =>
{
changelog.streams.badgesContainer.Children[index].Activate();
changelog.Show();
indexIncrement();
});
AddWaitStep(4);
AddStep(@"Hide", changelog.Hide);
AddWaitStep(4);
AddStep(@"Show with listing", () =>
{
// .maybe changelog should have a function that does header.ActivateListing()
changelog.ActivateListing();
changelog.Show();
});
AddWaitStep(4);
AddStep(@"Hide", changelog.Hide);
AddWaitStep(4);
AddStep(@"Activate release", () =>
{
changelog.streams.badgesContainer.Children[index].Activate();
indexIncrement();
});
AddStep(@"Show with listing", () =>
{
changelog.ActivateListing();
changelog.Show();
});
}
public TestCaseChangelog()
{
}
}
}

View File

@ -133,7 +133,9 @@ namespace osu.Game.Overlays.Changelog
{
Top = 10,
Left = 7,
Right = 9,
// + chevron size, and account for gained space on left by
// listing's font draw width being smaller
Right = 18,
Bottom = 15,
},
Children = new Drawable[]

View File

@ -37,18 +37,10 @@ namespace osu.Game.Overlays.Changelog.Header
public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic)
{
if (!string.IsNullOrEmpty(displayText))
{
text.Text = displayText;
}
lineBadge.IsCollapsed = false;
if (!string.IsNullOrEmpty(displayText)) text.Text = displayText;
text.MoveToY(0, duration, easing)
.FadeIn(duration, easing)
.Finally(d => {
// waiting until text is drawn to use its DrawWidth
UpdateBadgeWidth();
lineBadge.IsCollapsed = false;
});
.FadeIn(duration, easing);
}
/// <param name="duration">
@ -61,19 +53,15 @@ namespace osu.Game.Overlays.Changelog.Header
.FadeOut(duration, easing)
.Then()
.MoveToY(0, duration, easing)
.FadeIn(duration, easing)
.OnComplete(dd => {
UpdateBadgeWidth();
lineBadge.IsCollapsed = false;
});
.FadeIn(duration, easing);
// since using .finally/.oncomplete after first fadeout made the badge
// not hide sometimes in visual tests(because FinishTransforms()/CancelTransforms()
// didn't apply to transforms that come after the .finally), I'm using a scheduler here
Scheduler.AddDelayed(() =>
{
//lineBadge.ResizeWidthTo(0); // resizes when not visible
if (!string.IsNullOrEmpty(displayText)) text.Text = displayText;
lineBadge.IsCollapsed = false;
}, duration);
}
@ -93,13 +81,13 @@ namespace osu.Game.Overlays.Changelog.Header
{
Top = 5,
Bottom = 15,
Left = 10,
Right = 10,
}
},
lineBadge = new LineBadge(startCollapsed)
{
Width = 1,
Colour = badgeColour,
RelativeSizeAxes = Axes.X,
}
};
}
@ -115,7 +103,5 @@ namespace osu.Game.Overlays.Changelog.Header
lineBadge.IsCollapsed = false;
text.Font = "Exo2.0-Bold";
}
public void UpdateBadgeWidth() => lineBadge.ResizeWidthTo(text.DrawWidth);
}
}

View File

@ -19,6 +19,11 @@ namespace osu.Game.Overlays.Changelog.Header
text.Anchor = Anchor.TopCentre;
text.Origin = Anchor.TopCentre;
// I'm using this for constant badge width here, so that the whole
// thing doesn't jump left/right when listing's size changes
// due to different font weight (and thus width)
lineBadge.RelativeSizeAxes = Axes.None;
// this doesn't work without the scheduler
// (because the text isn't yet fully drawn when it's loaded?)
text.OnLoadComplete = d => Scheduler.Add(UpdateBadgeWidth);
@ -57,5 +62,7 @@ namespace osu.Game.Overlays.Changelog.Header
if (lineBadge.IsCollapsed) lineBadge.ResizeHeightTo(1, lineBadge.TransitionDuration);
base.OnHoverLost(state);
}
public void UpdateBadgeWidth() => lineBadge.ResizeWidthTo(text.DrawWidth);
}
}

View File

@ -12,7 +12,6 @@ namespace osu.Game.Overlays.Changelog.Header
public TextBadgePairRelease(ColourInfo badgeColour, string displayText) : base(badgeColour, displayText)
{
this.listingBadge = listingBadge;
text.Font = "Exo2.0-Bold";
text.Y = 20;
text.Alpha = 0;

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays
{
private readonly ScrollContainer scroll;
public readonly ChangelogHeader header;
private ChangelogHeader header;
public readonly ChangelogStreams streams;
protected Color4 purple = new Color4(191, 4, 255, 255);
@ -87,6 +87,8 @@ namespace osu.Game.Overlays
};
}
public void ActivateListing() => header.ActivateListing();
// receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;