forked from cantorsdust/StardewMods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenericModConfigMenuIntegration.cs
86 lines (82 loc) · 4.07 KB
/
GenericModConfigMenuIntegration.cs
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
using System;
using cantorsdust.Common.Integrations;
using StardewModdingAPI;
namespace InstantGrowTrees.Framework
{
/// <summary>Configures the integration with Generic Mod Config Menu.</summary>
internal static class GenericModConfigMenuIntegration
{
/*********
** Public methods
*********/
/// <summary>Add a config UI to Generic Mod Config Menu if it's installed.</summary>
/// <param name="manifest">The mod manifest.</param>
/// <param name="modRegistry">The mod registry from which to get the API.</param>
/// <param name="monitor">The monitor with which to log errors.</param>
/// <param name="getConfig">Get the current mod configuration.</param>
/// <param name="reset">Reset the config to its default values.</param>
/// <param name="save">Save the current config to the <c>config.json</c> file.</param>
public static void Register(IManifest manifest, IModRegistry modRegistry, IMonitor monitor, Func<ModConfig> getConfig, Action reset, Action save)
{
// get API
IGenericModConfigMenuApi api = IntegrationHelper.GetGenericModConfigMenu(modRegistry, monitor);
if (api == null)
return;
// register config UI
api.Register(manifest, reset, save);
// fruit tree section
api.AddSectionTitle(manifest, I18n.Config_FruitTrees);
api.AddBoolOption(
manifest,
name: I18n.Config_FruitTrees_InstantlyAge_Name,
tooltip: I18n.Config_FruitTrees_InstantlyAge_Desc,
getValue: () => getConfig().FruitTrees.InstantlyAge,
setValue: value => getConfig().FruitTrees.InstantlyAge = value
);
api.AddBoolOption(
manifest,
name: I18n.Config_FruitTrees_InstantlyGrow_Name,
tooltip: I18n.Config_FruitTrees_InstantlyGrow_Desc,
getValue: () => getConfig().FruitTrees.InstantlyGrow,
setValue: value => getConfig().FruitTrees.InstantlyGrow = value
);
api.AddBoolOption(
manifest,
name: I18n.Config_FruitTrees_InstantlyGrowInWinter_Name,
tooltip: I18n.Config_FruitTrees_InstantlyGrowInWinter_Desc,
getValue: () => getConfig().FruitTrees.InstantlyGrowInWinter,
setValue: value => getConfig().FruitTrees.InstantlyGrowInWinter = value
);
api.AddBoolOption(
manifest,
name: I18n.Config_FruitTrees_InstantlyGrowWhenInvalid_Name,
tooltip: I18n.Config_FruitTrees_InstantlyGrowWhenInvalid_Desc,
getValue: () => getConfig().FruitTrees.InstantlyGrowWhenInvalid,
setValue: value => getConfig().FruitTrees.InstantlyGrowWhenInvalid = value
);
// non-fruit tree section
api.AddSectionTitle(manifest, I18n.Config_Trees);
api.AddBoolOption(
manifest,
name: I18n.Config_Trees_InstantlyGrow_Name,
tooltip: I18n.Config_Trees_InstantlyGrow_Desc,
getValue: () => getConfig().FruitTrees.InstantlyGrow,
setValue: value => getConfig().FruitTrees.InstantlyGrow = value
);
api.AddBoolOption(
manifest,
name: I18n.Config_Trees_InstantlyGrowInWinter_Name,
tooltip: I18n.Config_Trees_InstantlyGrowInWinter_Desc,
getValue: () => getConfig().FruitTrees.InstantlyGrowInWinter,
setValue: value => getConfig().FruitTrees.InstantlyGrowInWinter = value
);
api.AddBoolOption(
manifest,
name: I18n.Config_Trees_InstantlyGrowWhenInvalid_Name,
tooltip: I18n.Config_Trees_InstantlyGrowWhenInvalid_Desc,
getValue: () => getConfig().FruitTrees.InstantlyGrowWhenInvalid,
setValue: value => getConfig().FruitTrees.InstantlyGrowWhenInvalid = value
);
}
}
}