feat: more assorted modifications

This commit is contained in:
rjindael 2023-07-29 15:00:08 -07:00
parent 85cad1d1c1
commit 7312842e7d
No known key found for this signature in database
GPG Key ID: D069369C906CCF31
7 changed files with 64 additions and 28 deletions

View File

@ -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");
}
}
}

View File

@ -1,20 +1,46 @@
using System.Reflection;
using Microsoft.Win32;
namespace Kiseki.Launcher.Windows namespace Kiseki.Launcher.Windows
{ {
public class Launcher : ILauncher 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() 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() public void Unregister()
{ {
throw new NotImplementedException(); Registry.CurrentUser.DeleteSubKey($@"Software\{ProjectName}");
}
public void CreateShortcuts()
{
throw new NotImplementedException();
} }
} }
} }

View File

@ -15,7 +15,7 @@ namespace Kiseki.Launcher.Windows
Page = new TaskDialogPage() Page = new TaskDialogPage()
{ {
Caption = "Kiseki", Caption = Launcher.ProjectName,
AllowMinimize = true, AllowMinimize = true,
ProgressBar = new TaskDialogProgressBar() ProgressBar = new TaskDialogProgressBar()
@ -26,7 +26,7 @@ namespace Kiseki.Launcher.Windows
Buttons = { CloseButton } Buttons = { CloseButton }
}; };
Controller = new Controller("test.kiseki.lol", args); Controller = new Controller(Launcher.BaseUrl, args);
Controller.PageHeadingChanged += Controller_PageHeadingChanged; Controller.PageHeadingChanged += Controller_PageHeadingChanged;
Controller.ProgressBarChanged += Controller_ProgressBarChanged; Controller.ProgressBarChanged += Controller_ProgressBarChanged;
Controller.ProgressBarStateChanged += Controller_ProgressBarStateChanged; Controller.ProgressBarStateChanged += Controller_ProgressBarStateChanged;
@ -84,4 +84,4 @@ namespace Kiseki.Launcher.Windows
TaskDialog.ShowDialog(Page); TaskDialog.ShowDialog(Page);
} }
} }
} }

View File

@ -2,14 +2,9 @@ namespace Kiseki.Launcher.Windows
{ {
internal static class Program internal static class Program
{ {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread] [STAThread]
static void Main(string[] args) 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(); ApplicationConfiguration.Initialize();
Application.Run(new MainWindow(args)); Application.Run(new MainWindow(args));
} }

View File

@ -4,6 +4,8 @@ namespace Kiseki.Launcher.Windows
{ {
public class Protocol : IProtocol public class Protocol : IProtocol
{ {
public const string ProtocolKey = "kiseki";
public void Register(string key, string name, string handler) public void Register(string key, string name, string handler)
{ {
string arguments = $"\"{handler}\" \"%1\""; string arguments = $"\"{handler}\" \"%1\"";
@ -30,17 +32,7 @@ namespace Kiseki.Launcher.Windows
public void Unregister(string key) public void Unregister(string key)
{ {
try Registry.CurrentUser.DeleteSubKeyTree(@$"Software\Classes\{key}");
{
Registry.CurrentUser.DeleteSubKeyTree(@$"Software\Classes\{key}");
}
catch (Exception)
{
// Key doesn't exist (and why are we here?)
#if DEBUG
throw;
#endif
}
} }
} }
} }

View File

@ -4,7 +4,6 @@ namespace Kiseki.Launcher
{ {
void Register(); void Register();
void Unregister(); void Unregister();
void CreateShortcuts();
} }
interface IProtocol interface IProtocol

View File

@ -2,4 +2,6 @@
Launches Kiseki game clients from the website Launches Kiseki game clients from the website
# License # 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).