mirror of
https://github.com/ppy/osu.git
synced 2025-01-09 02:24:10 +08:00
Adjust online play header to be reusable for new daily challenge screen
This commit is contained in:
parent
19f39ca1b6
commit
d80f09e0c0
@ -1,13 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -20,10 +18,10 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
{
|
{
|
||||||
public const float HEIGHT = 80;
|
public const float HEIGHT = 80;
|
||||||
|
|
||||||
private readonly ScreenStack stack;
|
private readonly ScreenStack? stack;
|
||||||
private readonly MultiHeaderTitle title;
|
private readonly MultiHeaderTitle title;
|
||||||
|
|
||||||
public Header(string mainTitle, ScreenStack stack)
|
public Header(LocalisableString mainTitle, ScreenStack? stack)
|
||||||
{
|
{
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
|
|
||||||
@ -37,12 +35,15 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (stack != null)
|
||||||
|
{
|
||||||
// unnecessary to unbind these as this header has the same lifetime as the screen stack we are attaching to.
|
// unnecessary to unbind these as this header has the same lifetime as the screen stack we are attaching to.
|
||||||
stack.ScreenPushed += (_, _) => updateSubScreenTitle();
|
stack.ScreenPushed += (_, _) => updateSubScreenTitle();
|
||||||
stack.ScreenExited += (_, _) => updateSubScreenTitle();
|
stack.ScreenExited += (_, _) => updateSubScreenTitle();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSubScreenTitle() => title.Screen = stack.CurrentScreen as IOnlinePlaySubScreen;
|
private void updateSubScreenTitle() => title.Screen = stack?.CurrentScreen as IOnlinePlaySubScreen;
|
||||||
|
|
||||||
private partial class MultiHeaderTitle : CompositeDrawable
|
private partial class MultiHeaderTitle : CompositeDrawable
|
||||||
{
|
{
|
||||||
@ -51,13 +52,16 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
private readonly OsuSpriteText dot;
|
private readonly OsuSpriteText dot;
|
||||||
private readonly OsuSpriteText pageTitle;
|
private readonly OsuSpriteText pageTitle;
|
||||||
|
|
||||||
[CanBeNull]
|
public IOnlinePlaySubScreen? Screen
|
||||||
public IOnlinePlaySubScreen Screen
|
|
||||||
{
|
{
|
||||||
set => pageTitle.Text = value?.ShortTitle.Titleize() ?? string.Empty;
|
set
|
||||||
|
{
|
||||||
|
pageTitle.Text = value?.ShortTitle.Titleize() ?? default(LocalisableString);
|
||||||
|
dot.Alpha = pageTitle.Text == default ? 0 : 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultiHeaderTitle(string mainTitle)
|
public MultiHeaderTitle(LocalisableString mainTitle)
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
@ -82,14 +86,14 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.TorusAlternate.With(size: 24),
|
Font = OsuFont.TorusAlternate.With(size: 24),
|
||||||
Text = "·"
|
Text = "·",
|
||||||
|
Alpha = 0,
|
||||||
},
|
},
|
||||||
pageTitle = new OsuSpriteText
|
pageTitle = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.TorusAlternate.With(size: 24),
|
Font = OsuFont.TorusAlternate.With(size: 24),
|
||||||
Text = "Lounge"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user