-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathLazerCalculationSettings.cs
More file actions
138 lines (119 loc) · 5.06 KB
/
LazerCalculationSettings.cs
File metadata and controls
138 lines (119 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// 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
{
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",
Current = { BindTarget = parent.EnableScorev1Overwrite }
},
}
}
}
});
}
}
}