Replace ScreenTitle with OverlayTitle and update titles to match new design

This commit is contained in:
TheWildTree 2020-03-24 22:08:20 +01:00
parent 127c16fccd
commit a5781d7fc5
9 changed files with 34 additions and 90 deletions

View File

@ -100,21 +100,21 @@ public ColourProvidedContainer(OverlayColourScheme colourScheme, OverlayHeader h
private class TestNoBackgroundHeader : OverlayHeader private class TestNoBackgroundHeader : OverlayHeader
{ {
protected override ScreenTitle CreateTitle() => new TestTitle(); protected override OverlayTitle CreateTitle() => new TestTitle();
} }
private class TestNoControlHeader : OverlayHeader private class TestNoControlHeader : OverlayHeader
{ {
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/changelog"); protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/changelog");
protected override ScreenTitle CreateTitle() => new TestTitle(); protected override OverlayTitle CreateTitle() => new TestTitle();
} }
private class TestStringTabControlHeader : TabControlOverlayHeader<string> private class TestStringTabControlHeader : TabControlOverlayHeader<string>
{ {
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/news"); protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/news");
protected override ScreenTitle CreateTitle() => new TestTitle(); protected override OverlayTitle CreateTitle() => new TestTitle();
protected override Drawable CreateTitleContent() => new OverlayRulesetSelector(); protected override Drawable CreateTitleContent() => new OverlayRulesetSelector();
@ -129,7 +129,7 @@ private class TestEnumTabControlHeader : TabControlOverlayHeader<TestEnum>
{ {
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/rankings"); protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/rankings");
protected override ScreenTitle CreateTitle() => new TestTitle(); protected override OverlayTitle CreateTitle() => new TestTitle();
} }
private enum TestEnum private enum TestEnum
@ -141,7 +141,7 @@ private enum TestEnum
private class TestBreadcrumbControlHeader : BreadcrumbControlOverlayHeader private class TestBreadcrumbControlHeader : BreadcrumbControlOverlayHeader
{ {
protected override ScreenTitle CreateTitle() => new TestTitle(); protected override OverlayTitle CreateTitle() => new TestTitle();
public TestBreadcrumbControlHeader() public TestBreadcrumbControlHeader()
{ {
@ -151,15 +151,13 @@ public TestBreadcrumbControlHeader()
} }
} }
private class TestTitle : ScreenTitle private class TestTitle : OverlayTitle
{ {
public TestTitle() public TestTitle()
{ {
Title = "title"; Title = "title";
Section = "section"; IconTexture = "Icons/changelog";
} }
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/changelog");
} }
} }
} }

View File

@ -1,24 +1,19 @@
// 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.
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.BeatmapListing namespace osu.Game.Overlays.BeatmapListing
{ {
public class BeatmapListingHeader : OverlayHeader public class BeatmapListingHeader : OverlayHeader
{ {
protected override ScreenTitle CreateTitle() => new BeatmapListingTitle(); protected override OverlayTitle CreateTitle() => new BeatmapListingTitle();
private class BeatmapListingTitle : ScreenTitle private class BeatmapListingTitle : OverlayTitle
{ {
public BeatmapListingTitle() public BeatmapListingTitle()
{ {
Title = @"beatmap"; Title = "beatmap listing";
Section = @"listing"; IconTexture = "Icons/changelog";
} }
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/changelog");
} }
} }
} }

View File

@ -3,7 +3,6 @@
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets; using osu.Game.Rulesets;
namespace osu.Game.Overlays.BeatmapSet namespace osu.Game.Overlays.BeatmapSet
@ -14,22 +13,20 @@ public class BeatmapSetHeader : OverlayHeader
public BeatmapRulesetSelector RulesetSelector { get; private set; } public BeatmapRulesetSelector RulesetSelector { get; private set; }
protected override ScreenTitle CreateTitle() => new BeatmapHeaderTitle(); protected override OverlayTitle CreateTitle() => new BeatmapHeaderTitle();
protected override Drawable CreateTitleContent() => RulesetSelector = new BeatmapRulesetSelector protected override Drawable CreateTitleContent() => RulesetSelector = new BeatmapRulesetSelector
{ {
Current = Ruleset Current = Ruleset
}; };
private class BeatmapHeaderTitle : ScreenTitle private class BeatmapHeaderTitle : OverlayTitle
{ {
public BeatmapHeaderTitle() public BeatmapHeaderTitle()
{ {
Title = @"beatmap"; Title = "beatmap info";
Section = @"info"; IconTexture = "Icons/changelog";
} }
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/changelog");
} }
} }
} }

