From c4f5a97be93a4929c5ea58b2bca9ab494d193da0 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Mon, 23 Jun 2025 01:35:01 +0300 Subject: [PATCH 1/3] Update SimulateScreen.cs --- PerformanceCalculatorGUI/Screens/SimulateScreen.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PerformanceCalculatorGUI/Screens/SimulateScreen.cs b/PerformanceCalculatorGUI/Screens/SimulateScreen.cs index 735049deb5..73201cfe4f 100644 --- a/PerformanceCalculatorGUI/Screens/SimulateScreen.cs +++ b/PerformanceCalculatorGUI/Screens/SimulateScreen.cs @@ -61,7 +61,7 @@ public partial class SimulateScreen : PerformanceCalculatorScreen private LimitedLabelledNumberBox comboTextBox; private LimitedLabelledNumberBox scoreTextBox; - private LabelledNumberBox scoreIdTextBox; + private LabelledTextBox scoreIdTextBox; private StatefulButton scoreIdPopulateButton; private GridContainer accuracyContainer; @@ -226,12 +226,12 @@ private void load(OsuColour osuColour) Direction = FillDirection.Horizontal, Children = new Drawable[] { - scoreIdTextBox = new LabelledNumberBox + scoreIdTextBox = new LabelledTextBox { RelativeSizeAxes = Axes.X, Width = 0.7f, Label = "Score ID", - PlaceholderText = "0", + PlaceholderText = "0 or osu/0", }, scoreIdPopulateButton = new StatefulButton("Populate from score") { @@ -241,7 +241,7 @@ private void load(OsuColour osuColour) { if (!string.IsNullOrEmpty(scoreIdTextBox.Current.Value)) { - populateSettingsFromScore(long.Parse(scoreIdTextBox.Current.Value)); + populateSettingsFromScore(scoreIdTextBox.Current.Value); } else { @@ -991,7 +991,7 @@ private void showError(string message, bool log = true) private long? legacyTotalScore; - private void populateSettingsFromScore(long scoreId) + private void populateSettingsFromScore(string scoreId) { if (scoreIdPopulateButton.State.Value == ButtonState.Loading) return; From f34bded1f636842948a109e6a97de3642b3fcdda Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Mon, 30 Jun 2025 02:53:27 +0300 Subject: [PATCH 2/3] Add validation --- .../Screens/SimulateScreen.cs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/PerformanceCalculatorGUI/Screens/SimulateScreen.cs b/PerformanceCalculatorGUI/Screens/SimulateScreen.cs index 73201cfe4f..e6b293587c 100644 --- a/PerformanceCalculatorGUI/Screens/SimulateScreen.cs +++ b/PerformanceCalculatorGUI/Screens/SimulateScreen.cs @@ -239,7 +239,7 @@ private void load(OsuColour osuColour) Width = 0.3f, Action = () => { - if (!string.IsNullOrEmpty(scoreIdTextBox.Current.Value)) + if (validateScoreId(scoreIdTextBox.Current.Value)) { populateSettingsFromScore(scoreIdTextBox.Current.Value); } @@ -1118,5 +1118,30 @@ private void updateMissesTextboxes() fixupTextBox(missesTextBox); } } + + private bool validateScoreId(string scoreId) + { + string[] validRulesetNames = { "osu", "taiko", "fruits", "mania" }; + + if (string.IsNullOrWhiteSpace(scoreId)) + return false; + + // Check if it's just a numeric id from lazer leaderboard + if (long.TryParse(scoreId, out _)) + return true; + + // Check if it's valid legacy database score id + string[] parts = scoreId.Split('/'); + if (parts.Length == 2) + { + string ruleset = parts[0]; + string idPart = parts[1]; + + if (validRulesetNames.Contains(ruleset) && long.TryParse(idPart, out _)) + return true; + } + + return false; + } } } From 9a78df5d065152d1b4f7c500e8caca8b9b551b0c Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Mon, 30 Jun 2025 02:58:29 +0300 Subject: [PATCH 3/3] fix CI --- PerformanceCalculatorGUI/Screens/SimulateScreen.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/PerformanceCalculatorGUI/Screens/SimulateScreen.cs b/PerformanceCalculatorGUI/Screens/SimulateScreen.cs index e6b293587c..a014857570 100644 --- a/PerformanceCalculatorGUI/Screens/SimulateScreen.cs +++ b/PerformanceCalculatorGUI/Screens/SimulateScreen.cs @@ -1119,7 +1119,7 @@ private void updateMissesTextboxes() } } - private bool validateScoreId(string scoreId) + private static bool validateScoreId(string scoreId) { string[] validRulesetNames = { "osu", "taiko", "fruits", "mania" }; @@ -1132,12 +1132,13 @@ private bool validateScoreId(string scoreId) // Check if it's valid legacy database score id string[] parts = scoreId.Split('/'); + if (parts.Length == 2) { - string ruleset = parts[0]; + string rulesetPart = parts[0]; string idPart = parts[1]; - if (validRulesetNames.Contains(ruleset) && long.TryParse(idPart, out _)) + if (validRulesetNames.Contains(rulesetPart) && long.TryParse(idPart, out _)) return true; }