mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 08:27:44 +01:00
Switched to pseudo-semantic versioning, new updater code for manual downloading of udpates
This commit is contained in:
32
Code/Data/SemVer.cs
Normal file
32
Code/Data/SemVer.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Flowframes.Data
|
||||||
|
{
|
||||||
|
public struct SemVer
|
||||||
|
{
|
||||||
|
public int major;
|
||||||
|
public int minor;
|
||||||
|
public int patch;
|
||||||
|
|
||||||
|
public SemVer(int majorNum, int minorNum, int patchNum)
|
||||||
|
{
|
||||||
|
major = majorNum;
|
||||||
|
minor = minorNum;
|
||||||
|
patch = patchNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SemVer(string versionStr)
|
||||||
|
{
|
||||||
|
string[] nums = versionStr.Trim().Split('.');
|
||||||
|
major = nums[0].GetInt();
|
||||||
|
minor = nums[1].GetInt();
|
||||||
|
patch = nums[2].GetInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString ()
|
||||||
|
{
|
||||||
|
return $"{major}.{minor}.{patch}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -171,6 +171,7 @@
|
|||||||
<Compile Include="Data\BatchEntry.cs" />
|
<Compile Include="Data\BatchEntry.cs" />
|
||||||
<Compile Include="Data\Networks.cs" />
|
<Compile Include="Data\Networks.cs" />
|
||||||
<Compile Include="Data\Padding.cs" />
|
<Compile Include="Data\Padding.cs" />
|
||||||
|
<Compile Include="Data\SemVer.cs" />
|
||||||
<Compile Include="Forms\BatchForm.cs">
|
<Compile Include="Forms\BatchForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace Flowframes
|
|||||||
private void Form1_Load(object sender, EventArgs e)
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CheckForIllegalCrossThreadCalls = false;
|
CheckForIllegalCrossThreadCalls = false;
|
||||||
Text = $"Flowframes v{Program.version}";
|
Text = $"Flowframes {Updater.GetInstalledVer()}";
|
||||||
|
|
||||||
// Main Tab
|
// Main Tab
|
||||||
UIUtils.InitCombox(interpFactorCombox, 0);
|
UIUtils.InitCombox(interpFactorCombox, 0);
|
||||||
@@ -228,7 +228,7 @@ namespace Flowframes
|
|||||||
{
|
{
|
||||||
UpdateOutputFPS();
|
UpdateOutputFPS();
|
||||||
if (Interpolate.interpFactor > 2 && !GetAi().supportsAnyExp && Config.GetInt("autoEncMode") > 0)
|
if (Interpolate.interpFactor > 2 && !GetAi().supportsAnyExp && Config.GetInt("autoEncMode") > 0)
|
||||||
Logger.Log($"Warning: This AI will run multiple times for {Interpolate.interpFactor}x. Auto-Encode will only work on the last run.");
|
Logger.Log($"Warning: {GetAi().aiName.Replace("_", "-")} doesn't natively support 4x/8x and will run multiple times for {Interpolate.interpFactor}x. Auto-Encode will only work on the last run.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetWorking(bool state)
|
public void SetWorking(bool state)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using Flowframes.OS;
|
using Flowframes.Data;
|
||||||
|
using Flowframes.OS;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
@@ -8,8 +10,8 @@ namespace Flowframes.Forms
|
|||||||
{
|
{
|
||||||
public partial class UpdaterForm : Form
|
public partial class UpdaterForm : Form
|
||||||
{
|
{
|
||||||
int installed;
|
SemVer installed;
|
||||||
int latest;
|
SemVer latest;
|
||||||
|
|
||||||
public UpdaterForm()
|
public UpdaterForm()
|
||||||
{
|
{
|
||||||
@@ -32,7 +34,7 @@ namespace Flowframes.Forms
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(installed < latest)
|
if(Updater.IsVersionNewer(installed, latest))
|
||||||
{
|
{
|
||||||
updateBtn.Text = "Update To Latest Version!";
|
updateBtn.Text = "Update To Latest Version!";
|
||||||
statusLabel.Text = "Update Available!";
|
statusLabel.Text = "Update Available!";
|
||||||
@@ -57,12 +59,9 @@ namespace Flowframes.Forms
|
|||||||
|
|
||||||
private async void updateBtn_Click(object sender, EventArgs e)
|
private async void updateBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
await Task.Run(() => DoUpdate());
|
string link = Updater.GetLatestVerLink();
|
||||||
}
|
if(!string.IsNullOrWhiteSpace(link))
|
||||||
|
Process.Start(link);
|
||||||
async void DoUpdate ()
|
|
||||||
{
|
|
||||||
await Updater.UpdateTo(latest, this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ namespace Flowframes.IO
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetVerPath()
|
||||||
|
{
|
||||||
|
return Path.Combine(GetDataPath(), "ver.ini");
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetDataPath ()
|
public static string GetDataPath ()
|
||||||
{
|
{
|
||||||
string path = Path.Combine(IOUtils.GetExeDir(), "FlowframesData");
|
string path = Path.Combine(IOUtils.GetExeDir(), "FlowframesData");
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Flowframes.Forms;
|
using Flowframes.Data;
|
||||||
|
using Flowframes.Forms;
|
||||||
using Flowframes.IO;
|
using Flowframes.IO;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -13,22 +14,76 @@ namespace Flowframes.OS
|
|||||||
{
|
{
|
||||||
class Updater
|
class Updater
|
||||||
{
|
{
|
||||||
public static string latestVerUrl = "https://dl.nmkd.de/flowframes/exe/latest.txt";
|
public static string latestVerUrl = "https://dl.nmkd.de/flowframes/exe/latest.ini";
|
||||||
|
|
||||||
public static int GetInstalledVer()
|
public static SemVer GetInstalledVer()
|
||||||
{
|
{
|
||||||
return Program.version;
|
try
|
||||||
|
{
|
||||||
|
string verStr = IOUtils.ReadLines(Paths.GetVerPath())[0];
|
||||||
|
return new SemVer(verStr);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Log("Error getting installed version: " + e.Message);
|
||||||
|
return new SemVer(0, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetLatestVer ()
|
public static bool IsVersionNewer (SemVer currentVer, SemVer newVer)
|
||||||
|
{
|
||||||
|
if (newVer.major > currentVer.major)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(newVer.minor > currentVer.minor)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (newVer.patch > currentVer.patch)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool VersionMatches (SemVer v1, SemVer v2)
|
||||||
|
{
|
||||||
|
return v1.major == v2.major && v1.minor == v2.minor && v1.patch == v2.patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SemVer GetLatestVer ()
|
||||||
{
|
{
|
||||||
var client = new WebClient();
|
var client = new WebClient();
|
||||||
return client.DownloadString(latestVerUrl).GetInt();
|
return new SemVer(client.DownloadString(latestVerUrl).SplitIntoLines()[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetLatestVerLink()
|
||||||
|
{
|
||||||
|
var client = new WebClient();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return client.DownloadString(latestVerUrl).SplitIntoLines()[1].Trim();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Logger.Log("Failed to get latest version link from latest.ini!", true);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task UpdateTo (int version, UpdaterForm form = null)
|
public static async Task UpdateTo (int version, UpdaterForm form = null)
|
||||||
{
|
{
|
||||||
Logger.Log("Updating to v" + version, true);
|
Logger.Log("Updating to " + version, true);
|
||||||
string savePath = Path.Combine(IOUtils.GetExeDir(), $"FlowframesV{version}");
|
string savePath = Path.Combine(IOUtils.GetExeDir(), $"FlowframesV{version}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -77,15 +132,13 @@ namespace Flowframes.OS
|
|||||||
|
|
||||||
public static async Task AsyncUpdateCheck ()
|
public static async Task AsyncUpdateCheck ()
|
||||||
{
|
{
|
||||||
var client = new WebClient();
|
SemVer latest = GetLatestVer();
|
||||||
var latestVer = await client.DownloadStringTaskAsync(latestVerUrl);
|
SemVer installed = GetInstalledVer();
|
||||||
int latest = latestVer.GetInt();
|
|
||||||
int installed = GetInstalledVer();
|
|
||||||
|
|
||||||
if (installed < latest)
|
if (IsVersionNewer(installed, latest))
|
||||||
Logger.Log("An update for Flowframes is available! Download it using the Updater.");
|
Logger.Log($"An update for Flowframes ({latest}) is available! Download it from the Updater.");
|
||||||
else
|
else
|
||||||
Logger.Log("Flowframes is up to date.");
|
Logger.Log($"Flowframes is up to date ({installed}).");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Flowframes
|
|||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
public const int version = 18;
|
//public const int version = 18;
|
||||||
|
|
||||||
public static Form1 mainForm;
|
public static Form1 mainForm;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user