mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
add ScreenTitle class
This commit is contained in:
73
osu.Game/Graphics/UserInterface/ScreenTitle.cs
Normal file
73
osu.Game/Graphics/UserInterface/ScreenTitle.cs
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// 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.Game.Graphics.Sprites;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
{
|
||||||
|
public class ScreenTitle : CompositeDrawable, IHasAccentColour
|
||||||
|
{
|
||||||
|
private readonly SpriteIcon iconSprite;
|
||||||
|
private readonly OsuSpriteText titleText, pageText;
|
||||||
|
|
||||||
|
public FontAwesome Icon
|
||||||
|
{
|
||||||
|
get => iconSprite.Icon;
|
||||||
|
set => iconSprite.Icon = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Title
|
||||||
|
{
|
||||||
|
get => titleText.Text;
|
||||||
|
set => titleText.Text = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Page
|
||||||
|
{
|
||||||
|
get => pageText.Text;
|
||||||
|
set => pageText.Text = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color4 AccentColour
|
||||||
|
{
|
||||||
|
get => pageText.Colour;
|
||||||
|
set => pageText.Colour = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScreenTitle()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
iconSprite = new SpriteIcon
|
||||||
|
{
|
||||||
|
Size = new Vector2(25),
|
||||||
|
Anchor = Anchor.TopLeft,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
Margin = new MarginPadding { Right = 10 },
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
titleText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.GetFont(size: 25),
|
||||||
|
},
|
||||||
|
pageText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.GetFont(size: 25),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,10 +7,8 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
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.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.SearchableList;
|
using osu.Game.Overlays.SearchableList;
|
||||||
using osuTK;
|
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Multi
|
namespace osu.Game.Screens.Multi
|
||||||
@ -19,7 +17,7 @@ namespace osu.Game.Screens.Multi
|
|||||||
{
|
{
|
||||||
public const float HEIGHT = 121;
|
public const float HEIGHT = 121;
|
||||||
|
|
||||||
private readonly OsuSpriteText screenType;
|
private readonly ScreenTitle title;
|
||||||
private readonly HeaderBreadcrumbControl breadcrumbs;
|
private readonly HeaderBreadcrumbControl breadcrumbs;
|
||||||
|
|
||||||
public Header(ScreenStack stack)
|
public Header(ScreenStack stack)
|
||||||
@ -40,39 +38,12 @@ namespace osu.Game.Screens.Multi
|
|||||||
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING },
|
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new FillFlowContainer
|
title = new ScreenTitle
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Position = new Vector2(-35f, 5f),
|
Icon = FontAwesome.fa_osu_multi,
|
||||||
AutoSizeAxes = Axes.Both,
|
Title = "multiplayer ",
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Spacing = new Vector2(10f, 0f),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new SpriteIcon
|
|
||||||
{
|
|
||||||
Size = new Vector2(25),
|
|
||||||
Icon = FontAwesome.fa_osu_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)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
breadcrumbs = new HeaderBreadcrumbControl(stack)
|
breadcrumbs = new HeaderBreadcrumbControl(stack)
|
||||||
{
|
{
|
||||||
@ -87,7 +58,7 @@ namespace osu.Game.Screens.Multi
|
|||||||
breadcrumbs.Current.ValueChanged += scren =>
|
breadcrumbs.Current.ValueChanged += scren =>
|
||||||
{
|
{
|
||||||
if (scren.NewValue is IMultiplayerSubScreen multiScreen)
|
if (scren.NewValue is IMultiplayerSubScreen multiScreen)
|
||||||
screenType.Text = multiScreen.ShortTitle.ToLowerInvariant();
|
title.Page = multiScreen.ShortTitle.ToLowerInvariant();
|
||||||
};
|
};
|
||||||
|
|
||||||
breadcrumbs.Current.TriggerChange();
|
breadcrumbs.Current.TriggerChange();
|
||||||
@ -96,7 +67,7 @@ namespace osu.Game.Screens.Multi
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
screenType.Colour = colours.Yellow;
|
title.AccentColour = colours.Yellow;
|
||||||
breadcrumbs.StripColour = colours.Green;
|
breadcrumbs.StripColour = colours.Green;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user