diff --git a/PerformanceCalculatorGUI/Screens/SimulateScreen.cs b/PerformanceCalculatorGUI/Screens/SimulateScreen.cs index 6dbe06f863..6f56fe25da 100644 --- a/PerformanceCalculatorGUI/Screens/SimulateScreen.cs +++ b/PerformanceCalculatorGUI/Screens/SimulateScreen.cs @@ -63,6 +63,7 @@ public partial class SimulateScreen : PerformanceCalculatorScreen private LabelledNumberBox scoreIdTextBox; private StatefulButton scoreIdPopulateButton; + private LabelledSwitchButton legacyScoreSwitchButton; private GridContainer accuracyContainer; private LimitedLabelledFractionalNumberBox accuracyTextBox; @@ -229,7 +230,7 @@ private void load(OsuColour osuColour) scoreIdTextBox = new LabelledNumberBox { RelativeSizeAxes = Axes.X, - Width = 0.7f, + Width = 0.45f, Label = "Score ID", PlaceholderText = "0", }, @@ -248,6 +249,13 @@ private void load(OsuColour osuColour) notificationDisplay.Display(new Notification("Incorrect score id")); } } + }, + legacyScoreSwitchButton = new LabelledSwitchButton + { + RelativeSizeAxes = Axes.X, + Width = 0.25f, + Anchor = Anchor.TopLeft, + Label = "Is legacy score?", } } }, @@ -356,10 +364,7 @@ private void load(OsuColour osuColour) RelativeSizeAxes = Axes.X, Anchor = Anchor.TopLeft, Label = "Score", - PlaceholderText = "1000000", MinValue = 0, - MaxValue = 1000000, - Value = { Value = 1000000 } }, new OsuSpriteText { @@ -516,6 +521,11 @@ private void load(OsuColour osuColour) sliderTailMissesTextBox.Value.BindValueChanged(_ => debouncedCalculatePerformance()); comboTextBox.Value.BindValueChanged(_ => debouncedCalculatePerformance()); scoreTextBox.Value.BindValueChanged(_ => debouncedCalculatePerformance()); + legacyScoreSwitchButton.Current.BindValueChanged(_ => + { + updateMissesTextboxes(); + updateScoreTextBox(); + }); fullScoreDataSwitch.Current.BindValueChanged(val => updateAccuracyParams(val.NewValue)); @@ -563,6 +573,11 @@ private void modsChanged(ValueChangedEvent> mods) if (working is null) return; + // We expect that if user have added CL mod - they want to calculate legacy score + if (!mods.OldValue.OfType().Any() && mods.NewValue.OfType().Any(m => m.UsesDefaultConfiguration)) + legacyScoreSwitchButton.Current.Value = true; + + updateScoreTextBox(); updateMissesTextboxes(); // recreate calculators to update DHOs @@ -734,7 +749,8 @@ private void calculatePerformance() Mods = appliedMods.Value.ToArray(), TotalScore = score, Ruleset = ruleset.Value, - LegacyTotalScore = legacyTotalScore, + IsLegacyScore = legacyScoreSwitchButton.Current.Value, + LegacyTotalScore = scoreTextBox.Value.Value, }, difficultyAttributes); performanceAttributesContainer.Attributes.Value = AttributeConversion.ToDictionary(ppAttributes); @@ -768,6 +784,9 @@ private void populateScoreParams() { largeTickMissesTextBox.Show(); sliderTailMissesTextBox.Show(); + + scoreTextBox.Value.Value = 0; + scoreTextBox.Text = string.Empty; } } else if (ruleset.Value.ShortName == "mania") @@ -777,8 +796,8 @@ private void populateScoreParams() missesTextBox.Show(); + scoreTextBox.Value.Value = 1000000; scoreTextBox.Text = string.Empty; - scoreTextBox.Show(); } else { @@ -795,6 +814,8 @@ private void populateScoreParams() scoreTextBox.Text = string.Empty; scoreTextBox.Show(); } + + updateScoreTextBox(); } private void updateAccuracyParams(bool useFullScoreData) @@ -869,6 +890,36 @@ private void updateAccuracyParams(bool useFullScoreData) } } + private void updateScoreTextBox() + { + if (!appliedMods.Value.OfType().Any(m => m.UsesDefaultConfiguration)) + { + legacyScoreSwitchButton.Current.Value = false; + legacyScoreSwitchButton.Hide(); + } + else if (ruleset.Value.ShortName == "osu") + { + legacyScoreSwitchButton.Show(); + } + + if (ruleset.Value.ShortName == "osu" && legacyScoreSwitchButton.Current.Value) + { + scoreTextBox.PlaceholderText = "0"; + scoreTextBox.MaxValue = int.MaxValue; + scoreTextBox.Show(); + } + else if (ruleset.Value.ShortName == "mania") + { + scoreTextBox.PlaceholderText = "1000000"; + scoreTextBox.MaxValue = 1000000; + scoreTextBox.Show(); + } + else + { + scoreTextBox.Hide(); + } + } + private void fixupTextBox(LabelledTextBox textbox) { // This is a hack around TextBox's way of updating layout and positioning of text @@ -897,7 +948,6 @@ private void resetCalculations() createCalculators(); resetMods(); - legacyTotalScore = null; calculateDifficulty(); calculatePerformance(); @@ -989,8 +1039,6 @@ private void showError(string message, bool log = true) notificationDisplay.Display(new Notification(message)); } - private long? legacyTotalScore; - private void populateSettingsFromScore(long scoreId) { if (scoreIdPopulateButton.State.Value == ButtonState.Loading) @@ -1010,10 +1058,16 @@ private void populateSettingsFromScore(long scoreId) changeBeatmap(scoreInfo.BeatmapID.ToString()); } + legacyScoreSwitchButton.Current.Value = scoreInfo.IsLegacyScore; + ruleset.Value = rulesets.GetRuleset(scoreInfo.RulesetID); appliedMods.Value = scoreInfo.Mods.Select(x => x.ToMod(ruleset.Value.CreateInstance())).ToList(); - legacyTotalScore = scoreInfo.LegacyTotalScore; + if (scoreInfo.LegacyTotalScore != null) + { + scoreTextBox.Value.Value = (int)scoreInfo.LegacyTotalScore; + scoreTextBox.Text = scoreInfo.LegacyTotalScore.ToString(); + } fullScoreDataSwitch.Current.Value = true; @@ -1104,7 +1158,7 @@ private void updateMissesTextboxes() if (ruleset.Value.ShortName == "osu") { // Large tick misses and slider tail misses are only relevant in PP if slider head accuracy exists - if (appliedMods.Value.OfType().Any(m => m.NoSliderHeadAccuracy.Value)) + if (legacyScoreSwitchButton.Current.Value) { missesContainer.Content = new[] { new[] { missesTextBox } }; missesContainer.ColumnDimensions = [new Dimension()];