From 204a5f7eec66ba6e0518f09ac5630a3bca71ccab Mon Sep 17 00:00:00 2001 From: Nikita Grebenyuk Date: Thu, 17 Aug 2023 19:48:08 +1000 Subject: [PATCH] feat: Ask if json should be overwritten --- WolvenKit/Forms/MVVM/frmModExplorer.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/WolvenKit/Forms/MVVM/frmModExplorer.cs b/WolvenKit/Forms/MVVM/frmModExplorer.cs index 95b493f0..83f8d147 100644 --- a/WolvenKit/Forms/MVVM/frmModExplorer.cs +++ b/WolvenKit/Forms/MVVM/frmModExplorer.cs @@ -920,6 +920,7 @@ private void exportJSONToolStripMenuItem_Click(object sender, EventArgs e) return; } + bool overwriteJson = MessageBox.Show("(If there are any) Overwrite existing json files?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes; string savePath; int percent_old = -1; Task.Run(() => //Run the method in another thread to prevent freezing UI @@ -946,7 +947,11 @@ private void exportJSONToolStripMenuItem_Click(object sender, EventArgs e) savePath = $"{rootDir}_{scriptName}\\{cr2wPaths[i].Substring(rootDir.Length + 1, cr2wPaths[i].Length - (rootDir.Length + 1))}.json"; Directory.CreateDirectory(Path.GetDirectoryName(savePath)); } - if (CR2WJsonTool.ExportJSON(cr2wPaths[i], savePath, new CR2WJsonToolOptions())) + if (File.Exists(savePath) && !overwriteJson) + { + logger?.LogString($"[{scriptName}] ({percent}%) SKIP, JSON exists: {cr2wPaths[i]}..", Logtype.Success); + } + else if (CR2WJsonTool.ExportJSON(cr2wPaths[i], savePath, new CR2WJsonToolOptions())) { logger?.LogString($"[{scriptName}] ({percent}%) OK exported JSON: {cr2wPaths[i]}..", Logtype.Success); }