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 @@ private void load(OsuColour colours)
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 @@ protected TestScreen()
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 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 @@ public OsuTabItem(T value) : base(value)
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 @@ public Header(Screen initialScreen)
},
};
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 @@ public class Lounge : MultiplayerScreen
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 @@ public abstract class MultiplayerScreen : OsuScreen
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 @@
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>