mirror of
https://github.com/ppy/osu
synced 2025-02-03 20:02:16 +00:00
Replace all legacy ruleset checks with a helper property call
This commit is contained in:
parent
d4a2645510
commit
fab9323707
@ -108,10 +108,7 @@ namespace osu.Desktop
|
||||
presence.Assets.LargeImageText = $"{user.Value.Username}" + (user.Value.Statistics?.GlobalRank > 0 ? $" (rank #{user.Value.Statistics.GlobalRank:N0})" : string.Empty);
|
||||
|
||||
// update ruleset
|
||||
int onlineID = ruleset.Value.OnlineID;
|
||||
bool isLegacyRuleset = onlineID >= 0 && onlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID;
|
||||
|
||||
presence.Assets.SmallImageKey = isLegacyRuleset ? $"mode_{onlineID}" : "mode_custom";
|
||||
presence.Assets.SmallImageKey = ruleset.Value.IsLegacyRuleset ? $"mode_{ruleset.Value.OnlineID}" : "mode_custom";
|
||||
presence.Assets.SmallImageText = ruleset.Value.Name;
|
||||
|
||||
client.SetPresence(presence);
|
||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Beatmaps
|
||||
requestedUserId = api.LocalUser.Value.Id;
|
||||
|
||||
// only query API for built-in rulesets
|
||||
rulesets.AvailableRulesets.Where(ruleset => ruleset.OnlineID >= 0 && ruleset.OnlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID).ForEach(rulesetInfo =>
|
||||
rulesets.AvailableRulesets.Where(ruleset => ruleset.IsLegacyRuleset).ForEach(rulesetInfo =>
|
||||
{
|
||||
var req = new GetUserRequest(api.LocalUser.Value.Id, rulesetInfo);
|
||||
|
||||
|
@ -29,5 +29,10 @@ namespace osu.Game.Rulesets
|
||||
string InstantiationInfo { get; }
|
||||
|
||||
Ruleset CreateInstance();
|
||||
|
||||
/// <summary>
|
||||
/// Whether this ruleset's online ID is within the range that defines it as a legacy ruleset (ie. either osu!, osu!taiko, osu!catch or osu!mania).
|
||||
/// </summary>
|
||||
public bool IsLegacyRuleset => OnlineID >= 0 && OnlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID;
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,11 @@ namespace osu.Game.Rulesets
|
||||
Available = Available
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Whether this ruleset's online ID is within the range that defines it as a legacy ruleset (ie. either osu!, osu!taiko, osu!catch or osu!mania).
|
||||
/// </summary>
|
||||
public bool IsLegacyRuleset => ((IRulesetInfo)this).IsLegacyRuleset;
|
||||
|
||||
public Ruleset CreateInstance()
|
||||
{
|
||||
if (!Available)
|
||||
|
@ -7,7 +7,6 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Solo;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
@ -32,7 +31,7 @@ namespace osu.Game.Screens.Play
|
||||
if (beatmapId <= 0)
|
||||
return null;
|
||||
|
||||
if (rulesetId < 0 || rulesetId > ILegacyRuleset.MAX_LEGACY_RULESET_ID)
|
||||
if (!Ruleset.Value.IsLegacyRuleset)
|
||||
return null;
|
||||
|
||||
return new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash);
|
||||
|
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
return null;
|
||||
}
|
||||
|
||||
if (fetchRuleset.OnlineID <= 0 || fetchRuleset.OnlineID > ILegacyRuleset.MAX_LEGACY_RULESET_ID)
|
||||
if (!fetchRuleset.IsLegacyRuleset)
|
||||
{
|
||||
SetErrorState(LeaderboardState.RulesetUnavailable);
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user