View File

@ -9,7 +9,6 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Changelog namespace osu.Game.Overlays.Changelog
@ -50,8 +49,6 @@ private void load(OverlayColourProvider colourProvider)
streamsBackground.Colour = colourProvider.Background5; streamsBackground.Colour = colourProvider.Background5;
} }
private ChangelogHeaderTitle title;
private void showBuild(ValueChangedEvent<APIChangelogBuild> e) private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
{ {
if (e.OldValue != null) if (e.OldValue != null)
@ -63,14 +60,11 @@ private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
Current.Value = e.NewValue.ToString(); Current.Value = e.NewValue.ToString();
updateCurrentStream(); updateCurrentStream();
title.Version = e.NewValue.UpdateStream.DisplayName;
} }
else else
{ {
Current.Value = listing_string; Current.Value = listing_string;
Streams.Current.Value = null; Streams.Current.Value = null;
title.Version = null;
} }
} }
@ -100,7 +94,7 @@ private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
} }
}; };
protected override ScreenTitle CreateTitle() => title = new ChangelogHeaderTitle(); protected override OverlayTitle CreateTitle() => new ChangelogHeaderTitle();
public void Populate(List<APIUpdateStream> streams) public void Populate(List<APIUpdateStream> streams)
{ {
@ -116,20 +110,13 @@ private void updateCurrentStream()
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Build.Value.UpdateStream.Name); Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Build.Value.UpdateStream.Name);
} }
private class ChangelogHeaderTitle : ScreenTitle private class ChangelogHeaderTitle : OverlayTitle
{ {
public string Version
{
set => Section = value ?? listing_string;
}
public ChangelogHeaderTitle() public ChangelogHeaderTitle()
{ {
Title = "changelog"; Title = "changelog";
Version = null; IconTexture = "Icons/changelog";
} }
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/changelog");
} }
} }
} }

View File

@ -3,7 +3,6 @@
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using System; using System;
namespace osu.Game.Overlays.News namespace osu.Game.Overlays.News
@ -12,8 +11,6 @@ public class NewsHeader : BreadcrumbControlOverlayHeader
{ {
private const string front_page_string = "frontpage"; private const string front_page_string = "frontpage";
private NewsHeaderTitle title;
public readonly Bindable<string> Post = new Bindable<string>(null); public readonly Bindable<string> Post = new Bindable<string>(null);
public Action ShowFrontPage; public Action ShowFrontPage;
@ -40,36 +37,24 @@ private void showPost(ValueChangedEvent<string> e)
{ {
TabControl.AddItem(e.NewValue); TabControl.AddItem(e.NewValue);
Current.Value = e.NewValue; Current.Value = e.NewValue;
title.IsReadingPost = true;
} }
else else
{ {
Current.Value = front_page_string; Current.Value = front_page_string;
title.IsReadingPost = false;
} }
} }
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/news"); protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/news");
protected override ScreenTitle CreateTitle() => title = new NewsHeaderTitle(); protected override OverlayTitle CreateTitle() => new NewsHeaderTitle();
private class NewsHeaderTitle : ScreenTitle private class NewsHeaderTitle : OverlayTitle
{ {
private const string post_string = "post";
public bool IsReadingPost
{
set => Section = value ? post_string : front_page_string;
}
public NewsHeaderTitle() public NewsHeaderTitle()
{ {
Title = "news"; Title = "news";
IsReadingPost = false; IconTexture = "Icons/news";
} }
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/news");
} }
} }
} }

View File

