Skip to content

Commit

Permalink
feat: Ask if json should be overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
nikich340 committed Aug 17, 2023
1 parent 5f16d7c commit 204a5f7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion WolvenKit/Forms/MVVM/frmModExplorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down

0 comments on commit 204a5f7

Please sign in to comment.