Skip to content
Open
Next Next commit
ported from master
  • Loading branch information
Givikap120 committed Aug 13, 2024
commit 62294c99f0b15cf8a0da4844b477ae36c97358ce
428 changes: 60 additions & 368 deletions PerformanceCalculatorGUI/Components/ExtendedProfileScore.cs

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions PerformanceCalculatorGUI/Components/LazerCalculationSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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.

{
private readonly Bindable<bool> calculateRankedMaps = new(true);
private readonly Bindable<bool> calculateUnrankedMaps = new(false);

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

private readonly Bindable<bool> enableScorev1Overwrite = new(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.Mods.Any(h => h is OsuModRelax || h is OsuModAutopilot))
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(
new[] { calculateRankedMaps, calculateUnrankedMaps, calculateUnsubmittedScores, calculateUnrankedMods, enableScorev1Overwrite });

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

public partial class LazerCalculationSettingsPopover : OsuPopover
{
private readonly Bindable<bool>[] bindables;

public LazerCalculationSettingsPopover(Bindable<bool>[] bindables)
{
this.bindables = bindables;
}

[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 (ranked & approved)",
Current = { BindTarget = bindables[0] }
},
new OsuCheckbox
{
LabelText = "Calculate Unranked Maps (everything else)",
Current = { BindTarget = bindables[1] }
},
new OsuCheckbox
{
LabelText = "Calculate Unsubmitted Scores (on local difficulties for example)",
Current = { BindTarget = bindables[2] }
},
new OsuCheckbox
{
LabelText = "Calculate Unranked Mods (RX and AP are excluded regardless)",
Current = { BindTarget = bindables[3] }
},
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 = bindables[4] }
},
}
}
}
});
}
}
}
Loading