Skip to content

Commit b74a63a

Browse files
committed
Add ResoniteBugFixMonkey
1 parent 59eef9e commit b74a63a

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

CommunityBugFixCollection/BugFixOptions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
using MonkeyLoader.Configuration;
2+
using MonkeyLoader.Patching;
23
using System;
34
using System.Collections.Generic;
45
using System.Text;
56

67
namespace CommunityBugFixCollection
78
{
8-
internal sealed class BugFixOptions : ConfigSection
9+
internal sealed class BugFixOptions : SingletonConfigSection<BugFixOptions>
910
{
1011
private static readonly DefiningConfigKey<bool> _useIecByteFormat = new("UseIecByteFormat", "Whether to format bytes using IEC as opposed to decimal format when <i>LocalizedByteFormatting</i> is enabled.", () => true);
1112

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using MonkeyLoader.Configuration;
2+
using MonkeyLoader.Meta;
3+
using MonkeyLoader.Patching;
4+
using MonkeyLoader.Resonite;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Text;
8+
9+
namespace CommunityBugFixCollection
10+
{
11+
/// <summary>
12+
/// Represents the base class for patchers that run after Resonite's assemblies
13+
/// have been loaded and that hook into the game's lifecycle.<br/>
14+
/// Defaults <see cref="CanBeDisabled">CanBeDisabled</see> to <see langword="true"/>
15+
/// and provides the <see cref="BugFixOptions"/> as a <see cref="ConfigSection">ConfigSection</see>.
16+
/// </summary>
17+
/// <inheritdoc/>
18+
internal abstract class ResoniteBugFixMonkey<TMonkey> : ResoniteMonkey<TMonkey>, IConfiguredMonkey<BugFixOptions>
19+
where TMonkey : ResoniteBugFixMonkey<TMonkey>, new()
20+
{
21+
/// <inheritdoc/>
22+
public abstract override IEnumerable<string> Authors { get; }
23+
24+
/// <remarks>
25+
/// <i>By default:</i> <see langword="true"/>
26+
/// </remarks>
27+
/// <inheritdoc/>
28+
public override bool CanBeDisabled => true;
29+
30+
BugFixOptions IConfiguredMonkey<BugFixOptions>.ConfigSection => ConfigSection;
31+
ConfigSection IConfiguredMonkey.ConfigSection => ConfigSection;
32+
33+
/// <remarks>
34+
/// This is always the <see cref="BugFixOptions"/>.<see cref="SingletonConfigSection{TConfigSection}.Instance">Instance</see>.
35+
/// </remarks>
36+
/// <inheritdoc cref="IConfiguredMonkey{TConfigSection}.ConfigSection"/>
37+
protected static BugFixOptions ConfigSection => BugFixOptions.Instance;
38+
39+
/// <inheritdoc cref="ConfiguredMonkey{TMonkey, TConfigSection}.OnLoaded"/>
40+
protected override bool OnLoaded()
41+
{
42+
if (BugFixOptions.Instance is null)
43+
Config.LoadSection<BugFixOptions>();
44+
45+
return base.OnLoaded();
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)