|
|
@@ -117,15 +117,22 @@ namespace TBMM |
|
|
|
public void SaveFileList(ModInfo mod) |
|
|
|
{ |
|
|
|
if (mod.ModFiles != null) |
|
|
|
File.WriteAllText(mod.Name + ".json", JsonConvert.SerializeObject(mod.ModFiles)); |
|
|
|
{ |
|
|
|
Directory.CreateDirectory(GamePath("\\ModInfo")); |
|
|
|
File.WriteAllText(GamePath($"\\ModInfo\\{mod.Name}.json"), JsonConvert.SerializeObject(mod.ModFiles)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void LoadFileList(ModInfo mod) |
|
|
|
{ |
|
|
|
if (File.Exists(mod.Name + ".json")) |
|
|
|
mod.ModFiles = JsonConvert.DeserializeObject<HashSet<string>>(File.ReadAllText(mod.Name + ".json")); |
|
|
|
else |
|
|
|
mod.ModFiles = new HashSet<string>(); |
|
|
|
string[] paths = |
|
|
|
{ |
|
|
|
GamePath($"\\ModInfo\\{mod.Name}.json"), |
|
|
|
mod.Name + ".json" |
|
|
|
}; |
|
|
|
mod.ModFiles = |
|
|
|
paths.Where(File.Exists).Select(File.ReadAllText).Select(JsonConvert.DeserializeObject<HashSet<string>>) |
|
|
|
.FirstOrDefault() ?? new HashSet<string>(); |
|
|
|
} |
|
|
|
|
|
|
|
public void UninstallMod(ModInfo mod) |
|
|
@@ -146,6 +153,9 @@ namespace TBMM |
|
|
|
parent.Delete(); //May delete the Plugins dir if empty |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (File.Exists(GamePath($"\\ModInfo\\{mod.Name}.json"))) |
|
|
|
File.Delete(GamePath($"\\ModInfo\\{mod.Name}.json")); |
|
|
|
File.Delete(mod.Name + ".json"); |
|
|
|
mod.Version = null; //Not installed |
|
|
|
if (mod.Author != null) |
|
|
|