-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(LivePerformance): add pp options
- Loading branch information
1 parent
be314c4
commit e8fbd4a
Showing
7 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Osu.Patcher.Hook/Patches/LivePerformance/PerformanceCalculatorType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
|
||
namespace Osu.Patcher.Hook.Patches.LivePerformance; | ||
|
||
/// <summary> | ||
/// The type of performance counter display to show in UI. | ||
/// </summary> | ||
[Serializable] | ||
public enum PerformanceCalculatorType | ||
{ | ||
/// <summary> | ||
/// Use Bancho pp calculations. | ||
/// </summary> | ||
Bancho, | ||
|
||
/// <summary> | ||
/// Use Akatsuki pp calculations. | ||
/// </summary> | ||
Akatsuki, | ||
|
||
/// <summary> | ||
/// Use Akatsuki pp calculations when either Relax or Autopilot is enabled, and Bancho otherwise. | ||
/// </summary> | ||
AkatsukiLimited, | ||
} |
90 changes: 90 additions & 0 deletions
90
Osu.Patcher.Hook/Patches/LivePerformance/PerformanceOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
using Osu.Stubs.GameModes.Options; | ||
using Osu.Stubs.Graphics; | ||
using Osu.Stubs.Wrappers; | ||
using Osu.Utils.Extensions; | ||
using static Osu.Patcher.Hook.Patches.CustomStrings.CustomStrings; | ||
|
||
namespace Osu.Patcher.Hook.Patches.LivePerformance; | ||
|
||
[UsedImplicitly] | ||
internal class PerformanceOptions : PatchOptions | ||
{ | ||
private static readonly OptionDropdown OptionDropdownStub = new(typeof(PerformanceCalculatorType)); | ||
|
||
public override IEnumerable<object> CreateOptions() => | ||
[ | ||
CreateInGameDisplayOption(), | ||
CreateLeaderboardDisplayOption(), | ||
CreatePerformanceTypeOption(), | ||
]; | ||
|
||
public override void Load(Settings config) | ||
{ | ||
ShowPerformanceInGame.Value = config.ShowPerformanceInGame; | ||
ShowPerformanceOnLeaderboard.Value = config.ShowPerformanceOnLeaderboard; | ||
PerformanceType.Value = config.PerformanceCalculator; | ||
} | ||
|
||
public override void Save(Settings config) | ||
{ | ||
config.ShowPerformanceInGame = ShowPerformanceInGame.Value; | ||
config.ShowPerformanceOnLeaderboard = ShowPerformanceOnLeaderboard.Value; | ||
config.PerformanceCalculator = PerformanceType.Value; | ||
} | ||
|
||
#region Options Creation | ||
|
||
private static object CreateInGameDisplayOption() => OptionCheckbox.Constructor.Invoke([ | ||
/* title: */ "Show PP during gameplay", | ||
/* tooltip: */ "A small PP counter display will be visible below the accuracy display.", | ||
/* binding: */ ShowPerformanceInGame.Bindable, | ||
/* onChange: */ null, | ||
]); | ||
|
||
private static object CreateLeaderboardDisplayOption() => OptionCheckbox.Constructor.Invoke([ | ||
/* title: */ "Show PP on local leaderboards", | ||
/* tooltip: */ "A small PP counter display will be visible on each local score.", | ||
/* binding: */ ShowPerformanceOnLeaderboard.Bindable, | ||
/* onChange: */ null, | ||
]); | ||
|
||
private static object CreatePerformanceTypeOption() | ||
{ | ||
var dropdownOptions = new[] | ||
{ | ||
pDropdownItem.Constructor.Invoke(["Bancho", PerformanceCalculatorType.Bancho]), | ||
pDropdownItem.Constructor.Invoke(["Akatsuki", PerformanceCalculatorType.Akatsuki]), | ||
pDropdownItem.Constructor.Invoke([ | ||
"Akatsuki if RX/AP else Bancho", | ||
PerformanceCalculatorType.AkatsukiLimited, | ||
]), | ||
}.ToType(pDropdownItem.Class.Reference); | ||
|
||
return OptionDropdownStub.Constructor.Invoke([ | ||
/* title: */ AddOsuString("PatcherPerformance", "PP calculator"), | ||
/* items: */ dropdownOptions, | ||
/* bindable: */ PerformanceType.Bindable, | ||
/* onChange: */ null, | ||
]); | ||
} | ||
|
||
#endregion | ||
|
||
#region Bindables | ||
|
||
public static readonly BindableWrapper<bool> ShowPerformanceInGame = | ||
new(BindableType.Bool, false, Settings.Default.ShowPerformanceInGame); | ||
|
||
public static readonly BindableWrapper<bool> ShowPerformanceOnLeaderboard = | ||
new(BindableType.Bool, false, Settings.Default.ShowPerformanceOnLeaderboard); | ||
|
||
public static readonly BindableWrapper<PerformanceCalculatorType> PerformanceType = new( | ||
BindableType.Object, | ||
Settings.Default.PerformanceCalculator, | ||
Settings.Default.PerformanceCalculator | ||
); | ||
|
||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters