@@ -56,9 +56,15 @@ public ModList GetModList()
56
56
{
57
57
return JsonConvert . DeserializeObject < ModList > ( File . ReadAllText ( ModListDirectory . FullName ) ) ;
58
58
}
59
+
60
+ public void SaveModList ( ModList ml )
61
+ {
62
+ SaveModList ( modList ) ;
63
+ }
64
+
59
65
public async Task DeleteAllFilesAddedByTexTools ( )
60
66
{
61
- var modList = JsonConvert . DeserializeObject < ModList > ( File . ReadAllText ( ModListDirectory . FullName ) ) ;
67
+ var modList = GetModList ( ) ;
62
68
var modsToRemove = modList . Mods . Where ( it => it . source == "FilesAddedByTexTools" ) ;
63
69
foreach ( var mod in modsToRemove )
64
70
{
@@ -85,7 +91,7 @@ public void CreateModlist()
85
91
Mods = new List < Mod > ( )
86
92
} ;
87
93
88
- File . WriteAllText ( ModListDirectory . FullName , JsonConvert . SerializeObject ( modList , Formatting . Indented ) ) ;
94
+ SaveModList ( modList ) ;
89
95
}
90
96
91
97
/// <summary>
@@ -99,7 +105,7 @@ public Task<Mod> TryGetModEntry(string internalFilePath)
99
105
{
100
106
internalFilePath = internalFilePath . Replace ( "\\ " , "/" ) ;
101
107
102
- var modList = JsonConvert . DeserializeObject < ModList > ( File . ReadAllText ( ModListDirectory . FullName ) ) ;
108
+ var modList = GetModList ( ) ;
103
109
104
110
if ( modList == null ) return null ;
105
111
@@ -218,15 +224,15 @@ public async Task ToggleModStatus(string internalFilePath, bool enable)
218
224
219
225
var modListDirectory = new DirectoryInfo ( Path . Combine ( _gameDirectory . Parent . Parent . FullName , XivStrings . ModlistFilePath ) ) ;
220
226
221
- var modList = JsonConvert . DeserializeObject < ModList > ( File . ReadAllText ( modListDirectory . FullName ) ) ;
227
+ var modList = GetModList ( ) ;
222
228
223
229
var entryEnableUpdate = ( from entry in modList . Mods
224
230
where entry . fullPath . Equals ( modEntry . fullPath )
225
231
select entry ) . FirstOrDefault ( ) ;
226
232
227
233
entryEnableUpdate . enabled = enable ;
228
234
229
- File . WriteAllText ( modListDirectory . FullName , JsonConvert . SerializeObject ( modList , Formatting . Indented ) ) ;
235
+ SaveModList ( modList ) ;
230
236
}
231
237
232
238
/// <summary>
@@ -238,7 +244,7 @@ public async Task ToggleModPackStatus(string modPackName, bool enable)
238
244
{
239
245
var index = new Index ( _gameDirectory ) ;
240
246
241
- var modList = JsonConvert . DeserializeObject < ModList > ( File . ReadAllText ( ModListDirectory . FullName ) ) ;
247
+ var modList = GetModList ( ) ;
242
248
var modListDirectory = new DirectoryInfo ( Path . Combine ( _gameDirectory . Parent . Parent . FullName , XivStrings . ModlistFilePath ) ) ;
243
249
List < Mod > mods = null ;
244
250
@@ -279,7 +285,7 @@ public async Task ToggleModPackStatus(string modPackName, bool enable)
279
285
}
280
286
}
281
287
282
- File . WriteAllText ( modListDirectory . FullName , JsonConvert . SerializeObject ( modList , Formatting . Indented ) ) ;
288
+ SaveModList ( modList ) ;
283
289
}
284
290
285
291
/// <summary>
@@ -290,9 +296,9 @@ public async Task ToggleAllMods(bool enable, IProgress<(int current, int total,
290
296
{
291
297
var index = new Index ( _gameDirectory ) ;
292
298
293
- var modList = JsonConvert . DeserializeObject < ModList > ( File . ReadAllText ( ModListDirectory . FullName ) ) ;
299
+ var modList = GetModList ( ) ;
294
300
295
- if ( modList == null || modList . modCount == 0 ) return ;
301
+ if ( modList == null || modList . modCount == 0 ) return ;
296
302
297
303
var modNum = 0 ;
298
304
foreach ( var modEntry in modList . Mods )
@@ -359,7 +365,7 @@ public async Task DisableOldModList(DirectoryInfo oldModListDirectory)
359
365
/// <param name="modItemPath">The mod item path of the mod to delete</param>
360
366
public async Task DeleteMod ( string modItemPath )
361
367
{
362
- var modList = JsonConvert . DeserializeObject < ModList > ( File . ReadAllText ( ModListDirectory . FullName ) ) ;
368
+ var modList = GetModList ( ) ;
363
369
364
370
var modToRemove = ( from mod in modList . Mods
365
371
where mod . fullPath . Equals ( modItemPath )
@@ -396,7 +402,7 @@ where mod.fullPath.Equals(modItemPath)
396
402
modList . modCount -= 1 ;
397
403
398
404
399
- File . WriteAllText ( ModListDirectory . FullName , JsonConvert . SerializeObject ( modList , Formatting . Indented ) ) ;
405
+ SaveModList ( modList ) ;
400
406
}
401
407
402
408
/// <summary>
@@ -405,7 +411,7 @@ where mod.fullPath.Equals(modItemPath)
405
411
/// <param name="modPackName">The name of the Mod Pack to be deleted</param>
406
412
public async Task DeleteModPack ( string modPackName )
407
413
{
408
- var modList = JsonConvert . DeserializeObject < ModList > ( File . ReadAllText ( ModListDirectory . FullName ) ) ;
414
+ var modList = GetModList ( ) ;
409
415
410
416
var modPackItem = ( from modPack in modList . ModPacks
411
417
where modPack . name . Equals ( modPackName )
@@ -454,7 +460,7 @@ where modPack.name.Equals(modPackName)
454
460
modList . modCount -= modRemoveCount ;
455
461
modList . modPackCount -= 1 ;
456
462
457
- File . WriteAllText ( ModListDirectory . FullName , JsonConvert . SerializeObject ( modList , Formatting . Indented ) ) ;
463
+ SaveModList ( modList ) ;
458
464
}
459
465
}
460
466
}
0 commit comments