Merge branch 'master' into fix-notes-test-scene

This commit is contained in:
Dan Balasescu
2019-09-10 18:39:44 +09:00
committed by GitHub
13 changed files with 177 additions and 49 deletions

View File

@ -63,6 +63,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.904.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2019.904.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.905.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2019.909.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -79,7 +79,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
return null; return null;
case OsuSkinComponents.HitCircleText: case OsuSkinComponents.HitCircleText:
var font = GetConfig<OsuSkinConfiguration, string>(OsuSkinConfiguration.HitCircleFont)?.Value ?? "default"; var font = GetConfig<OsuSkinConfiguration, string>(OsuSkinConfiguration.HitCirclePrefix)?.Value ?? "default";
var overlap = GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.HitCircleOverlap)?.Value ?? 0; var overlap = GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.HitCircleOverlap)?.Value ?? 0;
return !hasFont(font) return !hasFont(font)

View File

@ -5,7 +5,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
{ {
public enum OsuSkinConfiguration public enum OsuSkinConfiguration
{ {
HitCircleFont, HitCirclePrefix,
HitCircleOverlap, HitCircleOverlap,
SliderBorderSize, SliderBorderSize,
SliderPathRadius, SliderPathRadius,

View File

@ -0,0 +1,108 @@
// 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 System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Chat;
using osu.Game.Overlays.Chat;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.Online
{
[TestFixture]
public class TestSceneChatLineTruncation : OsuTestScene
{
private readonly TestChatLineContainer textContainer;
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ChatLine),
typeof(Message),
typeof(LinkFlowContainer),
typeof(MessageFormatter)
};
public TestSceneChatLineTruncation()
{
Add(textContainer = new TestChatLineContainer
{
Padding = new MarginPadding { Left = 20, Right = 20 },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
});
}
[BackgroundDependencyLoader]
private void load()
{
testFormatting();
}
private void clear() => AddStep("clear messages", textContainer.Clear);
private void addMessageWithChecks(string text, bool isAction = false, bool isImportant = false, string username = null)
{
int index = textContainer.Count + 1;
var newLine = new ChatLine(new DummyMessage(text, isAction, isImportant, index, username));
textContainer.Add(newLine);
}
private void testFormatting()
{
for (int a = 0; a < 25; a++)
addMessageWithChecks($"Wide {a} character username.", username: new string('w', a));
addMessageWithChecks("Short name with spaces.", username: "sho rt name");
addMessageWithChecks("Long name with spaces.", username: "long name with s p a c e s");
}
private class DummyMessage : Message
{
private static long messageCounter;
internal static readonly User TEST_SENDER_BACKGROUND = new User
{
Username = @"i-am-important",
Id = 42,
Colour = "#250cc9",
};
internal static readonly User TEST_SENDER = new User
{
Username = @"Somebody",
Id = 1,
};
public new DateTimeOffset Timestamp = DateTimeOffset.Now;
public DummyMessage(string text, bool isAction = false, bool isImportant = false, int number = 0, string username = null)
: base(messageCounter++)
{
Content = text;
IsAction = isAction;
Sender = new User
{
Username = username ?? $"user {number}",
Id = number,
Colour = isImportant ? "#250cc9" : null,
};
}
}
private class TestChatLineContainer : FillFlowContainer<ChatLine>
{
protected override int Compare(Drawable x, Drawable y)
{
var xC = (ChatLine)x;
var yC = (ChatLine)y;
return xC.Message.CompareTo(yC.Message);
}
}
}
}

View File

@ -9,6 +9,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
using osu.Game.Tests.Beatmaps;
using osuTK; using osuTK;
namespace osu.Game.Tests.Visual.SongSelect namespace osu.Game.Tests.Visual.SongSelect
@ -30,14 +31,14 @@ namespace osu.Game.Tests.Visual.SongSelect
Size = new Vector2(550f, 450f), Size = new Vector2(550f, 450f),
}); });
AddStep("all metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null) AddStep("all metrics", () => detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
{ {
BeatmapSetInfo = BeatmapInfo =
{
BeatmapSet = new BeatmapSetInfo
{ {
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() } Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
}, },
BeatmapInfo =
{
Version = "All Metrics", Version = "All Metrics",
Metadata = new BeatmapMetadata Metadata = new BeatmapMetadata
{ {
@ -58,17 +59,16 @@ namespace osu.Game.Tests.Visual.SongSelect
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
}, },
} }
} }));
);
AddStep("all except source", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null) AddStep("all except source", () => detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
{ {
BeatmapSetInfo = BeatmapInfo =
{
BeatmapSet = new BeatmapSetInfo
{ {
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() } Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
}, },
BeatmapInfo =
{
Version = "All Metrics", Version = "All Metrics",
Metadata = new BeatmapMetadata Metadata = new BeatmapMetadata
{ {
@ -88,16 +88,16 @@ namespace osu.Game.Tests.Visual.SongSelect
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
}, },
} }
}); }));
AddStep("ratings", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null) AddStep("ratings", () => detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
{ {
BeatmapSetInfo = BeatmapInfo =
{
BeatmapSet = new BeatmapSetInfo
{ {
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() } Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
}, },
BeatmapInfo =
{
Version = "Only Ratings", Version = "Only Ratings",
Metadata = new BeatmapMetadata Metadata = new BeatmapMetadata
{ {
@ -113,9 +113,9 @@ namespace osu.Game.Tests.Visual.SongSelect
}, },
StarDifficulty = 4.8f StarDifficulty = 4.8f
} }
}); }));
AddStep("fails+retries", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null) AddStep("fails+retries", () => detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
{ {
BeatmapInfo = BeatmapInfo =
{ {
@ -139,9 +139,9 @@ namespace osu.Game.Tests.Visual.SongSelect
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
}, },
} }
}); }));
AddStep("null metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null) AddStep("null metrics", () => detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
{ {
BeatmapInfo = BeatmapInfo =
{ {
@ -160,7 +160,7 @@ namespace osu.Game.Tests.Visual.SongSelect
}, },
StarDifficulty = 1.97f, StarDifficulty = 1.97f,
} }
}); }));
AddStep("null beatmap", () => detailsArea.Beatmap = null); AddStep("null beatmap", () => detailsArea.Beatmap = null);
} }

