1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-15 14:47:18 +08:00

Merge pull request #24955 from peppy/mods-stable-ordering

Display mod icons using stable (consistent, not osu!stable) ordering
This commit is contained in:
Bartłomiej Dach 2023-09-28 20:04:28 +02:00 committed by GitHub
commit 841142b6cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 21 additions and 16 deletions

View File

@ -31,6 +31,7 @@ using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets.Mods;
using osu.Game.Utils; using osu.Game.Utils;
namespace osu.Game.Online.Leaderboards namespace osu.Game.Online.Leaderboards
@ -242,7 +243,7 @@ namespace osu.Game.Online.Leaderboards
Origin = Anchor.BottomRight, Origin = Anchor.BottomRight,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
ChildrenEnumerable = Score.Mods.Select(mod => new ModIcon(mod) { Scale = new Vector2(0.375f) }) ChildrenEnumerable = Score.Mods.AsOrdered().Select(mod => new ModIcon(mod) { Scale = new Vector2(0.375f) })
}, },
}, },
}, },

View File

@ -118,7 +118,7 @@ namespace osu.Game.Online.Leaderboards
topScoreStatistics.Clear(); topScoreStatistics.Clear();
bottomScoreStatistics.Clear(); bottomScoreStatistics.Clear();
foreach (var mod in score.Mods) foreach (var mod in score.Mods.AsOrdered())
{ {
modStatistics.Add(new ModCell(mod)); modStatistics.Add(new ModCell(mod));
} }

View File

@ -24,6 +24,7 @@ using osu.Framework.Localisation;
using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring.Drawables; using osu.Game.Scoring.Drawables;
namespace osu.Game.Overlays.BeatmapSet.Scores namespace osu.Game.Overlays.BeatmapSet.Scores
@ -195,7 +196,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Spacing = new Vector2(1), Spacing = new Vector2(1),
ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m) ChildrenEnumerable = score.Mods.AsOrdered().Select(m => new ModIcon(m)
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.3f) Scale = new Vector2(0.3f)

View File

@ -275,7 +275,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
set set
{ {
modsContainer.Clear(); modsContainer.Clear();
modsContainer.Children = value.Select(mod => new ModIcon(mod) modsContainer.Children = value.AsOrdered().Select(mod => new ModIcon(mod)
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.25f), Scale = new Vector2(0.25f),

View File

@ -159,7 +159,7 @@ namespace osu.Game.Overlays.Mods
private void updateState() private void updateState()
{ {
scrollContent.ChildrenEnumerable = saveableMods.Select(mod => new ModPresetRow(mod)); scrollContent.ChildrenEnumerable = saveableMods.AsOrdered().Select(mod => new ModPresetRow(mod));
useCurrentModsButton.Enabled.Value = checkSelectedModsDiffersFromSaved(); useCurrentModsButton.Enabled.Value = checkSelectedModsDiffersFromSaved();
} }

View File

@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Mods
return; return;
lastPreset = preset; lastPreset = preset;
Content.ChildrenEnumerable = preset.Mods.Select(mod => new ModPresetRow(mod)); Content.ChildrenEnumerable = preset.Mods.AsOrdered().Select(mod => new ModPresetRow(mod));
} }
protected override void PopIn() => this.FadeIn(transition_duration, Easing.OutQuint); protected override void PopIn() => this.FadeIn(transition_duration, Easing.OutQuint);

View File

@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Mods
{ {
modSettingsFlow.Clear(); modSettingsFlow.Clear();
foreach (var mod in SelectedMods.Value.OrderBy(mod => mod.Type).ThenBy(mod => mod.Acronym)) foreach (var mod in SelectedMods.Value.AsOrdered())
{ {
var settings = mod.CreateSettingsControls().ToList(); var settings = mod.CreateSettingsControls().ToList();

View File

@ -15,6 +15,7 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards; using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Scoring.Drawables; using osu.Game.Scoring.Drawables;
using osu.Game.Utils; using osu.Game.Utils;
@ -48,6 +49,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(RulesetStore rulesets) private void load(RulesetStore rulesets)
{ {
var ruleset = rulesets.GetRuleset(Score.RulesetID)?.CreateInstance() ?? throw new InvalidOperationException($"Ruleset with ID of {Score.RulesetID} not found locally");
AddInternal(new ProfileItemContainer AddInternal(new ProfileItemContainer
{ {
Children = new Drawable[] Children = new Drawable[]
@ -132,14 +135,9 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(2), Spacing = new Vector2(2),
Children = Score.Mods.Select(mod => Children = Score.Mods.Select(m => m.ToMod(ruleset)).AsOrdered().Select(mod => new ModIcon(mod)
{ {
var ruleset = rulesets.GetRuleset(Score.RulesetID) ?? throw new InvalidOperationException($"Ruleset with ID of {Score.RulesetID} not found locally"); Scale = new Vector2(0.35f)
return new ModIcon(mod.ToMod(ruleset.CreateInstance()))
{
Scale = new Vector2(0.35f)
};
}).ToList(), }).ToList(),
} }
} }

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring; using osu.Game.Scoring;
@ -28,5 +29,9 @@ namespace osu.Game.Rulesets.Mods
} }
}; };
} }
public static IEnumerable<Mod> AsOrdered(this IEnumerable<Mod> mods) => mods
.OrderBy(m => m.Type)
.ThenBy(m => m.Acronym);
} }
} }

View File

@ -63,7 +63,7 @@ namespace osu.Game.Screens.Play.HUD
{ {
iconsContainer.Clear(); iconsContainer.Clear();
foreach (Mod mod in mods.NewValue) foreach (Mod mod in mods.NewValue.AsOrdered())
iconsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.6f) }); iconsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.6f) });
appearTransform(); appearTransform();

View File

@ -68,7 +68,7 @@ namespace osu.Game.Screens.Play.HUD
Spacing = new Vector2(0, -12 * iconScale); Spacing = new Vector2(0, -12 * iconScale);
foreach (Mod mod in current.Value) foreach (Mod mod in current.Value.AsOrdered())
{ {
Add(new ModIcon(mod) Add(new ModIcon(mod)
{ {