@ -14,7 +14,7 @@ namespace osu.Game.Overlays
public abstract class OverlayHeader : Container public abstract class OverlayHeader : Container
{ {
private readonly Box titleBackground; private readonly Box titleBackground;
private readonly ScreenTitle title; private readonly OverlayTitle title;
protected readonly FillFlowContainer HeaderInfo; protected readonly FillFlowContainer HeaderInfo;
@ -57,7 +57,6 @@ protected OverlayHeader()
Padding = new MarginPadding Padding = new MarginPadding
{ {
Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Horizontal = UserProfileOverlay.CONTENT_X_MARGIN,
Vertical = 10,
}, },
Children = new[] Children = new[]
{ {
@ -86,7 +85,6 @@ protected OverlayHeader()
private void load(OverlayColourProvider colourProvider) private void load(OverlayColourProvider colourProvider)
{ {
titleBackground.Colour = colourProvider.Dark5; titleBackground.Colour = colourProvider.Dark5;
title.AccentColour = colourProvider.Highlight1;
} }
[NotNull] [NotNull]
@ -96,11 +94,11 @@ private void load(OverlayColourProvider colourProvider)
protected virtual Drawable CreateBackground() => Empty(); protected virtual Drawable CreateBackground() => Empty();
/// <summary> /// <summary>
/// Creates a <see cref="Drawable"/> on the opposite side of the <see cref="ScreenTitle"/>. Used mostly to create <see cref="OverlayRulesetSelector"/>. /// Creates a <see cref="Drawable"/> on the opposite side of the <see cref="OverlayTitle"/>. Used mostly to create <see cref="OverlayRulesetSelector"/>.
/// </summary> /// </summary>
[NotNull] [NotNull]
protected virtual Drawable CreateTitleContent() => Empty(); protected virtual Drawable CreateTitleContent() => Empty();
protected abstract ScreenTitle CreateTitle(); protected abstract OverlayTitle CreateTitle();
} }
} }

View File

@ -63,7 +63,7 @@ private class OverlayTitleIcon : Sprite
public OverlayTitleIcon(string textureName) public OverlayTitleIcon(string textureName)
{ {
this.textureName = textureName; this.textureName = textureName;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
@ -77,4 +77,4 @@ private void load(TextureStore textures)
} }
} }
} }
} }

View File

@ -7,7 +7,6 @@
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Profile.Header; using osu.Game.Overlays.Profile.Header;
using osu.Game.Users; using osu.Game.Users;
@ -87,19 +86,17 @@ protected override Drawable CreateBackground() =>
} }
}; };
protected override ScreenTitle CreateTitle() => new ProfileHeaderTitle(); protected override OverlayTitle CreateTitle() => new ProfileHeaderTitle();
private void updateDisplay(User user) => coverContainer.User = user; private void updateDisplay(User user) => coverContainer.User = user;
private class ProfileHeaderTitle : ScreenTitle private class ProfileHeaderTitle : OverlayTitle
{ {
public ProfileHeaderTitle() public ProfileHeaderTitle()
{ {
Title = "player"; Title = "player info";
Section = "info"; IconTexture = "Icons/profile";
} }
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/profile");
} }
} }
} }

View File

@ -3,7 +3,6 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Users; using osu.Game.Users;
@ -18,33 +17,21 @@ public class RankingsOverlayHeader : TabControlOverlayHeader<RankingsScope>
private OverlayRulesetSelector rulesetSelector; private OverlayRulesetSelector rulesetSelector;
private CountryFilter countryFilter; private CountryFilter countryFilter;
protected override ScreenTitle CreateTitle() => new RankingsTitle protected override OverlayTitle CreateTitle() => new RankingsTitle();
{
Scope = { BindTarget = Current }
};
protected override Drawable CreateTitleContent() => rulesetSelector = new OverlayRulesetSelector(); protected override Drawable CreateTitleContent() => rulesetSelector = new OverlayRulesetSelector();
protected override Drawable CreateContent() => countryFilter = new CountryFilter(); protected override Drawable CreateContent() => countryFilter = new CountryFilter();
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/rankings"); protected override Drawable CreateBackground() => new OverlayHeaderBackground("Headers/rankings");
private class RankingsTitle : ScreenTitle private class RankingsTitle : OverlayTitle
{ {
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
public RankingsTitle() public RankingsTitle()
{ {
Title = "ranking"; Title = "ranking";
IconTexture = "Icons/rankings";
} }
protected override void LoadComplete()
{
base.LoadComplete();
Scope.BindValueChanged(scope => Section = scope.NewValue.ToString().ToLowerInvariant(), true);
}
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/rankings");
} }
} }