Skip to content

Commit

Permalink
fixed CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Givikap120 committed Aug 13, 2024
1 parent 8ec4ed2 commit 1c81765
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 42 deletions.
13 changes: 8 additions & 5 deletions PerformanceCalculatorGUI/Components/LazerCalculationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ namespace PerformanceCalculatorGUI.Components
{
public partial class LazerCalculationSettings : ToolbarButton, IHasPopover
{
private readonly Bindable<bool> calculateRankedMaps = new(true);
private readonly Bindable<bool> calculateUnrankedMaps = new(false);
private readonly Bindable<bool> calculateRankedMaps = new Bindable<bool>(true);
private readonly Bindable<bool> calculateUnrankedMaps = new Bindable<bool>(false);

private readonly Bindable<bool> calculateUnsubmittedScores = new(true);
private readonly Bindable<bool> calculateUnrankedMods = new(true);
private readonly Bindable<bool> calculateUnsubmittedScores = new Bindable<bool>(true);
private readonly Bindable<bool> calculateUnrankedMods = new Bindable<bool>(true);

private readonly Bindable<bool> enableScorev1Overwrite = new(false);
private readonly Bindable<bool> enableScorev1Overwrite = new Bindable<bool>(false);

public bool IsScorev1OverwritingEnabled => enableScorev1Overwrite.Value;

Expand All @@ -47,6 +47,9 @@ public bool ShouldBeFiltered(ScoreInfo score)
if (score.Mods.Any(h => h is OsuModRelax || h is OsuModAutopilot))
return true;

if (score.BeatmapInfo == null)
return true;

if (!calculateRankedMaps.Value && score.BeatmapInfo.Status.GrantsPerformancePoints())
return true;

Expand Down
15 changes: 7 additions & 8 deletions PerformanceCalculatorGUI/Components/ProfileScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ private static SoloScoreInfo toSoloScoreInfo(ScoreInfo score)
{
APIBeatmapSet dummySet = new APIBeatmapSet
{
Title = score.BeatmapInfo.Metadata.Title,
TitleUnicode = score.BeatmapInfo.Metadata.TitleUnicode,
Artist = score.BeatmapInfo.Metadata.Artist,
ArtistUnicode = score.BeatmapInfo.Metadata.ArtistUnicode,
Title = score.BeatmapInfo?.Metadata.Title ?? "Error Title",
TitleUnicode = score.BeatmapInfo?.Metadata.TitleUnicode ?? "Error Title",
Artist = score.BeatmapInfo?.Metadata.Artist ?? "Error Artist",
ArtistUnicode = score.BeatmapInfo?.Metadata.ArtistUnicode ?? "Error Artist",
};
APIBeatmap dummyBeatmap = new APIBeatmap
{
OnlineID = score.BeatmapInfo.OnlineID,
DifficultyName = score.BeatmapInfo.DifficultyName,
OnlineID = score.BeatmapInfo?.OnlineID ?? 0,
DifficultyName = score.BeatmapInfo?.DifficultyName ?? "Error Difficulty",
};
SoloScoreInfo soloScoreInfo = new SoloScoreInfo
{
Expand All @@ -79,7 +79,6 @@ private static SoloScoreInfo toSoloScoreInfo(ScoreInfo score)

return soloScoreInfo;
}

}

public partial class DrawableProfileScore : CompositeDrawable
Expand Down Expand Up @@ -214,7 +213,7 @@ private void load(RulesetStore rulesets)
Width = performance_width,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Children = new Drawable[]
Children = new[]
{
new Box
{
Expand Down
1 change: 0 additions & 1 deletion PerformanceCalculatorGUI/Configuration/SettingsManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.IO;
using System.Reflection;
using osu.Framework.Configuration;
Expand Down
5 changes: 3 additions & 2 deletions PerformanceCalculatorGUI/RulesetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ public static int GenerateModsHash(Mod[] mods, BeatmapDifficulty difficulty, Rul
bool isSliderAccuracy = mods.OfType<OsuModClassic>().All(m => !m.NoSliderHeadAccuracy.Value);

byte flashlightHash = 0;

if (mods.Any(h => h is OsuModFlashlight))
{
if (!mods.Any(h => h is OsuModHidden)) flashlightHash = 1;
else flashlightHash = 2;
flashlightHash = (byte)(mods.Any(h => h is OsuModHidden) ? 2 : 1);
}

byte mirrorHash = 0;

if (mods.FirstOrDefault(m => m is OsuModMirror) is OsuModMirror mirror)
{
mirrorHash = (byte)(1 + (int)(mirror.Reflection.Value));
Expand Down
9 changes: 2 additions & 7 deletions PerformanceCalculatorGUI/Screens/BeatmapLeaderboardScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private void calculate()

var difficultyCalculator = rulesetInstance.CreateDifficultyCalculator(working);

Dictionary<int, DifficultyAttributes> attributesCache = new();
Dictionary<int, DifficultyAttributes> attributesCache = new Dictionary<int, DifficultyAttributes>();

foreach (var score in leaderboard.Scores)
{
Expand All @@ -236,14 +236,9 @@ private void calculate()

var parsedScore = new ProcessorScoreDecoder(working).Parse(scoreInfo);

DifficultyAttributes difficultyAttributes;
int modsHash = RulesetHelper.GenerateModsHash(mods, working.BeatmapInfo.Difficulty, ruleset.Value);

if (attributesCache.ContainsKey(modsHash))
{
difficultyAttributes = attributesCache[modsHash];
}
else
if (!attributesCache.TryGetValue(modsHash, out var difficultyAttributes))
{
difficultyAttributes = difficultyCalculator.Calculate(mods);
attributesCache[modsHash] = difficultyAttributes;
Expand Down
33 changes: 14 additions & 19 deletions PerformanceCalculatorGUI/Screens/ProfileScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ private void calculateProfileFromLazer(string username)

List<ProfileScore> tempScores = [];

Dictionary<int, DifficultyAttributes> attributesCache = new();
Dictionary<int, DifficultyAttributes> attributesCache = new Dictionary<int, DifficultyAttributes>();

foreach (var score in scoreList)
{
Expand All @@ -471,14 +471,9 @@ private void calculateProfileFromLazer(string username)

Schedule(() => loadingLayer.Text.Value = $"Calculating {player.Username}'s scores... {currentScoresCount} / {totalScoresCount}");

Check failure on line 472 in PerformanceCalculatorGUI/Screens/ProfileScreen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Captured variable is modified in the outer scope in PerformanceCalculatorGUI\Screens\ProfileScreen.cs on line 472

DifficultyAttributes difficultyAttributes;
int modsHash = RulesetHelper.GenerateModsHash(score.Mods, working.BeatmapInfo.Difficulty, ruleset.Value);

if (attributesCache.ContainsKey(modsHash))
{
difficultyAttributes = attributesCache[modsHash];
}
else
if (!attributesCache.TryGetValue(modsHash, out var difficultyAttributes))
{
difficultyAttributes = difficultyCalculator.Calculate(score.Mods);
attributesCache[modsHash] = difficultyAttributes;
Expand Down Expand Up @@ -560,27 +555,27 @@ private List<List<ScoreInfo>> getRealmScores(RealmAccess realm)
Schedule(() => loadingLayer.Text.Value = "Filtering scores...");

realmScores.RemoveAll(x => !currentUser.Contains(x.User.Username) // Wrong username
|| x.BeatmapInfo == null // No map for score
|| x.Passed == false || x.Rank == ScoreRank.F // Failed score
|| x.Ruleset.OnlineID != ruleset.Value.OnlineID // Incorrect ruleset
|| settingsMenu.ShouldBeFiltered(x)); // Customisable filters

List<List<ScoreInfo>> groupedScores = realmScores.GroupBy(g => g.BeatmapHash)
.Select(s => s.ToList())
.ToList();
|| x.BeatmapInfo == null // No map for score

Check failure on line 558 in PerformanceCalculatorGUI/Screens/ProfileScreen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Indent size is incorrect, expected indent 27 spaces in PerformanceCalculatorGUI\Screens\ProfileScreen.cs on line 558
|| x.Passed == false || x.Rank == ScoreRank.F // Failed score
|| x.Ruleset.OnlineID != ruleset.Value.OnlineID // Incorrect ruleset
|| settingsMenu.ShouldBeFiltered(x)); // Customisable filters

List<List<ScoreInfo>> groupedScores = realmScores.GroupBy(g => g.BeatmapHash).Select(s => s.ToList()).ToList();

// Simulate scorev1 if enabled
if (settingsMenu.IsScorev1OverwritingEnabled)
{
var rulesetInstance = ruleset.Value.CreateInstance();

List<List<ScoreInfo>> filteredScores = new();
List<List<ScoreInfo>> filteredScores = new List<List<ScoreInfo>>();

foreach (var mapScores in groupedScores)
{
List<ScoreInfo> filteredMapScores = mapScores.Where(s => s.IsLegacyScore)
.GroupBy(x => rulesetInstance.ConvertToLegacyMods(x.Mods))
.Select(x => x.MaxBy(x => x.LegacyTotalScore))
.ToList();
.GroupBy(x => rulesetInstance.ConvertToLegacyMods(x.Mods))
.Select(g => g.MaxBy(g => g.LegacyTotalScore))

Check failure on line 576 in PerformanceCalculatorGUI/Screens/ProfileScreen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Parameter 'g' hides outer parameter with the same name in PerformanceCalculatorGUI\Screens\ProfileScreen.cs on line 576
.ToList();

filteredMapScores.AddRange(mapScores.Where(s => !s.IsLegacyScore));
filteredScores.Add(mapScores);
}
Expand Down

0 comments on commit 1c81765

Please sign in to comment.