Skip to content

Commit

Permalink
Merge pull request #26221 from bdach/system-title-only-on-top-level-menu
Browse files Browse the repository at this point in the history
Do not display system title in inital menu state
  • Loading branch information
peppy authored Dec 29, 2023
2 parents 9548818 + db78d73 commit 2b81f4f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
15 changes: 11 additions & 4 deletions osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,40 @@

using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Screens.Menu;
using osuTK.Input;

namespace osu.Game.Tests.Visual.Menus
{
public partial class TestSceneMainMenu : OsuGameTestScene
{
private SystemTitle systemTitle => Game.ChildrenOfType<SystemTitle>().Single();

[Test]
public void TestSystemTitle()
{
AddStep("set system title", () => Game.ChildrenOfType<SystemTitle>().Single().Current.Value = new APISystemTitle
AddStep("set system title", () => systemTitle.Current.Value = new APISystemTitle
{
Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png",
Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023",
});
AddStep("set another title", () => Game.ChildrenOfType<SystemTitle>().Single().Current.Value = new APISystemTitle
AddAssert("system title not visible", () => systemTitle.State.Value, () => Is.EqualTo(Visibility.Hidden));
AddStep("enter menu", () => InputManager.Key(Key.Enter));
AddUntilStep("system title visible", () => systemTitle.State.Value, () => Is.EqualTo(Visibility.Visible));
AddStep("set another title", () => systemTitle.Current.Value = new APISystemTitle
{
Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png",
Url = @"https://osu.ppy.sh/community/contests/189",
});
AddStep("set title with nonexistent image", () => Game.ChildrenOfType<SystemTitle>().Single().Current.Value = new APISystemTitle
AddStep("set title with nonexistent image", () => systemTitle.Current.Value = new APISystemTitle
{
Image = @"https://test.invalid/@2x", // .invalid TLD reserved by https://datatracker.ietf.org/doc/html/rfc2606#section-2
Url = @"https://osu.ppy.sh/community/contests/189",
});
AddStep("unset system title", () => Game.ChildrenOfType<SystemTitle>().Single().Current.Value = null);
AddStep("unset system title", () => systemTitle.Current.Value = null);
}
}
}
5 changes: 4 additions & 1 deletion osu.Game/Screens/Menu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public partial class MainMenu : OsuScreen, IHandlePresentBeatmap, IKeyBindingHan
private ParallaxContainer buttonsContainer;
private SongTicker songTicker;
private Container logoTarget;
private SystemTitle systemTitle;
private MenuTip menuTip;
private FillFlowContainer bottomElementsFlow;
private SupporterDisplay supporterDisplay;
Expand Down Expand Up @@ -173,7 +174,7 @@ private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
new SystemTitle
systemTitle = new SystemTitle
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Expand All @@ -196,10 +197,12 @@ private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings
case ButtonSystemState.Initial:
case ButtonSystemState.Exit:
ApplyToBackground(b => b.FadeColour(Color4.White, 500, Easing.OutSine));
systemTitle.State.Value = Visibility.Hidden;
break;
default:
ApplyToBackground(b => b.FadeColour(OsuColour.Gray(0.8f), 500, Easing.OutSine));
systemTitle.State.Value = Visibility.Visible;
break;
}
};
Expand Down
12 changes: 11 additions & 1 deletion osu.Game/Screens/Menu/SystemTitle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

namespace osu.Game.Screens.Menu
{
public partial class SystemTitle : CompositeDrawable
public partial class SystemTitle : VisibilityContainer
{
internal Bindable<APISystemTitle?> Current { get; } = new Bindable<APISystemTitle?>();

private const float transition_duration = 500;

private Container content = null!;
private CancellationTokenSource? cancellationTokenSource;
private SystemTitleImage? currentImage;
Expand All @@ -32,9 +34,13 @@ public partial class SystemTitle : CompositeDrawable
private void load(OsuGame? game)
{
AutoSizeAxes = Axes.Both;
AutoSizeDuration = transition_duration;
AutoSizeEasing = Easing.OutQuint;

InternalChild = content = new OsuClickableContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Action = () =>
{
Expand All @@ -51,6 +57,10 @@ private void load(OsuGame? game)
};
}

protected override void PopIn() => content.FadeInFromZero(transition_duration, Easing.OutQuint);

protected override void PopOut() => content.FadeOut(transition_duration, Easing.OutQuint);

protected override bool OnHover(HoverEvent e)
{
content.ScaleTo(1.05f, 2000, Easing.OutQuint);
Expand Down

0 comments on commit 2b81f4f

Please sign in to comment.