mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Fix and refactor star difficulty calculation boilerplate
Moves star difficulty calculation entry-point to Beatmap, and sets star difficulty at the correct place for song select to display.
This commit is contained in:
@ -19,7 +19,7 @@ namespace osu.Game.Modes.Catch
|
|||||||
|
|
||||||
protected override HitObjectConverter<CatchBaseHit> Converter => new CatchConverter();
|
protected override HitObjectConverter<CatchBaseHit> Converter => new CatchConverter();
|
||||||
|
|
||||||
protected override double ComputeDifficulty(Dictionary<String, String> categoryDifficulty)
|
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Modes.Mania
|
|||||||
|
|
||||||
protected override HitObjectConverter<ManiaBaseHit> Converter => new ManiaConverter(columns);
|
protected override HitObjectConverter<ManiaBaseHit> Converter => new ManiaConverter(columns);
|
||||||
|
|
||||||
protected override double ComputeDifficulty(Dictionary<String, String> categoryDifficulty)
|
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Modes.Osu
|
|||||||
((Slider)h).Curve.Calculate();
|
((Slider)h).Curve.Calculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override double ComputeDifficulty(Dictionary<String, String> categoryDifficulty)
|
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
|
||||||
{
|
{
|
||||||
// Fill our custom DifficultyHitObject class, that carries additional information
|
// Fill our custom DifficultyHitObject class, that carries additional information
|
||||||
DifficultyHitObjects.Clear();
|
DifficultyHitObjects.Clear();
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Modes.Taiko
|
|||||||
|
|
||||||
protected override HitObjectConverter<TaikoBaseHit> Converter => new TaikoConverter();
|
protected override HitObjectConverter<TaikoBaseHit> Converter => new TaikoConverter();
|
||||||
|
|
||||||
protected override double ComputeDifficulty(Dictionary<String, String> categoryDifficulty)
|
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using OpenTK.Graphics;
|
|||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
|
using osu.Game.Modes;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
@ -57,5 +58,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
return timingPoint ?? ControlPoint.Default;
|
return timingPoint ?? ControlPoint.Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double CalculateStarDifficulty() => Ruleset.GetRuleset(BeatmapInfo.Mode).CreateDifficultyCalculator(this).Calculate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
protected double TimeRate = 1;
|
protected double TimeRate = 1;
|
||||||
|
|
||||||
protected abstract double ComputeDifficulty(Dictionary<String, String> categoryDifficulty);
|
protected abstract double CalculateInternal(Dictionary<String, String> categoryDifficulty);
|
||||||
|
|
||||||
private void loadTiming()
|
private void loadTiming()
|
||||||
{
|
{
|
||||||
@ -23,10 +23,10 @@ namespace osu.Game.Beatmaps
|
|||||||
TimeRate = audioRate / 100.0;
|
TimeRate = audioRate / 100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetDifficulty(Dictionary<string, string> categoryDifficulty = null)
|
public double Calculate(Dictionary<string, string> categoryDifficulty = null)
|
||||||
{
|
{
|
||||||
loadTiming();
|
loadTiming();
|
||||||
double difficulty = ComputeDifficulty(categoryDifficulty);
|
double difficulty = CalculateInternal(categoryDifficulty);
|
||||||
return difficulty;
|
return difficulty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,16 +59,21 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeatmapGroup(WorkingBeatmap beatmap)
|
public BeatmapGroup(BeatmapSetInfo beatmapSet, BeatmapDatabase database)
|
||||||
{
|
{
|
||||||
|
BeatmapSet = beatmapSet;
|
||||||
|
WorkingBeatmap beatmap = database.GetWorkingBeatmap(BeatmapSet.Beatmaps.FirstOrDefault());
|
||||||
|
foreach (var b in BeatmapSet.Beatmaps)
|
||||||
|
b.StarDifficulty = (float)database.GetWorkingBeatmap(b).Beatmap.CalculateStarDifficulty();
|
||||||
|
|
||||||
Header = new BeatmapSetHeader(beatmap)
|
Header = new BeatmapSetHeader(beatmap)
|
||||||
{
|
{
|
||||||
GainedSelection = headerGainedSelection,
|
GainedSelection = headerGainedSelection,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
};
|
};
|
||||||
|
|
||||||
BeatmapSet = beatmap.BeatmapSetInfo;
|
BeatmapSet.Beatmaps = BeatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList();
|
||||||
BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b)
|
BeatmapPanels = BeatmapSet.Beatmaps.Select(b => new BeatmapPanel(b)
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
GainedSelection = panelGainedSelection,
|
GainedSelection = panelGainedSelection,
|
||||||
|
@ -73,7 +73,6 @@ namespace osu.Game.Database
|
|||||||
// Metadata
|
// Metadata
|
||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
|
|
||||||
//todo: background threaded computation of this
|
|
||||||
private float starDifficulty = -1;
|
private float starDifficulty = -1;
|
||||||
public float StarDifficulty
|
public float StarDifficulty
|
||||||
{
|
{
|
||||||
@ -85,11 +84,6 @@ namespace osu.Game.Database
|
|||||||
set { starDifficulty = value; }
|
set { starDifficulty = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ComputeDifficulty(BeatmapDatabase database)
|
|
||||||
{
|
|
||||||
StarDifficulty = (float)Ruleset.GetRuleset(Mode).CreateDifficultyCalculator(database.GetWorkingBeatmap(this).Beatmap).GetDifficulty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(BeatmapInfo other)
|
public bool Equals(BeatmapInfo other)
|
||||||
{
|
{
|
||||||
return ID == other?.ID;
|
return ID == other?.ID;
|
||||||
|
@ -325,11 +325,7 @@ namespace osu.Game.Screens.Select
|
|||||||
if (b.Metadata == null) b.Metadata = beatmapSet.Metadata;
|
if (b.Metadata == null) b.Metadata = beatmapSet.Metadata;
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var b in beatmapSet.Beatmaps)
|
var group = new BeatmapGroup(beatmapSet, database)
|
||||||
b.ComputeDifficulty(database);
|
|
||||||
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList();
|
|
||||||
|
|
||||||
var group = new BeatmapGroup(database.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault()))
|
|
||||||
{
|
{
|
||||||
SelectionChanged = selectionChanged,
|
SelectionChanged = selectionChanged,
|
||||||
StartRequested = b => footer.StartButton.TriggerClick()
|
StartRequested = b => footer.StartButton.TriggerClick()
|
||||||
|
Reference in New Issue
Block a user