Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to input slider tail hits/misses to simulate screen #221

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions PerformanceCalculatorGUI/RulesetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.Taiko.Objects;
Expand Down Expand Up @@ -103,19 +104,19 @@ public static int AdjustManiaScore(int score, IReadOnlyList<Mod> mods)
return (int)Math.Round(1000000 * scoreMultiplier);
}

public static Dictionary<HitResult, int> GenerateHitResultsForRuleset(RulesetInfo ruleset, double accuracy, IBeatmap beatmap, int countMiss, int? countMeh, int? countGood, int? countLargeTickMisses)
public static Dictionary<HitResult, int> GenerateHitResultsForRuleset(RulesetInfo ruleset, bool hasSliderAccuracy, double accuracy, IBeatmap beatmap, int countMiss, int? countMeh, int? countGood, int countLargeTickMisses, int countSliderTailMisses)
{
return ruleset.OnlineID switch
{
0 => generateOsuHitResults(accuracy, beatmap, countMiss, countMeh, countGood, countLargeTickMisses),
0 => generateOsuHitResults(accuracy, hasSliderAccuracy, beatmap, countMiss, countMeh, countGood, countLargeTickMisses, countSliderTailMisses),
1 => generateTaikoHitResults(accuracy, beatmap, countMiss, countGood),
2 => generateCatchHitResults(accuracy, beatmap, countMiss, countMeh, countGood),
3 => generateManiaHitResults(accuracy, beatmap, countMiss),
_ => throw new ArgumentException("Invalid ruleset ID provided.")
};
}

private static Dictionary<HitResult, int> generateOsuHitResults(double accuracy, IBeatmap beatmap, int countMiss, int? countMeh, int? countGood, int? countLargeTickMisses)
private static Dictionary<HitResult, int> generateOsuHitResults(double accuracy, bool hasSliderAccuracy, IBeatmap beatmap, int countMiss, int? countMeh, int? countGood, int countLargeTickMisses, int countSliderTailMisses)
{
int countGreat;

Expand Down Expand Up @@ -191,12 +192,15 @@ private static Dictionary<HitResult, int> generateOsuHitResults(double accuracy,
countGreat = (int)(totalResultCount - countGood - countMeh - countMiss);
}

int sliderTailHits = beatmap.HitObjects.Count(x => x is Slider) - countSliderTailMisses;

return new Dictionary<HitResult, int>
{
{ HitResult.Great, countGreat },
{ HitResult.Ok, countGood ?? 0 },
{ HitResult.Meh, countMeh ?? 0 },
{ HitResult.LargeTickMiss, countLargeTickMisses ?? 0 },
{ HitResult.LargeTickMiss, countLargeTickMisses },
{ hasSliderAccuracy ? HitResult.SliderTailHit : HitResult.SmallTickHit, sliderTailHits },
{ HitResult.Miss, countMiss }
};
}
Expand Down
20 changes: 19 additions & 1 deletion PerformanceCalculatorGUI/Screens/SimulateScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.Play.HUD;
Expand All @@ -53,6 +54,7 @@ public partial class SimulateScreen : PerformanceCalculatorScreen

private LimitedLabelledNumberBox missesTextBox;
private LimitedLabelledNumberBox largeTickMissesTextBox;
private LimitedLabelledNumberBox sliderTailMissesTextBox;
private LimitedLabelledNumberBox comboTextBox;
private LimitedLabelledNumberBox scoreTextBox;

Expand Down Expand Up @@ -269,6 +271,7 @@ private void load(OsuColour osuColour)
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(),
new Dimension()
},
Expand All @@ -292,6 +295,14 @@ private void load(OsuColour osuColour)
Label = "Large Tick Misses",
PlaceholderText = "0",
MinValue = 0
},
sliderTailMissesTextBox = new LimitedLabelledNumberBox
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.TopLeft,
Label = "Slider Tail Misses",
PlaceholderText = "0",
MinValue = 0
}
}
}
Expand Down Expand Up @@ -472,6 +483,7 @@ private void load(OsuColour osuColour)
mehsTextBox.Value.BindValueChanged(_ => debouncedCalculatePerformance());
missesTextBox.Value.BindValueChanged(_ => debouncedCalculatePerformance());
largeTickMissesTextBox.Value.BindValueChanged(_ => debouncedCalculatePerformance());
sliderTailMissesTextBox.Value.BindValueChanged(_ => debouncedCalculatePerformance());
comboTextBox.Value.BindValueChanged(_ => debouncedCalculatePerformance());
scoreTextBox.Value.BindValueChanged(_ => debouncedCalculatePerformance());

Expand Down Expand Up @@ -660,10 +672,13 @@ private void calculatePerformance()
var accuracy = accuracyTextBox.Value.Value / 100.0;
Dictionary<HitResult, int> statistics = new Dictionary<HitResult, int>();



if (ruleset.Value.OnlineID != -1)
{
// official rulesets can generate more precise hits from accuracy
statistics = RulesetHelper.GenerateHitResultsForRuleset(ruleset.Value, accuracyTextBox.Value.Value / 100.0, beatmap, missesTextBox.Value.Value, countMeh, countGood, largeTickMissesTextBox.Value.Value);
bool hasSliderAccuracy = !appliedMods.Value.OfType<OsuModClassic>().All(m => m.NoSliderHeadAccuracy.Value);
statistics = RulesetHelper.GenerateHitResultsForRuleset(ruleset.Value, hasSliderAccuracy, accuracyTextBox.Value.Value / 100.0, beatmap, missesTextBox.Value.Value, countMeh, countGood, largeTickMissesTextBox.Value.Value, sliderTailMissesTextBox.Value.Value);

accuracy = RulesetHelper.GetAccuracyForRuleset(ruleset.Value, statistics);
}
Expand Down Expand Up @@ -700,6 +715,7 @@ private void populateScoreParams()
comboTextBox.Hide();
missesTextBox.Hide();
largeTickMissesTextBox.Hide();
sliderTailMissesTextBox.Hide();
scoreTextBox.Hide();

if (ruleset.Value.ShortName == "osu" || ruleset.Value.ShortName == "taiko" || ruleset.Value.ShortName == "fruits")
Expand All @@ -714,6 +730,7 @@ private void populateScoreParams()
if (ruleset.Value.ShortName == "osu")
{
largeTickMissesTextBox.Show();
sliderTailMissesTextBox.Show();
}
}
else if (ruleset.Value.ShortName == "mania")
Expand All @@ -736,6 +753,7 @@ private void populateScoreParams()
comboTextBox.Show();
missesTextBox.Show();
largeTickMissesTextBox.Show();
sliderTailMissesTextBox.Show();

scoreTextBox.Text = string.Empty;
scoreTextBox.Show();
Expand Down
Loading