1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 15:43:22 +08:00

Merge remote-tracking branch 'upstream/master' into overlay-panels-context-menu

This commit is contained in:
Joseph Madamba 2022-12-26 17:54:15 -08:00
commit bb58976838
33 changed files with 216 additions and 135 deletions

View File

@ -10,7 +10,7 @@
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.1219.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2022.1226.0" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<!-- Fody does not handle Android build well, and warns when unchanged. <!-- Fody does not handle Android build well, and warns when unchanged.

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -32,7 +31,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin) private void load(ISkinSource skin)
{ {
foreach (var state in Enum.GetValues(typeof(CatcherAnimationState)).Cast<CatcherAnimationState>()) foreach (var state in Enum.GetValues<CatcherAnimationState>())
{ {
AddInternal(drawables[state] = getDrawableFor(state).With(d => AddInternal(drawables[state] = getDrawableFor(state).With(d =>
{ {

View File

@ -160,9 +160,9 @@ namespace osu.Game.Rulesets.Osu.Tests
static bool assertSamples(HitObject hitObject) => hitObject.Samples.All(s => s.Name != HitSampleInfo.HIT_CLAP && s.Name != HitSampleInfo.HIT_WHISTLE); static bool assertSamples(HitObject hitObject) => hitObject.Samples.All(s => s.Name != HitSampleInfo.HIT_CLAP && s.Name != HitSampleInfo.HIT_WHISTLE);
} }
private Drawable testSimpleBig(int repeats = 0) => createSlider(2, repeats: repeats); private Drawable testSimpleBig(int repeats = 0) => createSlider(repeats: repeats);
private Drawable testSimpleBigLargeStackOffset(int repeats = 0) => createSlider(2, repeats: repeats, stackHeight: 10); private Drawable testSimpleBigLargeStackOffset(int repeats = 0) => createSlider(repeats: repeats, stackHeight: 10);
private Drawable testDistanceOverflow(int repeats = 0) private Drawable testDistanceOverflow(int repeats = 0)
{ {

View File

@ -67,7 +67,7 @@ namespace osu.Game.Rulesets.Osu.UI
HitPolicy = new StartTimeOrderedHitPolicy(); HitPolicy = new StartTimeOrderedHitPolicy();
var hitWindows = new OsuHitWindows(); var hitWindows = new OsuHitWindows();
foreach (var result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r > HitResult.None && hitWindows.IsHitResultAllowed(r))) foreach (var result in Enum.GetValues<HitResult>().Where(r => r > HitResult.None && hitWindows.IsHitResultAllowed(r)))
poolDictionary.Add(result, new DrawableJudgementPool(result, onJudgementLoaded)); poolDictionary.Add(result, new DrawableJudgementPool(result, onJudgementLoaded));
AddRangeInternal(poolDictionary.Values); AddRangeInternal(poolDictionary.Values);

View File

@ -190,7 +190,7 @@ namespace osu.Game.Rulesets.Taiko.UI
var hitWindows = new TaikoHitWindows(); var hitWindows = new TaikoHitWindows();
foreach (var result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => hitWindows.IsHitResultAllowed(r))) foreach (var result in Enum.GetValues<HitResult>().Where(r => hitWindows.IsHitResultAllowed(r)))
{ {
judgementPools.Add(result, new DrawablePool<DrawableTaikoJudgement>(15)); judgementPools.Add(result, new DrawablePool<DrawableTaikoJudgement>(15));
explosionPools.Add(result, new HitExplosionPool(result)); explosionPools.Add(result, new HitExplosionPool(result));

View File

@ -60,6 +60,6 @@ namespace osu.Game.Tests.Mods
/// This local helper is used rather than <see cref="Ruleset.CreateAllMods"/>, because the aforementioned method flattens multi mods. /// This local helper is used rather than <see cref="Ruleset.CreateAllMods"/>, because the aforementioned method flattens multi mods.
/// </remarks>> /// </remarks>>
private static IEnumerable<MultiMod> getMultiMods(Ruleset ruleset) private static IEnumerable<MultiMod> getMultiMods(Ruleset ruleset)
=> Enum.GetValues(typeof(ModType)).Cast<ModType>().SelectMany(ruleset.GetModsFor).OfType<MultiMod>(); => Enum.GetValues<ModType>().SelectMany(ruleset.GetModsFor).OfType<MultiMod>();
} }
} }

View File

@ -257,7 +257,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
prepareTestAPI(true); prepareTestAPI(true);
createPlayerTest(false, createRuleset: () => new OsuRuleset createPlayerTest(createRuleset: () => new OsuRuleset
{ {
RulesetInfo = RulesetInfo =
{ {

View File

@ -127,7 +127,7 @@ namespace osu.Game.Tournament.IPC
using (var stream = IPCStorage.GetStream(file_ipc_state_filename)) using (var stream = IPCStorage.GetStream(file_ipc_state_filename))
using (var sr = new StreamReader(stream)) using (var sr = new StreamReader(stream))
{ {
State.Value = (TourneyState)Enum.Parse(typeof(TourneyState), sr.ReadLine().AsNonNull()); State.Value = Enum.Parse<TourneyState>(sr.ReadLine().AsNonNull());
} }
} }
catch (Exception) catch (Exception)

View File

@ -43,7 +43,7 @@ namespace osu.Game.Tournament.Screens.Editors
{ {
var countries = new List<TournamentTeam>(); var countries = new List<TournamentTeam>();
foreach (var country in Enum.GetValues(typeof(CountryCode)).Cast<CountryCode>().Skip(1)) foreach (var country in Enum.GetValues<CountryCode>().Skip(1))
{ {
countries.Add(new TournamentTeam countries.Add(new TournamentTeam
{ {

View File

@ -160,7 +160,7 @@ namespace osu.Game.Beatmaps.Formats
break; break;
case @"SampleSet": case @"SampleSet":
defaultSampleBank = (LegacySampleBank)Enum.Parse(typeof(LegacySampleBank), pair.Value); defaultSampleBank = Enum.Parse<LegacySampleBank>(pair.Value);
break; break;
case @"SampleVolume": case @"SampleVolume":
@ -218,7 +218,7 @@ namespace osu.Game.Beatmaps.Formats
break; break;
case @"Countdown": case @"Countdown":
beatmap.BeatmapInfo.Countdown = (CountdownType)Enum.Parse(typeof(CountdownType), pair.Value); beatmap.BeatmapInfo.Countdown = Enum.Parse<CountdownType>(pair.Value);
break; break;
case @"CountdownOffset": case @"CountdownOffset":

View File

@ -301,11 +301,11 @@ namespace osu.Game.Beatmaps.Formats
} }
} }
private string parseLayer(string value) => Enum.Parse(typeof(LegacyStoryLayer), value).ToString(); private string parseLayer(string value) => Enum.Parse<LegacyStoryLayer>(value).ToString();
private Anchor parseOrigin(string value) private Anchor parseOrigin(string value)
{ {
var origin = (LegacyOrigins)Enum.Parse(typeof(LegacyOrigins), value); var origin = Enum.Parse<LegacyOrigins>(value);
switch (origin) switch (origin)
{ {
@ -343,8 +343,8 @@ namespace osu.Game.Beatmaps.Formats
private AnimationLoopType parseAnimationLoopType(string value) private AnimationLoopType parseAnimationLoopType(string value)
{ {
var parsed = (AnimationLoopType)Enum.Parse(typeof(AnimationLoopType), value); var parsed = Enum.Parse<AnimationLoopType>(value);
return Enum.IsDefined(typeof(AnimationLoopType), parsed) ? parsed : AnimationLoopType.LoopForever; return Enum.IsDefined(parsed) ? parsed : AnimationLoopType.LoopForever;
} }
private void handleVariables(string line) private void handleVariables(string line)

View File

@ -22,38 +22,8 @@ namespace osu.Game.Graphics
public static Color4 Gray(byte amt) => new Color4(amt, amt, amt, 255); public static Color4 Gray(byte amt) => new Color4(amt, amt, amt, 255);
/// <summary> /// <summary>
/// Retrieves the colour for a <see cref="DifficultyRating"/>. /// Retrieves the colour for a given point in the star range.
/// </summary> /// </summary>
/// <remarks>
/// Sourced from the @diff-{rating} variables in https://github.com/ppy/osu-web/blob/71fbab8936d79a7929d13854f5e854b4f383b236/resources/assets/less/variables.less.
/// </remarks>
public Color4 ForDifficultyRating(DifficultyRating difficulty, bool useLighterColour = false)
{
switch (difficulty)
{
case DifficultyRating.Easy:
return Color4Extensions.FromHex("4ebfff");
case DifficultyRating.Normal:
return Color4Extensions.FromHex("66ff91");
case DifficultyRating.Hard:
return Color4Extensions.FromHex("f7e85d");
case DifficultyRating.Insane:
return Color4Extensions.FromHex("ff7e68");
case DifficultyRating.Expert:
return Color4Extensions.FromHex("fe3c71");
case DifficultyRating.ExpertPlus:
return Color4Extensions.FromHex("6662dd");
default:
throw new ArgumentOutOfRangeException(nameof(difficulty));
}
}
public Color4 ForStarDifficulty(double starDifficulty) => ColourUtils.SampleFromLinearGradient(new[] public Color4 ForStarDifficulty(double starDifficulty) => ColourUtils.SampleFromLinearGradient(new[]
{ {
(0.1f, Color4Extensions.FromHex("aaaaaa")), (0.1f, Color4Extensions.FromHex("aaaaaa")),

View File

@ -12,7 +12,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
public OsuEnumDropdown() public OsuEnumDropdown()
{ {
Items = (T[])Enum.GetValues(typeof(T)); Items = Enum.GetValues<T>();
} }
} }
} }

View File

@ -21,7 +21,7 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty] [JsonProperty]
private string type private string type
{ {
set => Type = (RecentActivityType)Enum.Parse(typeof(RecentActivityType), value.ToPascalCase()); set => Type = Enum.Parse<RecentActivityType>(value.ToPascalCase());
} }
public RecentActivityType Type; public RecentActivityType Type;
@ -29,7 +29,7 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty] [JsonProperty]
private string scoreRank private string scoreRank
{ {
set => ScoreRank = (ScoreRank)Enum.Parse(typeof(ScoreRank), value); set => ScoreRank = Enum.Parse<ScoreRank>(value);
} }
public ScoreRank ScoreRank; public ScoreRank ScoreRank;

View File

@ -185,7 +185,7 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"playstyle")] [JsonProperty(@"playstyle")]
private string[] playStyle private string[] playStyle
{ {
set => PlayStyles = value?.Select(str => Enum.Parse(typeof(APIPlayStyle), str, true)).Cast<APIPlayStyle>().ToArray(); set => PlayStyles = value?.Select(str => Enum.Parse<APIPlayStyle>(str, true)).ToArray();
} }
public APIPlayStyle[] PlayStyles; public APIPlayStyle[] PlayStyles;

View File

@ -353,6 +353,9 @@ namespace osu.Game
break; break;
case LinkAction.SearchBeatmapSet: case LinkAction.SearchBeatmapSet:
if (link.Argument is RomanisableString romanisable)
SearchBeatmapSet(romanisable.GetPreferred(Localisation.CurrentParameters.Value.PreferOriginalScript));
else
SearchBeatmapSet(argString); SearchBeatmapSet(argString);
break; break;
@ -723,7 +726,7 @@ namespace osu.Game
{ {
base.LoadComplete(); base.LoadComplete();
var languages = Enum.GetValues(typeof(Language)).OfType<Language>(); var languages = Enum.GetValues<Language>();
var mappings = languages.Select(language => var mappings = languages.Select(language =>
{ {

View File

@ -46,6 +46,7 @@ using osu.Game.Online.API;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
using osu.Game.Online.Metadata; using osu.Game.Online.Metadata;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Online.Solo;
using osu.Game.Online.Spectator; using osu.Game.Online.Spectator;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
@ -193,6 +194,7 @@ namespace osu.Game
protected MultiplayerClient MultiplayerClient { get; private set; } protected MultiplayerClient MultiplayerClient { get; private set; }
private MetadataClient metadataClient; private MetadataClient metadataClient;
private SoloStatisticsWatcher soloStatisticsWatcher;
private RealmAccess realm; private RealmAccess realm;
@ -301,6 +303,7 @@ namespace osu.Game
dependencies.CacheAs(spectatorClient = new OnlineSpectatorClient(endpoints)); dependencies.CacheAs(spectatorClient = new OnlineSpectatorClient(endpoints));
dependencies.CacheAs(MultiplayerClient = new OnlineMultiplayerClient(endpoints)); dependencies.CacheAs(MultiplayerClient = new OnlineMultiplayerClient(endpoints));
dependencies.CacheAs(metadataClient = new OnlineMetadataClient(endpoints)); dependencies.CacheAs(metadataClient = new OnlineMetadataClient(endpoints));
dependencies.CacheAs(soloStatisticsWatcher = new SoloStatisticsWatcher());
AddInternal(new BeatmapOnlineChangeIngest(beatmapUpdater, realm, metadataClient)); AddInternal(new BeatmapOnlineChangeIngest(beatmapUpdater, realm, metadataClient));
@ -346,6 +349,7 @@ namespace osu.Game
AddInternal(spectatorClient); AddInternal(spectatorClient);
AddInternal(MultiplayerClient); AddInternal(MultiplayerClient);
AddInternal(metadataClient); AddInternal(metadataClient);
AddInternal(soloStatisticsWatcher);
AddInternal(rulesetConfigCache); AddInternal(rulesetConfigCache);
@ -603,7 +607,7 @@ namespace osu.Game
try try
{ {
foreach (ModType type in Enum.GetValues(typeof(ModType))) foreach (ModType type in Enum.GetValues<ModType>())
{ {
dict[type] = instance.GetModsFor(type) dict[type] = instance.GetModsFor(type)
// Rulesets should never return null mods, but let's be defensive just in case. // Rulesets should never return null mods, but let's be defensive just in case.

View File

@ -3,6 +3,7 @@
#nullable disable #nullable disable
using System;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -11,17 +12,20 @@ using osu.Framework.Graphics;
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.Framework.Graphics.Sprites;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat;
using osu.Game.Overlays.BeatmapSet.Buttons; using osu.Game.Overlays.BeatmapSet.Buttons;
using osuTK; using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.BeatmapSet namespace osu.Game.Overlays.BeatmapSet
{ {
@ -40,12 +44,10 @@ namespace osu.Game.Overlays.BeatmapSet
private readonly UpdateableOnlineBeatmapSetCover cover; private readonly UpdateableOnlineBeatmapSetCover cover;
private readonly Box coverGradient; private readonly Box coverGradient;
private readonly OsuSpriteText title, artist; private readonly LinkFlowContainer title, artist;
private readonly AuthorInfo author; private readonly AuthorInfo author;
private readonly ExplicitContentBeatmapBadge explicitContent; private ExternalLinkButton externalLink;
private readonly SpotlightBeatmapBadge spotlight;
private readonly FeaturedArtistBeatmapBadge featuredArtist;
private readonly FillFlowContainer downloadButtonsContainer; private readonly FillFlowContainer downloadButtonsContainer;
private readonly BeatmapAvailability beatmapAvailability; private readonly BeatmapAvailability beatmapAvailability;
@ -64,8 +66,6 @@ namespace osu.Game.Overlays.BeatmapSet
public BeatmapSetHeaderContent() public BeatmapSetHeaderContent()
{ {
ExternalLinkButton externalLink;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
InternalChild = new Container InternalChild = new Container
@ -115,58 +115,19 @@ namespace osu.Game.Overlays.BeatmapSet
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Child = Picker = new BeatmapPicker(), Child = Picker = new BeatmapPicker(),
}, },
new FillFlowContainer title = new MetadataFlowContainer(s =>
{
s.Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true);
})
{ {
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = 15 }, Margin = new MarginPadding { Top = 15 },
Children = new Drawable[]
{
title = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true)
}, },
externalLink = new ExternalLinkButton artist = new MetadataFlowContainer(s =>
{ {
Anchor = Anchor.BottomLeft, s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true);
Origin = Anchor.BottomLeft, })
Margin = new MarginPadding { Left = 5, Bottom = 4 }, // To better lineup with the font
},
explicitContent = new ExplicitContentBeatmapBadge
{ {
Alpha = 0f,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Margin = new MarginPadding { Left = 10, Bottom = 4 },
},
spotlight = new SpotlightBeatmapBadge
{
Alpha = 0f,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Margin = new MarginPadding { Left = 10, Bottom = 4 },
}
}
},
new FillFlowContainer
{
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Bottom = 20 }, Margin = new MarginPadding { Bottom = 20 },
Children = new Drawable[]
{
artist = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true),
},
featuredArtist = new FeaturedArtistBeatmapBadge
{
Alpha = 0f,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Margin = new MarginPadding { Left = 10 }
}
}
}, },
new Container new Container
{ {
@ -192,7 +153,7 @@ namespace osu.Game.Overlays.BeatmapSet
Padding = new MarginPadding { Left = buttons_height + buttons_spacing }, Padding = new MarginPadding { Left = buttons_height + buttons_spacing },
Spacing = new Vector2(buttons_spacing), Spacing = new Vector2(buttons_spacing),
}, },
}, }
}, },
}, },
}, },
@ -231,12 +192,17 @@ namespace osu.Game.Overlays.BeatmapSet
Picker.Beatmap.ValueChanged += b => Picker.Beatmap.ValueChanged += b =>
{ {
Details.BeatmapInfo = b.NewValue; Details.BeatmapInfo = b.NewValue;
externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineID}"; updateExternalLink();
onlineStatusPill.Status = b.NewValue?.Status ?? BeatmapOnlineStatus.None; onlineStatusPill.Status = b.NewValue?.Status ?? BeatmapOnlineStatus.None;
}; };
} }
private void updateExternalLink()
{
if (externalLink != null) externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineID}#{Picker.Beatmap.Value?.Ruleset.ShortName}/{Picker.Beatmap.Value?.OnlineID}";
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load(OverlayColourProvider colourProvider)
{ {
@ -269,12 +235,38 @@ namespace osu.Game.Overlays.BeatmapSet
loading.Hide(); loading.Hide();
title.Text = new RomanisableString(setInfo.NewValue.TitleUnicode, setInfo.NewValue.Title); var titleText = new RomanisableString(setInfo.NewValue.TitleUnicode, setInfo.NewValue.Title);
artist.Text = new RomanisableString(setInfo.NewValue.ArtistUnicode, setInfo.NewValue.Artist); var artistText = new RomanisableString(setInfo.NewValue.ArtistUnicode, setInfo.NewValue.Artist);
explicitContent.Alpha = setInfo.NewValue.HasExplicitContent ? 1 : 0; title.Clear();
spotlight.Alpha = setInfo.NewValue.FeaturedInSpotlight ? 1 : 0; artist.Clear();
featuredArtist.Alpha = setInfo.NewValue.TrackId != null ? 1 : 0;
title.AddLink(titleText, LinkAction.SearchBeatmapSet, titleText);
title.AddArbitraryDrawable(Empty().With(d => d.Width = 5));
title.AddArbitraryDrawable(externalLink = new ExternalLinkButton());
if (setInfo.NewValue.HasExplicitContent)
{
title.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
title.AddArbitraryDrawable(new ExplicitContentBeatmapBadge());
}
if (setInfo.NewValue.FeaturedInSpotlight)
{
title.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
title.AddArbitraryDrawable(new SpotlightBeatmapBadge());
}
artist.AddLink(artistText, LinkAction.SearchBeatmapSet, artistText);
if (setInfo.NewValue.TrackId != null)
{
artist.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
artist.AddArbitraryDrawable(new FeaturedArtistBeatmapBadge());
}
updateExternalLink();
onlineStatusPill.FadeIn(500, Easing.OutQuint); onlineStatusPill.FadeIn(500, Easing.OutQuint);
@ -321,5 +313,32 @@ namespace osu.Game.Overlays.BeatmapSet
break; break;
} }
} }
public partial class MetadataFlowContainer : LinkFlowContainer
{
public MetadataFlowContainer(Action<SpriteText> defaultCreationParameters = null)
: base(defaultCreationParameters)
{
TextAnchor = Anchor.CentreLeft;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
}
protected override DrawableLinkCompiler CreateLinkCompiler(ITextPart textPart) => new MetadataLinkCompiler(textPart);
public partial class MetadataLinkCompiler : DrawableLinkCompiler
{
public MetadataLinkCompiler(ITextPart part)
: base(part)
{
}
[BackgroundDependencyLoader]
private void load()
{
IdleColour = Color4.White;
}
}
}
} }
} }

View File

@ -95,8 +95,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersScore, Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)), new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersScore, Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)),
new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersAccuracy, Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, minSize: 60, maxSize: 70)), new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersAccuracy, Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, minSize: 60, maxSize: 70)),
new TableColumn("", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, 25)), // flag new TableColumn("", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, 25)), // flag
new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersPlayer, Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 125)), new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersPlayer, Anchor.CentreLeft, new Dimension(minSize: 125)),
new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersCombo, Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 120)) new TableColumn(BeatmapsetsStrings.ShowScoreboardHeadersCombo, Anchor.CentreLeft, new Dimension(minSize: 70, maxSize: 120))
}; };
// All statistics across all scores, unordered. // All statistics across all scores, unordered.
@ -116,7 +116,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
var displayName = ruleset.GetDisplayNameForHitResult(result); var displayName = ruleset.GetDisplayNameForHitResult(result);
columns.Add(new TableColumn(displayName, Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 35, maxSize: 60))); columns.Add(new TableColumn(displayName, Anchor.CentreLeft, new Dimension(minSize: 35, maxSize: 60)));
statisticResultTypes.Add((result, displayName)); statisticResultTypes.Add((result, displayName));
} }

