-
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(PatcherOptions): reload options when finished initializing
- Loading branch information
1 parent
a36411f
commit 52454d8
Showing
4 changed files
with
89 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using JetBrains.Annotations; | ||
using Osu.Utils.Lazy; | ||
using static System.Reflection.Emit.OpCodes; | ||
|
||
namespace Osu.Stubs.Helpers; | ||
|
||
[PublicAPI] | ||
public class Scheduler | ||
{ | ||
/// <summary> | ||
/// Original: <c>osu_common.Helpers.Scheduler</c> | ||
/// </summary> | ||
[Stub] | ||
public static readonly LazyType Class = new( | ||
"osu_common.Helpers.Scheduler", | ||
() => Add!.Reference.DeclaringType | ||
); | ||
|
||
/// <summary> | ||
/// Original: <c>Add(VoidDelegate task, bool forceScheduled)</c> | ||
/// Returns whether the supplied task was immediately run without scheduling. | ||
/// </summary> | ||
[Stub] | ||
public static readonly LazyMethod<bool> Add = LazyMethod<bool>.ByPartialSignature( | ||
"osu_common.Helpers.Scheduler::Add(VoidDelegate, bool)", | ||
[ | ||
Ldloca_S, | ||
Call, | ||
Ldarg_0, | ||
Ldfld, | ||
Ldarg_1, | ||
Callvirt, | ||
Leave_S, | ||
Ldloc_1, | ||
Brfalse_S, | ||
Ldloc_0, | ||
Call, | ||
Endfinally, | ||
Ldc_I4_0, | ||
Ret, | ||
] | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using JetBrains.Annotations; | ||
using Osu.Stubs.GameModes.Options; | ||
using Osu.Stubs.Helpers; | ||
using Osu.Stubs.Root; | ||
|
||
namespace Osu.Stubs.Wrappers; | ||
|
||
[PublicAPI] | ||
public static class OptionsUtils | ||
{ | ||
/// <summary> | ||
/// Reloads the options panel to reset the available options. | ||
/// </summary> | ||
/// <param name="scrollToTop">Forcefully scroll to the top after reloading.</param> | ||
public static void ReloadOptions(bool scrollToTop = true) | ||
{ | ||
var mainScheduler = GameBase.Scheduler.Get(); | ||
var options = GameBase.Options.Get(); | ||
|
||
var task = VoidDelegate.MakeInstance(() => | ||
Options.ReloadElements.Invoke(options, [scrollToTop])); | ||
|
||
Scheduler.Add.Invoke(mainScheduler, [ | ||
/* task: */ task, | ||
/* forceScheduled: */ false, | ||
]); | ||
} | ||
} |