sofii/SoFii/Program.cs

43 lines
1.7 KiB
C#

using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace SoFii {
public static class Program {
public static readonly Assembly CurrentAssembly = Assembly.GetExecutingAssembly();
public static readonly AssemblyName CurrentAssemblyName = CurrentAssembly.GetName();
[STAThread]
public static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
int version = GetSemVerInt();
int lastVersion = Settings.LastVersion;
if(version < lastVersion) {
DialogResult result = MessageBox.Show("You're opening an older version of SoFii after already having used a newer version.\r\nThis could corrupt your settings. Are you sure you want to continue?", "SoFii :: Old version warning", MessageBoxButtons.YesNo);
if(result != DialogResult.Yes)
return;
Settings.LastVersion = version;
} else if(version > lastVersion)
Settings.LastVersion = version;
if(!File.Exists(Settings.GamePath) && File.Exists(Constants.MP_EXE))
Settings.GamePath = Path.GetFullPath(Constants.MP_EXE);
Application.Run(new MainWindow());
}
public static string GetSemVerString() {
Version version = CurrentAssemblyName.Version;
return $"{version.Major}.{version.Minor}.{version.Build}";
}
public static int GetSemVerInt() {
Version version = CurrentAssemblyName.Version;
return (version.Major << 20) | (version.Minor << 10) | version.Build;
}
}
}