1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-23 16:27:20 +08:00

Centralise fetching of overlay component titles and textures

This commit is contained in:
Dean Herbert 2020-09-03 15:46:56 +09:00
parent 19de6124b6
commit dceae21bbf
32 changed files with 98 additions and 95 deletions

View File

@ -12,7 +12,8 @@ namespace osu.Game.Overlays.BeatmapListing
public BeatmapListingTitle()
{
Title = "beatmap listing";
IconTexture = "Icons/changelog";
Description = "Browse for new beatmaps";
IconTexture = "Icons/Hexacons/music";
}
}
}

View File

@ -24,7 +24,9 @@ namespace osu.Game.Overlays
public const float X_PADDING = 40;
public const float Y_PADDING = 25;
public const float RIGHT_WIDTH = 275;
protected readonly Header Header;
//todo: should be an OverlayHeader? or maybe not?
protected new readonly Header Header;
[Resolved]
private RulesetStore rulesets { get; set; }

View File

@ -115,6 +115,7 @@ namespace osu.Game.Overlays.Changelog
public ChangelogHeaderTitle()
{
Title = "changelog";
Description = "Track recent dev updates in the osu! ecosystem";
IconTexture = "Icons/changelog";
}
}

View File

@ -25,10 +25,10 @@ namespace osu.Game.Overlays
{
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
protected ChangelogHeader Header;
private Container<ChangelogContent> content;
protected new ChangelogHeader Header;
private SampleChannel sampleBack;
private List<APIChangelogBuild> builds;
@ -61,9 +61,10 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
Header = new ChangelogHeader
base.Header = Header = new ChangelogHeader
{
ListingSelected = ShowListing,
Build = { BindTarget = Current }
},
content = new Container<ChangelogContent>
{
@ -77,8 +78,6 @@ namespace osu.Game.Overlays
sampleBack = audio.Samples.Get(@"UI/generic-select-soft");
Header.Build.BindTo(Current);
Current.BindValueChanged(e =>
{
if (e.NewValue != null)

View File

@ -26,8 +26,12 @@ using osu.Framework.Graphics.Sprites;
namespace osu.Game.Overlays
{
public class ChatOverlay : OsuFocusedOverlayContainer
public class ChatOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent
{
public string IconTexture => "Icons/chat";
public string Title => "Chat";
public string Description => "Join the real-time discussion";
private const float textbox_height = 60;
private const float channel_selection_min_height = 0.3f;

View File

@ -12,7 +12,8 @@ namespace osu.Game.Overlays.Dashboard
public DashboardTitle()
{
Title = "dashboard";
IconTexture = "Icons/changelog";
Description = "View your friends and other top level information";
IconTexture = "Icons/hexacons/dashboard";
}
}
}

View File

@ -50,7 +50,7 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
header = new DashboardOverlayHeader
Header = header = new DashboardOverlayHeader
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,

View File

@ -12,8 +12,14 @@ using osuTK.Graphics;
namespace osu.Game.Overlays
{
public abstract class FullscreenOverlay : WaveOverlayContainer, IOnlineComponent
public abstract class FullscreenOverlay : WaveOverlayContainer, IOnlineComponent, INamedOverlayComponent
{
public virtual string IconTexture => Header?.Title.IconTexture ?? string.Empty;
public virtual string Title => Header?.Title.Title ?? string.Empty;
public virtual string Description => Header?.Title.Description ?? string.Empty;
public OverlayHeader Header { get; protected set; }
[Resolved]
protected IAPIProvider API { get; private set; }

View File

@ -0,0 +1,14 @@
// 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.
namespace osu.Game.Overlays
{
public interface INamedOverlayComponent
{
string IconTexture { get; }
string Title { get; }
string Description { get; }
}
}

View File

@ -57,6 +57,7 @@ namespace osu.Game.Overlays.News
public NewsHeaderTitle()
{
Title = "news";
Description = "Get up-to-date on community happenings";
IconTexture = "Icons/news";
}
}

View File

@ -19,7 +19,6 @@ namespace osu.Game.Overlays
private Container content;
private LoadingLayer loading;
private NewsHeader header;
private OverlayScrollContainer scrollFlow;
public NewsOverlay()
@ -48,7 +47,7 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
header = new NewsHeader
Header = new NewsHeader
{
ShowFrontPage = ShowFrontPage
},
@ -110,6 +109,8 @@ namespace osu.Game.Overlays
cancellationToken?.Cancel();
loading.Show();
var header = (NewsHeader)Header;
if (e.NewValue == null)
{
header.SetFrontPage();

View File

@ -16,8 +16,12 @@ using osu.Framework.Threading;
namespace osu.Game.Overlays
{
public class NotificationOverlay : OsuFocusedOverlayContainer
public class NotificationOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent
{
public string IconTexture => "Icons/Hexacons/";
public string Title => "Notifications";
public string Description => "Waiting for 'ya";
private const float width = 320;
public const float TRANSITION_LENGTH = 600;

View File

@ -25,8 +25,12 @@ using osuTK.Graphics;
namespace osu.Game.Overlays
{
public class NowPlayingOverlay : OsuFocusedOverlayContainer
public class NowPlayingOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent
{
public string IconTexture => "Icons/Hexacons/music";
public string Title => "Now playing";
public string Description => "Manage the currently playing track";
private const float player_height = 130;
private const float transition_length = 800;
private const float progress_height = 10;

View File

@ -12,6 +12,8 @@ namespace osu.Game.Overlays
{
public abstract class OverlayHeader : Container
{
public OverlayTitle Title { get; }
private float contentSidePadding;
/// <summary>
@ -73,7 +75,7 @@ namespace osu.Game.Overlays
AutoSizeAxes = Axes.Y,
Children = new[]
{
CreateTitle().With(title =>
Title = CreateTitle().With(title =>
{
title.Anchor = Anchor.CentreLeft;
title.Origin = Anchor.CentreLeft;

View File

@ -12,19 +12,27 @@ using osuTK;
namespace osu.Game.Overlays
{
public abstract class OverlayTitle : CompositeDrawable
public abstract class OverlayTitle : CompositeDrawable, INamedOverlayComponent
{
private readonly OsuSpriteText title;
private readonly OsuSpriteText titleText;
private readonly Container icon;
protected string Title
private string title;
public string Title
{
set => title.Text = value;
get => title;
protected set => titleText.Text = title = value;
}
protected string IconTexture
public string Description { get; protected set; }
private string iconTexture;
public string IconTexture
{
set => icon.Child = new OverlayTitleIcon(value);
get => iconTexture;
protected set => icon.Child = new OverlayTitleIcon(iconTexture = value);
}
protected OverlayTitle()
@ -45,7 +53,7 @@ namespace osu.Game.Overlays
Margin = new MarginPadding { Horizontal = 5 }, // compensates for osu-web sprites having around 5px of whitespace on each side
Size = new Vector2(30)
},
title = new OsuSpriteText
titleText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -30,6 +30,7 @@ namespace osu.Game.Overlays.Rankings
public RankingsTitle()
{
Title = "ranking";
Description = "Find out who's the best right now";
IconTexture = "Icons/rankings";
}
}

View File

@ -55,7 +55,7 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
header = new RankingsOverlayHeader
Header = header = new RankingsOverlayHeader
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,

View File

@ -29,7 +29,7 @@ namespace osu.Game.Overlays.SearchableList
{
private readonly Container scrollContainer;
protected readonly SearchableListHeader<THeader> Header;
protected new readonly SearchableListHeader<THeader> Header;
protected readonly SearchableListFilterControl<TTab, TCategory> Filter;
protected readonly FillFlowContainer ScrollFlow;

View File

@ -13,8 +13,12 @@ using osu.Framework.Bindables;
namespace osu.Game.Overlays
{
public class SettingsOverlay : SettingsPanel
public class SettingsOverlay : SettingsPanel, INamedOverlayComponent
{
public string IconTexture => "Icons/Hexacons/settings";
public string Title => "Settings";
public string Description => "Change your settings";
protected override IEnumerable<SettingsSection> CreateSections() => new SettingsSection[]
{
new GeneralSection(),

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar
@ -11,10 +10,6 @@ namespace osu.Game.Overlays.Toolbar
{
public ToolbarBeatmapListingButton()
{
SetIcon(OsuIcon.ChevronDownCircle);
TooltipMain = "Beatmap listing";
TooltipSub = "Browse for new beatmaps";
Hotkey = GlobalAction.ToggleDirect;
}

View File

@ -35,17 +35,6 @@ namespace osu.Game.Overlays.Toolbar
IconContainer.Show();
}
public void SetIcon(IconUsage icon) => SetIcon(new SpriteIcon
{
Size = new Vector2(20),
Icon = icon
});
public IconUsage Icon
{
set => SetIcon(value);
}
public string Text
{
get => DrawableText.Text;

View File

@ -2,19 +2,11 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Overlays.Toolbar
{
public class ToolbarChangelogButton : ToolbarOverlayToggleButton
{
public ToolbarChangelogButton()
{
SetIcon(FontAwesome.Solid.Bullhorn);
TooltipMain = "Changelog";
TooltipSub = "Track recent dev updates in the osu! ecosystem";
}
[BackgroundDependencyLoader(true)]
private void load(ChangelogOverlay changelog)
{

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar
@ -11,10 +10,6 @@ namespace osu.Game.Overlays.Toolbar
{
public ToolbarChatButton()
{
SetIcon(FontAwesome.Solid.Comments);
TooltipMain = "Chat";
TooltipSub = "Join the real-time discussion";
Hotkey = GlobalAction.ToggleChat;
}

View File

@ -1,7 +1,6 @@
// 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.Sprites;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar
@ -10,7 +9,7 @@ namespace osu.Game.Overlays.Toolbar
{
public ToolbarHomeButton()
{
Icon = FontAwesome.Solid.Home;
// todo: icon
TooltipMain = "Home";
TooltipSub = "Return to the main menu";

View File

@ -3,7 +3,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar
@ -14,10 +13,6 @@ namespace osu.Game.Overlays.Toolbar
public ToolbarMusicButton()
{
Icon = FontAwesome.Solid.Music;
TooltipMain = "Now playing";
TooltipSub = "Manage the currently playing track";
Hotkey = GlobalAction.ToggleNowPlaying;
}

View File

@ -2,19 +2,11 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Overlays.Toolbar
{
public class ToolbarNewsButton : ToolbarOverlayToggleButton
{
public ToolbarNewsButton()
{
Icon = FontAwesome.Solid.Newspaper;
TooltipMain = "News";
TooltipSub = "Get up-to-date on community happenings";
}
[BackgroundDependencyLoader(true)]
private void load(NewsOverlay news)
{

View File

@ -6,7 +6,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings;
@ -25,10 +24,6 @@ namespace osu.Game.Overlays.Toolbar
public ToolbarNotificationButton()
{
Icon = FontAwesome.Solid.Bars;
TooltipMain = "Notifications";
TooltipSub = "Waiting for 'ya";
Hotkey = GlobalAction.ToggleNotifications;
Add(countDisplay = new CountCircle

View File

@ -1,11 +1,14 @@
// 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.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
namespace osu.Game.Overlays.Toolbar
@ -18,6 +21,9 @@ namespace osu.Game.Overlays.Toolbar
private readonly Bindable<Visibility> overlayState = new Bindable<Visibility>();
[Resolved]
private TextureStore textures { get; set; }
public OverlayContainer StateContainer
{
get => stateContainer;
@ -32,6 +38,16 @@ namespace osu.Game.Overlays.Toolbar
Action = stateContainer.ToggleVisibility;
overlayState.BindTo(stateContainer.State);
}
if (stateContainer is INamedOverlayComponent named)
{
TooltipMain = named.Title;
TooltipSub = named.Description;
SetIcon(new Sprite
{
Texture = textures.Get(named.IconTexture),
});
}
}
}

View File

@ -2,19 +2,11 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Overlays.Toolbar
{
public class ToolbarRankingsButton : ToolbarOverlayToggleButton
{
public ToolbarRankingsButton()
{
SetIcon(FontAwesome.Regular.ChartBar);
TooltipMain = "Ranking";
TooltipSub = "Find out who's the best right now";
}
[BackgroundDependencyLoader(true)]
private void load(RankingsOverlay rankings)
{

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar
@ -11,10 +10,6 @@ namespace osu.Game.Overlays.Toolbar
{
public ToolbarSettingsButton()
{
Icon = FontAwesome.Solid.Cog;
TooltipMain = "Settings";
TooltipSub = "Change your settings";
Hotkey = GlobalAction.ToggleSettings;
}

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar
@ -11,10 +10,6 @@ namespace osu.Game.Overlays.Toolbar
{
public ToolbarSocialButton()
{
Icon = FontAwesome.Solid.Users;
TooltipMain = "Friends";
TooltipSub = "Interact with those close to you";
Hotkey = GlobalAction.ToggleSocial;
}

View File

@ -22,7 +22,7 @@ namespace osu.Game.Overlays
private ProfileSection lastSection;
private ProfileSection[] sections;
private GetUserRequest userReq;
protected ProfileHeader Header;
protected new ProfileHeader Header;
private ProfileSectionsContainer sectionsContainer;
private ProfileSectionTabControl tabs;
@ -77,7 +77,7 @@ namespace osu.Game.Overlays
Add(sectionsContainer = new ProfileSectionsContainer
{
ExpandableHeader = Header = new ProfileHeader(),
ExpandableHeader = base.Header = Header = new ProfileHeader(),
FixedHeader = tabs,
HeaderBackground = new Box
{