diff --git a/CodeLegacy/Forms/BatchForm.cs b/CodeLegacy/Forms/BatchForm.cs index c80fe25..16c824e 100644 --- a/CodeLegacy/Forms/BatchForm.cs +++ b/CodeLegacy/Forms/BatchForm.cs @@ -22,6 +22,14 @@ namespace Flowframes.Forms private void addToQueue_Click(object sender, EventArgs e) { + var entry = Program.mainForm.GetCurrentSettings(); + + if (!BatchProcessing.EntryIsValid(entry, msgBox: true)) + { + BringToFront(); + return; + } + Program.batchQueue.Enqueue(Program.mainForm.GetCurrentSettings()); RefreshGui(); } diff --git a/CodeLegacy/Main/BatchProcessing.cs b/CodeLegacy/Main/BatchProcessing.cs index 8d2b978..86636f6 100644 --- a/CodeLegacy/Main/BatchProcessing.cs +++ b/CodeLegacy/Main/BatchProcessing.cs @@ -2,6 +2,7 @@ using Flowframes.Forms; using Flowframes.IO; using Flowframes.Os; +using Flowframes.Ui; using System; using System.Collections.Generic; using System.IO; @@ -68,7 +69,7 @@ namespace Flowframes.Main stopped = true; } - static async Task RunEntry(InterpSettings entry) + public static async Task RunEntry(InterpSettings entry) { SetBusy(true); Program.mainForm.SetWorking(true); @@ -99,35 +100,35 @@ namespace Flowframes.Main Logger.Log($"Queue: Done processing {mf.Name} ({entry.interpFactor}x {entry.ai.NameShort})."); } - static void SetBusy(bool state) + private static void SetBusy(bool state) { busy = state; - - if (currentBatchForm != null) - currentBatchForm.SetWorking(state); - + currentBatchForm?.SetWorking(state); Program.mainForm.GetMainTabControl().Enabled = !state; // Lock GUI } - static bool EntryIsValid(InterpSettings entry) + public static bool EntryIsValid(InterpSettings entry, bool msgBox = false) { + bool Fail(string err) + { + Logger.Log($"Queue: Can't process queue entry: {err}"); + if (msgBox) UiUtils.ShowMessageBox(err, UiUtils.MessageType.Error); + return false; + } if (entry.inPath == null || (IoUtils.IsPathDirectory(entry.inPath) && !Directory.Exists(entry.inPath)) || (!IoUtils.IsPathDirectory(entry.inPath) && !File.Exists(entry.inPath))) { - Logger.Log("Queue: Can't process queue entry: Input path is invalid."); - return false; + return Fail("Input path is invalid."); } if (entry.outPath == null || (!Directory.Exists(entry.outPath) && Config.GetInt("outFolderLoc") != 1)) { - Logger.Log("Queue: Can't process queue entry: Output path is invalid."); - return false; + return Fail("Output path is invalid."); } if (IoUtils.GetAmountOfFiles(Path.Combine(Paths.GetPkgPath(), entry.ai.PkgDir), true) < 1) { - Logger.Log("Queue: Can't process queue entry: Selected AI is not available."); - return false; + return Fail("Selected AI is not available."); } return true;