@@ -20,8 +20,43 @@ public class ExportResoniteToJson : ResoniteMod
20
20
public override string Link => "https://github.com/LimeProgramming/ExportNeosToJson" ;
21
21
22
22
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
+
23
56
public override void OnEngineInit ( )
24
57
{
58
+ Config = GetConfiguration ( ) ; //Get this mods' current ModConfiguration
59
+
25
60
Harmony harmony = new Harmony ( "net.CalamityLime.ExportResoniteToJson" ) ;
26
61
FieldInfo formatsField = AccessTools . DeclaredField ( typeof ( ModelExportable ) , "formats" ) ;
27
62
if ( formatsField == null )
@@ -32,11 +67,32 @@ public override void OnEngineInit()
32
67
33
68
// inject addional formats
34
69
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
+ }
40
96
41
97
42
98
// ---------- Patch the Export Model function ----------
@@ -214,6 +270,31 @@ public static bool Load_Prefix(ref DataTreeDictionary __result, string file, str
214
270
215
271
216
272
}
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
217
293
218
294
}
295
+
296
+
297
+
298
+
299
+
219
300
}
0 commit comments