nit: clean up constants
This commit is contained in:
parent
23a362d40e
commit
a36eac87fc
|
|
@ -18,7 +18,7 @@ namespace Kiseki.Launcher.Windows
|
|||
Versions = Path.Combine(Base, "Versions");
|
||||
|
||||
License = Path.Combine(Base, "license.bin");
|
||||
Application = Path.Combine(Base, $"{Constants.ProjectName}.Launcher.exe");
|
||||
Application = Path.Combine(Base, $"{Constants.PROJECT_NAME}.Launcher.exe");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ namespace Kiseki.Launcher.Windows
|
|||
if (response != Web.RESPONSE_MAINTENANCE)
|
||||
{
|
||||
// The Kiseki website is either down or we can't connect to the internet.
|
||||
MessageBox.Show($"Failed to connect to the {Constants.ProjectName} website. Please check your internet connection.", Constants.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show($"Failed to connect to the {Constants.PROJECT_NAME} website. Please check your internet connection.", Constants.PROJECT_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
else
|
||||
|
|
@ -36,7 +36,7 @@ namespace Kiseki.Launcher.Windows
|
|||
{
|
||||
// ... and if it's invalid, keep asking for a new one.
|
||||
File.Delete(Directories.License);
|
||||
MessageBox.Show($"Corrupt license file! Please verify the contents of your license file (it should be named \"license.bin\".)", Constants.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show($"Corrupt license file! Please verify the contents of your license file (it should be named \"license.bin\".)", Constants.PROJECT_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
AskForLicense(Directories.License, false);
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ namespace Kiseki.Launcher.Windows
|
|||
|
||||
private static void AskForLicense(string licensePath, bool showDialog = true)
|
||||
{
|
||||
DialogResult answer = showDialog ? MessageBox.Show($"{Constants.ProjectName} is currently under maintenance and requires a license in order to access games. Would you like to look for the license file now?", Constants.ProjectName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) : DialogResult.Yes;
|
||||
DialogResult answer = showDialog ? MessageBox.Show($"{Constants.PROJECT_NAME} is currently under maintenance and requires a license in order to access games. Would you like to look for the license file now?", Constants.PROJECT_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) : DialogResult.Yes;
|
||||
|
||||
if (answer == DialogResult.Yes)
|
||||
{
|
||||
|
|
@ -71,15 +71,15 @@ namespace Kiseki.Launcher.Windows
|
|||
// TODO: Implement this
|
||||
public static void Register()
|
||||
{
|
||||
using (RegistryKey applicationKey = Registry.CurrentUser.CreateSubKey($@"Software\{Constants.ProjectName}"))
|
||||
using (RegistryKey applicationKey = Registry.CurrentUser.CreateSubKey($@"Software\{Constants.PROJECT_NAME}"))
|
||||
{
|
||||
applicationKey.SetValue("InstallLocation", Directories.Base);
|
||||
}
|
||||
|
||||
using RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{Constants.ProjectName}");
|
||||
using RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{Constants.PROJECT_NAME}");
|
||||
|
||||
uninstallKey.SetValue("DisplayIcon", $"{Directories.Application},0");
|
||||
uninstallKey.SetValue("DisplayName", Constants.ProjectName);
|
||||
uninstallKey.SetValue("DisplayName", Constants.PROJECT_NAME);
|
||||
uninstallKey.SetValue("DisplayVersion", Version);
|
||||
|
||||
if (uninstallKey.GetValue("InstallDate") is null)
|
||||
|
|
@ -87,18 +87,18 @@ namespace Kiseki.Launcher.Windows
|
|||
|
||||
uninstallKey.SetValue("InstallLocation", Directories.Base);
|
||||
uninstallKey.SetValue("NoRepair", 1);
|
||||
uninstallKey.SetValue("Publisher", Constants.ProjectName);
|
||||
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.ProjectRepository}");
|
||||
uninstallKey.SetValue("URLUpdateInfo", $"https://github.com/{Constants.ProjectRepository}/releases/latest");
|
||||
uninstallKey.SetValue("URLInfoAbout", $"https://github.com/{Constants.PROJECT_REPOSITORY}");
|
||||
uninstallKey.SetValue("URLUpdateInfo", $"https://github.com/{Constants.PROJECT_REPOSITORY}/releases/latest");
|
||||
}
|
||||
|
||||
// TODO: Implement this
|
||||
public static void Unregister()
|
||||
{
|
||||
Registry.CurrentUser.DeleteSubKey($@"Software\{Constants.ProjectName}");
|
||||
Registry.CurrentUser.DeleteSubKey($@"Software\{Constants.PROJECT_NAME}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ namespace Kiseki.Launcher.Windows
|
|||
CloseButton = TaskDialogButton.Close;
|
||||
Page = new TaskDialogPage()
|
||||
{
|
||||
Caption = Constants.ProjectName,
|
||||
Caption = Constants.PROJECT_NAME,
|
||||
AllowMinimize = true,
|
||||
|
||||
ProgressBar = new TaskDialogProgressBar()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Kiseki.Launcher.Windows
|
|||
static void Main(string[] args)
|
||||
{
|
||||
string parentFolder = Path.GetDirectoryName(AppContext.BaseDirectory)!;
|
||||
if (parentFolder.ToLower().Contains(Constants.ProjectName))
|
||||
if (parentFolder.ToLower().Contains(Constants.PROJECT_NAME))
|
||||
{
|
||||
// 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);
|
||||
|
|
@ -16,7 +16,7 @@ namespace Kiseki.Launcher.Windows
|
|||
else
|
||||
{
|
||||
// Set to the default directory (user likely hasn't installed the launcher yet)
|
||||
Directories.Initialize(Path.Combine(Directories.LocalAppData, Constants.ProjectName));
|
||||
Directories.Initialize(Path.Combine(Directories.LocalAppData, Constants.PROJECT_NAME));
|
||||
}
|
||||
|
||||
Web.Initialize();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace Kiseki.Launcher.Windows
|
|||
{
|
||||
public class Protocol : IProtocol
|
||||
{
|
||||
public const string ProtocolKey = "kiseki";
|
||||
public const string PROTOCOL_KEY = "kiseki";
|
||||
|
||||
public void Register(string key, string name, string handler)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ namespace Kiseki.Launcher
|
|||
{
|
||||
public static class Constants
|
||||
{
|
||||
public const string ProjectName = "Kiseki";
|
||||
public const string ProjectRepository = "kiseki-lol/launcher";
|
||||
public const string PROJECT_NAME = "Kiseki";
|
||||
public const string PROJECT_REPOSITORY = "kiseki-lol/launcher";
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ namespace Kiseki.Launcher
|
|||
{
|
||||
if (!Base64.IsBase64String(payload))
|
||||
{
|
||||
ErrorShow($"Failed to launch {Constants.ProjectName}", $"Try launching {Constants.ProjectName} from the website again.");
|
||||
ErrorShow($"Failed to launch {Constants.PROJECT_NAME}", $"Try launching {Constants.PROJECT_NAME} from the website again.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ namespace Kiseki.Launcher
|
|||
payload = Base64.ConvertBase64ToString(payload);
|
||||
if (payload.Split("|").Length != 2)
|
||||
{
|
||||
ErrorShow($"Failed to launch {Constants.ProjectName}", $"Try launching {Constants.ProjectName} from the website again.");
|
||||
ErrorShow($"Failed to launch {Constants.PROJECT_NAME}", $"Try launching {Constants.PROJECT_NAME} from the website again.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,22 +5,20 @@ namespace Kiseki.Launcher
|
|||
{
|
||||
public static class Web
|
||||
{
|
||||
public const int RESPONSE_SUCCESS = 0;
|
||||
public const int RESPONSE_FAILURE = -1;
|
||||
|
||||
public const int RESPONSE_SUCCESS = 0;
|
||||
public const int RESPONSE_MAINTENANCE = 1;
|
||||
|
||||
public const string BaseUrl = "kiseki.lol";
|
||||
public const string MaintenanceDomain = "test";
|
||||
public const string BASE_URL = "kiseki.lol";
|
||||
public const string MAINTENANCE_DOMAIN = "test";
|
||||
|
||||
public static readonly HttpClient HttpClient = new();
|
||||
public static string CurrentUrl { get; private set; } = "";
|
||||
public static bool MaintenanceMode { get; private set; } = false;
|
||||
|
||||
public static void Initialize() => CurrentUrl = BaseUrl;
|
||||
public static void Initialize() => CurrentUrl = BASE_URL;
|
||||
public static string Url(string path) => $"https://{CurrentUrl}{path}";
|
||||
|
||||
private static bool MaintenanceMode = false;
|
||||
|
||||
public static int CheckHealth()
|
||||
{
|
||||
var response = Helpers.Http.GetJson<Models.HealthCheck>(Url("/api/health"));
|
||||
|
|
@ -32,7 +30,7 @@ namespace Kiseki.Launcher
|
|||
{
|
||||
if (!MaintenanceMode)
|
||||
{
|
||||
CurrentUrl = $"{MaintenanceDomain}.{CurrentUrl}";
|
||||
CurrentUrl = $"{MAINTENANCE_DOMAIN}.{CurrentUrl}";
|
||||
MaintenanceMode = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue