From 5cf0a6074e532809403c930c4c481d2c761a269e Mon Sep 17 00:00:00 2001 From: StanR Date: Fri, 31 Jan 2025 20:49:00 +0500 Subject: [PATCH 1/4] Update configs, update packages, fix new warnings --- .editorconfig | 43 ++++--- .gitattributes | 1 + .gitignore | 113 +++++++++++++++--- CodeAnalysis/BannedSymbols.txt | 20 ++++ CodeAnalysis/osu.Tools.globalconfig | 109 +++++++++++++++++ .../LegacyScoreAttributesCommand.cs | 2 +- .../LegacyScoreConversionCommand.cs | 2 +- .../Difficulty/ModsCommand.cs | 3 +- .../PerformanceCalculator.csproj | 10 +- PerformanceCalculator/ProcessorCommand.cs | 2 +- .../Simulate/OsuSimulateCommand.cs | 7 +- PerformanceCalculatorGUI/APIManager.cs | 6 +- .../Components/ExtendedProfileScore.cs | 2 +- .../LimitedLabelledFractionalNumberBox.cs | 2 - .../PerformanceCalculatorGUI.csproj | 10 +- PerformanceCalculatorGUI/RulesetHelper.cs | 7 +- .../Screens/BeatmapLeaderboardScreen.cs | 8 +- .../Screens/LeaderboardScreen.cs | 6 +- .../ObjectDifficultyValuesContainer.cs | 3 +- .../ObjectInspectorDifficultyValue.cs | 6 +- .../Screens/ProfileScreen.cs | 12 +- .../Screens/SimulateScreen.cs | 2 +- osu.Tools.props | 26 +++- osu.Tools.sln | 13 ++ osu.Tools.sln.DotSettings | 20 +++- 25 files changed, 354 insertions(+), 81 deletions(-) create mode 100644 CodeAnalysis/BannedSymbols.txt create mode 100644 CodeAnalysis/osu.Tools.globalconfig diff --git a/.editorconfig b/.editorconfig index 440c24fe1d..3ac4a835d9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,17 @@ # EditorConfig is awesome: http://editorconfig.org root = true +[*.{csproj,props,targets}] +charset = utf-8-bom +end_of_line = crlf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +[g_*.cs] +generated_code = true + [*.cs] end_of_line = crlf insert_final_newline = true @@ -8,6 +19,9 @@ indent_style = space indent_size = 4 trim_trailing_whitespace = true +#license header +file_header_template = Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.\nSee the LICENCE file in the repository root for full licence text. + #Roslyn naming styles #PascalCase for public and protected members @@ -121,7 +135,7 @@ dotnet_style_qualification_for_event = false:warning dotnet_style_predefined_type_for_locals_parameters_members = true:warning dotnet_style_predefined_type_for_member_access = true:warning csharp_style_var_when_type_is_apparent = true:none -csharp_style_var_for_built_in_types = true:none +csharp_style_var_for_built_in_types = false:warning csharp_style_var_elsewhere = true:silent #Style - modifiers @@ -165,7 +179,7 @@ csharp_style_unused_value_assignment_preference = discard_variable:warning #Style - variable declaration csharp_style_inlined_variable_declaration = true:warning -csharp_style_deconstructed_variable_declaration = true:warning +csharp_style_deconstructed_variable_declaration = false:silent #Style - other C# 7.x features dotnet_style_prefer_inferred_tuple_names = true:warning @@ -176,19 +190,20 @@ dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent #Style - C# 8 features csharp_prefer_static_local_function = true:warning csharp_prefer_simple_using_statement = true:silent -csharp_style_prefer_index_operator = true:warning -csharp_style_prefer_range_operator = true:warning +csharp_style_prefer_index_operator = false:silent +csharp_style_prefer_range_operator = false:silent csharp_style_prefer_switch_expression = false:none -#Supressing roslyn built-in analyzers -# Suppress: EC112 +csharp_style_namespace_declarations = block_scoped:warning + +#Style - C# 12 features +csharp_style_prefer_primary_constructors = false -#Private method is unused -dotnet_diagnostic.IDE0051.severity = silent -#Private member is unused -dotnet_diagnostic.IDE0052.severity = silent +[*.{yaml,yml}] +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true -#Rules for disposable -dotnet_diagnostic.IDE0067.severity = none -dotnet_diagnostic.IDE0068.severity = none -dotnet_diagnostic.IDE0069.severity = none \ No newline at end of file +dotnet_diagnostic.OLOC001.words_in_name = 5 +dotnet_diagnostic.OLOC001.license_header = // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.\n// See the LICENCE file in the repository root for full licence text. diff --git a/.gitattributes b/.gitattributes index e3ffd343db..c61ca25cd2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,6 +15,7 @@ App.config text eol=crlf *.cmd text eol=crlf *.snippet text eol=crlf *.manifest text eol=crlf +*.licenseheader text eol=crlf # Check out with lf (UNIX) line endings *.sh text eol=lf diff --git a/.gitignore b/.gitignore index 2b9c125a2a..3dca4218d9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,12 +10,8 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs -### Cake ### -tools/** -build/tools/** - # Build results -bin/[Dd]ebug/ +[Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ @@ -102,7 +98,6 @@ $tf/ _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user -inspectcode # JustCode is a .NET coding add-in .JustCode @@ -196,6 +191,7 @@ ClientBin/ *.publishsettings node_modules/ orleans.codegen.cs +Resource.designer.cs # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) @@ -251,21 +247,102 @@ paket-files/ # FAKE - F# Make .fake/ -# JetBrains Rider -.idea/.idea.osu.Tools/.idea/*.xml -.idea/.idea.osu.Tools/.idea/codeStyles/*.xml -.idea/.idea.osu.Tools/.idea/dataSources/*.xml -.idea/.idea.osu.Tools/.idea/dictionaries/*.xml -.idea/.idea.osu.Tools/*.iml -*.sln.iml - -# CodeRush -.cr/ - # Python Tools for Visual Studio (PTVS) __pycache__/ *.pyc -Staging/ +# Cake # +/tools/** +/build/tools/** +/build/temp/** + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf +.idea/*/.idea/projectSettingsUpdater.xml +.idea/*/.idea/encodings.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +.idea/modules.xml +.idea/*.iml +.idea/modules +*.iml +*.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# fastlane +fastlane/report.xml + +# inspectcode inspectcodereport.xml +inspectcode + +# BenchmarkDotNet +/BenchmarkDotNet.Artifacts + +*.GeneratedMSBuildEditorConfig.editorconfig + +# Fody (pulled in by Realm) - schema file +FodyWeavers.xsd + +.idea/.idea.osu.Desktop/.idea/misc.xml +.idea/.idea.osu.Android/.idea/deploymentTargetDropDown.xml + PerformanceCalculator/cache/ diff --git a/CodeAnalysis/BannedSymbols.txt b/CodeAnalysis/BannedSymbols.txt new file mode 100644 index 0000000000..550f7c8e11 --- /dev/null +++ b/CodeAnalysis/BannedSymbols.txt @@ -0,0 +1,20 @@ +M:System.Object.Equals(System.Object,System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead. +M:System.Object.Equals(System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable or EqualityComparer.Default instead. +M:System.ValueType.Equals(System.Object)~System.Boolean;Don't use object.Equals(Fallbacks to ValueType). Use IEquatable or EqualityComparer.Default instead. +M:System.Nullable`1.Equals(System.Object)~System.Boolean;Use == instead. +T:System.IComparable;Don't use non-generic IComparable. Use generic version instead. +T:SixLabors.ImageSharp.IDeepCloneable`1;Use osu.Game.Utils.IDeepCloneable instead. +M:osu.Framework.Graphics.Sprites.SpriteText.#ctor;Use OsuSpriteText. +M:osu.Framework.Bindables.IBindableList`1.GetBoundCopy();Fails on iOS. Use manual ctor + BindTo instead. (see https://github.com/mono/mono/issues/19900) +T:NuGet.Packaging.CollectionExtensions;Don't use internal extension methods. +M:Realms.IRealmCollection`1.SubscribeForNotifications`1(Realms.NotificationCallbackDelegate{``0});Use osu.Game.Database.RealmObjectExtensions.QueryAsyncWithNotifications(IRealmCollection,NotificationCallbackDelegate) instead. +M:System.Guid.#ctor;Probably meaning to use Guid.NewGuid() instead. If actually wanting empty, use Guid.Empty. +M:Realms.CollectionExtensions.SubscribeForNotifications`1(System.Linq.IQueryable{``0},Realms.NotificationCallbackDelegate{``0});Use osu.Game.Database.RealmObjectExtensions.QueryAsyncWithNotifications(IQueryable,NotificationCallbackDelegate) instead. +M:Realms.CollectionExtensions.SubscribeForNotifications`1(System.Collections.Generic.IList{``0},Realms.NotificationCallbackDelegate{``0});Use osu.Game.Database.RealmObjectExtensions.QueryAsyncWithNotifications(IList,NotificationCallbackDelegate) instead. +M:System.Threading.Tasks.Task.Wait();Don't use Task.Wait. Use Task.WaitSafely() to ensure we avoid deadlocks. +P:System.Threading.Tasks.Task`1.Result;Don't use Task.Result. Use Task.GetResultSafely() to ensure we avoid deadlocks. +M:System.Threading.ManualResetEventSlim.Wait();Specify a timeout to avoid waiting forever. +M:Humanizer.InflectorExtensions.Pascalize(System.String);Humanizer's .Pascalize() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToPascalCase() instead. +M:Humanizer.InflectorExtensions.Camelize(System.String);Humanizer's .Camelize() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToCamelCase() instead. +M:Humanizer.InflectorExtensions.Underscore(System.String);Humanizer's .Underscore() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToSnakeCase() instead. +M:Humanizer.InflectorExtensions.Kebaberize(System.String);Humanizer's .Kebaberize() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToKebabCase() instead. diff --git a/CodeAnalysis/osu.Tools.globalconfig b/CodeAnalysis/osu.Tools.globalconfig new file mode 100644 index 0000000000..247a825033 --- /dev/null +++ b/CodeAnalysis/osu.Tools.globalconfig @@ -0,0 +1,109 @@ +# .NET Code Style +# IDE styles reference: https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ +is_global = true + +# IDE0001: Simplify names +dotnet_diagnostic.IDE0001.severity = warning + +# IDE0002: Simplify member access +dotnet_diagnostic.IDE0002.severity = warning + +# IDE0003: Remove qualification +dotnet_diagnostic.IDE0003.severity = warning + +# IDE0004: Remove unnecessary cast +dotnet_diagnostic.IDE0004.severity = warning + +# IDE0005: Remove unnecessary imports +dotnet_diagnostic.IDE0005.severity = warning + +# IDE0034: Simplify default literal +dotnet_diagnostic.IDE0034.severity = warning + +# IDE0036: Sort modifiers +dotnet_diagnostic.IDE0036.severity = warning + +# IDE0040: Add accessibility modifier +dotnet_diagnostic.IDE0040.severity = warning + +# IDE0049: Use keyword for type name +dotnet_diagnostic.IDE0040.severity = warning + +# IDE0055: Fix formatting +dotnet_diagnostic.IDE0055.severity = warning + +# IDE0051: Private method is unused +dotnet_diagnostic.IDE0051.severity = silent + +# IDE0052: Private member is unused +dotnet_diagnostic.IDE0052.severity = silent + +# IDE0073: File header +dotnet_diagnostic.IDE0073.severity = warning + +# IDE0130: Namespace mismatch with folder +dotnet_diagnostic.IDE0130.severity = warning + +# IDE1006: Naming style +dotnet_diagnostic.IDE1006.severity = warning + +# CA1305: Specify IFormatProvider +# Too many noisy warnings for parsing/formatting numbers +dotnet_diagnostic.CA1305.severity = none + +# CA1507: Use nameof to express symbol names +# Flaggs serialization name attributes +dotnet_diagnostic.CA1507.severity = suggestion + +# CA1806: Do not ignore method results +# The usages for numeric parsing are explicitly optional +dotnet_diagnostic.CA1806.severity = suggestion + +# CA1822: Mark members as static +# Potential false positive around reflection/too much noise +dotnet_diagnostic.CA1822.severity = none + +# CA1826: Do not use Enumerable method on indexable collections +dotnet_diagnostic.CA1826.severity = suggestion + +# CA1859: Use concrete types when possible for improved performance +# Involves design considerations +dotnet_diagnostic.CA1859.severity = suggestion + +# CA1860: Avoid using 'Enumerable.Any()' extension method +dotnet_diagnostic.CA1860.severity = suggestion + +# CA1861: Avoid constant arrays as arguments +# Outdated with collection expressions +dotnet_diagnostic.CA1861.severity = suggestion + +# CA2007: Consider calling ConfigureAwait on the awaited task +dotnet_diagnostic.CA2007.severity = warning + +# CA2016: Forward the 'CancellationToken' parameter to methods +# Some overloads are having special handling for debugger +dotnet_diagnostic.CA2016.severity = suggestion + +# CA2021: Do not call Enumerable.Cast or Enumerable.OfType with incompatible types +# Causing a lot of false positives with generics +dotnet_diagnostic.CA2021.severity = none + +# CA2101: Specify marshaling for P/Invoke string arguments +# Reports warning for all non-UTF16 usages on DllImport; consider migrating to LibraryImport +dotnet_diagnostic.CA2101.severity = none + +# CA2201: Do not raise reserved exception types +dotnet_diagnostic.CA2201.severity = warning + +# CA2208: Instantiate argument exceptions correctly +dotnet_diagnostic.CA2208.severity = suggestion + +# CA2242: Test for NaN correctly +dotnet_diagnostic.CA2242.severity = warning + +# Banned APIs +dotnet_diagnostic.RS0030.severity = error + +# Temporarily disable analysing CanBeNull = true in NRT contexts due to mobile issues. +# See: https://github.com/ppy/osu/pull/19677 +dotnet_diagnostic.OSUF001.severity = none diff --git a/PerformanceCalculator/Difficulty/LegacyScoreAttributesCommand.cs b/PerformanceCalculator/Difficulty/LegacyScoreAttributesCommand.cs index 053287b7d2..375b84e83d 100644 --- a/PerformanceCalculator/Difficulty/LegacyScoreAttributesCommand.cs +++ b/PerformanceCalculator/Difficulty/LegacyScoreAttributesCommand.cs @@ -144,7 +144,7 @@ private Mod[] getMods(Ruleset ruleset) foreach (var modString in Mods) { - Mod newMod = availableMods.FirstOrDefault(m => string.Equals(m.Acronym, modString, StringComparison.CurrentCultureIgnoreCase)); + Mod newMod = availableMods.FirstOrDefault(m => string.Equals(m.Acronym, modString, StringComparison.OrdinalIgnoreCase)); if (newMod == null) throw new ArgumentException($"Invalid mod provided: {modString}"); diff --git a/PerformanceCalculator/Difficulty/LegacyScoreConversionCommand.cs b/PerformanceCalculator/Difficulty/LegacyScoreConversionCommand.cs index 190baa3ef0..a7731814e5 100644 --- a/PerformanceCalculator/Difficulty/LegacyScoreConversionCommand.cs +++ b/PerformanceCalculator/Difficulty/LegacyScoreConversionCommand.cs @@ -99,7 +99,7 @@ private Mod[] getMods(Ruleset ruleset) foreach (var modString in Mods) { - Mod newMod = availableMods.FirstOrDefault(m => string.Equals(m.Acronym, modString, StringComparison.CurrentCultureIgnoreCase)); + Mod newMod = availableMods.FirstOrDefault(m => string.Equals(m.Acronym, modString, StringComparison.OrdinalIgnoreCase)); if (newMod == null) throw new ArgumentException($"Invalid mod provided: {modString}"); diff --git a/PerformanceCalculator/Difficulty/ModsCommand.cs b/PerformanceCalculator/Difficulty/ModsCommand.cs index f3f5ea59bb..4298ab9256 100644 --- a/PerformanceCalculator/Difficulty/ModsCommand.cs +++ b/PerformanceCalculator/Difficulty/ModsCommand.cs @@ -11,6 +11,7 @@ using McMaster.Extensions.CommandLineUtils; using Newtonsoft.Json; using osu.Game.Configuration; +using osu.Game.Extensions; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; @@ -75,7 +76,7 @@ IEnumerable getSettingsDefinitions(Mod mod) yield return new { - Name = propertyInfo.Name.Underscore(), + Name = propertyInfo.Name.ToSnakeCase(), Type = getJsonType(netType), Label = settingsSource.Label.ToString(), Description = settingsSource.Description.ToString(), diff --git a/PerformanceCalculator/PerformanceCalculator.csproj b/PerformanceCalculator/PerformanceCalculator.csproj index ef2d471570..17b3e4e9b3 100644 --- a/PerformanceCalculator/PerformanceCalculator.csproj +++ b/PerformanceCalculator/PerformanceCalculator.csproj @@ -8,10 +8,10 @@ - - - - - + + + + + diff --git a/PerformanceCalculator/ProcessorCommand.cs b/PerformanceCalculator/ProcessorCommand.cs index 392631c00a..d09012060e 100644 --- a/PerformanceCalculator/ProcessorCommand.cs +++ b/PerformanceCalculator/ProcessorCommand.cs @@ -88,7 +88,7 @@ public void OutputPerformance(ScoreInfo score, PerformanceAttributes performance var ppAttributeValues = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(result.PerformanceAttributes)) ?? new Dictionary(); foreach (var attrib in ppAttributeValues) - document.Children.Add(FormatDocumentLine(attrib.Key.Humanize().ToLower(), FormattableString.Invariant($"{attrib.Value:N2}"))); + document.Children.Add(FormatDocumentLine(attrib.Key.Humanize().ToLower(CultureInfo.InvariantCulture), FormattableString.Invariant($"{attrib.Value:N2}"))); AddSectionHeader(document, "Difficulty attributes"); diff --git a/PerformanceCalculator/Simulate/OsuSimulateCommand.cs b/PerformanceCalculator/Simulate/OsuSimulateCommand.cs index c981095e49..337a9c2541 100644 --- a/PerformanceCalculator/Simulate/OsuSimulateCommand.cs +++ b/PerformanceCalculator/Simulate/OsuSimulateCommand.cs @@ -161,19 +161,18 @@ protected override double GetAccuracy(IBeatmap beatmap, Dictionary x is Slider); - var countSliderTailHit = statistics[HitResult.SliderTailHit]; total += 3 * countSliderTailHit; max += 3 * countSliders; } - if (statistics.ContainsKey(HitResult.LargeTickMiss)) + if (statistics.TryGetValue(HitResult.LargeTickMiss, out int countLargeTickMiss)) { var countLargeTicks = beatmap.HitObjects.Sum(obj => obj.NestedHitObjects.Count(x => x is SliderTick or SliderRepeat)); - var countLargeTickHit = countLargeTicks - statistics[HitResult.LargeTickMiss]; + var countLargeTickHit = countLargeTicks - countLargeTickMiss; total += 0.6 * countLargeTickHit; max += 0.6 * countLargeTicks; diff --git a/PerformanceCalculatorGUI/APIManager.cs b/PerformanceCalculatorGUI/APIManager.cs index 65aec6721e..02551d0577 100644 --- a/PerformanceCalculatorGUI/APIManager.cs +++ b/PerformanceCalculatorGUI/APIManager.cs @@ -35,14 +35,14 @@ public async Task GetJsonFromApi(string request) { if (token == null) { - await getAccessToken(); + await getAccessToken().ConfigureAwait(false); Debug.Assert(token != null); } using var req = new JsonWebRequest($"{ENDPOINT_CONFIGURATION.APIEndpointUrl}/api/v2/{request}"); req.AddHeader("x-api-version", api_version.ToString(CultureInfo.InvariantCulture)); req.AddHeader(System.Net.HttpRequestHeader.Authorization.ToString(), $"Bearer {token.AccessToken}"); - await req.PerformAsync(); + await req.PerformAsync().ConfigureAwait(false); return req.ResponseObject; } @@ -58,7 +58,7 @@ private async Task getAccessToken() req.AddParameter("client_secret", clientSecretBindable.Value); req.AddParameter("grant_type", "client_credentials"); req.AddParameter("scope", "public"); - await req.PerformAsync(); + await req.PerformAsync().ConfigureAwait(false); token = req.ResponseObject; } diff --git a/PerformanceCalculatorGUI/Components/ExtendedProfileScore.cs b/PerformanceCalculatorGUI/Components/ExtendedProfileScore.cs index 626c52e17b..6f5d5692df 100644 --- a/PerformanceCalculatorGUI/Components/ExtendedProfileScore.cs +++ b/PerformanceCalculatorGUI/Components/ExtendedProfileScore.cs @@ -125,7 +125,7 @@ private void load(RulesetStore rulesets) Anchor = Anchor.Centre, Origin = Anchor.Centre, Colour = colourProvider.Light1, - Text = Score.PositionChange.Value.ToString() + Text = $"{Score.PositionChange.Value:+0;-0;-}" } }, new Container diff --git a/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledFractionalNumberBox.cs b/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledFractionalNumberBox.cs index f1d4841863..f6fbbad29f 100644 --- a/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledFractionalNumberBox.cs +++ b/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledFractionalNumberBox.cs @@ -11,8 +11,6 @@ public partial class LimitedLabelledFractionalNumberBox : ExtendedLabelledTextBo { private partial class FractionalNumberBox : OsuTextBox { - protected override bool AllowIme => false; - protected override bool CanAddCharacter(char character) => char.IsAsciiDigit(character) || character == CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]; protected override void OnUserTextAdded(string added) diff --git a/PerformanceCalculatorGUI/PerformanceCalculatorGUI.csproj b/PerformanceCalculatorGUI/PerformanceCalculatorGUI.csproj index 85130649f9..adb994fbd9 100644 --- a/PerformanceCalculatorGUI/PerformanceCalculatorGUI.csproj +++ b/PerformanceCalculatorGUI/PerformanceCalculatorGUI.csproj @@ -6,10 +6,10 @@ latest - - - - - + + + + + diff --git a/PerformanceCalculatorGUI/RulesetHelper.cs b/PerformanceCalculatorGUI/RulesetHelper.cs index 659c509147..00d85da367 100644 --- a/PerformanceCalculatorGUI/RulesetHelper.cs +++ b/PerformanceCalculatorGUI/RulesetHelper.cs @@ -280,19 +280,18 @@ private static double getOsuAccuracy(IBeatmap beatmap, Dictionary x is Slider); - var countSliderTailHit = statistics[HitResult.SliderTailHit]; total += 3 * countSliderTailHit; max += 3 * countSliders; } - if (statistics.ContainsKey(HitResult.LargeTickMiss)) + if (statistics.TryGetValue(HitResult.LargeTickMiss, out int countLargeTicksMiss)) { var countLargeTicks = beatmap.HitObjects.Sum(obj => obj.NestedHitObjects.Count(x => x is SliderTick or SliderRepeat)); - var countLargeTickHit = countLargeTicks - statistics[HitResult.LargeTickMiss]; + var countLargeTickHit = countLargeTicks - countLargeTicksMiss; total += 0.6 * countLargeTickHit; max += 0.6 * countLargeTicks; diff --git a/PerformanceCalculatorGUI/Screens/BeatmapLeaderboardScreen.cs b/PerformanceCalculatorGUI/Screens/BeatmapLeaderboardScreen.cs index 00a8334f58..0de1d5a0f0 100644 --- a/PerformanceCalculatorGUI/Screens/BeatmapLeaderboardScreen.cs +++ b/PerformanceCalculatorGUI/Screens/BeatmapLeaderboardScreen.cs @@ -196,7 +196,7 @@ private void calculate() { Schedule(() => loadingLayer.Text.Value = "Getting leaderboard..."); - var leaderboard = await apiManager.GetJsonFromApi($@"beatmaps/{beatmapIdTextBox.Current.Value}/scores?scope=global&mode={ruleset.Value.ShortName}"); + var leaderboard = await apiManager.GetJsonFromApi($@"beatmaps/{beatmapIdTextBox.Current.Value}/scores?scope=global&mode={ruleset.Value.ShortName}").ConfigureAwait(false); var plays = new List(); @@ -236,9 +236,11 @@ private void calculate() var difficultyAttributes = difficultyCalculator.Calculate(mods); var performanceCalculator = rulesetInstance.CreatePerformanceCalculator(); + if (performanceCalculator == null) + continue; - var perfAttributes = await performanceCalculator?.CalculateAsync(parsedScore.ScoreInfo, difficultyAttributes, token)!; - score.PP = perfAttributes?.Total ?? 0.0; + var perfAttributes = await performanceCalculator.CalculateAsync(parsedScore.ScoreInfo, difficultyAttributes, token).ConfigureAwait(false); + score.PP = perfAttributes.Total; plays.Add(score); } diff --git a/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs b/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs index 884899fbe1..bedfe84624 100644 --- a/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs +++ b/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs @@ -239,7 +239,7 @@ private void calculate() { Schedule(() => loadingLayer.Text.Value = "Getting leaderboard..."); - var leaderboard = await apiManager.GetJsonFromApi($"rankings/{ruleset.Value.ShortName}/performance?cursor[page]={pageTextBox.Value.Value - 1}"); + var leaderboard = await apiManager.GetJsonFromApi($"rankings/{ruleset.Value.ShortName}/performance?cursor[page]={pageTextBox.Value.Value - 1}").ConfigureAwait(false); var calculatedPlayers = new List(); var calculatedScores = new List(); @@ -253,7 +253,7 @@ private void calculate() Schedule(() => loadingLayer.Text.Value = $"Calculating {player.User.Username} top scores..."); - var playerData = await calculatePlayer(player, token); + var playerData = await calculatePlayer(player, token).ConfigureAwait(false); calculatedPlayers.Add(new LeaderboardUser { @@ -301,7 +301,7 @@ private async Task calculatePlayer(UserStatistics player, C var plays = new List(); - var apiScores = await apiManager.GetJsonFromApi>($"users/{player.User.OnlineID}/scores/best?mode={ruleset.Value.ShortName}&limit=100"); + var apiScores = await apiManager.GetJsonFromApi>($"users/{player.User.OnlineID}/scores/best?mode={ruleset.Value.ShortName}&limit=100").ConfigureAwait(false); var rulesetInstance = ruleset.Value.CreateInstance(); diff --git a/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectDifficultyValuesContainer.cs b/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectDifficultyValuesContainer.cs index b0e979991b..1cf9452b88 100644 --- a/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectDifficultyValuesContainer.cs +++ b/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectDifficultyValuesContainer.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; using osu.Game.Overlays; using osu.Game.Rulesets.Catch.Difficulty.Preprocessing; using osu.Game.Rulesets.Difficulty.Preprocessing; @@ -72,7 +73,7 @@ private void load(OverlayColourProvider colors) Colour = colors.Background6, RelativeSizeAxes = Axes.Both }, - hitObjectTypeText = new SpriteText + hitObjectTypeText = new OsuSpriteText { Font = new FontUsage(size: 30), Padding = new MarginPadding(10) diff --git a/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectInspectorDifficultyValue.cs b/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectInspectorDifficultyValue.cs index 49128f1f55..13c38abc21 100644 --- a/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectInspectorDifficultyValue.cs +++ b/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectInspectorDifficultyValue.cs @@ -3,8 +3,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osuTK; namespace PerformanceCalculatorGUI.Screens.ObjectInspection @@ -45,12 +45,12 @@ private void createLayout() { new Drawable[] { - new SpriteText + new OsuSpriteText { Text = label, Font = OsuFont.GetFont(weight: FontWeight.SemiBold) }, - new SpriteText + new OsuSpriteText { Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, diff --git a/PerformanceCalculatorGUI/Screens/ProfileScreen.cs b/PerformanceCalculatorGUI/Screens/ProfileScreen.cs index b31fdcf77b..885e25e75e 100644 --- a/PerformanceCalculatorGUI/Screens/ProfileScreen.cs +++ b/PerformanceCalculatorGUI/Screens/ProfileScreen.cs @@ -238,7 +238,7 @@ private void calculateProfile(string username) { Schedule(() => loadingLayer.Text.Value = "Getting user data..."); - var player = await apiManager.GetJsonFromApi($"users/{username}/{ruleset.Value.ShortName}"); + var player = await apiManager.GetJsonFromApi($"users/{username}/{ruleset.Value.ShortName}").ConfigureAwait(false); currentUser = player.Username; @@ -273,11 +273,11 @@ private void calculateProfile(string username) Schedule(() => loadingLayer.Text.Value = $"Calculating {player.Username} top scores..."); - var apiScores = await apiManager.GetJsonFromApi>($"users/{player.OnlineID}/scores/best?mode={ruleset.Value.ShortName}&limit=100"); + var apiScores = await apiManager.GetJsonFromApi>($"users/{player.OnlineID}/scores/best?mode={ruleset.Value.ShortName}&limit=100").ConfigureAwait(false); if (includePinnedCheckbox.Current.Value) { - var pinnedScores = await apiManager.GetJsonFromApi>($"users/{player.OnlineID}/scores/pinned?mode={ruleset.Value.ShortName}&limit=100"); + var pinnedScores = await apiManager.GetJsonFromApi>($"users/{player.OnlineID}/scores/pinned?mode={ruleset.Value.ShortName}&limit=100").ConfigureAwait(false); apiScores = apiScores.Concat(pinnedScores.Where(p => !apiScores.Any(b => b.ID == p.ID))).ToList(); } @@ -299,10 +299,12 @@ private void calculateProfile(string username) var difficultyCalculator = rulesetInstance.CreateDifficultyCalculator(working); var difficultyAttributes = difficultyCalculator.Calculate(mods); var performanceCalculator = rulesetInstance.CreatePerformanceCalculator(); + if (performanceCalculator == null) + continue; double? livePp = score.PP; - var perfAttributes = await performanceCalculator?.CalculateAsync(parsedScore.ScoreInfo, difficultyAttributes, token)!; - score.PP = perfAttributes?.Total ?? 0.0; + var perfAttributes = await performanceCalculator.CalculateAsync(parsedScore.ScoreInfo, difficultyAttributes, token).ConfigureAwait(false); + score.PP = perfAttributes.Total; var extendedScore = new ExtendedScore(score, livePp, perfAttributes); plays.Add(extendedScore); diff --git a/PerformanceCalculatorGUI/Screens/SimulateScreen.cs b/PerformanceCalculatorGUI/Screens/SimulateScreen.cs index 83b258fe3f..e650e4b98f 100644 --- a/PerformanceCalculatorGUI/Screens/SimulateScreen.cs +++ b/PerformanceCalculatorGUI/Screens/SimulateScreen.cs @@ -1022,7 +1022,7 @@ private void populateSettingsFromScore(long scoreId) { try { - var scoreInfo = await apiManager.GetJsonFromApi($"scores/{scoreId}"); + var scoreInfo = await apiManager.GetJsonFromApi($"scores/{scoreId}").ConfigureAwait(false); Schedule(() => { diff --git a/osu.Tools.props b/osu.Tools.props index 65fc2ef01f..6231ca4ecd 100644 --- a/osu.Tools.props +++ b/osu.Tools.props @@ -1,15 +1,35 @@ - + - 8.0 + 12.0 osu-tools.licenseheader + + + + + + + + Default + Default + Recommended + Recommended + Recommended + Recommended + Default + Minimum + Recommended + Default + Default + ppy Pty Ltd - Copyright (c) 2020 ppy Pty Ltd + https://github.com/ppy/osu-tools + Copyright (c) 2024 ppy Pty Ltd diff --git a/osu.Tools.sln b/osu.Tools.sln index 4513456249..743f448e26 100644 --- a/osu.Tools.sln +++ b/osu.Tools.sln @@ -7,6 +7,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerformanceCalculator", "Pe EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerformanceCalculatorGUI", "PerformanceCalculatorGUI\PerformanceCalculatorGUI.csproj", "{BB34B7BA-CB01-4F5F-9532-B070F3A2C52E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{10DF8F12-50FD-45D8-8A38-17BA764BF54D}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + osu.Tools.props = osu.Tools.props + osu.Tools.sln.DotSettings = osu.Tools.sln.DotSettings + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodeAnalysis", "CodeAnalysis", "{FB156649-D457-4D1A-969C-D3A23FD31513}" + ProjectSection(SolutionItems) = preProject + CodeAnalysis\BannedSymbols.txt = CodeAnalysis\BannedSymbols.txt + CodeAnalysis\osu.Tools.globalconfig = CodeAnalysis\osu.Tools.globalconfig + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/osu.Tools.sln.DotSettings b/osu.Tools.sln.DotSettings index 1c52afdeb1..ccd6db354b 100644 --- a/osu.Tools.sln.DotSettings +++ b/osu.Tools.sln.DotSettings @@ -15,10 +15,12 @@ HINT HINT WARNING + WARNING WARNING WARNING WARNING True + DO_NOT_SHOW WARNING WARNING HINT @@ -65,8 +67,9 @@ HINT WARNING DO_NOT_SHOW + HINT WARNING - WARNING + HINT WARNING WARNING DO_NOT_SHOW @@ -80,6 +83,7 @@ WARNING WARNING HINT + DO_NOT_SHOW WARNING HINT DO_NOT_SHOW @@ -149,7 +153,6 @@ HINT HINT WARNING - HINT HINT WARNING WARNING @@ -165,6 +168,7 @@ WARNING WARNING WARNING + HINT WARNING WARNING WARNING @@ -251,6 +255,7 @@ HINT DO_NOT_SHOW WARNING + DO_NOT_SHOW WARNING WARNING WARNING @@ -263,6 +268,7 @@ WARNING WARNING WARNING + HINT WARNING HINT HINT @@ -335,12 +341,14 @@ API ARGB BPM + DDKK EF FPS GC GL GLSL HID + HP HSL HSPA HSV @@ -352,6 +360,8 @@ IP IPC JIT + KDDK + KKDD LTRB MD5 NS @@ -370,6 +380,7 @@ QAT BNG UI + WIP False HINT <?xml version="1.0" encoding="utf-16"?> @@ -834,6 +845,7 @@ See the LICENCE file in the repository root for full licence text. True True True + True True True True @@ -841,6 +853,7 @@ See the LICENCE file in the repository root for full licence text. True True True + True True True True @@ -1011,6 +1024,7 @@ private void load() True True True + True True True True @@ -1047,4 +1061,6 @@ private void load() True True True + True + True True From 5c438d2a92a072926e9f5b3f3379f9aa25e8997b Mon Sep 17 00:00:00 2001 From: StanR Date: Fri, 31 Jan 2025 20:58:38 +0500 Subject: [PATCH 2/4] Fix `Use explicit type` --- .../Difficulty/DifficultyCommand.cs | 2 +- .../LegacyScoreAttributesCommand.cs | 8 +-- .../LegacyScoreConversionCommand.cs | 2 +- .../Difficulty/ModsCommand.cs | 2 +- .../Leaderboard/LeaderboardCommand.cs | 6 +-- PerformanceCalculator/ProcessorCommand.cs | 6 +-- .../ProcessorWorkingBeatmap.cs | 2 +- .../Profile/ProfileCommand.cs | 6 +-- .../Simulate/CatchSimulateCommand.cs | 2 +- .../Simulate/ManiaSimulateCommand.cs | 4 +- .../Simulate/OsuSimulateCommand.cs | 16 +++--- .../Simulate/SimulateCommand.cs | 2 +- .../Simulate/TaikoSimulateCommand.cs | 12 ++--- .../Components/ExtendedOsuSpriteText.cs | 4 +- .../Components/StrainVisualizer.cs | 14 +++--- .../LimitedLabelledFractionalNumberBox.cs | 4 +- .../TextBoxes/LimitedLabelledNumberBox.cs | 4 +- .../ProcessorWorkingBeatmap.cs | 2 +- PerformanceCalculatorGUI/RulesetHelper.cs | 50 +++++++++---------- .../Screens/LeaderboardScreen.cs | 4 +- .../ObjectDifficultyValuesContainer.cs | 2 +- .../OsuObjectInspectorRuleset.cs | 2 +- .../Screens/ProfileScreen.cs | 6 +-- 23 files changed, 81 insertions(+), 81 deletions(-) diff --git a/PerformanceCalculator/Difficulty/DifficultyCommand.cs b/PerformanceCalculator/Difficulty/DifficultyCommand.cs index 8bdb8fd895..83cb473dfb 100644 --- a/PerformanceCalculator/Difficulty/DifficultyCommand.cs +++ b/PerformanceCalculator/Difficulty/DifficultyCommand.cs @@ -71,7 +71,7 @@ public override void Execute() { var document = new Document(); - foreach (var error in resultSet.Errors) + foreach (string error in resultSet.Errors) document.Children.Add(new Span(error), "\n"); if (resultSet.Errors.Count > 0) document.Children.Add("\n"); diff --git a/PerformanceCalculator/Difficulty/LegacyScoreAttributesCommand.cs b/PerformanceCalculator/Difficulty/LegacyScoreAttributesCommand.cs index 375b84e83d..2ec64674c2 100644 --- a/PerformanceCalculator/Difficulty/LegacyScoreAttributesCommand.cs +++ b/PerformanceCalculator/Difficulty/LegacyScoreAttributesCommand.cs @@ -67,7 +67,7 @@ public override void Execute() { var document = new Document(); - foreach (var error in resultSet.Errors) + foreach (string error in resultSet.Errors) document.Children.Add(new Span(error), "\n"); if (resultSet.Errors.Count > 0) document.Children.Add("\n"); @@ -85,7 +85,7 @@ public override void Execute() // Headers if (firstResult) { - foreach (var column in new[] { "Beatmap", "Mods", "Accuracy score", "Combo score", "Bonus score ratio", "Mod multiplier" }) + foreach (string column in new[] { "Beatmap", "Mods", "Accuracy score", "Combo score", "Bonus score ratio", "Mod multiplier" }) { grid.Columns.Add(GridLength.Auto); grid.Children.Add(new Cell(column)); @@ -121,7 +121,7 @@ private Result processBeatmap(WorkingBeatmap beatmap) var attributes = simulator.Simulate(beatmap, playableBeatmap); var conversionInfo = LegacyBeatmapConversionDifficultyInfo.FromBeatmap(playableBeatmap); - var modMultiplier = simulator.GetLegacyScoreMultiplier(mods, conversionInfo); + double modMultiplier = simulator.GetLegacyScoreMultiplier(mods, conversionInfo); return new Result { @@ -142,7 +142,7 @@ private Mod[] getMods(Ruleset ruleset) var availableMods = ruleset.CreateAllMods().ToList(); - foreach (var modString in Mods) + foreach (string modString in Mods) { Mod newMod = availableMods.FirstOrDefault(m => string.Equals(m.Acronym, modString, StringComparison.OrdinalIgnoreCase)); if (newMod == null) diff --git a/PerformanceCalculator/Difficulty/LegacyScoreConversionCommand.cs b/PerformanceCalculator/Difficulty/LegacyScoreConversionCommand.cs index a7731814e5..751c58627b 100644 --- a/PerformanceCalculator/Difficulty/LegacyScoreConversionCommand.cs +++ b/PerformanceCalculator/Difficulty/LegacyScoreConversionCommand.cs @@ -97,7 +97,7 @@ private Mod[] getMods(Ruleset ruleset) var availableMods = ruleset.CreateAllMods().ToList(); var mods = new List(); - foreach (var modString in Mods) + foreach (string modString in Mods) { Mod newMod = availableMods.FirstOrDefault(m => string.Equals(m.Acronym, modString, StringComparison.OrdinalIgnoreCase)); if (newMod == null) diff --git a/PerformanceCalculator/Difficulty/ModsCommand.cs b/PerformanceCalculator/Difficulty/ModsCommand.cs index 4298ab9256..8c93202cf0 100644 --- a/PerformanceCalculator/Difficulty/ModsCommand.cs +++ b/PerformanceCalculator/Difficulty/ModsCommand.cs @@ -67,7 +67,7 @@ IEnumerable getSettingsDefinitions(Mod mod) foreach (var (settingsSource, propertyInfo) in sourceProperties) { - var bindable = propertyInfo.GetValue(mod); + object? bindable = propertyInfo.GetValue(mod); Debug.Assert(bindable != null); diff --git a/PerformanceCalculator/Leaderboard/LeaderboardCommand.cs b/PerformanceCalculator/Leaderboard/LeaderboardCommand.cs index a9455ae3ac..42958a541d 100644 --- a/PerformanceCalculator/Leaderboard/LeaderboardCommand.cs +++ b/PerformanceCalculator/Leaderboard/LeaderboardCommand.cs @@ -33,7 +33,7 @@ public class LeaderboardCommand : ApiCommand public override void Execute() { - var rulesetApiName = LegacyHelper.GetRulesetShortNameFromId(Ruleset ?? 0); + string rulesetApiName = LegacyHelper.GetRulesetShortNameFromId(Ruleset ?? 0); var leaderboard = GetJsonFromApi($"rankings/{rulesetApiName}/performance?cursor[page]={LeaderboardPage - 1}"); var calculatedPlayers = new List(); @@ -78,7 +78,7 @@ public override void Execute() double nonBonusLivePP = liveOrdered.Sum(play => Math.Pow(0.95, index++) * play); //todo: implement properly. this is pretty damn wrong. - var playcountBonusPP = (totalLivePP - nonBonusLivePP); + double playcountBonusPP = (totalLivePP - nonBonusLivePP); totalLocalPP += playcountBonusPP; calculatedPlayers.Add(new LeaderboardPlayerInfo @@ -94,7 +94,7 @@ public override void Execute() if (OutputJson) { - var json = JsonConvert.SerializeObject(calculatedPlayers); + string json = JsonConvert.SerializeObject(calculatedPlayers); Console.Write(json); } diff --git a/PerformanceCalculator/ProcessorCommand.cs b/PerformanceCalculator/ProcessorCommand.cs index d09012060e..39738a898d 100644 --- a/PerformanceCalculator/ProcessorCommand.cs +++ b/PerformanceCalculator/ProcessorCommand.cs @@ -118,9 +118,9 @@ public void OutputDocument(Document document) { ConsoleRenderer.RenderDocumentToText(document, new TextRenderTarget(writer), new Rect(0, 0, 250, Size.Infinity)); - var str = writer.GetStringBuilder().ToString(); + string str = writer.GetStringBuilder().ToString(); - var lines = str.Split('\n'); + string[] lines = str.Split('\n'); for (int i = 0; i < lines.Length; i++) lines[i] = lines[i].TrimEnd(); str = string.Join('\n', lines); @@ -143,7 +143,7 @@ public static Mod[] ParseMods(Ruleset ruleset, string[] acronyms, string[] optio var mods = new List(); - foreach (var acronym in acronyms) + foreach (string acronym in acronyms) { APIMod mod = new APIMod { Acronym = acronym }; diff --git a/PerformanceCalculator/ProcessorWorkingBeatmap.cs b/PerformanceCalculator/ProcessorWorkingBeatmap.cs index 5eac8c0679..b8ecfa6229 100644 --- a/PerformanceCalculator/ProcessorWorkingBeatmap.cs +++ b/PerformanceCalculator/ProcessorWorkingBeatmap.cs @@ -58,7 +58,7 @@ public static ProcessorWorkingBeatmap FromFileOrId(string fileOrId) return new ProcessorWorkingBeatmap(fileOrId); } - if (!int.TryParse(fileOrId, out var beatmapId)) + if (!int.TryParse(fileOrId, out int beatmapId)) throw new ArgumentException("Could not parse provided beatmap ID."); string cachePath = Path.Combine("cache", $"{beatmapId}.osu"); diff --git a/PerformanceCalculator/Profile/ProfileCommand.cs b/PerformanceCalculator/Profile/ProfileCommand.cs index 7cb90d6f3e..7d61071126 100644 --- a/PerformanceCalculator/Profile/ProfileCommand.cs +++ b/PerformanceCalculator/Profile/ProfileCommand.cs @@ -32,7 +32,7 @@ public override void Execute() var displayPlays = new List(); var ruleset = LegacyHelper.GetRulesetFromLegacyID(Ruleset ?? 0); - var rulesetApiName = LegacyHelper.GetRulesetShortNameFromId(Ruleset ?? 0); + string rulesetApiName = LegacyHelper.GetRulesetShortNameFromId(Ruleset ?? 0); Console.WriteLine("Getting user data..."); var userData = GetJsonFromApi($"users/{ProfileName}/{ruleset.ShortName}"); @@ -81,13 +81,13 @@ public override void Execute() double nonBonusLivePP = liveOrdered.Sum(play => Math.Pow(0.95, index++) * play.LivePP); //todo: implement properly. this is pretty damn wrong. - var playcountBonusPP = (totalLivePP - nonBonusLivePP); + double playcountBonusPP = (totalLivePP - nonBonusLivePP); totalLocalPP += playcountBonusPP; double totalDiffPP = totalLocalPP - totalLivePP; if (OutputJson) { - var json = JsonConvert.SerializeObject(new + string json = JsonConvert.SerializeObject(new { Username = userData.Username, LivePp = totalLivePP, diff --git a/PerformanceCalculator/Simulate/CatchSimulateCommand.cs b/PerformanceCalculator/Simulate/CatchSimulateCommand.cs index 86fa471011..d1b1c33dd2 100644 --- a/PerformanceCalculator/Simulate/CatchSimulateCommand.cs +++ b/PerformanceCalculator/Simulate/CatchSimulateCommand.cs @@ -40,7 +40,7 @@ public class CatchSimulateCommand : SimulateCommand private static Dictionary generateHitResults(IBeatmap beatmap, double accuracy, int countMiss, int? countMeh, int? countGood) { - var maxCombo = beatmap.GetMaxCombo(); + int maxCombo = beatmap.GetMaxCombo(); int maxTinyDroplets = beatmap.HitObjects.OfType().Sum(s => s.NestedHitObjects.OfType().Count()); int maxDroplets = beatmap.HitObjects.OfType().Sum(s => s.NestedHitObjects.OfType().Count()) - maxTinyDroplets; int maxFruits = beatmap.HitObjects.Sum(h => h is Fruit ? 1 : (h as JuiceStream)?.NestedHitObjects.Count(n => n is Fruit) ?? 0); diff --git a/PerformanceCalculator/Simulate/ManiaSimulateCommand.cs b/PerformanceCalculator/Simulate/ManiaSimulateCommand.cs index 0287c50df1..ff79ca7961 100644 --- a/PerformanceCalculator/Simulate/ManiaSimulateCommand.cs +++ b/PerformanceCalculator/Simulate/ManiaSimulateCommand.cs @@ -41,7 +41,7 @@ public class ManiaSimulateCommand : SimulateCommand private static Dictionary generateHitResults(IBeatmap beatmap, double accuracy, int countMiss, int? countMeh, int? countOk, int? countGood, int? countGreat) { // One judgement per normal note. Two judgements per hold note (head + tail). - var totalHits = beatmap.HitObjects.Count + beatmap.HitObjects.Count(ho => ho is HoldNote); + int totalHits = beatmap.HitObjects.Count + beatmap.HitObjects.Count(ho => ho is HoldNote); if (countMeh != null || countOk != null || countGood != null || countGreat != null) { @@ -59,7 +59,7 @@ private static Dictionary generateHitResults(IBeatmap beatmap, d } // Let Great=Perfect=6, Good=4, Ok=2, Meh=1, Miss=0. The total should be this. - var targetTotal = (int)Math.Round(accuracy * totalHits * 6); + int targetTotal = (int)Math.Round(accuracy * totalHits * 6); // Start by assuming every non miss is a meh // This is how much increase is needed by the rest diff --git a/PerformanceCalculator/Simulate/OsuSimulateCommand.cs b/PerformanceCalculator/Simulate/OsuSimulateCommand.cs index 337a9c2541..08c5149bff 100644 --- a/PerformanceCalculator/Simulate/OsuSimulateCommand.cs +++ b/PerformanceCalculator/Simulate/OsuSimulateCommand.cs @@ -62,7 +62,7 @@ private static Dictionary generateHitResults(IBeatmap beatmap, d { int countGreat; - var totalResultCount = beatmap.HitObjects.Count; + int totalResultCount = beatmap.HitObjects.Count; if (countMeh != null || countGood != null) { @@ -153,17 +153,17 @@ private static Dictionary generateHitResults(IBeatmap beatmap, d protected override double GetAccuracy(IBeatmap beatmap, Dictionary statistics) { - var countGreat = statistics[HitResult.Great]; - var countGood = statistics[HitResult.Ok]; - var countMeh = statistics[HitResult.Meh]; - var countMiss = statistics[HitResult.Miss]; + int countGreat = statistics[HitResult.Great]; + int countGood = statistics[HitResult.Ok]; + int countMeh = statistics[HitResult.Meh]; + int countMiss = statistics[HitResult.Miss]; double total = 6 * countGreat + 2 * countGood + countMeh; double max = 6 * (countGreat + countGood + countMeh + countMiss); if (statistics.TryGetValue(HitResult.SliderTailHit, out int countSliderTailHit)) { - var countSliders = beatmap.HitObjects.Count(x => x is Slider); + int countSliders = beatmap.HitObjects.Count(x => x is Slider); total += 3 * countSliderTailHit; max += 3 * countSliders; @@ -171,8 +171,8 @@ protected override double GetAccuracy(IBeatmap beatmap, Dictionary obj.NestedHitObjects.Count(x => x is SliderTick or SliderRepeat)); - var countLargeTickHit = countLargeTicks - countLargeTickMiss; + int countLargeTicks = beatmap.HitObjects.Sum(obj => obj.NestedHitObjects.Count(x => x is SliderTick or SliderRepeat)); + int countLargeTickHit = countLargeTicks - countLargeTickMiss; total += 0.6 * countLargeTickHit; max += 0.6 * countLargeTicks; diff --git a/PerformanceCalculator/Simulate/SimulateCommand.cs b/PerformanceCalculator/Simulate/SimulateCommand.cs index 6854325179..ca88346d51 100644 --- a/PerformanceCalculator/Simulate/SimulateCommand.cs +++ b/PerformanceCalculator/Simulate/SimulateCommand.cs @@ -66,7 +66,7 @@ public override void Execute() var mods = ParseMods(ruleset, Mods, ModOptions); var beatmap = workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods); - var beatmapMaxCombo = beatmap.GetMaxCombo(); + int beatmapMaxCombo = beatmap.GetMaxCombo(); var statistics = GenerateHitResults(beatmap, mods); var scoreInfo = new ScoreInfo(beatmap.BeatmapInfo, ruleset.RulesetInfo) { diff --git a/PerformanceCalculator/Simulate/TaikoSimulateCommand.cs b/PerformanceCalculator/Simulate/TaikoSimulateCommand.cs index bf537a7c8e..a1ebe4ec9e 100644 --- a/PerformanceCalculator/Simulate/TaikoSimulateCommand.cs +++ b/PerformanceCalculator/Simulate/TaikoSimulateCommand.cs @@ -34,7 +34,7 @@ public class TaikoSimulateCommand : SimulateCommand private static Dictionary generateHitResults(double accuracy, IBeatmap beatmap, int countMiss, int? countGood) { - var totalResultCount = beatmap.GetMaxCombo(); + int totalResultCount = beatmap.GetMaxCombo(); int countGreat; @@ -45,7 +45,7 @@ private static Dictionary generateHitResults(double accuracy, IB else { // Let Great=2, Good=1, Miss=0. The total should be this. - var targetTotal = (int)Math.Round(accuracy * totalResultCount * 2); + int targetTotal = (int)Math.Round(accuracy * totalResultCount * 2); countGreat = targetTotal - (totalResultCount - countMiss); countGood = totalResultCount - countGreat - countMiss; @@ -62,10 +62,10 @@ private static Dictionary generateHitResults(double accuracy, IB protected override double GetAccuracy(IBeatmap beatmap, Dictionary statistics) { - var countGreat = statistics[HitResult.Great]; - var countGood = statistics[HitResult.Ok]; - var countMiss = statistics[HitResult.Miss]; - var total = countGreat + countGood + countMiss; + int countGreat = statistics[HitResult.Great]; + int countGood = statistics[HitResult.Ok]; + int countMiss = statistics[HitResult.Miss]; + int total = countGreat + countGood + countMiss; return (double)((2 * countGreat) + countGood) / (2 * total); } diff --git a/PerformanceCalculatorGUI/Components/ExtendedOsuSpriteText.cs b/PerformanceCalculatorGUI/Components/ExtendedOsuSpriteText.cs index d9ad4dee3a..325cfb28a8 100644 --- a/PerformanceCalculatorGUI/Components/ExtendedOsuSpriteText.cs +++ b/PerformanceCalculatorGUI/Components/ExtendedOsuSpriteText.cs @@ -60,9 +60,9 @@ public void SetContent(string data) currentData = data; - var split = data.Split('\n'); + string[] split = data.Split('\n'); - foreach (var line in split) + foreach (string line in split) textContainer.Add(new OsuSpriteText { Text = line }); } diff --git a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs index 4b47fa8bf7..76c6f334a9 100644 --- a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs +++ b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs @@ -76,7 +76,7 @@ private void updateGraphs(ValueChangedEvent val) { // this is ugly, but it works var graphToggleBindable = new Bindable(); - var graphNum = i; + int graphNum = i; graphToggleBindable.BindValueChanged(state => { if (state.NewValue) @@ -186,7 +186,7 @@ private void load(OsuColour colours) private void addStrainBars(Skill[] skills, List strainLists) { - var strainMaxValue = strainLists.Max(list => list.Max()); + float strainMaxValue = strainLists.Max(list => list.Max()); for (int i = 0; i < skills.Length; i++) { @@ -223,7 +223,7 @@ private void addTooltipBars(List strainLists, int nBars = 1000) for (int i = 0; i < nBars; i++) { var strainTime = TimeSpan.FromMilliseconds(TimeUntilFirstStrain.Value + lastStrainTime * i / nBars); - var tooltipText = $"~{strainTime:mm\\:ss\\.ff}"; + string tooltipText = $"~{strainTime:mm\\:ss\\.ff}"; tooltipList.Add(tooltipText); } @@ -248,13 +248,13 @@ private static List getStrainLists(Skill[] skills) foreach (var skill in skills) { - var strains = ((StrainSkill)skill).GetCurrentStrainPeaks().ToArray(); + double[] strains = ((StrainSkill)skill).GetCurrentStrainPeaks().ToArray(); var skillStrainList = new List(); for (int i = 0; i < strains.Length; i++) { - var strain = strains[i]; + double strain = strains[i]; skillStrainList.Add(((float)strain)); } @@ -281,7 +281,7 @@ public IEnumerable Values { Clear(); - foreach (var val in value) + foreach (float val in value) { float length = MaxValue ?? value.Max(); if (length != 0) @@ -324,7 +324,7 @@ public IEnumerable Values { Clear(); - foreach (var tooltip in value) + foreach (string tooltip in value) { float size = value.Count(); if (size != 0) diff --git a/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledFractionalNumberBox.cs b/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledFractionalNumberBox.cs index f6fbbad29f..2e33541072 100644 --- a/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledFractionalNumberBox.cs +++ b/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledFractionalNumberBox.cs @@ -17,7 +17,7 @@ protected override void OnUserTextAdded(string added) { base.OnUserTextAdded(added); - var textToParse = Text; + string textToParse = Text; if (string.IsNullOrEmpty(Text)) { @@ -39,7 +39,7 @@ protected override void OnUserTextAdded(string added) protected override void OnUserTextRemoved(string removed) { - var textToParse = Text; + string textToParse = Text; if (string.IsNullOrEmpty(Text)) { diff --git a/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledNumberBox.cs b/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledNumberBox.cs index f083804735..62e4633e82 100644 --- a/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledNumberBox.cs +++ b/PerformanceCalculatorGUI/Components/TextBoxes/LimitedLabelledNumberBox.cs @@ -15,7 +15,7 @@ protected override void OnUserTextAdded(string added) { base.OnUserTextAdded(added); - var textToParse = Text; + string textToParse = Text; if (string.IsNullOrEmpty(Text)) { @@ -37,7 +37,7 @@ protected override void OnUserTextAdded(string added) protected override void OnUserTextRemoved(string removed) { - var textToParse = Text; + string textToParse = Text; if (string.IsNullOrEmpty(Text)) { diff --git a/PerformanceCalculatorGUI/ProcessorWorkingBeatmap.cs b/PerformanceCalculatorGUI/ProcessorWorkingBeatmap.cs index a8845d3edb..f4fe1f7d1b 100644 --- a/PerformanceCalculatorGUI/ProcessorWorkingBeatmap.cs +++ b/PerformanceCalculatorGUI/ProcessorWorkingBeatmap.cs @@ -66,7 +66,7 @@ public static ProcessorWorkingBeatmap FromFileOrId(string fileOrId, AudioManager return new ProcessorWorkingBeatmap(fileOrId, null, audioManager); } - if (!int.TryParse(fileOrId, out var beatmapId)) + if (!int.TryParse(fileOrId, out int beatmapId)) throw new ArgumentException("Could not parse provided beatmap ID."); cachePath = Path.Combine(cachePath, $"{beatmapId}.osu"); diff --git a/PerformanceCalculatorGUI/RulesetHelper.cs b/PerformanceCalculatorGUI/RulesetHelper.cs index 00d85da367..0160785f97 100644 --- a/PerformanceCalculatorGUI/RulesetHelper.cs +++ b/PerformanceCalculatorGUI/RulesetHelper.cs @@ -81,7 +81,7 @@ private static Dictionary generateOsuHitResults(double accuracy, { int countGreat; - var totalResultCount = beatmap.HitObjects.Count; + int totalResultCount = beatmap.HitObjects.Count; if (countMeh != null || countGood != null) { @@ -172,7 +172,7 @@ private static Dictionary generateOsuHitResults(double accuracy, private static Dictionary generateTaikoHitResults(double accuracy, IBeatmap beatmap, int countMiss, int? countGood) { - var totalResultCount = beatmap.HitObjects.OfType().Count(); + int totalResultCount = beatmap.HitObjects.OfType().Count(); int countGreat; @@ -183,7 +183,7 @@ private static Dictionary generateTaikoHitResults(double accurac else { // Let Great=2, Good=1, Miss=0. The total should be this. - var targetTotal = (int)Math.Round(accuracy * totalResultCount * 2); + int targetTotal = (int)Math.Round(accuracy * totalResultCount * 2); countGreat = targetTotal - (totalResultCount - countMiss); countGood = totalResultCount - countGreat - countMiss; @@ -200,7 +200,7 @@ private static Dictionary generateTaikoHitResults(double accurac private static Dictionary generateCatchHitResults(double accuracy, IBeatmap beatmap, int countMiss, int? countMeh, int? countGood) { - var maxCombo = beatmap.HitObjects.Count(h => h is Fruit) + beatmap.HitObjects.OfType().SelectMany(j => j.NestedHitObjects).Count(h => !(h is TinyDroplet)); + int maxCombo = beatmap.HitObjects.Count(h => h is Fruit) + beatmap.HitObjects.OfType().SelectMany(j => j.NestedHitObjects).Count(h => !(h is TinyDroplet)); int maxTinyDroplets = beatmap.HitObjects.OfType().Sum(s => s.NestedHitObjects.OfType().Count()); int maxDroplets = beatmap.HitObjects.OfType().Sum(s => s.NestedHitObjects.OfType().Count()) - maxTinyDroplets; @@ -231,14 +231,14 @@ private static Dictionary generateCatchHitResults(double accurac private static Dictionary generateManiaHitResults(double accuracy, IBeatmap beatmap, int countMiss) { - var totalResultCount = beatmap.HitObjects.Count; + int totalResultCount = beatmap.HitObjects.Count; // Let Great=6, Good=2, Meh=1, Miss=0. The total should be this. - var targetTotal = (int)Math.Round(accuracy * totalResultCount * 6); + int targetTotal = (int)Math.Round(accuracy * totalResultCount * 6); // Start by assuming every non miss is a meh // This is how much increase is needed by greats and goods - var delta = targetTotal - (totalResultCount - countMiss); + int delta = targetTotal - (totalResultCount - countMiss); // Each great increases total by 5 (great-meh=5) int countGreat = delta / 5; @@ -272,17 +272,17 @@ public static double GetAccuracyForRuleset(RulesetInfo ruleset, IBeatmap beatmap private static double getOsuAccuracy(IBeatmap beatmap, Dictionary statistics) { - var countGreat = statistics[HitResult.Great]; - var countGood = statistics[HitResult.Ok]; - var countMeh = statistics[HitResult.Meh]; - var countMiss = statistics[HitResult.Miss]; + int countGreat = statistics[HitResult.Great]; + int countGood = statistics[HitResult.Ok]; + int countMeh = statistics[HitResult.Meh]; + int countMiss = statistics[HitResult.Miss]; double total = 6 * countGreat + 2 * countGood + countMeh; double max = 6 * (countGreat + countGood + countMeh + countMiss); if (statistics.TryGetValue(HitResult.SliderTailHit, out int countSliderTailHit)) { - var countSliders = beatmap.HitObjects.Count(x => x is Slider); + int countSliders = beatmap.HitObjects.Count(x => x is Slider); total += 3 * countSliderTailHit; max += 3 * countSliders; @@ -290,8 +290,8 @@ private static double getOsuAccuracy(IBeatmap beatmap, Dictionary obj.NestedHitObjects.Count(x => x is SliderTick or SliderRepeat)); - var countLargeTickHit = countLargeTicks - countLargeTicksMiss; + int countLargeTicks = beatmap.HitObjects.Sum(obj => obj.NestedHitObjects.Count(x => x is SliderTick or SliderRepeat)); + int countLargeTickHit = countLargeTicks - countLargeTicksMiss; total += 0.6 * countLargeTickHit; max += 0.6 * countLargeTicks; @@ -302,10 +302,10 @@ private static double getOsuAccuracy(IBeatmap beatmap, Dictionary statistics) { - var countGreat = statistics[HitResult.Great]; - var countGood = statistics[HitResult.Ok]; - var countMiss = statistics[HitResult.Miss]; - var total = countGreat + countGood + countMiss; + int countGreat = statistics[HitResult.Great]; + int countGood = statistics[HitResult.Ok]; + int countMiss = statistics[HitResult.Miss]; + int total = countGreat + countGood + countMiss; return (double)((2 * countGreat) + countGood) / (2 * total); } @@ -320,13 +320,13 @@ private static double getCatchAccuracy(Dictionary statistics) private static double getManiaAccuracy(Dictionary statistics) { - var countPerfect = statistics[HitResult.Perfect]; - var countGreat = statistics[HitResult.Great]; - var countGood = statistics[HitResult.Good]; - var countOk = statistics[HitResult.Ok]; - var countMeh = statistics[HitResult.Meh]; - var countMiss = statistics[HitResult.Miss]; - var total = countPerfect + countGreat + countGood + countOk + countMeh + countMiss; + int countPerfect = statistics[HitResult.Perfect]; + int countGreat = statistics[HitResult.Great]; + int countGood = statistics[HitResult.Good]; + int countOk = statistics[HitResult.Ok]; + int countMeh = statistics[HitResult.Meh]; + int countMiss = statistics[HitResult.Miss]; + int total = countPerfect + countGreat + countGood + countOk + countMeh + countMiss; return (double) ((6 * (countPerfect + countGreat)) + (4 * countGood) + (2 * countOk) + countMeh) / diff --git a/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs b/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs index bedfe84624..c15270513b 100644 --- a/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs +++ b/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs @@ -323,7 +323,7 @@ private async Task calculatePlayer(UserStatistics player, C var difficultyAttributes = difficultyCalculator.Calculate(mods); var performanceCalculator = rulesetInstance.CreatePerformanceCalculator(); - var livePp = score.PP ?? 0.0; + double livePp = score.PP ?? 0.0; var perfAttributes = performanceCalculator?.Calculate(parsedScore.ScoreInfo, difficultyAttributes); score.PP = perfAttributes?.Total ?? 0.0; @@ -356,7 +356,7 @@ private async Task calculatePlayer(UserStatistics player, C decimal nonBonusLivePP = (decimal)liveOrdered.Select(x => x.LivePP).Sum(play => Math.Pow(0.95, index++) * play); //todo: implement properly. this is pretty damn wrong. - var playcountBonusPP = (totalLivePP - nonBonusLivePP); + decimal playcountBonusPP = (totalLivePP - nonBonusLivePP); totalLocalPP += playcountBonusPP; return new UserLeaderboardData diff --git a/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectDifficultyValuesContainer.cs b/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectDifficultyValuesContainer.cs index 1cf9452b88..5c8d761446 100644 --- a/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectDifficultyValuesContainer.cs +++ b/PerformanceCalculatorGUI/Screens/ObjectInspection/ObjectDifficultyValuesContainer.cs @@ -121,7 +121,7 @@ private void updateValues(DifficultyHitObject hitObject) private void drawOsuValues(OsuDifficultyHitObject hitObject) { - var hidden = appliedMods.Value.Any(x => x is ModHidden); + bool hidden = appliedMods.Value.Any(x => x is ModHidden); flowContainer.AddRange(new[] { new ObjectInspectorDifficultyValue("Position", (hitObject.BaseObject as OsuHitObject)!.StackedPosition), diff --git a/PerformanceCalculatorGUI/Screens/ObjectInspection/OsuObjectInspectorRuleset.cs b/PerformanceCalculatorGUI/Screens/ObjectInspection/OsuObjectInspectorRuleset.cs index a058eef85e..657d8926db 100644 --- a/PerformanceCalculatorGUI/Screens/ObjectInspection/OsuObjectInspectorRuleset.cs +++ b/PerformanceCalculatorGUI/Screens/ObjectInspection/OsuObjectInspectorRuleset.cs @@ -90,7 +90,7 @@ private void updateState(DrawableHitObject hitObject, ArmedState state) using (hitObject.BeginAbsoluteSequence(hitObject.StartTimeBindable.Value)) { - var hitObjectDuration = hitObject.HitObject.GetEndTime() - hitObject.StartTimeBindable.Value; + double hitObjectDuration = hitObject.HitObject.GetEndTime() - hitObject.StartTimeBindable.Value; hitObject.Delay(hitObjectDuration) .FadeTo(0.25f, 200f, Easing.Out) diff --git a/PerformanceCalculatorGUI/Screens/ProfileScreen.cs b/PerformanceCalculatorGUI/Screens/ProfileScreen.cs index 885e25e75e..b5b4bc1836 100644 --- a/PerformanceCalculatorGUI/Screens/ProfileScreen.cs +++ b/PerformanceCalculatorGUI/Screens/ProfileScreen.cs @@ -331,17 +331,17 @@ private void calculateProfile(string username) }); decimal totalLocalPP = 0; - for (var i = 0; i < localOrdered.Count; i++) + for (int i = 0; i < localOrdered.Count; i++) totalLocalPP += (decimal)(Math.Pow(0.95, i) * (localOrdered[i].SoloScore.PP ?? 0)); decimal totalLivePP = player.Statistics.PP ?? (decimal)0.0; decimal nonBonusLivePP = 0; - for (var i = 0; i < liveOrdered.Count; i++) + for (int i = 0; i < liveOrdered.Count; i++) nonBonusLivePP += (decimal)(Math.Pow(0.95, i) * liveOrdered[i].LivePP ?? 0); //todo: implement properly. this is pretty damn wrong. - var playcountBonusPP = (totalLivePP - nonBonusLivePP); + decimal playcountBonusPP = (totalLivePP - nonBonusLivePP); totalLocalPP += playcountBonusPP; Schedule(() => From 03c60ad39fb18d0c8ceadbdc04a0b0530a2acc9a Mon Sep 17 00:00:00 2001 From: StanR Date: Fri, 31 Jan 2025 21:27:12 +0500 Subject: [PATCH 3/4] Fix remaining code style issues --- .../Difficulty/ModsCommand.cs | 1 - .../Profile/ProfileCommand.cs | 2 +- .../Components/ScreenSelectionButtonIcon.cs | 15 +++++----- .../ExtendedCatchDifficultyCalculator.cs | 29 ++++++++++--------- .../ExtendedOsuDifficultyCalculator.cs | 29 ++++++++++--------- .../ExtendedTaikoDifficultyCalculator.cs | 29 ++++++++++--------- PerformanceCalculatorGUI/RulesetHelper.cs | 18 ------------ .../Screens/LeaderboardScreen.cs | 6 ++-- .../Screens/ProfileScreen.cs | 2 +- 9 files changed, 58 insertions(+), 73 deletions(-) diff --git a/PerformanceCalculator/Difficulty/ModsCommand.cs b/PerformanceCalculator/Difficulty/ModsCommand.cs index 8c93202cf0..f922958b52 100644 --- a/PerformanceCalculator/Difficulty/ModsCommand.cs +++ b/PerformanceCalculator/Difficulty/ModsCommand.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using Humanizer; using McMaster.Extensions.CommandLineUtils; using Newtonsoft.Json; using osu.Game.Configuration; diff --git a/PerformanceCalculator/Profile/ProfileCommand.cs b/PerformanceCalculator/Profile/ProfileCommand.cs index 7d61071126..c55f515bea 100644 --- a/PerformanceCalculator/Profile/ProfileCommand.cs +++ b/PerformanceCalculator/Profile/ProfileCommand.cs @@ -89,7 +89,7 @@ public override void Execute() { string json = JsonConvert.SerializeObject(new { - Username = userData.Username, + userData.Username, LivePp = totalLivePP, LocalPp = totalLocalPP, PlaycountPp = playcountBonusPP, diff --git a/PerformanceCalculatorGUI/Components/ScreenSelectionButtonIcon.cs b/PerformanceCalculatorGUI/Components/ScreenSelectionButtonIcon.cs index 103a9eaf9f..bfdb69cf72 100644 --- a/PerformanceCalculatorGUI/Components/ScreenSelectionButtonIcon.cs +++ b/PerformanceCalculatorGUI/Components/ScreenSelectionButtonIcon.cs @@ -5,14 +5,15 @@ using osu.Framework.Localisation; using osu.Game.Beatmaps.Drawables.Cards; -namespace PerformanceCalculatorGUI.Components; - -public partial class ScreenSelectionButtonIcon : IconPill +namespace PerformanceCalculatorGUI.Components { - public ScreenSelectionButtonIcon(IconUsage? icon = null) - : base(icon ?? FontAwesome.Solid.List) + public partial class ScreenSelectionButtonIcon : IconPill { - } + public ScreenSelectionButtonIcon(IconUsage? icon = null) + : base(icon ?? FontAwesome.Solid.List) + { + } - public override LocalisableString TooltipText => string.Empty; + public override LocalisableString TooltipText => string.Empty; + } } diff --git a/PerformanceCalculatorGUI/ExtendedCatchDifficultyCalculator.cs b/PerformanceCalculatorGUI/ExtendedCatchDifficultyCalculator.cs index 15cfbe2435..f4f65f205f 100644 --- a/PerformanceCalculatorGUI/ExtendedCatchDifficultyCalculator.cs +++ b/PerformanceCalculatorGUI/ExtendedCatchDifficultyCalculator.cs @@ -10,23 +10,24 @@ using osu.Game.Rulesets.Difficulty.Skills; using osu.Game.Rulesets.Mods; -namespace PerformanceCalculatorGUI; - -public class ExtendedCatchDifficultyCalculator : CatchDifficultyCalculator, IExtendedDifficultyCalculator +namespace PerformanceCalculatorGUI { - private Skill[] skills; - - public ExtendedCatchDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap) - : base(ruleset, beatmap) + public class ExtendedCatchDifficultyCalculator : CatchDifficultyCalculator, IExtendedDifficultyCalculator { - } + private Skill[] skills; - public Skill[] GetSkills() => skills; - public DifficultyHitObject[] GetDifficultyHitObjects(IBeatmap beatmap, double clockRate) => CreateDifficultyHitObjects(beatmap, clockRate).ToArray(); + public ExtendedCatchDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap) + : base(ruleset, beatmap) + { + } - protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) - { - this.skills = skills; - return base.CreateDifficultyAttributes(beatmap, mods, skills, clockRate); + public Skill[] GetSkills() => skills; + public DifficultyHitObject[] GetDifficultyHitObjects(IBeatmap beatmap, double clockRate) => CreateDifficultyHitObjects(beatmap, clockRate).ToArray(); + + protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) + { + this.skills = skills; + return base.CreateDifficultyAttributes(beatmap, mods, skills, clockRate); + } } } diff --git a/PerformanceCalculatorGUI/ExtendedOsuDifficultyCalculator.cs b/PerformanceCalculatorGUI/ExtendedOsuDifficultyCalculator.cs index 5738e40e52..b5040ebf6e 100644 --- a/PerformanceCalculatorGUI/ExtendedOsuDifficultyCalculator.cs +++ b/PerformanceCalculatorGUI/ExtendedOsuDifficultyCalculator.cs @@ -10,23 +10,24 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu.Difficulty; -namespace PerformanceCalculatorGUI; - -public class ExtendedOsuDifficultyCalculator : OsuDifficultyCalculator, IExtendedDifficultyCalculator +namespace PerformanceCalculatorGUI { - private Skill[] skills; - - public ExtendedOsuDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap) - : base(ruleset, beatmap) + public class ExtendedOsuDifficultyCalculator : OsuDifficultyCalculator, IExtendedDifficultyCalculator { - } + private Skill[] skills; - public Skill[] GetSkills() => skills; - public DifficultyHitObject[] GetDifficultyHitObjects(IBeatmap beatmap, double clockRate) => CreateDifficultyHitObjects(beatmap, clockRate).ToArray(); + public ExtendedOsuDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap) + : base(ruleset, beatmap) + { + } - protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) - { - this.skills = skills; - return base.CreateDifficultyAttributes(beatmap, mods, skills, clockRate); + public Skill[] GetSkills() => skills; + public DifficultyHitObject[] GetDifficultyHitObjects(IBeatmap beatmap, double clockRate) => CreateDifficultyHitObjects(beatmap, clockRate).ToArray(); + + protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) + { + this.skills = skills; + return base.CreateDifficultyAttributes(beatmap, mods, skills, clockRate); + } } } diff --git a/PerformanceCalculatorGUI/ExtendedTaikoDifficultyCalculator.cs b/PerformanceCalculatorGUI/ExtendedTaikoDifficultyCalculator.cs index 60589cda7e..6db12c51e0 100644 --- a/PerformanceCalculatorGUI/ExtendedTaikoDifficultyCalculator.cs +++ b/PerformanceCalculatorGUI/ExtendedTaikoDifficultyCalculator.cs @@ -10,23 +10,24 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Taiko.Difficulty; -namespace PerformanceCalculatorGUI; - -public class ExtendedTaikoDifficultyCalculator : TaikoDifficultyCalculator, IExtendedDifficultyCalculator +namespace PerformanceCalculatorGUI { - private Skill[] skills; - - public ExtendedTaikoDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap) - : base(ruleset, beatmap) + public class ExtendedTaikoDifficultyCalculator : TaikoDifficultyCalculator, IExtendedDifficultyCalculator { - } + private Skill[] skills; - public Skill[] GetSkills() => skills; - public DifficultyHitObject[] GetDifficultyHitObjects(IBeatmap beatmap, double clockRate) => CreateDifficultyHitObjects(beatmap, clockRate).ToArray(); + public ExtendedTaikoDifficultyCalculator(IRulesetInfo ruleset, IWorkingBeatmap beatmap) + : base(ruleset, beatmap) + { + } - protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) - { - this.skills = skills; - return base.CreateDifficultyAttributes(beatmap, mods, skills, clockRate); + public Skill[] GetSkills() => skills; + public DifficultyHitObject[] GetDifficultyHitObjects(IBeatmap beatmap, double clockRate) => CreateDifficultyHitObjects(beatmap, clockRate).ToArray(); + + protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate) + { + this.skills = skills; + return base.CreateDifficultyAttributes(beatmap, mods, skills, clockRate); + } } } diff --git a/PerformanceCalculatorGUI/RulesetHelper.cs b/PerformanceCalculatorGUI/RulesetHelper.cs index 0160785f97..c323dcc3ab 100644 --- a/PerformanceCalculatorGUI/RulesetHelper.cs +++ b/PerformanceCalculatorGUI/RulesetHelper.cs @@ -332,23 +332,5 @@ private static double getManiaAccuracy(Dictionary statistics) ((6 * (countPerfect + countGreat)) + (4 * countGood) + (2 * countOk) + countMeh) / (6 * total); } - - private class EmptyWorkingBeatmap : WorkingBeatmap - { - public EmptyWorkingBeatmap() - : base(new BeatmapInfo(), null) - { - } - - protected override IBeatmap GetBeatmap() => throw new NotImplementedException(); - - public override Texture GetBackground() => throw new NotImplementedException(); - - protected override Track GetBeatmapTrack() => throw new NotImplementedException(); - - protected override ISkin GetSkin() => throw new NotImplementedException(); - - public override Stream GetStream(string storagePath) => throw new NotImplementedException(); - } } } diff --git a/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs b/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs index c15270513b..3943ea23b0 100644 --- a/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs +++ b/PerformanceCalculatorGUI/Screens/LeaderboardScreen.cs @@ -323,7 +323,7 @@ private async Task calculatePlayer(UserStatistics player, C var difficultyAttributes = difficultyCalculator.Calculate(mods); var performanceCalculator = rulesetInstance.CreatePerformanceCalculator(); - double livePp = score.PP ?? 0.0; + double? livePp = score.PP; var perfAttributes = performanceCalculator?.Calculate(parsedScore.ScoreInfo, difficultyAttributes); score.PP = perfAttributes?.Total ?? 0.0; @@ -346,14 +346,14 @@ private async Task calculatePlayer(UserStatistics player, C catch (OperationCanceledException) { } var localOrdered = plays.OrderByDescending(x => x.SoloScore.PP).ToList(); - var liveOrdered = plays.OrderByDescending(x => x.LivePP).ToList(); + var liveOrdered = plays.OrderByDescending(x => x.LivePP ?? 0.0).ToList(); int index = 0; decimal totalLocalPP = (decimal)(localOrdered.Select(x => x.SoloScore.PP).Sum(play => Math.Pow(0.95, index++) * play) ?? 0.0); decimal totalLivePP = player.PP ?? (decimal)0.0; index = 0; - decimal nonBonusLivePP = (decimal)liveOrdered.Select(x => x.LivePP).Sum(play => Math.Pow(0.95, index++) * play); + decimal nonBonusLivePP = (decimal)liveOrdered.Select(x => x.LivePP ?? 0.0).Sum(play => Math.Pow(0.95, index++) * play); //todo: implement properly. this is pretty damn wrong. decimal playcountBonusPP = (totalLivePP - nonBonusLivePP); diff --git a/PerformanceCalculatorGUI/Screens/ProfileScreen.cs b/PerformanceCalculatorGUI/Screens/ProfileScreen.cs index b5b4bc1836..79b9bf1b06 100644 --- a/PerformanceCalculatorGUI/Screens/ProfileScreen.cs +++ b/PerformanceCalculatorGUI/Screens/ProfileScreen.cs @@ -278,7 +278,7 @@ private void calculateProfile(string username) if (includePinnedCheckbox.Current.Value) { var pinnedScores = await apiManager.GetJsonFromApi>($"users/{player.OnlineID}/scores/pinned?mode={ruleset.Value.ShortName}&limit=100").ConfigureAwait(false); - apiScores = apiScores.Concat(pinnedScores.Where(p => !apiScores.Any(b => b.ID == p.ID))).ToList(); + apiScores = apiScores.Concat(pinnedScores.Where(p => !apiScores.Any(b => b.ID == p.ID)).ToArray()).ToList(); } foreach (var score in apiScores) From b8c55b4f81371488301e274f909fe3b0bb19d543 Mon Sep 17 00:00:00 2001 From: StanR Date: Fri, 31 Jan 2025 21:30:50 +0500 Subject: [PATCH 4/4] Fix remaining code style issues part 2 --- .../IExtendedDifficultyCalculator.cs | 11 ++++++----- PerformanceCalculatorGUI/RulesetHelper.cs | 4 ---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/PerformanceCalculatorGUI/IExtendedDifficultyCalculator.cs b/PerformanceCalculatorGUI/IExtendedDifficultyCalculator.cs index 5671a0b04b..787502c470 100644 --- a/PerformanceCalculatorGUI/IExtendedDifficultyCalculator.cs +++ b/PerformanceCalculatorGUI/IExtendedDifficultyCalculator.cs @@ -5,10 +5,11 @@ using osu.Game.Rulesets.Difficulty.Preprocessing; using osu.Game.Rulesets.Difficulty.Skills; -namespace PerformanceCalculatorGUI; - -public interface IExtendedDifficultyCalculator +namespace PerformanceCalculatorGUI { - Skill[] GetSkills(); - DifficultyHitObject[] GetDifficultyHitObjects(IBeatmap beatmap, double clockRate); + public interface IExtendedDifficultyCalculator + { + Skill[] GetSkills(); + DifficultyHitObject[] GetDifficultyHitObjects(IBeatmap beatmap, double clockRate); + } } diff --git a/PerformanceCalculatorGUI/RulesetHelper.cs b/PerformanceCalculatorGUI/RulesetHelper.cs index c323dcc3ab..feaba54332 100644 --- a/PerformanceCalculatorGUI/RulesetHelper.cs +++ b/PerformanceCalculatorGUI/RulesetHelper.cs @@ -3,10 +3,7 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using osu.Framework.Audio.Track; -using osu.Framework.Graphics.Textures; using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Catch; @@ -19,7 +16,6 @@ using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Taiko; using osu.Game.Rulesets.Taiko.Objects; -using osu.Game.Skinning; namespace PerformanceCalculatorGUI {