mirror of
https://github.com/ppy/osu.git
synced 2026-05-23 22:04:49 +08:00
Merge pull request #35763 from stanriders/real-map-difficulty-settings
Use actual mod-adjusted map difficulty settings in the `SongBar`
This commit is contained in:
@@ -5,6 +5,10 @@ using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
@@ -52,6 +56,7 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
beatmap.ApproachRate = 6.8f;
|
||||
beatmap.OverallDifficulty = 5.5f;
|
||||
beatmap.StarRating = 4.56f;
|
||||
beatmap.DrainRate = 1.23f;
|
||||
beatmap.Length = 123456;
|
||||
beatmap.BPM = 133;
|
||||
beatmap.OnlineID = ladderBeatmap.OnlineID;
|
||||
@@ -61,11 +66,18 @@ namespace osu.Game.Tournament.Tests.Components
|
||||
|
||||
AddStep("set mods to HR", () => songBar.Mods = LegacyMods.HardRock);
|
||||
AddStep("set mods to DT", () => songBar.Mods = LegacyMods.DoubleTime);
|
||||
AddStep("set mods to HDHRDT", () => songBar.Mods = LegacyMods.Hidden | LegacyMods.HardRock | LegacyMods.DoubleTime);
|
||||
|
||||
AddStep("unset mods", () => songBar.Mods = LegacyMods.None);
|
||||
|
||||
AddToggleStep("toggle expanded", expanded => songBar.Expanded = expanded);
|
||||
|
||||
AddStep("set null beatmap", () => songBar.Beatmap = null);
|
||||
|
||||
AddStep("set ruleset to osu", () => Ruleset.Value = new OsuRuleset().RulesetInfo);
|
||||
AddStep("set ruleset to taiko", () => Ruleset.Value = new TaikoRuleset().RulesetInfo);
|
||||
AddStep("set ruleset to catch", () => Ruleset.Value = new CatchRuleset().RulesetInfo);
|
||||
AddStep("set ruleset to mania", () => Ruleset.Value = new ManiaRuleset().RulesetInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// 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.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@@ -14,6 +15,7 @@ using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Models;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
@@ -123,27 +125,19 @@ namespace osu.Game.Tournament.Components
|
||||
},
|
||||
};
|
||||
|
||||
double bpm = beatmap.BPM;
|
||||
double length = beatmap.Length;
|
||||
string hardRockExtra = "";
|
||||
var rulesetInstance = ruleset.Value.CreateInstance();
|
||||
|
||||
var convertedMods = rulesetInstance.ConvertFromLegacyMods(mods).ToList();
|
||||
var adjustedDifficulty = rulesetInstance.GetAdjustedDisplayDifficulty(beatmap, convertedMods);
|
||||
|
||||
double rate = ModUtils.CalculateRateWithMods(convertedMods);
|
||||
double bpm = FormatUtils.RoundBPM(beatmap.BPM, rate);
|
||||
double length = beatmap.Length / rate;
|
||||
|
||||
string srExtra = "";
|
||||
|
||||
float ar = beatmap.Difficulty.ApproachRate;
|
||||
|
||||
if ((mods & LegacyMods.HardRock) > 0)
|
||||
if (convertedMods.Any(x => x is ModHardRock) || convertedMods.Any(x => x is ModDoubleTime))
|
||||
{
|
||||
hardRockExtra = "*";
|
||||
srExtra = "*";
|
||||
}
|
||||
|
||||
if ((mods & LegacyMods.DoubleTime) > 0)
|
||||
{
|
||||
// temporary local calculation (taken from OsuDifficultyCalculator)
|
||||
double preempt = (int)IBeatmapDifficultyInfo.DifficultyRange(ar, 1800, 1200, 450) / 1.5;
|
||||
ar = (float)(preempt > 1200 ? (1800 - preempt) / 120 : (1200 - preempt) / 150 + 5);
|
||||
|
||||
bpm *= 1.5f;
|
||||
length /= 1.5f;
|
||||
srExtra = "*";
|
||||
}
|
||||
|
||||
@@ -154,9 +148,9 @@ namespace osu.Game.Tournament.Components
|
||||
default:
|
||||
stats = new (string heading, string content)[]
|
||||
{
|
||||
("CS", $"{beatmap.Difficulty.CircleSize:0.#}{hardRockExtra}"),
|
||||
("AR", $"{ar:0.#}{hardRockExtra}"),
|
||||
("OD", $"{beatmap.Difficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
||||
("CS", $"{adjustedDifficulty.CircleSize:0.#}"),
|
||||
("AR", $"{adjustedDifficulty.ApproachRate:0.#}"),
|
||||
("OD", $"{adjustedDifficulty.OverallDifficulty:0.#}"),
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -164,16 +158,16 @@ namespace osu.Game.Tournament.Components
|
||||
case 3:
|
||||
stats = new (string heading, string content)[]
|
||||
{
|
||||
("OD", $"{beatmap.Difficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
||||
("HP", $"{beatmap.Difficulty.DrainRate:0.#}{hardRockExtra}")
|
||||
("OD", $"{adjustedDifficulty.OverallDifficulty:0.#}"),
|
||||
("HP", $"{adjustedDifficulty.DrainRate:0.#}")
|
||||
};
|
||||
break;
|
||||
|
||||
case 2:
|
||||
stats = new (string heading, string content)[]
|
||||
{
|
||||
("CS", $"{beatmap.Difficulty.CircleSize:0.#}{hardRockExtra}"),
|
||||
("AR", $"{ar:0.#}"),
|
||||
("CS", $"{adjustedDifficulty.CircleSize:0.#}"),
|
||||
("AR", $"{adjustedDifficulty.ApproachRate:0.#}"),
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using static osu.Game.Online.API.Requests.Responses.APIBeatmap;
|
||||
|
||||
namespace osu.Game.Tournament.Models
|
||||
{
|
||||
@@ -31,6 +32,8 @@ namespace osu.Game.Tournament.Models
|
||||
|
||||
public BeatmapSetOnlineCovers Covers { get; set; }
|
||||
|
||||
public IRulesetInfo Ruleset { get; set; } = new APIRuleset();
|
||||
|
||||
public TournamentBeatmap()
|
||||
{
|
||||
}
|
||||
@@ -47,6 +50,7 @@ namespace osu.Game.Tournament.Models
|
||||
Covers = beatmap.BeatmapSet?.Covers ?? new BeatmapSetOnlineCovers();
|
||||
EndTimeObjectCount = beatmap.EndTimeObjectCount;
|
||||
TotalObjectCount = beatmap.TotalObjectCount;
|
||||
Ruleset = beatmap.Ruleset;
|
||||
}
|
||||
|
||||
public bool Equals(IBeatmapInfo? other) => other is TournamentBeatmap b && this.MatchesOnlineID(b);
|
||||
@@ -83,7 +87,7 @@ namespace osu.Game.Tournament.Models
|
||||
|
||||
string IBeatmapInfo.MD5Hash => throw new NotImplementedException();
|
||||
|
||||
IRulesetInfo IBeatmapInfo.Ruleset => throw new NotImplementedException();
|
||||
IRulesetInfo IBeatmapInfo.Ruleset => Ruleset;
|
||||
|
||||
DateTimeOffset IBeatmapSetOnlineInfo.Submitted => throw new NotImplementedException();
|
||||
|
||||
|
||||
@@ -146,6 +146,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
|
||||
public string Name => $@"{nameof(APIRuleset)} (ID: {OnlineID})";
|
||||
|
||||
[JsonIgnore]
|
||||
public string ShortName
|
||||
{
|
||||
get
|
||||
|
||||
Reference in New Issue
Block a user