Move screen titles to OsuScreen

This commit is contained in:
Dean Herbert 2018-05-28 13:02:06 +09:00
parent 0ca6d73f0e
commit 02c37ebc1f
6 changed files with 15 additions and 14 deletions

View File

@ -84,12 +84,9 @@ namespace osu.Game.Tests.Visual
private abstract class TestScreen : OsuScreen
{
protected abstract string Title { get; }
protected abstract string NextTitle { get; }
protected abstract TestScreen CreateNextScreen();
public override string ToString() => Title;
public TestScreen PushNext()
{
TestScreen screen = CreateNextScreen();
@ -130,14 +127,14 @@ namespace osu.Game.Tests.Visual
private class TestScreenOne : TestScreen
{
protected override string Title => @"Screen One";
public override string Title => @"Screen One";
protected override string NextTitle => @"Two";
protected override TestScreen CreateNextScreen() => new TestScreenTwo();
}
private class TestScreenTwo : TestScreen
{
protected override string Title => @"Screen Two";
public override string Title => @"Screen Two";
protected override string NextTitle => @"One";
protected override TestScreen CreateNextScreen() => new TestScreenOne();
}

View File

@ -6,6 +6,7 @@ using System.Linq;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -157,7 +158,7 @@ namespace osu.Game.Graphics.UserInterface
Margin = new MarginPadding { Top = 5, Bottom = 5 },
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Text = (value as Enum)?.GetDescription() ?? value.ToString(),
Text = (value as IHasDescription)?.Description ?? (value as Enum)?.GetDescription() ?? value.ToString(),
TextSize = 14,
Font = @"Exo2.0-Bold", // Font should only turn bold when active?
},

View File

@ -86,7 +86,7 @@ namespace osu.Game.Screens.Multi
},
};
breadcrumbs.Current.ValueChanged += s => screenTitle.Text = s is MultiplayerScreen m ? m.Title : s.ToString();
breadcrumbs.Current.ValueChanged += s => screenTitle.Text = ((MultiplayerScreen)s).Title;
breadcrumbs.Current.TriggerChange();
}

View File

@ -26,7 +26,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge
protected readonly RoomInspector Inspector;
public override string Title => "lounge";
public override string Name => "Lounge";
protected override Container<Drawable> TransitionContent => content;
private IEnumerable<Room> rooms;

View File

@ -15,11 +15,6 @@ namespace osu.Game.Screens.Multi.Screens
protected virtual Container<Drawable> TransitionContent => Content;
public abstract string Title { get; }
public abstract string Name { get; }
public override string ToString() => Name;
protected override void OnEntering(Screen last)
{
base.OnEntering(last);

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using Microsoft.EntityFrameworkCore.Internal;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
@ -20,10 +21,17 @@ using OpenTK.Input;
namespace osu.Game.Screens
{
public abstract class OsuScreen : Screen, IKeyBindingHandler<GlobalAction>
public abstract class OsuScreen : Screen, IKeyBindingHandler<GlobalAction>, IHasDescription
{
public BackgroundScreen Background { get; private set; }
/// <summary>
/// A user-facing title for this screen.
/// </summary>
public virtual string Title => GetType().ShortDisplayName();
public string Description => Title;
protected virtual bool AllowBackButton => true;
/// <summary>