-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathConfig.cs
176 lines (142 loc) · 7.25 KB
/
Config.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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
namespace DaLion.Overhaul.Modules.Tools;
#region using directives
using DaLion.Overhaul.Modules.Tools.Configs;
using DaLion.Overhaul.Modules.Tools.Integrations;
using Microsoft.Xna.Framework;
using Newtonsoft.Json;
using StardewModdingAPI.Utilities;
#endregion using directives
/// <summary>The user-configurable settings for TOLS.</summary>
public sealed class Config : Shared.Configs.Config
{
/// <inheritdoc cref="AxeConfig"/>
[JsonProperty]
public AxeConfig Axe { get; internal set; } = new();
/// <inheritdoc cref="PickaxeConfig"/>
[JsonProperty]
public PickaxeConfig Pick { get; internal set; } = new();
/// <inheritdoc cref="HoeConfig"/>
[JsonProperty]
public HoeConfig Hoe { get; internal set; } = new();
/// <inheritdoc cref="WateringCanConfig"/>
[JsonProperty]
public WateringCanConfig Can { get; internal set; } = new();
/// <inheritdoc cref="WateringCanConfig"/>
[JsonProperty]
public ScytheConfig Scythe { get; internal set; } = new();
/// <summary>Gets a value indicating whether determines whether charging requires holding a mod key.</summary>
[JsonProperty]
public bool HoldToCharge { get; internal set; } = true;
/// <summary>Gets the chosen mod key(s) for charging resource tools.</summary>
[JsonProperty]
public KeybindList ChargeKey { get; internal set; } = KeybindList.Parse("LeftShift, LeftShoulder");
/// <summary>Gets a value indicating whether to play the shockwave animation when the charged Axe is released.</summary>
[JsonProperty]
public bool PlayShockwaveAnimation { get; internal set; } = true;
/// <summary>Gets affects the shockwave travel speed. Lower is faster. Set to 0 for instant.</summary>
[JsonProperty]
public uint TicksBetweenCrests { get; internal set; } = 4;
/// <summary>Gets a value indicating whether determines whether to show affected tiles overlay while charging.</summary>
[JsonProperty]
public bool HideAffectedTiles { get; internal set; } = false;
/// <summary>Gets a value indicating whether face the current cursor position before swinging your tools.</summary>
[JsonProperty]
public bool FaceMouseCursor { get; internal set; } = true;
/// <summary>Gets a value indicating whether to allow auto-selecting tools.</summary>
[JsonProperty]
public bool EnableAutoSelection { get; internal set; } = true;
/// <summary>Gets the chosen key(s) for toggling auto-selection.</summary>
[JsonProperty]
public KeybindList SelectionKey { get; internal set; } = KeybindList.Parse("LeftShift, LeftShoulder");
/// <summary>Gets the <see cref="Color"/> used to indicate tools enabled or auto-selection.</summary>
[JsonProperty]
public Color SelectionBorderColor { get; internal set; } = Color.Magenta;
/// <summary>Gets a value indicating whether to color the title text of upgraded tools.</summary>
[JsonProperty]
public bool ColorCodedForYourConvenience { get; internal set; } = false;
/// <summary>Gets a value indicating whether to allow upgrading tools at the Volcano Forge.</summary>
[JsonProperty]
public bool EnableForgeUpgrading { get; internal set; } = true;
/// <inheritdoc />
public override bool Validate()
{
var isValid = true;
Log.T("[TOLS]: Verifying tool configs...");
var maxToolUpgrade = MoonMisadventuresIntegration.Instance?.IsLoaded == true ? 7 : this.EnableForgeUpgrading ? 6 : 5;
if (this.Axe.RadiusAtEachPowerLevel.Length != maxToolUpgrade)
{
var preface = this.Axe.RadiusAtEachPowerLevel.Length < maxToolUpgrade ? "Missing" : "Too many";
Log.W($"[TOLS]: {preface} values in Axe.RadiusAtEachPowerLevel. The default values will be restored.");
this.Axe.RadiusAtEachPowerLevel = new uint[maxToolUpgrade];
uint i = 0;
while (i < maxToolUpgrade)
{
this.Axe.RadiusAtEachPowerLevel[i] = ++i;
}
isValid = false;
}
if (this.Pick.RadiusAtEachPowerLevel.Length != maxToolUpgrade)
{
var preface = this.Pick.RadiusAtEachPowerLevel.Length < maxToolUpgrade ? "Missing" : "Too many";
Log.W($"[TOLS]: {preface} values Pickaxe.RadiusAtEachPowerLevel. The default values will be restored.");
this.Pick.RadiusAtEachPowerLevel = new uint[maxToolUpgrade];
uint i = 0;
while (i < maxToolUpgrade)
{
this.Pick.RadiusAtEachPowerLevel[i] = ++i;
}
isValid = false;
}
if (this.Hoe.AffectedTilesAtEachPowerLevel.Length != maxToolUpgrade)
{
var preface = this.Hoe.AffectedTilesAtEachPowerLevel.Length < maxToolUpgrade ? "Missing" : "Too many";
Log.W($"[TOLS]: {preface} values in Hoe.AffectedTilesAtEachPowerLevel. The default values will be restored.");
this.Hoe.AffectedTilesAtEachPowerLevel = maxToolUpgrade switch
{
> 6 => new (uint, uint)[] { (3, 0), (5, 0), (3, 1), (6, 1), (5, 2), (7, 3), (9, 4), },
> 5 => new (uint, uint)[] { (3, 0), (5, 0), (3, 1), (6, 1), (5, 2), (7, 3), },
_ => new (uint, uint)[] { (3, 0), (5, 0), (3, 1), (6, 1), (5, 2), },
};
isValid = false;
}
if (this.Can.AffectedTilesAtEachPowerLevel.Length != maxToolUpgrade)
{
var preface = this.Can.AffectedTilesAtEachPowerLevel.Length < maxToolUpgrade ? "Missing" : "Too many";
Log.W($"[TOLS]: {preface} values in Can.AffectedTilesAtEachPowerLevel. The default values will be restored.");
this.Can.AffectedTilesAtEachPowerLevel = maxToolUpgrade switch
{
> 6 => new (uint, uint)[] { (3, 0), (5, 0), (3, 1), (6, 1), (5, 2), (7, 3), (9, 4), },
> 5 => new (uint, uint)[] { (3, 0), (5, 0), (3, 1), (6, 1), (5, 2), (7, 3), },
_ => new (uint, uint)[] { (3, 0), (5, 0), (3, 1), (6, 1), (5, 2), },
};
isValid = false;
}
if (this.HoldToCharge && !this.ChargeKey.IsBound)
{
Log.W(
"[TOLS]: 'ChargingRequiresModKey' setting is set to true, but no ModKey is bound. Default keybind will be restored. To disable the ModKey, set this value to false.");
this.ChargeKey = KeybindList.ForSingle(SButton.LeftShift);
isValid = false;
}
if (this.Axe.ChargedStaminaCostMultiplier < 0)
{
Log.W("[TOLS]: Axe 'ChargedStaminaMultiplier' is set to an illegal negative value. The value will default to 1");
this.Axe.ChargedStaminaCostMultiplier = 1f;
isValid = false;
}
if (this.Pick.ChargedStaminaMultiplier < 0)
{
Log.W("[TOLS]: Pickaxe 'ChargedStaminaMultiplier' is set to an illegal negative value. The value will default to 1");
this.Pick.ChargedStaminaMultiplier = 1f;
isValid = false;
}
if (this.TicksBetweenCrests > 100)
{
Log.W(
"[TOLS]: The value of 'TicksBetweenWaves' is excessively large. This is probably a mistake. The default value will be restored.");
this.TicksBetweenCrests = 4;
isValid = false;
}
return isValid;
}
}