feat/fix: installation and numerous fixes
This commit is contained in:
parent
4f4f1b9cb5
commit
d93db964d9
|
|
@ -14,6 +14,12 @@ namespace Kiseki.Launcher.Windows
|
|||
{
|
||||
Base = baseDirectory;
|
||||
|
||||
if (!Directory.Exists(Base))
|
||||
{
|
||||
// just in case
|
||||
Directory.CreateDirectory(Base);
|
||||
}
|
||||
|
||||
Logs = Path.Combine(Base, "Logs");
|
||||
Versions = Path.Combine(Base, "Versions");
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,22 @@ namespace Kiseki.Launcher.Windows
|
|||
|
||||
public static void Install()
|
||||
{
|
||||
// Cleanup our registry entries beforehand (if they exist)
|
||||
Protocol.Unregister();
|
||||
Register();
|
||||
|
||||
Directory.CreateDirectory(Directories.Base);
|
||||
Directory.CreateDirectory(Directories.Versions);
|
||||
Directory.CreateDirectory(Directories.Logs);
|
||||
|
||||
File.Copy(Application.ExecutablePath, Directories.Application, true);
|
||||
|
||||
Register();
|
||||
Protocol.Register();
|
||||
|
||||
MessageBox.Show($"Sucessfully installed {Constants.PROJECT_NAME}!", Constants.PROJECT_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
Environment.Exit((int)Win32.ErrorCode.ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
public static void Uninstall(bool quiet = false)
|
||||
|
|
@ -46,9 +61,14 @@ namespace Kiseki.Launcher.Windows
|
|||
}
|
||||
|
||||
// Delete all files
|
||||
Directory.Delete(Directories.Logs, true);
|
||||
Directory.Delete(Directories.Versions, true);
|
||||
Directory.Delete(Directories.License);
|
||||
if (Directory.Exists(Directories.Logs))
|
||||
Directory.Delete(Directories.Logs, true);
|
||||
|
||||
if (Directory.Exists(Directories.Versions))
|
||||
Directory.Delete(Directories.Versions, true);
|
||||
|
||||
if (File.Exists(Directories.License))
|
||||
File.Delete(Directories.License);
|
||||
|
||||
// Cleanup our registry entries
|
||||
Unregister();
|
||||
|
|
@ -78,9 +98,12 @@ namespace Kiseki.Launcher.Windows
|
|||
}
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
{
|
||||
using RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{Constants.PROJECT_NAME}");
|
||||
|
||||
uninstallKey.SetValue("NoModify", 1);
|
||||
uninstallKey.SetValue("NoRepair", 1);
|
||||
|
||||
uninstallKey.SetValue("DisplayIcon", $"{Directories.Application},0");
|
||||
uninstallKey.SetValue("DisplayName", Constants.PROJECT_NAME);
|
||||
uninstallKey.SetValue("DisplayVersion", Version);
|
||||
|
|
@ -89,9 +112,7 @@ namespace Kiseki.Launcher.Windows
|
|||
uninstallKey.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd"));
|
||||
|
||||
uninstallKey.SetValue("InstallLocation", Directories.Base);
|
||||
uninstallKey.SetValue("NoRepair", 1);
|
||||
uninstallKey.SetValue("Publisher", Constants.PROJECT_NAME);
|
||||
uninstallKey.SetValue("ModifyPath", $"\"{Directories.Application}\" -menu");
|
||||
uninstallKey.SetValue("QuietUninstallString", $"\"{Directories.Application}\" -uninstall -quiet");
|
||||
uninstallKey.SetValue("UninstallString", $"\"{Directories.Application}\" -uninstall");
|
||||
uninstallKey.SetValue("URLInfoAbout", $"https://github.com/{Constants.PROJECT_REPOSITORY}");
|
||||
|
|
@ -151,7 +172,6 @@ namespace Kiseki.Launcher.Windows
|
|||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Directory.CreateDirectory(Directories.Base); // failsafe
|
||||
File.Copy(dialog.FileName, licensePath, true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@ namespace Kiseki.Launcher.Windows
|
|||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string parentFolder = Path.GetDirectoryName(AppContext.BaseDirectory)!;
|
||||
if (parentFolder.ToLower().Contains(Constants.PROJECT_NAME))
|
||||
string parentFolder = Path.GetDirectoryName(Application.ExecutablePath)!;
|
||||
|
||||
if (Path.GetDirectoryName(parentFolder)!.ToLower().Contains(Constants.PROJECT_NAME.ToLower()))
|
||||
{
|
||||
// Set to the current directory (either user-installed or default; it has "Kiseki" in the path, so that's good enough for us)
|
||||
Directories.Initialize(AppContext.BaseDirectory);
|
||||
Directories.Initialize(parentFolder);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -43,11 +44,11 @@ namespace Kiseki.Launcher.Windows
|
|||
if (args.Length == 0)
|
||||
{
|
||||
// Nothing for us to do :P
|
||||
Process.Start(Web.Url("/games"));
|
||||
Process.Start($"open {Web.Url("/games")}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0] == "uninstall")
|
||||
if (args[0] == "-uninstall")
|
||||
{
|
||||
Launcher.Uninstall(args[0] == "-quiet");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@ namespace Kiseki.Launcher.Windows
|
|||
{
|
||||
public class Protocol : IProtocol
|
||||
{
|
||||
public const string PROTOCOL_KEY = "kiseki";
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
string arguments = $"\"{Directories.Application}\" \"%1\"";
|
||||
|
||||
RegistryKey uriKey = Registry.CurrentUser.CreateSubKey(@$"Software\Classes\{PROTOCOL_KEY}");
|
||||
RegistryKey uriKey = Registry.CurrentUser.CreateSubKey(@$"Software\Classes\{Constants.PROTOCOL_KEY}");
|
||||
RegistryKey uriIconKey = uriKey.CreateSubKey("DefaultIcon");
|
||||
RegistryKey uriCommandKey = uriKey.CreateSubKey(@"shell\open\command");
|
||||
|
||||
|
|
@ -32,7 +30,16 @@ namespace Kiseki.Launcher.Windows
|
|||
|
||||
public static void Unregister()
|
||||
{
|
||||
Registry.CurrentUser.DeleteSubKeyTree(@$"Software\Classes\{PROTOCOL_KEY}");
|
||||
try
|
||||
{
|
||||
Registry.CurrentUser.DeleteSubKeyTree(@$"Software\Classes\{Constants.PROTOCOL_KEY}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
#if DEBUG
|
||||
throw;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,5 +4,10 @@ namespace Kiseki.Launcher
|
|||
{
|
||||
public const string PROJECT_NAME = "Kiseki";
|
||||
public const string PROJECT_REPOSITORY = "kiseki-lol/launcher";
|
||||
|
||||
public const string BASE_URL = "kiseki.lol";
|
||||
public const string MAINTENANCE_DOMAIN = "test";
|
||||
|
||||
public const string PROTOCOL_KEY = "kiseki";
|
||||
}
|
||||
}
|
||||
|
|
@ -9,9 +9,6 @@ namespace Kiseki.Launcher
|
|||
public const int RESPONSE_SUCCESS = 0;
|
||||
public const int RESPONSE_MAINTENANCE = 1;
|
||||
|
||||
public const string BASE_URL = "kiseki.lol";
|
||||
public const string MAINTENANCE_DOMAIN = "test";
|
||||
|
||||
public static string CurrentUrl { get; private set; } = "";
|
||||
public static bool IsInMaintenance { get; private set; } = false;
|
||||
|
||||
|
|
@ -19,7 +16,7 @@ namespace Kiseki.Launcher
|
|||
|
||||
public static bool Initialize()
|
||||
{
|
||||
CurrentUrl = IsInMaintenance ? $"{MAINTENANCE_DOMAIN}.{BASE_URL}" : BASE_URL;
|
||||
CurrentUrl = IsInMaintenance ? $"{Constants.MAINTENANCE_DOMAIN}.{Constants.BASE_URL}" : Constants.BASE_URL;
|
||||
|
||||
Task<int> task = CheckHealth();
|
||||
task.Wait();
|
||||
|
|
|
|||
Loading…
Reference in New Issue