View File

@ -42,6 +42,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep(@"No supporter", () => leaderboard.SetRetrievalState(PlaceholderState.NotSupporter)); AddStep(@"No supporter", () => leaderboard.SetRetrievalState(PlaceholderState.NotSupporter));
AddStep(@"Not logged in", () => leaderboard.SetRetrievalState(PlaceholderState.NotLoggedIn)); AddStep(@"Not logged in", () => leaderboard.SetRetrievalState(PlaceholderState.NotLoggedIn));
AddStep(@"Unavailable", () => leaderboard.SetRetrievalState(PlaceholderState.Unavailable)); AddStep(@"Unavailable", () => leaderboard.SetRetrievalState(PlaceholderState.Unavailable));
AddStep(@"None selected", () => leaderboard.SetRetrievalState(PlaceholderState.NoneSelected));
foreach (BeatmapSetOnlineStatus status in Enum.GetValues(typeof(BeatmapSetOnlineStatus))) foreach (BeatmapSetOnlineStatus status in Enum.GetValues(typeof(BeatmapSetOnlineStatus)))
AddStep($"{status} beatmap", () => showBeatmapWithStatus(status)); AddStep($"{status} beatmap", () => showBeatmapWithStatus(status));
} }

View File

@ -133,6 +133,10 @@ namespace osu.Game.Online.Leaderboards
}); });
break; break;
case PlaceholderState.NoneSelected:
replacePlaceholder(new MessagePlaceholder(@"Please select a beatmap!"));
break;
case PlaceholderState.Unavailable: case PlaceholderState.Unavailable:
replacePlaceholder(new MessagePlaceholder(@"Leaderboards are not available for this beatmap!")); replacePlaceholder(new MessagePlaceholder(@"Leaderboards are not available for this beatmap!"));
break; break;

