mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Merge pull request #16644 from peppy/ruleset-id-fixes
Update all usages of `RulesetID` and `Ruleset.ID` to use `Ruleset.OnlineID`
This commit is contained in:
@ -155,7 +155,6 @@ namespace osu.Game.Beatmaps
|
||||
[Ignored]
|
||||
public int RulesetID
|
||||
{
|
||||
get => Ruleset.OnlineID;
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Ruleset.InstantiationInfo))
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
|
||||
beatmap.BeatmapInfo.Ruleset = rulesetProvider(beatmap.BeatmapInfo.RulesetID).RulesetInfo;
|
||||
beatmap.BeatmapInfo.Ruleset = rulesetProvider(beatmap.BeatmapInfo.Ruleset.OnlineID).RulesetInfo;
|
||||
|
||||
if (beatmapId.HasValue)
|
||||
beatmap.BeatmapInfo.OnlineID = beatmapId.Value;
|
||||
|
@ -141,9 +141,11 @@ namespace osu.Game.Beatmaps.Formats
|
||||
break;
|
||||
|
||||
case @"Mode":
|
||||
beatmap.BeatmapInfo.RulesetID = Parsing.ParseInt(pair.Value);
|
||||
int rulesetID = Parsing.ParseInt(pair.Value);
|
||||
|
||||
switch (beatmap.BeatmapInfo.RulesetID)
|
||||
beatmap.BeatmapInfo.RulesetID = rulesetID;
|
||||
|
||||
switch (rulesetID)
|
||||
{
|
||||
case 0:
|
||||
parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(getOffsetTime(), FormatVersion);
|
||||
@ -397,7 +399,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
OmitFirstBarLine = omitFirstBarSignature,
|
||||
};
|
||||
|
||||
bool isOsuRuleset = beatmap.BeatmapInfo.RulesetID == 0;
|
||||
bool isOsuRuleset = beatmap.BeatmapInfo.Ruleset.OnlineID == 0;
|
||||
// scrolling rulesets use effect points rather than difficulty points for scroll speed adjustments.
|
||||
if (!isOsuRuleset)
|
||||
effectPoint.ScrollSpeed = speedMultiplier;
|
||||
|
@ -35,6 +35,8 @@ namespace osu.Game.Beatmaps.Formats
|
||||
[CanBeNull]
|
||||
private readonly ISkin skin;
|
||||
|
||||
private readonly int onlineRulesetID;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LegacyBeatmapEncoder"/>.
|
||||
/// </summary>
|
||||
@ -45,7 +47,9 @@ namespace osu.Game.Beatmaps.Formats
|
||||
this.beatmap = beatmap;
|
||||
this.skin = skin;
|
||||
|
||||
if (beatmap.BeatmapInfo.RulesetID < 0 || beatmap.BeatmapInfo.RulesetID > 3)
|
||||
onlineRulesetID = beatmap.BeatmapInfo.Ruleset.OnlineID;
|
||||
|
||||
if (onlineRulesetID < 0 || onlineRulesetID > 3)
|
||||
throw new ArgumentException("Only beatmaps in the osu, taiko, catch, or mania rulesets can be encoded to the legacy beatmap format.", nameof(beatmap));
|
||||
}
|
||||
|
||||
@ -88,7 +92,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
writer.WriteLine(FormattableString.Invariant($"Countdown: {(int)beatmap.BeatmapInfo.Countdown}"));
|
||||
writer.WriteLine(FormattableString.Invariant($"SampleSet: {toLegacySampleBank((beatmap.HitObjects.FirstOrDefault()?.SampleControlPoint ?? SampleControlPoint.DEFAULT).SampleBank)}"));
|
||||
writer.WriteLine(FormattableString.Invariant($"StackLeniency: {beatmap.BeatmapInfo.StackLeniency}"));
|
||||
writer.WriteLine(FormattableString.Invariant($"Mode: {beatmap.BeatmapInfo.RulesetID}"));
|
||||
writer.WriteLine(FormattableString.Invariant($"Mode: {onlineRulesetID}"));
|
||||
writer.WriteLine(FormattableString.Invariant($"LetterboxInBreaks: {(beatmap.BeatmapInfo.LetterboxInBreaks ? '1' : '0')}"));
|
||||
// if (beatmap.BeatmapInfo.UseSkinSprites)
|
||||
// writer.WriteLine(@"UseSkinSprites: 1");
|
||||
@ -102,7 +106,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
writer.WriteLine(@"EpilepsyWarning: 1");
|
||||
if (beatmap.BeatmapInfo.CountdownOffset > 0)
|
||||
writer.WriteLine(FormattableString.Invariant($@"CountdownOffset: {beatmap.BeatmapInfo.CountdownOffset}"));
|
||||
if (beatmap.BeatmapInfo.RulesetID == 3)
|
||||
if (onlineRulesetID == 3)
|
||||
writer.WriteLine(FormattableString.Invariant($"SpecialStyle: {(beatmap.BeatmapInfo.SpecialStyle ? '1' : '0')}"));
|
||||
writer.WriteLine(FormattableString.Invariant($"WidescreenStoryboard: {(beatmap.BeatmapInfo.WidescreenStoryboard ? '1' : '0')}"));
|
||||
if (beatmap.BeatmapInfo.SamplesMatchPlaybackRate)
|
||||
@ -147,7 +151,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
writer.WriteLine(FormattableString.Invariant($"ApproachRate: {beatmap.Difficulty.ApproachRate}"));
|
||||
|
||||
// Taiko adjusts the slider multiplier (see: LEGACY_TAIKO_VELOCITY_MULTIPLIER)
|
||||
writer.WriteLine(beatmap.BeatmapInfo.RulesetID == 1
|
||||
writer.WriteLine(onlineRulesetID == 1
|
||||
? FormattableString.Invariant($"SliderMultiplier: {beatmap.Difficulty.SliderMultiplier / LEGACY_TAIKO_VELOCITY_MULTIPLIER}")
|
||||
: FormattableString.Invariant($"SliderMultiplier: {beatmap.Difficulty.SliderMultiplier}"));
|
||||
|
||||
@ -179,7 +183,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
SampleControlPoint lastRelevantSamplePoint = null;
|
||||
DifficultyControlPoint lastRelevantDifficultyPoint = null;
|
||||
|
||||
bool isOsuRuleset = beatmap.BeatmapInfo.RulesetID == 0;
|
||||
bool isOsuRuleset = onlineRulesetID == 0;
|
||||
|
||||
// iterate over hitobjects and pull out all required sample and difficulty changes
|
||||
extractDifficultyControlPoints(beatmap.HitObjects);
|
||||
@ -318,7 +322,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
Vector2 position = new Vector2(256, 192);
|
||||
|
||||
switch (beatmap.BeatmapInfo.RulesetID)
|
||||
switch (onlineRulesetID)
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
@ -372,7 +376,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
break;
|
||||
|
||||
case IHasDuration _:
|
||||
if (beatmap.BeatmapInfo.RulesetID == 3)
|
||||
if (onlineRulesetID == 3)
|
||||
type |= LegacyHitObjectType.Hold;
|
||||
else
|
||||
type |= LegacyHitObjectType.Spinner;
|
||||
|
@ -90,11 +90,5 @@ namespace osu.Game.Rulesets
|
||||
|
||||
return ruleset;
|
||||
}
|
||||
|
||||
#region Compatibility properties
|
||||
|
||||
public int ID => OnlineID;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Scoring.Legacy
|
||||
this.score = score;
|
||||
this.beatmap = beatmap;
|
||||
|
||||
if (score.ScoreInfo.BeatmapInfo.RulesetID < 0 || score.ScoreInfo.BeatmapInfo.RulesetID > 3)
|
||||
if (score.ScoreInfo.BeatmapInfo.Ruleset.OnlineID < 0 || score.ScoreInfo.BeatmapInfo.Ruleset.OnlineID > 3)
|
||||
throw new ArgumentException("Only scores in the osu, taiko, catch, or mania rulesets can be encoded to the legacy score format.", nameof(score));
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ namespace osu.Game.Screens.Edit
|
||||
public EditorState GetState([CanBeNull] BeatmapInfo nextBeatmap = null) => new EditorState
|
||||
{
|
||||
Time = clock.CurrentTimeAccurate,
|
||||
ClipboardContent = nextBeatmap == null || editorBeatmap.BeatmapInfo.RulesetID == nextBeatmap.RulesetID ? Clipboard.Content.Value : string.Empty
|
||||
ClipboardContent = nextBeatmap == null || editorBeatmap.BeatmapInfo.Ruleset.ShortName == nextBeatmap.Ruleset.ShortName ? Clipboard.Content.Value : string.Empty
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@ -782,7 +782,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
var difficultyItems = new List<MenuItem>();
|
||||
|
||||
foreach (var rulesetBeatmaps in beatmapSet.Beatmaps.GroupBy(b => b.RulesetID).OrderBy(group => group.Key))
|
||||
foreach (var rulesetBeatmaps in beatmapSet.Beatmaps.GroupBy(b => b.Ruleset.ShortName).OrderBy(group => group.Key))
|
||||
{
|
||||
if (difficultyItems.Count > 0)
|
||||
difficultyItems.Add(new EditorMenuItemSpacer());
|
||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
bool match =
|
||||
criteria.Ruleset == null ||
|
||||
BeatmapInfo.Ruleset.ShortName == criteria.Ruleset.ShortName ||
|
||||
(BeatmapInfo.RulesetID == 0 && criteria.Ruleset.OnlineID != 0 && criteria.AllowConvertedBeatmaps);
|
||||
(BeatmapInfo.Ruleset.OnlineID == 0 && criteria.Ruleset.OnlineID != 0 && criteria.AllowConvertedBeatmaps);
|
||||
|
||||
if (BeatmapInfo.BeatmapSet?.Equals(criteria.SelectedBeatmapSet) == true)
|
||||
{
|
||||
@ -89,7 +89,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
default:
|
||||
case SortMode.Difficulty:
|
||||
int ruleset = BeatmapInfo.RulesetID.CompareTo(otherBeatmap.BeatmapInfo.RulesetID);
|
||||
int ruleset = BeatmapInfo.Ruleset.OnlineID.CompareTo(otherBeatmap.BeatmapInfo.Ruleset.OnlineID);
|
||||
if (ruleset != 0) return ruleset;
|
||||
|
||||
return BeatmapInfo.StarRating.CompareTo(otherBeatmap.BeatmapInfo.StarRating);
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
beatmapSet.Beatmaps
|
||||
.Where(b => !b.Hidden)
|
||||
.OrderBy(b => b.RulesetID)
|
||||
.OrderBy(b => b.Ruleset.OnlineID)
|
||||
.ThenBy(b => b.StarRating)
|
||||
.Select(b => new CarouselBeatmap(b))
|
||||
.ForEach(AddChild);
|
||||
|
@ -155,7 +155,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
var scores = r.All<ScoreInfo>()
|
||||
.AsEnumerable()
|
||||
// TODO: update to use a realm filter directly (or at least figure out the beatmap part to reduce scope).
|
||||
.Where(s => !s.DeletePending && s.BeatmapInfo.ID == fetchBeatmapInfo.ID && s.Ruleset.OnlineID == ruleset.Value.ID);
|
||||
.Where(s => !s.DeletePending && s.BeatmapInfo.ID == fetchBeatmapInfo.ID && s.Ruleset.ShortName == ruleset.Value.ShortName);
|
||||
|
||||
if (filterMods && !mods.Value.Any())
|
||||
{
|
||||
|
@ -502,7 +502,7 @@ namespace osu.Game.Screens.Select
|
||||
// clear pending task immediately to track any potential nested debounce operation.
|
||||
selectionChangedDebounce = null;
|
||||
|
||||
Logger.Log($"updating selection with beatmap:{beatmap?.ID.ToString() ?? "null"} ruleset:{ruleset?.ID.ToString() ?? "null"}");
|
||||
Logger.Log($"updating selection with beatmap:{beatmap?.ID.ToString() ?? "null"} ruleset:{ruleset?.ShortName ?? "null"}");
|
||||
|
||||
if (transferRulesetValue())
|
||||
{
|
||||
|
@ -219,11 +219,11 @@ namespace osu.Game.Stores
|
||||
var decodedInfo = decoded.BeatmapInfo;
|
||||
var decodedDifficulty = decodedInfo.Difficulty;
|
||||
|
||||
var ruleset = realm.All<RulesetInfo>().FirstOrDefault(r => r.OnlineID == decodedInfo.RulesetID);
|
||||
var ruleset = realm.All<RulesetInfo>().FirstOrDefault(r => r.OnlineID == decodedInfo.Ruleset.OnlineID);
|
||||
|
||||
if (ruleset?.Available != true)
|
||||
{
|
||||
Logger.Log($"Skipping import of {file.Filename} due to missing local ruleset {decodedInfo.RulesetID}.", LoggingTarget.Database);
|
||||
Logger.Log($"Skipping import of {file.Filename} due to missing local ruleset {decodedInfo.Ruleset.OnlineID}.", LoggingTarget.Database);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
var beatmap = decoder.Decode(stream);
|
||||
|
||||
var rulesetInstance = CreateRuleset();
|
||||
beatmap.BeatmapInfo.Ruleset = beatmap.BeatmapInfo.RulesetID == rulesetInstance.RulesetInfo.ID ? rulesetInstance.RulesetInfo : new RulesetInfo();
|
||||
beatmap.BeatmapInfo.Ruleset = beatmap.BeatmapInfo.Ruleset.OnlineID == rulesetInstance.RulesetInfo.OnlineID ? rulesetInstance.RulesetInfo : new RulesetInfo();
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
currentTestBeatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
|
||||
|
||||
// populate ruleset for beatmap converters that require it to be present.
|
||||
var ruleset = rulesetStore.GetRuleset(currentTestBeatmap.BeatmapInfo.RulesetID);
|
||||
var ruleset = rulesetStore.GetRuleset(currentTestBeatmap.BeatmapInfo.Ruleset.OnlineID);
|
||||
|
||||
Debug.Assert(ruleset != null);
|
||||
|
||||
|
@ -282,7 +282,7 @@ namespace osu.Game.Tests.Visual
|
||||
Status = beatmap.Status,
|
||||
Checksum = beatmap.MD5Hash,
|
||||
AuthorID = beatmap.Metadata.Author.OnlineID,
|
||||
RulesetID = beatmap.RulesetID,
|
||||
RulesetID = beatmap.Ruleset.OnlineID,
|
||||
StarRating = beatmap.StarRating,
|
||||
DifficultyName = beatmap.DifficultyName,
|
||||
}
|
||||
|
Reference in New Issue
Block a user