feat: more assorted modifications
This commit is contained in:
parent
85cad1d1c1
commit
7312842e7d
|
|
@ -0,0 +1,22 @@
|
|||
namespace Kiseki.Launcher.Windows
|
||||
{
|
||||
public static class Directories
|
||||
{
|
||||
public static string LocalAppData => Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
|
||||
public static string Base { get; private set; } = "";
|
||||
public static string Logs { get; private set; } = "";
|
||||
public static string Versions { get; private set; } = "";
|
||||
public static string Application { get; private set; } = "";
|
||||
|
||||
public static void Initialize(string baseDirectory)
|
||||
{
|
||||
Base = baseDirectory;
|
||||
|
||||
Logs = Path.Combine(Base, "Logs");
|
||||
Versions = Path.Combine(Base, "Versions");
|
||||
|
||||
Application = Path.Combine(Base, $"{Launcher.ProjectName}.exe");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,46 @@
|
|||
using System.Reflection;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Kiseki.Launcher.Windows
|
||||
{
|
||||
public class Launcher : ILauncher
|
||||
{
|
||||
public const string ProjectName = "Kiseki";
|
||||
public const string ProjectRepository = "kiseki-lol/launcher";
|
||||
|
||||
public readonly static string BaseUrl = "test.kiseki.lol"; // TODO: This should be set dynamically somehow
|
||||
public readonly static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
||||
|
||||
public void Register()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
using (RegistryKey applicationKey = Registry.CurrentUser.CreateSubKey($@"Software\{ProjectName}"))
|
||||
{
|
||||
applicationKey.SetValue("InstallLocation", Directories.Base);
|
||||
}
|
||||
|
||||
using RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{ProjectName}");
|
||||
|
||||
uninstallKey.SetValue("DisplayIcon", $"{Directories.Application},0");
|
||||
uninstallKey.SetValue("DisplayName", ProjectName);
|
||||
uninstallKey.SetValue("DisplayVersion", Version);
|
||||
|
||||
if (uninstallKey.GetValue("InstallDate") is null)
|
||||
uninstallKey.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd"));
|
||||
|
||||
uninstallKey.SetValue("InstallLocation", Directories.Base);
|
||||
uninstallKey.SetValue("NoRepair", 1);
|
||||
uninstallKey.SetValue("Publisher", ProjectName);
|
||||
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/{ProjectRepository}");
|
||||
uninstallKey.SetValue("URLUpdateInfo", $"https://github.com/{ProjectRepository}/releases/latest");
|
||||
}
|
||||
|
||||
public void Unregister()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CreateShortcuts()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Registry.CurrentUser.DeleteSubKey($@"Software\{ProjectName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ namespace Kiseki.Launcher.Windows
|
|||
|
||||
Page = new TaskDialogPage()
|
||||
{
|
||||
Caption = "Kiseki",
|
||||
Caption = Launcher.ProjectName,
|
||||
AllowMinimize = true,
|
||||
|
||||
ProgressBar = new TaskDialogProgressBar()
|
||||
|
|
@ -26,7 +26,7 @@ namespace Kiseki.Launcher.Windows
|
|||
Buttons = { CloseButton }
|
||||
};
|
||||
|
||||
Controller = new Controller("test.kiseki.lol", args);
|
||||
Controller = new Controller(Launcher.BaseUrl, args);
|
||||
Controller.PageHeadingChanged += Controller_PageHeadingChanged;
|
||||
Controller.ProgressBarChanged += Controller_ProgressBarChanged;
|
||||
Controller.ProgressBarStateChanged += Controller_ProgressBarStateChanged;
|
||||
|
|
@ -84,4 +84,4 @@ namespace Kiseki.Launcher.Windows
|
|||
TaskDialog.ShowDialog(Page);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,14 +2,9 @@ namespace Kiseki.Launcher.Windows
|
|||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new MainWindow(args));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ namespace Kiseki.Launcher.Windows
|
|||
{
|
||||
public class Protocol : IProtocol
|
||||
{
|
||||
public const string ProtocolKey = "kiseki";
|
||||
|
||||
public void Register(string key, string name, string handler)
|
||||
{
|
||||
string arguments = $"\"{handler}\" \"%1\"";
|
||||
|
|
@ -30,17 +32,7 @@ namespace Kiseki.Launcher.Windows
|
|||
|
||||
public void Unregister(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
Registry.CurrentUser.DeleteSubKeyTree(@$"Software\Classes\{key}");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Key doesn't exist (and why are we here?)
|
||||
#if DEBUG
|
||||
throw;
|
||||
#endif
|
||||
}
|
||||
Registry.CurrentUser.DeleteSubKeyTree(@$"Software\Classes\{key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ namespace Kiseki.Launcher
|
|||
{
|
||||
void Register();
|
||||
void Unregister();
|
||||
void CreateShortcuts();
|
||||
}
|
||||
|
||||
interface IProtocol
|
||||
|
|
|
|||
|
|
@ -2,4 +2,6 @@
|
|||
Launches Kiseki game clients from the website
|
||||
|
||||
# License
|
||||
Kiseki.Launcher is licensed under the Licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.txt). A copy of it has been included with Kiseki.Launcher.
|
||||
Kiseki.Launcher is licensed under the Licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.txt). A copy of it has been included with Kiseki.Launcher.
|
||||
|
||||
Some parts of Kiseki.Launcher are loosely adapted from [@pizzaboxer/bloxstrap](https://github.com/pizzaboxer/bloxstrap). Bloxstrap is a project licensed under the [MIT license](https://github.com/pizzaboxer/bloxstrap/blob/main/LICENSE).
|
||||
Loading…
Reference in New Issue