mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
Validate batch entries that are added from curr. UI settings
This commit is contained in:
@@ -22,6 +22,14 @@ namespace Flowframes.Forms
|
|||||||
|
|
||||||
private void addToQueue_Click(object sender, EventArgs e)
|
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());
|
Program.batchQueue.Enqueue(Program.mainForm.GetCurrentSettings());
|
||||||
RefreshGui();
|
RefreshGui();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Flowframes.Forms;
|
using Flowframes.Forms;
|
||||||
using Flowframes.IO;
|
using Flowframes.IO;
|
||||||
using Flowframes.Os;
|
using Flowframes.Os;
|
||||||
|
using Flowframes.Ui;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -68,7 +69,7 @@ namespace Flowframes.Main
|
|||||||
stopped = true;
|
stopped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async Task RunEntry(InterpSettings entry)
|
public static async Task RunEntry(InterpSettings entry)
|
||||||
{
|
{
|
||||||
SetBusy(true);
|
SetBusy(true);
|
||||||
Program.mainForm.SetWorking(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}).");
|
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;
|
busy = state;
|
||||||
|
currentBatchForm?.SetWorking(state);
|
||||||
if (currentBatchForm != null)
|
|
||||||
currentBatchForm.SetWorking(state);
|
|
||||||
|
|
||||||
Program.mainForm.GetMainTabControl().Enabled = !state; // Lock GUI
|
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)))
|
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 Fail("Input path is invalid.");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.outPath == null || (!Directory.Exists(entry.outPath) && Config.GetInt("outFolderLoc") != 1))
|
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 Fail("Output path is invalid.");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IoUtils.GetAmountOfFiles(Path.Combine(Paths.GetPkgPath(), entry.ai.PkgDir), true) < 1)
|
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 Fail("Selected AI is not available.");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user