Skip to content

Commit 3d051eb

Browse files
update, added mod menu options
1 parent a8336ff commit 3d051eb

File tree

1 file changed

+86
-5
lines changed

1 file changed

+86
-5
lines changed

ExportResoniteToJson/ExportResoniteToJson.cs

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,43 @@ public class ExportResoniteToJson : ResoniteMod
2020
public override string Link => "https://github.com/LimeProgramming/ExportNeosToJson";
2121

2222

23+
// ------------------------------------------------------------------------------------------ //
24+
/* ========== Register Mod Config Data/Keys ========== */
25+
26+
private static ModConfiguration Config;
27+
28+
29+
private static readonly ModConfigurationKey<bool> EXPORT_JSON = new ModConfigurationKey<bool>(
30+
"Export Json Type", "Enable exprting to Json file type. Changing this setting requires a game restart to apply.",
31+
() => true
32+
);
33+
34+
private static readonly ModConfigurationKey<bool> EXPORT_BSON = new ModConfigurationKey<bool>(
35+
"Export Bson Type", "Enable exprting to Bson file type. Changing this setting requires a game restart to apply.",
36+
() => false
37+
);
38+
39+
private static readonly ModConfigurationKey<bool> EXPORT_7ZBSON = new ModConfigurationKey<bool>(
40+
"Export 7zbon Type", "Enable exprting to 7zbon file type. Changing this setting requires a game restart to apply.",
41+
() => false
42+
);
43+
44+
private static readonly ModConfigurationKey<bool> EXPORT_LZ4BSON = new ModConfigurationKey<bool>(
45+
"Export LZ4BSON Type", "Enable exprting to LZ4BSON file type. Changing this setting requires a game restart to apply.",
46+
() => false
47+
);
48+
49+
50+
51+
52+
53+
// ------------------------------------------------------------------------------------------ //
54+
/* ========== Our Hook into the game ========== */
55+
2356
public override void OnEngineInit()
2457
{
58+
Config = GetConfiguration(); //Get this mods' current ModConfiguration
59+
2560
Harmony harmony = new Harmony("net.CalamityLime.ExportResoniteToJson");
2661
FieldInfo formatsField = AccessTools.DeclaredField(typeof(ModelExportable), "formats");
2762
if (formatsField == null)
@@ -32,11 +67,32 @@ public override void OnEngineInit()
3267

3368
// inject addional formats
3469
List<string> modelFormats = new List<string>((string[])formatsField.GetValue(null));
35-
modelFormats.Add("JSON");
36-
modelFormats.Add("BSON");
37-
modelFormats.Add("7ZBSON");
38-
modelFormats.Add("LZ4BSON");
39-
formatsField.SetValue(null, modelFormats.ToArray());
70+
71+
if (Config.GetValue(EXPORT_JSON))
72+
{
73+
modelFormats.Add("JSON");
74+
}
75+
76+
if (Config.GetValue(EXPORT_BSON))
77+
{
78+
modelFormats.Add("BSON");
79+
}
80+
81+
if (Config.GetValue(EXPORT_7ZBSON))
82+
{
83+
modelFormats.Add("7ZBSON");
84+
}
85+
86+
if (Config.GetValue(EXPORT_LZ4BSON))
87+
{
88+
modelFormats.Add("LZ4BSON");
89+
}
90+
91+
92+
if ( (Config.GetValue(EXPORT_JSON)) || (Config.GetValue(EXPORT_BSON)) || (Config.GetValue(EXPORT_7ZBSON)) || !(Config.GetValue(EXPORT_LZ4BSON)) )
93+
{
94+
formatsField.SetValue(null, modelFormats.ToArray());
95+
}
4096

4197

4298
// ---------- Patch the Export Model function ----------
@@ -214,6 +270,31 @@ public static bool Load_Prefix(ref DataTreeDictionary __result, string file, str
214270

215271

216272
}
273+
274+
275+
276+
277+
278+
279+
280+
281+
282+
283+
284+
285+
286+
287+
288+
289+
290+
291+
292+
217293

218294
}
295+
296+
297+
298+
299+
219300
}

0 commit comments

Comments
 (0)