View File

@ -79,8 +79,7 @@ namespace osu.Game.Overlays.FirstRunSetup
Direction = FillDirection.Full; Direction = FillDirection.Full;
Spacing = new Vector2(5); Spacing = new Vector2(5);
ChildrenEnumerable = Enum.GetValues(typeof(Language)) ChildrenEnumerable = Enum.GetValues<Language>()
.Cast<Language>()
.Select(l => new LanguageButton(l) .Select(l => new LanguageButton(l)
{ {
Action = () => frameworkLocale.Value = l.ToCultureCode() Action = () => frameworkLocale.Value = l.ToCultureCode()

View File

@ -85,7 +85,7 @@ namespace osu.Game.Rulesets
/// This comes with considerable allocation overhead. If only accessing for reference purposes (ie. not changing bindables / settings) /// This comes with considerable allocation overhead. If only accessing for reference purposes (ie. not changing bindables / settings)
/// use <see cref="AllMods"/> instead. /// use <see cref="AllMods"/> instead.
/// </remarks> /// </remarks>
public IEnumerable<Mod> CreateAllMods() => Enum.GetValues(typeof(ModType)).Cast<ModType>() public IEnumerable<Mod> CreateAllMods() => Enum.GetValues<ModType>()
// Confine all mods of each mod type into a single IEnumerable<Mod> // Confine all mods of each mod type into a single IEnumerable<Mod>
.SelectMany(GetModsFor) .SelectMany(GetModsFor)
// Filter out all null mods // Filter out all null mods

View File

@ -264,7 +264,7 @@ namespace osu.Game.Rulesets.Scoring
/// <summary> /// <summary>
/// An array of all scorable <see cref="HitResult"/>s. /// An array of all scorable <see cref="HitResult"/>s.
/// </summary> /// </summary>
public static readonly HitResult[] ALL_TYPES = ((HitResult[])Enum.GetValues(typeof(HitResult))).Except(new[] { HitResult.LegacyComboIncrease }).ToArray(); public static readonly HitResult[] ALL_TYPES = Enum.GetValues<HitResult>().Except(new[] { HitResult.LegacyComboIncrease }).ToArray();
/// <summary> /// <summary>
/// Whether a <see cref="HitResult"/> is valid within a given <see cref="HitResult"/> range. /// Whether a <see cref="HitResult"/> is valid within a given <see cref="HitResult"/> range.

View File

@ -55,7 +55,7 @@ namespace osu.Game.Screens.Edit.Setup
{ {
Label = EditorSetupStrings.CountdownSpeed, Label = EditorSetupStrings.CountdownSpeed,
Current = { Value = Beatmap.BeatmapInfo.Countdown != CountdownType.None ? Beatmap.BeatmapInfo.Countdown : CountdownType.Normal }, Current = { Value = Beatmap.BeatmapInfo.Countdown != CountdownType.None ? Beatmap.BeatmapInfo.Countdown : CountdownType.Normal },
Items = Enum.GetValues(typeof(CountdownType)).Cast<CountdownType>().Where(type => type != CountdownType.None) Items = Enum.GetValues<CountdownType>().Where(type => type != CountdownType.None)
}, },
CountdownOffset = new LabelledNumberBox CountdownOffset = new LabelledNumberBox
{ {

View File

@ -96,11 +96,11 @@ namespace osu.Game.Screens.Ranking
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
statisticsPanel = new StatisticsPanel statisticsPanel = CreateStatisticsPanel().With(panel =>
{ {
RelativeSizeAxes = Axes.Both, panel.RelativeSizeAxes = Axes.Both;
Score = { BindTarget = SelectedScore } panel.Score.BindTarget = SelectedScore;
}, }),
ScorePanelList = new ScorePanelList ScorePanelList = new ScorePanelList
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -231,6 +231,11 @@ namespace osu.Game.Screens.Ranking
/// <returns>An <see cref="APIRequest"/> responsible for the fetch operation. This will be queued and performed automatically.</returns> /// <returns>An <see cref="APIRequest"/> responsible for the fetch operation. This will be queued and performed automatically.</returns>
protected virtual APIRequest FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback) => null; protected virtual APIRequest FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
/// <summary>
/// Creates the <see cref="StatisticsPanel"/> to be used to display extended information about scores.
/// </summary>
protected virtual StatisticsPanel CreateStatisticsPanel() => new StatisticsPanel();
private void fetchScoresCallback(IEnumerable<ScoreInfo> scores) => Schedule(() => private void fetchScoresCallback(IEnumerable<ScoreInfo> scores) => Schedule(() =>
{ {
foreach (var s in scores) foreach (var s in scores)

View File

@ -7,11 +7,14 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Online.Solo;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Statistics;
namespace osu.Game.Screens.Ranking namespace osu.Game.Screens.Ranking
{ {
@ -22,11 +25,28 @@ namespace osu.Game.Screens.Ranking
[Resolved] [Resolved]
private RulesetStore rulesets { get; set; } private RulesetStore rulesets { get; set; }
[Resolved]
private SoloStatisticsWatcher soloStatisticsWatcher { get; set; }
private readonly Bindable<SoloStatisticsUpdate> statisticsUpdate = new Bindable<SoloStatisticsUpdate>();
public SoloResultsScreen(ScoreInfo score, bool allowRetry) public SoloResultsScreen(ScoreInfo score, bool allowRetry)
: base(score, allowRetry) : base(score, allowRetry)
{ {
} }
protected override void LoadComplete()
{
base.LoadComplete();
soloStatisticsWatcher.RegisterForStatisticsUpdateAfter(Score, update => statisticsUpdate.Value = update);
}
protected override StatisticsPanel CreateStatisticsPanel() => new SoloStatisticsPanel(Score)
{
StatisticsUpdate = { BindTarget = statisticsUpdate }
};
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
{ {
if (Score.BeatmapInfo.OnlineID <= 0 || Score.BeatmapInfo.Status <= BeatmapOnlineStatus.Pending) if (Score.BeatmapInfo.OnlineID <= 0 || Score.BeatmapInfo.Status <= BeatmapOnlineStatus.Pending)

View File

@ -0,0 +1,54 @@
// 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.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Online.Solo;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Statistics.User;
namespace osu.Game.Screens.Ranking.Statistics
{
public partial class SoloStatisticsPanel : StatisticsPanel
{
private readonly ScoreInfo achievedScore;
public SoloStatisticsPanel(ScoreInfo achievedScore)
{
this.achievedScore = achievedScore;
}
public Bindable<SoloStatisticsUpdate?> StatisticsUpdate { get; } = new Bindable<SoloStatisticsUpdate?>();
protected override ICollection<StatisticRow> CreateStatisticRows(ScoreInfo newScore, IBeatmap playableBeatmap)
{
var rows = base.CreateStatisticRows(newScore, playableBeatmap);
if (newScore.UserID > 1
&& newScore.UserID == achievedScore.UserID
&& newScore.OnlineID > 0
&& newScore.OnlineID == achievedScore.OnlineID)
{
rows = rows.Append(new StatisticRow
{
Columns = new[]
{
new StatisticItem("Overall Ranking", () => new OverallRanking
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 0.5f,
StatisticsUpdate = { BindTarget = StatisticsUpdate }
})
}
}).ToArray();
}
return rows;
}
}
}

View File

@ -100,7 +100,7 @@ namespace osu.Game.Screens.Ranking.Statistics
bool hitEventsAvailable = newScore.HitEvents.Count != 0; bool hitEventsAvailable = newScore.HitEvents.Count != 0;
Container<Drawable> container; Container<Drawable> container;
var statisticRows = newScore.Ruleset.CreateInstance().CreateStatisticsForScore(newScore, task.GetResultSafely()); var statisticRows = CreateStatisticRows(newScore, task.GetResultSafely());
if (!hitEventsAvailable && statisticRows.SelectMany(r => r.Columns).All(c => c.RequiresHitEvents)) if (!hitEventsAvailable && statisticRows.SelectMany(r => r.Columns).All(c => c.RequiresHitEvents))
{ {
@ -218,6 +218,14 @@ namespace osu.Game.Screens.Ranking.Statistics
}), localCancellationSource.Token); }), localCancellationSource.Token);
} }
/// <summary>
/// Creates the <see cref="StatisticRow"/>s to be displayed in this panel for a given <paramref name="newScore"/>.
/// </summary>
/// <param name="newScore">The score to create the rows for.</param>
/// <param name="playableBeatmap">The beatmap on which the score was set.</param>
protected virtual ICollection<StatisticRow> CreateStatisticRows(ScoreInfo newScore, IBeatmap playableBeatmap)
=> newScore.Ruleset.CreateInstance().CreateStatisticsForScore(newScore, playableBeatmap);
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
ToggleVisibility(); ToggleVisibility();

View File

@ -237,7 +237,7 @@ namespace osu.Game.Screens.Utility
switch (e.Key) switch (e.Key)
{ {
case Key.Space: case Key.Space:
int availableModes = Enum.GetValues(typeof(LatencyVisualMode)).Length; int availableModes = Enum.GetValues<LatencyVisualMode>().Length;
VisualMode.Value = (LatencyVisualMode)(((int)VisualMode.Value + 1) % availableModes); VisualMode.Value = (LatencyVisualMode)(((int)VisualMode.Value + 1) % availableModes);
return true; return true;

View File

@ -115,7 +115,7 @@ namespace osu.Game.Skinning.Components
.Cast<object?>() .Cast<object?>()
.ToArray(); .ToArray();
foreach (var type in Enum.GetValues(typeof(BeatmapAttribute)).Cast<BeatmapAttribute>()) foreach (var type in Enum.GetValues<BeatmapAttribute>())
{ {
numberedTemplate = numberedTemplate.Replace($"{{{{{type}}}}}", $"{{{1 + (int)type}}}"); numberedTemplate = numberedTemplate.Replace($"{{{{{type}}}}}", $"{{{1 + (int)type}}}");
} }

View File

@ -97,7 +97,7 @@ namespace osu.Game.Skinning
Configuration = new SkinConfiguration(); Configuration = new SkinConfiguration();
// skininfo files may be null for default skin. // skininfo files may be null for default skin.
foreach (GlobalSkinComponentLookup.LookupType skinnableTarget in Enum.GetValues(typeof(GlobalSkinComponentLookup.LookupType))) foreach (GlobalSkinComponentLookup.LookupType skinnableTarget in Enum.GetValues<GlobalSkinComponentLookup.LookupType>())
{ {
string filename = $"{skinnableTarget}.json"; string filename = $"{skinnableTarget}.json";

View File

@ -35,7 +35,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="10.18.0" /> <PackageReference Include="Realm" Version="10.18.0" />
<PackageReference Include="ppy.osu.Framework" Version="2022.1219.0" /> <PackageReference Include="ppy.osu.Framework" Version="2022.1226.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.1221.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.1221.0" />
<PackageReference Include="Sentry" Version="3.23.1" /> <PackageReference Include="Sentry" Version="3.23.1" />
<PackageReference Include="SharpCompress" Version="0.32.2" /> <PackageReference Include="SharpCompress" Version="0.32.2" />

View File

@ -16,7 +16,7 @@
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier> <RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.1219.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2022.1226.0" />
<!-- Required since Veldrid references a library that depends on Microsoft.DotNet.PlatformAbstractions (2.0.3), which doesn't play nice with Realm. --> <!-- Required since Veldrid references a library that depends on Microsoft.DotNet.PlatformAbstractions (2.0.3), which doesn't play nice with Realm. -->
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" /> <PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />

View File

@ -146,7 +146,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PropertyCanBeMadeInitOnly_002EGlobal/@EntryIndexedValue">HINT</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PropertyCanBeMadeInitOnly_002EGlobal/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PropertyCanBeMadeInitOnly_002ELocal/@EntryIndexedValue">HINT</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PropertyCanBeMadeInitOnly_002ELocal/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PublicConstructorInAbstractClass/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PublicConstructorInAbstractClass/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentDefaultValue/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentDefaultValue/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArrayCreationExpression/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArrayCreationExpression/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAttributeParentheses/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAttributeParentheses/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAttributeUsageProperty/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAttributeUsageProperty/@EntryIndexedValue">WARNING</s:String>