diff --git a/CodeLegacy/Data/Implementations.cs b/CodeLegacy/Data/Implementations.cs index c8908eb..ddd23b9 100644 --- a/CodeLegacy/Data/Implementations.cs +++ b/CodeLegacy/Data/Implementations.cs @@ -121,7 +121,6 @@ public static AiInfo GetAi(string aiName) return NetworksAll[0]; } - // New: Use enums public static AiInfo GetAi(Ai ai) { if (AiLookup.TryGetValue(ai, out AiInfo aiObj)) diff --git a/CodeLegacy/Extensions/ExtensionMethods.cs b/CodeLegacy/Extensions/ExtensionMethods.cs index af08e67..8c02cd4 100644 --- a/CodeLegacy/Extensions/ExtensionMethods.cs +++ b/CodeLegacy/Extensions/ExtensionMethods.cs @@ -62,6 +62,9 @@ public static bool GetBool(this string str) { try { + if (str.IsEmpty()) + return false; + return bool.Parse(str); } catch diff --git a/CodeLegacy/Forms/CustomForm.cs b/CodeLegacy/Forms/CustomForm.cs index 844951d..9e4ddda 100644 --- a/CodeLegacy/Forms/CustomForm.cs +++ b/CodeLegacy/Forms/CustomForm.cs @@ -8,12 +8,30 @@ namespace Flowframes.Forms public class CustomForm : Form { public Control FocusedControl { get { return this.GetControls().Where(c => c.Focused).FirstOrDefault(); } } + public List AllControls => GetAllControls(this); public bool AllowTextboxTab { get; set; } = true; public bool AllowEscClose { get; set; } = true; private List _tabOrderedControls; + private static List GetAllControls(Control parent) + { + var controls = new List(); + + foreach (Control ctrl in parent.Controls) + { + controls.Add(ctrl); + + if (ctrl.HasChildren) + { + controls.AddRange(GetAllControls(ctrl)); + } + } + + return controls; + } + public void TabOrderInit(List tabOrderedControls, int defaultFocusIndex = 0) { _tabOrderedControls = tabOrderedControls; diff --git a/CodeLegacy/Forms/Main/Form1.cs b/CodeLegacy/Forms/Main/Form1.cs index ec07563..9499edb 100644 --- a/CodeLegacy/Forms/Main/Form1.cs +++ b/CodeLegacy/Forms/Main/Form1.cs @@ -60,9 +60,9 @@ public Form1() } } - private async void Form1_Load(object sender, EventArgs e) + private void Form1_Load(object sender, EventArgs e) { - CheckForIllegalCrossThreadCalls = false; + CheckForIllegalCrossThreadCalls = Debugger.IsAttached; AutoScaleMode = AutoScaleMode.None; } diff --git a/CodeLegacy/Forms/SettingsForm.Designer.cs b/CodeLegacy/Forms/SettingsForm.Designer.cs index f833e27..068ade8 100644 --- a/CodeLegacy/Forms/SettingsForm.Designer.cs +++ b/CodeLegacy/Forms/SettingsForm.Designer.cs @@ -126,9 +126,11 @@ private void InitializeComponent() this.panTitleAiFramework = new System.Windows.Forms.Panel(); this.label32 = new System.Windows.Forms.Label(); this.panTorchGpus = new System.Windows.Forms.Panel(); + this.tooltipTorchGpu = new System.Windows.Forms.PictureBox(); this.label33 = new System.Windows.Forms.Label(); this.torchGpus = new System.Windows.Forms.ComboBox(); this.panNcnnGpus = new System.Windows.Forms.Panel(); + this.tooltipNcnnGpu = new System.Windows.Forms.PictureBox(); this.label5 = new System.Windows.Forms.Label(); this.ncnnGpus = new System.Windows.Forms.ComboBox(); this.panNcnnThreads = new System.Windows.Forms.Panel(); @@ -183,8 +185,8 @@ private void InitializeComponent() this.titleLabel = new System.Windows.Forms.Label(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.resetBtn = new HTAlt.WinForms.HTButton(); - this.tooltipTorchGpu = new System.Windows.Forms.PictureBox(); - this.tooltipNcnnGpu = new System.Windows.Forms.PictureBox(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.onlyShowRelevantSettings = new System.Windows.Forms.CheckBox(); this.settingsTabList.SuspendLayout(); this.generalTab.SuspendLayout(); this.flowPanelApplication.SuspendLayout(); @@ -220,7 +222,9 @@ private void InitializeComponent() this.flowPanelAiOptions.SuspendLayout(); this.panTitleAiFramework.SuspendLayout(); this.panTorchGpus.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tooltipTorchGpu)).BeginInit(); this.panNcnnGpus.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tooltipNcnnGpu)).BeginInit(); this.panNcnnThreads.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.ncnnThreads)).BeginInit(); this.panTitleRife.SuspendLayout(); @@ -231,8 +235,7 @@ private void InitializeComponent() this.vidExportTab.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.minOutVidLength)).BeginInit(); this.debugTab.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.tooltipTorchGpu)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.tooltipNcnnGpu)).BeginInit(); + this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // settingsTabList @@ -249,7 +252,7 @@ private void InitializeComponent() this.settingsTabList.ForeColor = System.Drawing.Color.DodgerBlue; this.settingsTabList.Location = new System.Drawing.Point(12, 62); this.settingsTabList.Name = "settingsTabList"; - this.settingsTabList.Size = new System.Drawing.Size(920, 779); + this.settingsTabList.Size = new System.Drawing.Size(920, 427); this.settingsTabList.TabIndex = 0; this.settingsTabList.SelectedIndexChanged += new System.EventHandler(this.settingsTabList_SelectedIndexChanged); // @@ -1320,7 +1323,7 @@ private void InitializeComponent() this.aiOptsPage.Controls.Add(this.flowPanelAiOptions); this.aiOptsPage.ForeColor = System.Drawing.Color.White; this.aiOptsPage.Name = "aiOptsPage"; - this.aiOptsPage.Size = new System.Drawing.Size(762, 771); + this.aiOptsPage.Size = new System.Drawing.Size(762, 419); this.aiOptsPage.Text = "AI Specific Options"; // // flowPanelAiOptions @@ -1339,7 +1342,7 @@ private void InitializeComponent() this.flowPanelAiOptions.Location = new System.Drawing.Point(0, 0); this.flowPanelAiOptions.Margin = new System.Windows.Forms.Padding(0); this.flowPanelAiOptions.Name = "flowPanelAiOptions"; - this.flowPanelAiOptions.Size = new System.Drawing.Size(762, 771); + this.flowPanelAiOptions.Size = new System.Drawing.Size(762, 419); this.flowPanelAiOptions.TabIndex = 95; // // panTitleAiFramework @@ -1373,6 +1376,16 @@ private void InitializeComponent() this.panTorchGpus.Size = new System.Drawing.Size(762, 30); this.panTorchGpus.TabIndex = 5; // + // tooltipTorchGpu + // + this.tooltipTorchGpu.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer; + this.tooltipTorchGpu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.tooltipTorchGpu.Location = new System.Drawing.Point(536, 7); + this.tooltipTorchGpu.Name = "tooltipTorchGpu"; + this.tooltipTorchGpu.Size = new System.Drawing.Size(29, 21); + this.tooltipTorchGpu.TabIndex = 91; + this.tooltipTorchGpu.TabStop = false; + // // label33 // this.label33.AutoSize = true; @@ -1405,6 +1418,16 @@ private void InitializeComponent() this.panNcnnGpus.Size = new System.Drawing.Size(762, 30); this.panNcnnGpus.TabIndex = 6; // + // tooltipNcnnGpu + // + this.tooltipNcnnGpu.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer; + this.tooltipNcnnGpu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.tooltipNcnnGpu.Location = new System.Drawing.Point(536, 7); + this.tooltipNcnnGpu.Name = "tooltipNcnnGpu"; + this.tooltipNcnnGpu.Size = new System.Drawing.Size(29, 21); + this.tooltipNcnnGpu.TabIndex = 92; + this.tooltipNcnnGpu.TabStop = false; + // // label5 // this.label5.AutoSize = true; @@ -1885,7 +1908,7 @@ private void InitializeComponent() this.debugTab.Controls.Add(this.cmdDebugMode); this.debugTab.ForeColor = System.Drawing.Color.White; this.debugTab.Name = "debugTab"; - this.debugTab.Size = new System.Drawing.Size(762, 419); + this.debugTab.Size = new System.Drawing.Size(762, 771); this.debugTab.Text = "Developer Options"; // // label7 @@ -2057,32 +2080,35 @@ private void InitializeComponent() this.resetBtn.UseVisualStyleBackColor = false; this.resetBtn.Click += new System.EventHandler(this.resetBtn_Click); // - // tooltipTorchGpu + // flowLayoutPanel1 // - this.tooltipTorchGpu.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer; - this.tooltipTorchGpu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.tooltipTorchGpu.Location = new System.Drawing.Point(536, 7); - this.tooltipTorchGpu.Name = "tooltipTorchGpu"; - this.tooltipTorchGpu.Size = new System.Drawing.Size(29, 21); - this.tooltipTorchGpu.TabIndex = 91; - this.tooltipTorchGpu.TabStop = false; + this.flowLayoutPanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); + this.flowLayoutPanel1.Controls.Add(this.onlyShowRelevantSettings); + this.flowLayoutPanel1.Location = new System.Drawing.Point(683, 12); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(200, 40); + this.flowLayoutPanel1.TabIndex = 41; // - // tooltipNcnnGpu + // onlyShowRelevantSettings // - this.tooltipNcnnGpu.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer; - this.tooltipNcnnGpu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.tooltipNcnnGpu.Location = new System.Drawing.Point(536, 7); - this.tooltipNcnnGpu.Name = "tooltipNcnnGpu"; - this.tooltipNcnnGpu.Size = new System.Drawing.Size(29, 21); - this.tooltipNcnnGpu.TabIndex = 92; - this.tooltipNcnnGpu.TabStop = false; + this.onlyShowRelevantSettings.Checked = true; + this.onlyShowRelevantSettings.CheckState = System.Windows.Forms.CheckState.Checked; + this.onlyShowRelevantSettings.ForeColor = System.Drawing.Color.White; + this.onlyShowRelevantSettings.Location = new System.Drawing.Point(9, 3); + this.onlyShowRelevantSettings.Margin = new System.Windows.Forms.Padding(9, 3, 3, 3); + this.onlyShowRelevantSettings.Name = "onlyShowRelevantSettings"; + this.onlyShowRelevantSettings.Size = new System.Drawing.Size(179, 34); + this.onlyShowRelevantSettings.TabIndex = 0; + this.onlyShowRelevantSettings.Text = "Only show relevant settings"; + this.onlyShowRelevantSettings.UseVisualStyleBackColor = true; // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))); - this.ClientSize = new System.Drawing.Size(944, 853); + this.ClientSize = new System.Drawing.Size(944, 501); + this.Controls.Add(this.flowLayoutPanel1); this.Controls.Add(this.resetBtn); this.Controls.Add(this.titleLabel); this.Controls.Add(this.settingsTabList); @@ -2151,8 +2177,10 @@ private void InitializeComponent() this.panTitleAiFramework.PerformLayout(); this.panTorchGpus.ResumeLayout(false); this.panTorchGpus.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tooltipTorchGpu)).EndInit(); this.panNcnnGpus.ResumeLayout(false); this.panNcnnGpus.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tooltipNcnnGpu)).EndInit(); this.panNcnnThreads.ResumeLayout(false); this.panNcnnThreads.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.ncnnThreads)).EndInit(); @@ -2171,8 +2199,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.minOutVidLength)).EndInit(); this.debugTab.ResumeLayout(false); this.debugTab.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.tooltipTorchGpu)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.tooltipNcnnGpu)).EndInit(); + this.flowLayoutPanel1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -2335,5 +2362,7 @@ private void InitializeComponent() public System.Windows.Forms.Panel panDainNcnnTileSize; private System.Windows.Forms.PictureBox tooltipTorchGpu; private System.Windows.Forms.PictureBox tooltipNcnnGpu; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.CheckBox onlyShowRelevantSettings; } } \ No newline at end of file diff --git a/CodeLegacy/Forms/SettingsForm.cs b/CodeLegacy/Forms/SettingsForm.cs index efdab58..284eeb9 100644 --- a/CodeLegacy/Forms/SettingsForm.cs +++ b/CodeLegacy/Forms/SettingsForm.cs @@ -14,15 +14,18 @@ namespace Flowframes.Forms { - public partial class SettingsForm : Form + public partial class SettingsForm : CustomForm { - bool initialized = false; + private bool _initialized = false; + private AiInfo _currentAi = null; - public SettingsForm(int index = 0) + public SettingsForm(int tabIndex = 0, AiInfo currentAi = null) { AutoScaleMode = AutoScaleMode.None; InitializeComponent(); - settingsTabList.SelectedIndex = index; + + _currentAi = currentAi == null ? Program.mainForm.GetAi() : currentAi; + settingsTabList.SelectedIndex = tabIndex; } private void SettingsForm_Load(object sender, EventArgs e) @@ -30,12 +33,13 @@ private void SettingsForm_Load(object sender, EventArgs e) MinimumSize = new Size(Width, Height); MaximumSize = new Size(Width, (Height * 1.5f).RoundToInt()); mpdecimateMode.FillFromEnum(useKeyNames: true); + onlyShowRelevantSettings.Click += (s, ea) => SetVisibility(); InitGpus(); InitServers(); LoadSettings(); AddTooltipClickFunction(); - initialized = true; + _initialized = true; Task.Run(() => CheckModelCacheSize()); } @@ -105,6 +109,7 @@ void SaveSettings() ncnnGpus.Text = ncnnGpus.Text.Replace(" ", ""); // General + ConfigParser.SaveGuiElement(onlyShowRelevantSettings); ConfigParser.SaveComboxIndex(processingMode); ConfigParser.SaveGuiElement(maxVidHeight, ConfigParser.StringMode.Int); ConfigParser.SaveComboxIndex(tempFolderLoc); @@ -150,6 +155,7 @@ void SaveSettings() void LoadSettings() { + ConfigParser.LoadGuiElement(onlyShowRelevantSettings); // General ConfigParser.LoadComboxIndex(processingMode); ConfigParser.LoadGuiElement(maxVidHeight); @@ -196,6 +202,8 @@ void LoadSettings() private void SetVisibility() { + bool onlyRelevant = onlyShowRelevantSettings.Checked; + // Dev options List devOptions = new List { panKeepTempFolder, }; devOptions.ForEach(c => c.SetVisible(Program.Debug)); @@ -205,37 +213,27 @@ private void SetVisibility() legacyUntestedOptions.ForEach(c => c.SetVisible(Program.Debug)); // AutoEnc options - bool autoEncEnabled = autoEncMode.SelectedIndex != 0; + bool autoEncPossible = !_currentAi.Piped; + autoEncMode.Visible = !(onlyRelevant && !autoEncPossible); + bool autoEncEnabled = autoEncMode.Visible && autoEncMode.SelectedIndex != 0; List autoEncOptions = new List { panAutoEncBackups, panAutoEncLowSpaceMode }; autoEncOptions.ForEach(c => c.SetVisible(autoEncEnabled)); panAutoEncInSbsMode.SetVisible(autoEncEnabled && panProcessingStyle.Visible); var availAis = Implementations.NetworksAvailable; - panTorchGpus.SetVisible(NvApi.NvGpus.Count > 0 && Python.IsPytorchReady()); - panNcnnGpus.SetVisible(VulkanUtils.VkDevices.Count > 0); - panRifeCudaHalfPrec.SetVisible(NvApi.NvGpus.Count > 0 && availAis.Contains(Implementations.rifeCuda)); - } - - private static List GetAllControls(Control parent) - { - var controls = new List(); - - foreach (Control ctrl in parent.Controls) - { - controls.Add(ctrl); - - if (ctrl.HasChildren) - { - controls.AddRange(GetAllControls(ctrl)); - } - } - - return controls; + bool showTorchSettings = !(onlyRelevant && _currentAi.Backend != AiInfo.AiBackend.Pytorch); + panTorchGpus.SetVisible(showTorchSettings && NvApi.NvGpus.Count > 0 && Python.IsPytorchReady()); + bool showNcnnSettings = !(onlyRelevant && _currentAi.Backend != AiInfo.AiBackend.Ncnn); + panNcnnGpus.SetVisible(showNcnnSettings && VulkanUtils.VkDevices.Count > 0); + bool showRifeCudaSettings = !(onlyRelevant && _currentAi != Implementations.rifeCuda); + panRifeCudaHalfPrec.SetVisible(showRifeCudaSettings && NvApi.NvGpus.Count > 0 && availAis.Contains(Implementations.rifeCuda)); + bool showDainNcnnSettings = !(onlyRelevant && _currentAi != Implementations.dainNcnn); + new List { panTitleDainNcnn, panDainNcnnTileSize }.ForEach(c => c.SetVisible(showDainNcnnSettings && availAis.Contains(Implementations.dainNcnn))); } private void AddTooltipClickFunction() { - foreach (Control control in GetAllControls(this)) + foreach (Control control in AllControls) { if(!(control is PictureBox)) continue; @@ -283,7 +281,7 @@ private void custOutDirBrowseBtn_Click(object sender, EventArgs e) private void cmdDebugMode_SelectedIndexChanged(object sender, EventArgs e) { - if (initialized && cmdDebugMode.SelectedIndex == 2) + if (_initialized && cmdDebugMode.SelectedIndex == 2) UiUtils.ShowMessageBox("If you enable this, you need to close the CMD window manually after the process has finished, otherwise processing will be paused!", UiUtils.MessageType.Warning); } diff --git a/CodeLegacy/IO/Config.cs b/CodeLegacy/IO/Config.cs index f6472d9..c78535a 100644 --- a/CodeLegacy/IO/Config.cs +++ b/CodeLegacy/IO/Config.cs @@ -259,6 +259,7 @@ private static string WriteDefaultValIfExists(string keyStr, Type type) return WriteDefault(keyStr, ""); } + if (key == Key.onlyShowRelevantSettings) return WriteDefault(key, true); if (key == Key.disablePreview) return WriteDefault(key, true); if (key == Key.maxVidHeight) return WriteDefault(key, "2160"); if (key == Key.clearLogOnInput) return WriteDefault(key, true); @@ -368,6 +369,7 @@ public enum Key mpdecimateMode, ncnnGpus, ncnnThreads, + onlyShowRelevantSettings, opusBitrate, processingMode, rifeCudaBufferSize,