mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
improve tests and refactor AdvancedStats
This commit is contained in:
@ -179,6 +179,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
AddStep("null beatmap", () => detailsArea.Beatmap = null);
|
AddStep("null beatmap", () => detailsArea.Beatmap = null);
|
||||||
|
|
||||||
|
Ruleset ruleset = rulesets.AvailableRulesets.First().CreateInstance();
|
||||||
|
|
||||||
AddStep("with EZ mod", () =>
|
AddStep("with EZ mod", () =>
|
||||||
{
|
{
|
||||||
detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
|
detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
|
||||||
@ -202,7 +204,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Mods.Value = new[] { rulesets.AvailableRulesets.First().CreateInstance().GetAllMods().First(m => m is ModEasy) };
|
Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModEasy) };
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("with HR mod", () =>
|
AddStep("with HR mod", () =>
|
||||||
@ -228,7 +230,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Mods.Value = new[] { rulesets.AvailableRulesets.First().CreateInstance().GetAllMods().First(m => m is ModHardRock) };
|
Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModHardRock) };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,6 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private OsuColour colours { get; set; }
|
|
||||||
|
|
||||||
private readonly StatisticRow firstValue, hpDrain, accuracy, approachRate, starDifficulty;
|
private readonly StatisticRow firstValue, hpDrain, accuracy, approachRate, starDifficulty;
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmap;
|
||||||
@ -60,11 +57,10 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
starDifficulty = new StatisticRow(10, true) { Title = "Star Difficulty" },
|
starDifficulty = new StatisticRow(10, true) { Title = "Star Difficulty" },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
starDifficulty.AccentColour = colours.Yellow;
|
starDifficulty.AccentColour = colours.Yellow;
|
||||||
mods.ValueChanged += _ => updateStatistics();
|
mods.ValueChanged += _ => updateStatistics();
|
||||||
@ -89,31 +85,24 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
if ((processed?.Ruleset?.ID ?? 0) == 3)
|
if ((processed?.Ruleset?.ID ?? 0) == 3)
|
||||||
{
|
{
|
||||||
firstValue.Title = "Key Amount";
|
firstValue.Title = "Key Amount";
|
||||||
firstValue.Value = (int)MathF.Round(moddedDifficulty?.CircleSize ?? 0);
|
firstValue.BaseValue = (int)MathF.Round(baseDifficulty?.CircleSize ?? 0);
|
||||||
|
firstValue.ModdedValue = (int)MathF.Round(moddedDifficulty?.CircleSize ?? 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
firstValue.Title = "Circle Size";
|
firstValue.Title = "Circle Size";
|
||||||
firstValue.Value = moddedDifficulty?.CircleSize ?? 0;
|
firstValue.BaseValue = baseDifficulty?.CircleSize ?? 0;
|
||||||
|
firstValue.ModdedValue = moddedDifficulty?.CircleSize ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hpDrain.Value = moddedDifficulty?.DrainRate ?? 0;
|
hpDrain.BaseValue = baseDifficulty?.DrainRate ?? 0;
|
||||||
accuracy.Value = moddedDifficulty?.OverallDifficulty ?? 0;
|
accuracy.BaseValue = baseDifficulty?.OverallDifficulty ?? 0;
|
||||||
approachRate.Value = moddedDifficulty?.ApproachRate ?? 0;
|
approachRate.BaseValue = baseDifficulty?.ApproachRate ?? 0;
|
||||||
starDifficulty.Value = (float)(processed?.StarDifficulty ?? 0);
|
starDifficulty.BaseValue = (float)(processed?.StarDifficulty ?? 0);
|
||||||
|
|
||||||
hpDrain.AccentColour = (moddedDifficulty?.DrainRate ?? 0) == (baseDifficulty?.DrainRate ?? 0) ?
|
hpDrain.ModdedValue = moddedDifficulty?.DrainRate ?? 0;
|
||||||
Color4.White : (moddedDifficulty?.DrainRate ?? 0) < (baseDifficulty?.DrainRate ?? 0) ?
|
accuracy.ModdedValue = moddedDifficulty?.OverallDifficulty ?? 0;
|
||||||
colours.BlueLight : colours.RedLight;
|
approachRate.ModdedValue = moddedDifficulty?.ApproachRate ?? 0;
|
||||||
accuracy.AccentColour = (moddedDifficulty?.OverallDifficulty ?? 0) == (baseDifficulty?.OverallDifficulty ?? 0) ?
|
|
||||||
Color4.White : (moddedDifficulty?.OverallDifficulty ?? 0) < (baseDifficulty?.OverallDifficulty ?? 0) ?
|
|
||||||
colours.BlueLight : colours.RedLight;
|
|
||||||
approachRate.AccentColour = (moddedDifficulty?.ApproachRate ?? 0) == (baseDifficulty?.ApproachRate ?? 0) ?
|
|
||||||
Color4.White : (moddedDifficulty?.ApproachRate ?? 0) < (baseDifficulty?.ApproachRate ?? 0) ?
|
|
||||||
colours.BlueLight : colours.RedLight;
|
|
||||||
firstValue.AccentColour = (moddedDifficulty?.CircleSize ?? 0) == (baseDifficulty?.CircleSize ?? 0) ?
|
|
||||||
Color4.White : (moddedDifficulty?.CircleSize ?? 0) < (baseDifficulty?.CircleSize ?? 0) ?
|
|
||||||
colours.BlueLight : colours.RedLight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class StatisticRow : Container, IHasAccentColour
|
private class StatisticRow : Container, IHasAccentColour
|
||||||
@ -124,7 +113,10 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
private readonly float maxValue;
|
private readonly float maxValue;
|
||||||
private readonly bool forceDecimalPlaces;
|
private readonly bool forceDecimalPlaces;
|
||||||
private readonly OsuSpriteText name, value;
|
private readonly OsuSpriteText name, value;
|
||||||
private readonly Bar bar;
|
private readonly Bar bar, modBar;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
public string Title
|
public string Title
|
||||||
{
|
{
|
||||||
@ -132,19 +124,39 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
set => name.Text = value;
|
set => name.Text = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float difficultyValue;
|
private float baseValue;
|
||||||
|
|
||||||
public float Value
|
private float moddedValue;
|
||||||
|
|
||||||
|
public float BaseValue
|
||||||
{
|
{
|
||||||
get => difficultyValue;
|
get => baseValue;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
difficultyValue = value;
|
baseValue = value;
|
||||||
bar.Length = value / maxValue;
|
bar.Length = value / maxValue;
|
||||||
this.value.Text = value.ToString(forceDecimalPlaces ? "0.00" : "0.##");
|
this.value.Text = value.ToString(forceDecimalPlaces ? "0.00" : "0.##");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float ModdedValue
|
||||||
|
{
|
||||||
|
get => moddedValue;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
moddedValue = value;
|
||||||
|
modBar.Length = value / maxValue;
|
||||||
|
this.value.Text = value.ToString(forceDecimalPlaces ? "0.00" : "0.##");
|
||||||
|
|
||||||
|
if (moddedValue > baseValue)
|
||||||
|
modBar.AccentColour = this.value.Colour = colours.Red;
|
||||||
|
else if (moddedValue < baseValue)
|
||||||
|
modBar.AccentColour = this.value.Colour = colours.BlueDark;
|
||||||
|
else
|
||||||
|
modBar.AccentColour = this.value.Colour = Color4.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Color4 AccentColour
|
public Color4 AccentColour
|
||||||
{
|
{
|
||||||
get => bar.AccentColour;
|
get => bar.AccentColour;
|
||||||
@ -178,6 +190,15 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
BackgroundColour = Color4.White.Opacity(0.5f),
|
BackgroundColour = Color4.White.Opacity(0.5f),
|
||||||
Padding = new MarginPadding { Left = name_width + 10, Right = value_width + 10 },
|
Padding = new MarginPadding { Left = name_width + 10, Right = value_width + 10 },
|
||||||
},
|
},
|
||||||
|
modBar = new Bar
|
||||||
|
{
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Alpha = 0.5f,
|
||||||
|
Height = 5,
|
||||||
|
Padding = new MarginPadding { Left = name_width + 10, Right = value_width + 10 },
|
||||||
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
|
Reference in New Issue
Block a user