diff --git a/FrostyEditor/Windows/MainWindow.xaml.cs b/FrostyEditor/Windows/MainWindow.xaml.cs index 37079c193..ab71d7915 100644 --- a/FrostyEditor/Windows/MainWindow.xaml.cs +++ b/FrostyEditor/Windows/MainWindow.xaml.cs @@ -386,19 +386,25 @@ private void launchButton_Click(object sender, RoutedEventArgs e) // setup ability to cancel the process CancellationTokenSource cancelToken = new CancellationTokenSource(); - Random r = new Random(); - string editorModName = $"EditorMod{r.Next(1000, 9999).ToString("D4")}.fbmod"; launchButton.IsEnabled = false; // get all mods List modPaths = new List(); - + DirectoryInfo modDirectory = new DirectoryInfo($"Mods/{ProfilesLibrary.ProfileName}"); foreach (string modPath in Directory.EnumerateFiles($"Mods/{ProfilesLibrary.ProfileName}/", "*.fbmod", SearchOption.AllDirectories)) - modPaths.Add(Path.GetFileName(modPath)); - + { + if(Path.GetFileName(modPath).Contains("EditorMod")) + File.Delete(modPath); + else + modPaths.Add(Path.GetFileName(modPath)); + } + + Random r = new Random(); + string editorModName = $"EditorMod_{r.Next(1000, 9999).ToString("D4")}.fbmod"; + // create temporary editor mod - ModSettings editorSettings = new ModSettings { Title = "Editor Mod", Author = "Frosty Editor", Version = "1", Category = "Editor" }; + ModSettings editorSettings = new ModSettings { Title = editorModName, Author = "Frosty Editor", Version = App.Version, Category = "Editor"}; // apply mod string additionalArgs = Config.Get("CommandLineArgs", "", ConfigScope.Game) + " "; @@ -420,6 +426,7 @@ private void launchButton_Click(object sender, RoutedEventArgs e) task.Update("Exporting Mod"); ExportMod(editorSettings, $"Mods/{ProfilesLibrary.ProfileName}/{editorModName}", true); modPaths.Add(editorModName); + App.Logger.Log("Editor temporary Mod saved to {0}", $"Mods/{ProfilesLibrary.ProfileName}/{editorModName}"); // allow cancelling in case of a big mod (will cancel after processing the mod) // @todo: add cancellation to different stages of mod exportation, to allow cancelling @@ -427,6 +434,18 @@ private void launchButton_Click(object sender, RoutedEventArgs e) cancelToken.Token.ThrowIfCancellationRequested(); + // Remove mods.json + task.Update("Removing mods.json"); + string gamePatchPath = "Patch"; + if (ProfilesLibrary.DataVersion == (int)ProfileVersion.Fifa17 || ProfilesLibrary.DataVersion == (int)ProfileVersion.DragonAgeInquisition || ProfilesLibrary.DataVersion == (int)ProfileVersion.Battlefield4 || ProfilesLibrary.DataVersion == (int)ProfileVersion.NeedForSpeed || ProfilesLibrary.DataVersion == (int)ProfileVersion.PlantsVsZombiesGardenWarfare2 || ProfilesLibrary.DataVersion == (int)ProfileVersion.NeedForSpeedRivals) + gamePatchPath = "Update\\Patch\\Data"; + else if (ProfilesLibrary.DataVersion == (int)ProfileVersion.PlantsVsZombiesBattleforNeighborville || ProfilesLibrary.DataVersion == (int)ProfileVersion.Battlefield5) //bfn and bfv dont have a patch directory + gamePatchPath = "Data"; + if (File.Exists(App.FileSystem.BasePath + $"\\ModData\\{App.SelectedPack}\\{gamePatchPath}\\mods.json")) + { + File.Delete(App.FileSystem.BasePath + $"\\ModData\\{App.SelectedPack}\\{gamePatchPath}\\mods.json"); + App.Logger.Log("Removed mods.json"); + } task.Update(""); executor.Run(App.FileSystem, cancelToken.Token, task.TaskLogger, $"Mods/{ProfilesLibrary.ProfileName}/", App.SelectedPack, additionalArgs.Trim(), modPaths.ToArray()); diff --git a/FrostyEditor/Windows/PrelaunchWindow2.xaml.cs b/FrostyEditor/Windows/PrelaunchWindow2.xaml.cs index 3af42e76a..a3827e528 100644 --- a/FrostyEditor/Windows/PrelaunchWindow2.xaml.cs +++ b/FrostyEditor/Windows/PrelaunchWindow2.xaml.cs @@ -198,7 +198,7 @@ private void IterateSubKeys(RegistryKey subKey, ref int totalCount) private void RemoveConfigButton_Click(object sender, RoutedEventArgs e) { - if (FrostyMessageBox.Show("Are you sure you want to delete this configuration?", "Frosty Mod Manager", MessageBoxButton.YesNo) == MessageBoxResult.Yes) + if (FrostyMessageBox.Show("Are you sure you want to delete this configuration?", "Frosty Editor", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { FrostyConfiguration selectedItem = ConfigList.SelectedItem as FrostyConfiguration; diff --git a/FrostyModSupport/FrostyModExecutor.cs b/FrostyModSupport/FrostyModExecutor.cs index a559a89d0..682c26747 100644 --- a/FrostyModSupport/FrostyModExecutor.cs +++ b/FrostyModSupport/FrostyModExecutor.cs @@ -1762,6 +1762,10 @@ public int Run(FileSystem inFs, CancellationToken cancelToken, ILogger inLogger, // create the frosty mod list file File.WriteAllText(Path.Combine(modDataPath, patchPath, "mods.json"), JsonConvert.SerializeObject(GenerateModInfoList(modPaths, rootPath), Formatting.Indented)); } + else + { + App.Logger.Log("Launching with previously generated data."); + } cancelToken.ThrowIfCancellationRequested();