Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implemented functionality to calculate all local scores using Realm #213

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
428 changes: 60 additions & 368 deletions PerformanceCalculatorGUI/Components/ExtendedProfileScore.cs

Large diffs are not rendered by default.

138 changes: 138 additions & 0 deletions PerformanceCalculatorGUI/Components/LazerCalculationSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK;
using osu.Framework.Extensions;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Overlays.Toolbar;
using osu.Framework.Bindables;
using osu.Game.Scoring;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.Mods;

namespace PerformanceCalculatorGUI.Components
{
public partial class LazerCalculationSettings : ToolbarButton, IHasPopover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it a toolbar button? It doesn't seem to be on the toolbar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I needed to make "options" button and ToolbarButton class was the easiest way to do it.

{
public readonly Bindable<bool> CalculateRankedMaps = new Bindable<bool>(true);
public readonly Bindable<bool> CalculateUnrankedMaps = new Bindable<bool>(false);

public readonly Bindable<bool> CalculateUnsubmittedScores = new Bindable<bool>(true);
public readonly Bindable<bool> CalculateUnrankedMods = new Bindable<bool>(true);

public readonly Bindable<bool> EnableScorev1Overwrite = new Bindable<bool>(false);

public bool IsScorev1OverwritingEnabled => EnableScorev1Overwrite.Value;

protected override Anchor TooltipAnchor => Anchor.TopRight;

public LazerCalculationSettings()
{
TooltipMain = "Calculation Settings";

SetIcon(new ScreenSelectionButtonIcon(FontAwesome.Solid.Cog) { IconSize = new Vector2(70) });
}

public bool ShouldBeFiltered(ScoreInfo score)
{
if (score.BeatmapInfo == null)
return true;

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

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

if (!CalculateUnrankedMods.Value)
{
// Check for legacy score because CL is unranked
if (!score.Mods.All(m => m.Ranked || (score.IsLegacyScore && m is OsuModClassic)))
return true;
}

if (!CalculateUnsubmittedScores.Value)
{
if (score.OnlineID <= 0 && score.LegacyOnlineID <= 0)
return true;
}

return false;
}

public Popover GetPopover() => new LazerCalculationSettingsPopover(this);

protected override bool OnClick(ClickEvent e)
{
this.ShowPopover();
return base.OnClick(e);
}
}

public partial class LazerCalculationSettingsPopover : OsuPopover
{
private readonly LazerCalculationSettings parent;

public LazerCalculationSettingsPopover(LazerCalculationSettings parent)
{
this.parent = parent;
}

[BackgroundDependencyLoader]
private void load()
{
Add(new Container
{
AutoSizeAxes = Axes.Y,
Width = 500,
Children = new Drawable[]
{
new FillFlowContainer
{
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(18),
Children = new Drawable[]
{
new OsuCheckbox
{
LabelText = "Calculate Ranked Maps",
Current = { BindTarget = parent.CalculateRankedMaps }
},
new OsuCheckbox
{
LabelText = "Calculate Unranked Maps",
Current = { BindTarget = parent.CalculateUnrankedMaps }
},
new OsuCheckbox
{
LabelText = "Calculate Unsubmitted Scores, such as scores set on local difficulties",
Current = { BindTarget = parent.CalculateUnsubmittedScores }
},
new OsuCheckbox
{
LabelText = "Calculate Unranked Mods, Autopilot is excluded regardless",
Current = { BindTarget = parent.CalculateUnsubmittedScores }
},
new OsuCheckbox
{
LabelText = "Enable Scorev1 score overwrite for legacy scores",
Copy link
Contributor

@smoogipoo smoogipoo Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this even mean? I'm struggling to understand what this option does.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In stable for each unique mod combination only score with the highest scorev1 is calculated. This switch is turning this mechanism on and off.

Copy link
Contributor

@smoogipoo smoogipoo Sep 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does that have to do with lazer? It doesn't sound like you've properly thought through what this PR is set to achieve and are just throwing flags around the place in the name of optimisation...

Like... why not just calculate all scores in the db all the time? If you want to only calculate the online scores then there already is a screen for that.

Copy link
Contributor Author

@Givikap120 Givikap120 Sep 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not about optimization
it's about giving user a choice between "accurate simulation" and "what if all my scores was weighted fairly"
for now it's not making big difference, but when combining with CSR - the difference in total pp can be quite big

If you want to only calculate the online scores then there already is a screen for that

online profile doesn't account for score outside of the top100 (and they can be severely buffed in reworks like CSR)
also online profile doesn't have option to calculate mods like DT rates and DA

Current = { BindTarget = parent.EnableScorev1Overwrite }
},
}
}
}
});
}
}
}
Loading