mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Merge pull request #4443 from jorolf/screen-title-class
Add ScreenTitle class Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
4225d41a84
80
osu.Game/Graphics/UserInterface/ScreenTitle.cs
Normal file
80
osu.Game/Graphics/UserInterface/ScreenTitle.cs
Normal file
@ -0,0 +1,80 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public abstract class ScreenTitle : CompositeDrawable, IHasAccentColour
|
||||
{
|
||||
private readonly SpriteIcon iconSprite;
|
||||
private readonly OsuSpriteText titleText, pageText;
|
||||
|
||||
protected IconUsage Icon
|
||||
{
|
||||
get => iconSprite.Icon;
|
||||
set => iconSprite.Icon = value;
|
||||
}
|
||||
|
||||
protected string Title
|
||||
{
|
||||
get => titleText.Text;
|
||||
set => titleText.Text = value;
|
||||
}
|
||||
|
||||
protected string Section
|
||||
{
|
||||
get => pageText.Text;
|
||||
set => pageText.Text = value;
|
||||
}
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get => pageText.Colour;
|
||||
set => pageText.Colour = value;
|
||||
}
|
||||
|
||||
protected ScreenTitle()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Spacing = new Vector2(10, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
iconSprite = new SpriteIcon
|
||||
{
|
||||
Size = new Vector2(25),
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(6, 0),
|
||||
Children = new[]
|
||||
{
|
||||
titleText = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 25),
|
||||
},
|
||||
pageText = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 25),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -5,13 +5,10 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi
|
||||
@ -20,11 +17,11 @@ namespace osu.Game.Screens.Multi
|
||||
{
|
||||
public const float HEIGHT = 121;
|
||||
|
||||
private readonly OsuSpriteText screenType;
|
||||
private readonly HeaderBreadcrumbControl breadcrumbs;
|
||||
|
||||
public Header(ScreenStack stack)
|
||||
{
|
||||
MultiHeaderTitle title;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = HEIGHT;
|
||||
|
||||
@ -41,39 +38,11 @@ namespace osu.Game.Screens.Multi
|
||||
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
title = new MultiHeaderTitle
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Position = new Vector2(-35f, 5f),
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(10f, 0f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Size = new Vector2(25),
|
||||
Icon = OsuIcon.Multi,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "multiplayer ",
|
||||
Font = OsuFont.GetFont(size: 25)
|
||||
},
|
||||
screenType = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 25)
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
X = -35,
|
||||
},
|
||||
breadcrumbs = new HeaderBreadcrumbControl(stack)
|
||||
{
|
||||
@ -85,10 +54,10 @@ namespace osu.Game.Screens.Multi
|
||||
},
|
||||
};
|
||||
|
||||
breadcrumbs.Current.ValueChanged += scren =>
|
||||
breadcrumbs.Current.ValueChanged += screen =>
|
||||
{
|
||||
if (scren.NewValue is IMultiplayerSubScreen multiScreen)
|
||||
screenType.Text = multiScreen.ShortTitle.ToLowerInvariant();
|
||||
if (screen.NewValue is IMultiplayerSubScreen multiScreen)
|
||||
title.Screen = multiScreen;
|
||||
};
|
||||
|
||||
breadcrumbs.Current.TriggerChange();
|
||||
@ -97,10 +66,25 @@ namespace osu.Game.Screens.Multi
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
screenType.Colour = colours.Yellow;
|
||||
breadcrumbs.StripColour = colours.Green;
|
||||
}
|
||||
|
||||
private class MultiHeaderTitle : ScreenTitle
|
||||
{
|
||||
public IMultiplayerSubScreen Screen
|
||||
{
|
||||
set => Section = value.ShortTitle.ToLowerInvariant();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Title = "multiplayer";
|
||||
Icon = OsuIcon.Multi;
|
||||
AccentColour = colours.Yellow;
|
||||
}
|
||||
}
|
||||
|
||||
private class HeaderBreadcrumbControl : ScreenBreadcrumbControl
|
||||
{
|
||||
public HeaderBreadcrumbControl(ScreenStack stack)
|
||||
|
Loading…
Reference in New Issue
Block a user