Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor] Fixed issue where editor mods did not get removed #274

Merged
merged 22 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d3c8aa3
[FsLocalizationPlugin] Add StringID convert (Not Finish)
shoushou1106 Aug 2, 2023
61b4b69
[Editor]Remove mod domain restrictions
shoushou1106 Aug 2, 2023
ac63741
[Editor & ModSupport] Fix BUG: Editor launch game will retain the las…
shoushou1106 Aug 2, 2023
88f1181
Merge branch '1.0.6.3' of https://github.com/shoushou1106/FrostyTools…
shoushou1106 Aug 2, 2023
7ce2ccf
Revert "[FsLocalizationPlugin] Add StringID convert (Not Finish)"
shoushou1106 Aug 2, 2023
5b90672
Revert "[Editor]Remove mod domain restrictions"
shoushou1106 Aug 2, 2023
2830c16
[Editor & ModSupport] Fix BUG
shoushou1106 Aug 2, 2023
caf1ab9
[Editor] Fix BUG
shoushou1106 Aug 2, 2023
1b39c29
[Editor] Reslove conversation
shoushou1106 Aug 3, 2023
ee6cdb3
Delete BuildDate.txt
shoushou1106 Aug 3, 2023
f187410
Delete BuildDate.txt
shoushou1106 Aug 3, 2023
255fa9a
sorry for that
shoushou1106 Aug 3, 2023
d54b4d6
Merge branch '1.0.6.3' of https://github.com/shoushou1106/FrostyTools…
shoushou1106 Aug 3, 2023
e215462
how can i undo that
shoushou1106 Aug 3, 2023
421841e
[Editor & ModExecutor] Resolve conversation
shoushou1106 Aug 4, 2023
14fa5f7
Fix formatting
shoushou1106 Aug 4, 2023
3384b83
Not finish, my vs crash
shoushou1106 Aug 5, 2023
e564f2f
Not finish too
shoushou1106 Aug 5, 2023
37d6cdb
Update MainWindow.xaml.cs
shoushou1106 Aug 5, 2023
9fdf6fb
fix bug
shoushou1106 Aug 7, 2023
9721e47
Merge branch 'CadeEvs:1.0.6.3' into 1.0.6.3
shoushou1106 Aug 7, 2023
a969fa4
Update MainWindow.xaml.cs
shoushou1106 Aug 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 24 additions & 5 deletions FrostyEditor/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> modPaths = new List<string>();

// Remove existing editor mods
DirectoryInfo modDirectory = new DirectoryInfo($"Mods/{ProfilesLibrary.ProfileName}");
foreach (string modPath in Directory.EnumerateFiles($"Mods/{ProfilesLibrary.ProfileName}/", "*.fbmod", SearchOption.AllDirectories))
modPaths.Add(Path.GetFileName(modPath));
foreach (string modPath in Directory.EnumerateFiles($"Mods/{ProfilesLibrary.ProfileName}/", "EditorMod*.fbmod", SearchOption.AllDirectories))
File.Delete(modPath);
shoushou1106 marked this conversation as resolved.
Show resolved Hide resolved

Random r = new Random();
string editorModName = $"EditorMod_{r.Next(1000, 9999).ToString("D4")}.fbmod";
while (File.Exists(editorModName))
shoushou1106 marked this conversation as resolved.
Show resolved Hide resolved
{
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<string>("CommandLineArgs", "", ConfigScope.Game) + " ";
Expand All @@ -420,13 +426,26 @@ 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
// at any stage of a large mod

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());

Expand Down
2 changes: 1 addition & 1 deletion FrostyEditor/Windows/PrelaunchWindow2.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions FrostyModSupport/FrostyModExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,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();

Expand Down