View File

@ -9,6 +9,7 @@ namespace osu.Game.Online.Leaderboards
Retrieving, Retrieving,
NetworkFailure, NetworkFailure,
Unavailable, Unavailable,
NoneSelected,
NoScores, NoScores,
NotLoggedIn, NotLoggedIn,
NotSupporter, NotSupporter,

View File

@ -31,6 +31,8 @@ namespace osu.Game.Overlays.Chat
protected virtual float MessagePadding => default_message_padding; protected virtual float MessagePadding => default_message_padding;
private const float timestamp_padding = 65;
private const float default_horizontal_padding = 15; private const float default_horizontal_padding = 15;
protected virtual float HorizontalPadding => default_horizontal_padding; protected virtual float HorizontalPadding => default_horizontal_padding;
@ -87,7 +89,12 @@ namespace osu.Game.Overlays.Chat
{ {
Shadow = false, Shadow = false,
Colour = hasBackground ? customUsernameColour : username_colours[message.Sender.Id % username_colours.Length], Colour = hasBackground ? customUsernameColour : username_colours[message.Sender.Id % username_colours.Length],
Font = OsuFont.GetFont(size: TextSize, weight: FontWeight.Bold, italics: true) Truncate = true,
EllipsisString = "… :",
Font = OsuFont.GetFont(size: TextSize, weight: FontWeight.Bold, italics: true),
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
MaxWidth = default_message_padding - timestamp_padding
}; };
if (hasBackground) if (hasBackground)
@ -142,6 +149,7 @@ namespace osu.Game.Overlays.Chat
new MessageSender(message.Sender) new MessageSender(message.Sender)
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = timestamp_padding },
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Child = effectedUsername, Child = effectedUsername,

View File

@ -27,8 +27,8 @@ namespace osu.Game.Screens.Select
set set
{ {
beatmap = value; beatmap = value;
Leaderboard.Beatmap = beatmap?.BeatmapInfo;
Details.Beatmap = beatmap?.BeatmapInfo; Details.Beatmap = beatmap?.BeatmapInfo;
Leaderboard.Beatmap = beatmap is DummyWorkingBeatmap ? null : beatmap?.BeatmapInfo;
} }
} }

View File

@ -83,6 +83,12 @@ namespace osu.Game.Screens.Select.Leaderboards
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
{ {
if (Beatmap == null)
{
PlaceholderState = PlaceholderState.NoneSelected;
return null;
}
if (Scope == BeatmapLeaderboardScope.Local) if (Scope == BeatmapLeaderboardScope.Local)
{ {
var scores = scoreManager var scores = scoreManager
@ -113,7 +119,7 @@ namespace osu.Game.Screens.Select.Leaderboards
return null; return null;
} }
if (Beatmap?.OnlineBeatmapID == null || Beatmap?.Status <= BeatmapSetOnlineStatus.Pending) if (Beatmap.OnlineBeatmapID == null || Beatmap?.Status <= BeatmapSetOnlineStatus.Pending)
{ {
PlaceholderState = PlaceholderState.Unavailable; PlaceholderState = PlaceholderState.Unavailable;
return null; return null;

View File

@ -26,7 +26,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.904.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2019.904.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.905.0" /> <PackageReference Include="ppy.osu.Framework" Version="2019.909.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" /> <PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" /> <PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -118,8 +118,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.904.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2019.904.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.905.0" /> <PackageReference Include="ppy.osu.Framework" Version="2019.909.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.905.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2019.909.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" /> <PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.11.0" /> <PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" /> <PackageReference Include="SharpRaven" Version="2.4.0" />