mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 07:23:14 +08:00
Add word wrap support
This commit is contained in:
parent
8518fce4a9
commit
c44a81bdf5
@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
@ -17,6 +19,12 @@ namespace osu.Game.Tests.Visual
|
||||
[Description("PlaySongSelect leaderboard")]
|
||||
public class TestCaseLeaderboard : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] {
|
||||
typeof(Placeholder),
|
||||
typeof(MessagePlaceholder),
|
||||
typeof(RetrievalFailurePlaceholder),
|
||||
};
|
||||
|
||||
private RulesetStore rulesets;
|
||||
|
||||
private readonly FailableLeaderboard leaderboard;
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -16,6 +17,8 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
protected override SpriteText CreateSpriteText() => new OsuSpriteText();
|
||||
|
||||
public void AddArbitraryDrawable(Drawable drawable) => AddInternal(drawable);
|
||||
|
||||
public void AddIcon(FontAwesome icon, Action<SpriteText> creationParameters = null) => AddText(((char)icon).ToString(), creationParameters);
|
||||
}
|
||||
}
|
||||
|
@ -331,23 +331,4 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum LeaderboardScope
|
||||
{
|
||||
Local,
|
||||
Country,
|
||||
Global,
|
||||
Friend,
|
||||
}
|
||||
|
||||
public enum PlaceholderState
|
||||
{
|
||||
Successful,
|
||||
Retrieving,
|
||||
NetworkFailure,
|
||||
Unavailable,
|
||||
NoScores,
|
||||
NotLoggedIn,
|
||||
NotSupporter,
|
||||
}
|
||||
}
|
||||
|
10
osu.Game/Screens/Select/Leaderboards/LeaderboardScope.cs
Normal file
10
osu.Game/Screens/Select/Leaderboards/LeaderboardScope.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
public enum LeaderboardScope
|
||||
{
|
||||
Local,
|
||||
Country,
|
||||
Global,
|
||||
Friend,
|
||||
}
|
||||
}
|
@ -2,10 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
@ -15,22 +12,13 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
public MessagePlaceholder(string message)
|
||||
{
|
||||
Direction = FillDirection.Horizontal;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Children = new Drawable[]
|
||||
AddIcon(FontAwesome.fa_exclamation_circle, cp =>
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Icon = FontAwesome.fa_exclamation_circle,
|
||||
Size = new Vector2(26),
|
||||
Margin = new MarginPadding { Right = 10 },
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = this.message = message,
|
||||
TextSize = 22,
|
||||
},
|
||||
};
|
||||
cp.TextSize = TEXT_SIZE;
|
||||
cp.Padding = new MarginPadding { Right = 10 };
|
||||
});
|
||||
|
||||
AddText(this.message = message);
|
||||
}
|
||||
|
||||
public override bool Equals(Placeholder other) => (other as MessagePlaceholder)?.message == message;
|
||||
|
@ -3,16 +3,27 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
public abstract class Placeholder : FillFlowContainer, IEquatable<Placeholder>
|
||||
public abstract class Placeholder : OsuTextFlowContainer, IEquatable<Placeholder>
|
||||
{
|
||||
protected const float TEXT_SIZE = 22;
|
||||
|
||||
public override bool HandleMouseInput => true;
|
||||
|
||||
protected Placeholder()
|
||||
: base(cp => cp.TextSize = TEXT_SIZE)
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
TextAnchor = Anchor.TopCentre;
|
||||
|
||||
Padding = new MarginPadding(20);
|
||||
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
}
|
||||
|
||||
public virtual bool Equals(Placeholder other) => GetType() == other?.GetType();
|
||||
|
13
osu.Game/Screens/Select/Leaderboards/PlaceholderState.cs
Normal file
13
osu.Game/Screens/Select/Leaderboards/PlaceholderState.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
public enum PlaceholderState
|
||||
{
|
||||
Successful,
|
||||
Retrieving,
|
||||
NetworkFailure,
|
||||
Unavailable,
|
||||
NoScores,
|
||||
NotLoggedIn,
|
||||
NotSupporter,
|
||||
}
|
||||
}
|
@ -3,11 +3,9 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Screens.Select.Leaderboards
|
||||
@ -18,22 +16,13 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
public RetrievalFailurePlaceholder()
|
||||
{
|
||||
Direction = FillDirection.Horizontal;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Children = new Drawable[]
|
||||
AddArbitraryDrawable(new RetryButton
|
||||
{
|
||||
new RetryButton
|
||||
{
|
||||
Action = () => OnRetry?.Invoke(),
|
||||
Margin = new MarginPadding { Right = 10 },
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Text = @"Couldn't retrieve scores!",
|
||||
TextSize = 22,
|
||||
},
|
||||
};
|
||||
Action = () => OnRetry?.Invoke(),
|
||||
Padding = new MarginPadding { Right = 10 }
|
||||
});
|
||||
|
||||
AddText(@"Couldn't retrieve scores!");
|
||||
}
|
||||
|
||||
public class RetryButton : OsuHoverContainer
|
||||
@ -44,18 +33,16 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
public RetryButton()
|
||||
{
|
||||
Height = 26;
|
||||
Width = 26;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Child = new OsuClickableContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Action = () => Action?.Invoke(),
|
||||
Child = icon = new SpriteIcon
|
||||
{
|
||||
Icon = FontAwesome.fa_refresh,
|
||||
Size = new Vector2(26),
|
||||
Size = new Vector2(TEXT_SIZE),
|
||||
Shadow = true,
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user