mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
Auto/EU/US server selection in settings
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Flowframes.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
@@ -15,7 +16,7 @@ namespace Flowframes.Data
|
||||
|
||||
public static List<Server> serverList = new List<Server> { hetznerEu, contaboUs };
|
||||
|
||||
public static Server closestServer = serverList[0];
|
||||
private static Server closestServer = serverList[0];
|
||||
|
||||
public class Server
|
||||
{
|
||||
@@ -62,5 +63,15 @@ namespace Flowframes.Data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Server GetServer ()
|
||||
{
|
||||
int server = Config.GetInt("serverCombox");
|
||||
|
||||
if (server == 0)
|
||||
return closestServer;
|
||||
else
|
||||
return serverList[server - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
Code/Forms/SettingsForm.Designer.cs
generated
36
Code/Forms/SettingsForm.Designer.cs
generated
@@ -187,6 +187,8 @@
|
||||
this.titleLabel = new System.Windows.Forms.Label();
|
||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.resetBtn = new HTAlt.WinForms.HTButton();
|
||||
this.serverCombox = new System.Windows.Forms.ComboBox();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.settingsTabList.SuspendLayout();
|
||||
this.generalTab.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.info1)).BeginInit();
|
||||
@@ -2022,6 +2024,8 @@
|
||||
// debugTab
|
||||
//
|
||||
this.debugTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
this.debugTab.Controls.Add(this.label7);
|
||||
this.debugTab.Controls.Add(this.serverCombox);
|
||||
this.debugTab.Controls.Add(this.ffEncArgs);
|
||||
this.debugTab.Controls.Add(this.label56);
|
||||
this.debugTab.Controls.Add(this.label54);
|
||||
@@ -2210,6 +2214,36 @@
|
||||
this.resetBtn.UseVisualStyleBackColor = false;
|
||||
this.resetBtn.Click += new System.EventHandler(this.resetBtn_Click);
|
||||
//
|
||||
// serverCombox
|
||||
//
|
||||
this.serverCombox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.serverCombox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.serverCombox.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.serverCombox.ForeColor = System.Drawing.Color.White;
|
||||
this.serverCombox.FormattingEnabled = true;
|
||||
this.serverCombox.Items.AddRange(new object[] {
|
||||
"Very Fast",
|
||||
"Faster",
|
||||
"Fast",
|
||||
"Medium",
|
||||
"Slow",
|
||||
"Slower",
|
||||
"Very Slow"});
|
||||
this.serverCombox.Location = new System.Drawing.Point(280, 67);
|
||||
this.serverCombox.Name = "serverCombox";
|
||||
this.serverCombox.Size = new System.Drawing.Size(250, 21);
|
||||
this.serverCombox.TabIndex = 86;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(10, 70);
|
||||
this.label7.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(121, 13);
|
||||
this.label7.TabIndex = 87;
|
||||
this.label7.Text = "Model Download Server";
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -2414,5 +2448,7 @@
|
||||
private System.Windows.Forms.TextBox custOutDir;
|
||||
private System.Windows.Forms.ComboBox outFolderLoc;
|
||||
private System.Windows.Forms.Label label78;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.ComboBox serverCombox;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Flowframes.IO;
|
||||
using Flowframes.Data;
|
||||
using Flowframes.IO;
|
||||
using Flowframes.Media;
|
||||
using Flowframes.MiscUtils;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
@@ -27,11 +28,23 @@ namespace Flowframes.Forms
|
||||
MinimumSize = new Size(Width, Height);
|
||||
MaximumSize = new Size(Width, (Height * 1.5f).RoundToInt());
|
||||
|
||||
InitServers();
|
||||
LoadSettings();
|
||||
initialized = true;
|
||||
Task.Run(() => CheckModelCacheSize());
|
||||
}
|
||||
|
||||
void InitServers()
|
||||
{
|
||||
serverCombox.Items.Clear();
|
||||
serverCombox.Items.Add($"Automatic (Closest)");
|
||||
|
||||
foreach (Servers.Server srv in Servers.serverList)
|
||||
serverCombox.Items.Add(srv.name);
|
||||
|
||||
serverCombox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
public async Task CheckModelCacheSize ()
|
||||
{
|
||||
await Task.Delay(200);
|
||||
@@ -122,6 +135,7 @@ namespace Flowframes.Forms
|
||||
ConfigParser.SaveGuiElement(imgSeqFormat);
|
||||
// Debugging
|
||||
ConfigParser.SaveComboxIndex(cmdDebugMode);
|
||||
ConfigParser.SaveComboxIndex(serverCombox);
|
||||
ConfigParser.SaveGuiElement(ffEncThreads, ConfigParser.StringMode.Int);
|
||||
ConfigParser.SaveGuiElement(ffEncPreset);
|
||||
ConfigParser.SaveGuiElement(ffEncArgs);
|
||||
@@ -182,6 +196,7 @@ namespace Flowframes.Forms
|
||||
ConfigParser.LoadGuiElement(imgSeqFormat);
|
||||
// Debugging
|
||||
ConfigParser.LoadComboxIndex(cmdDebugMode);
|
||||
ConfigParser.LoadComboxIndex(serverCombox);
|
||||
ConfigParser.LoadGuiElement(ffEncThreads);
|
||||
ConfigParser.LoadGuiElement(ffEncPreset);
|
||||
ConfigParser.LoadGuiElement(ffEncArgs);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Flowframes.IO
|
||||
static string GetMdlUrl (string ai, string relPath)
|
||||
{
|
||||
string custServer = Config.Get(Config.Key.customServer);
|
||||
string server = custServer.Trim().Length > 3 ? custServer : Servers.closestServer.GetUrl();
|
||||
string server = custServer.Trim().Length > 3 ? custServer : Servers.GetServer().GetUrl();
|
||||
string baseUrl = $"{server}/flowframes/mdl/";
|
||||
return Path.Combine(baseUrl, ai.ToLower(), relPath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user