more dynamic app variables
This commit is contained in:
parent
1998bdef9b
commit
f672e52ffc
6 changed files with 34 additions and 23 deletions
|
@ -13,7 +13,6 @@
|
|||
<PackageProjectUrl>https://github.com/pointfeev/CreamInstaller</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/pointfeev/CreamInstaller</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<AssemblyName>CreamInstaller</AssemblyName>
|
||||
<Company>CreamInstaller</Company>
|
||||
<Product>Automatic DLC Unlocker Installer & Configuration Generator</Product>
|
||||
<Authors>pointfeev</Authors>
|
||||
|
@ -24,17 +23,19 @@
|
|||
<SignAssembly>False</SignAssembly>
|
||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||
<AnalysisLevel>latest-all</AnalysisLevel>
|
||||
<Title>CreamInstaller</Title>
|
||||
<Description>Automatic DLC Unlocker Installer & Configuration Generator</Description>
|
||||
<Title>$(Company)</Title>
|
||||
<Description>$(Product)</Description>
|
||||
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<AssemblyName>$(Company)</AssemblyName>
|
||||
<DebugType>embedded</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DefineConstants>$(DefineConstants)</DefineConstants>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<AssemblyName>$(Company)-debug</AssemblyName>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
<Optimize>True</Optimize>
|
||||
<DebugType>embedded</DebugType>
|
||||
|
|
|
@ -66,7 +66,7 @@ internal partial class MainForm : CustomForm
|
|||
#if DEBUG
|
||||
DebugForm.Current.Attach(this);
|
||||
#endif
|
||||
GithubPackageResolver resolver = new("pointfeev", "CreamInstaller", "CreamInstaller.zip");
|
||||
GithubPackageResolver resolver = new(Program.RepositoryOwner, Program.RepositoryName, Program.RepositoryPackage);
|
||||
ZipPackageExtractor extractor = new();
|
||||
updateManager = new(AssemblyMetadata.FromAssembly(Program.EntryAssembly, Program.CurrentProcessFilePath), resolver, extractor);
|
||||
if (latestVersion is null)
|
||||
|
@ -114,7 +114,7 @@ internal partial class MainForm : CustomForm
|
|||
updateButton.Enabled = true;
|
||||
updateButton.Click += new(OnUpdate);
|
||||
changelogTreeView.Visible = true;
|
||||
Version currentVersion = new(Application.ProductVersion);
|
||||
Version currentVersion = new(Program.Version);
|
||||
#if DEBUG
|
||||
foreach (Version version in versions.Where(v => (v > currentVersion || v == latestVersion) && !changelogTreeView.Nodes.ContainsKey(v.ToString())))
|
||||
#else
|
||||
|
@ -161,12 +161,12 @@ internal partial class MainForm : CustomForm
|
|||
try
|
||||
{
|
||||
string FileName = Path.GetFileName(Program.CurrentProcessFilePath);
|
||||
if (FileName != "CreamInstaller.exe")
|
||||
if (FileName != Program.ApplicationExecutable)
|
||||
{
|
||||
using DialogForm form = new(this);
|
||||
if (form.Show(SystemIcons.Warning,
|
||||
"WARNING: CreamInstaller.exe was renamed!" +
|
||||
"\n\nThis will cause unwanted behavior when updating the program!",
|
||||
"WARNING: " + Program.ApplicationExecutable + " was renamed!" +
|
||||
"\n\nThis will cause undesirable behavior when updating the program!",
|
||||
"Ignore", "Abort") == DialogResult.Cancel)
|
||||
{
|
||||
Application.Exit();
|
||||
|
|
|
@ -14,12 +14,21 @@ namespace CreamInstaller;
|
|||
|
||||
internal static class Program
|
||||
{
|
||||
internal static readonly string Name = Application.CompanyName;
|
||||
internal static readonly string Description = Application.ProductName;
|
||||
internal static readonly string Version = Application.ProductVersion;
|
||||
|
||||
internal const string RepositoryOwner = "pointfeev";
|
||||
internal static readonly string RepositoryName = Name;
|
||||
internal static readonly string RepositoryPackage = Name + ".zip";
|
||||
#if DEBUG
|
||||
internal static readonly string ApplicationName = Application.CompanyName + " v" + Application.ProductVersion + "-debug: " + Application.ProductName;
|
||||
internal static readonly string ApplicationNameShort = Application.CompanyName + " v" + Application.ProductVersion + "-debug";
|
||||
internal static readonly string ApplicationName = Name + " v" + Version + "-debug: " + Description;
|
||||
internal static readonly string ApplicationNameShort = Name + " v" + Version + "-debug";
|
||||
internal static readonly string ApplicationExecutable = Name + "-debug.exe"; // should be the same as in .csproj
|
||||
#else
|
||||
internal static readonly string ApplicationName = Application.CompanyName + " v" + Application.ProductVersion + ": " + Application.ProductName;
|
||||
internal static readonly string ApplicationNameShort = Application.CompanyName + " v" + Application.ProductVersion;
|
||||
internal static readonly string ApplicationName = Name + " v" + Version + ": " + Description;
|
||||
internal static readonly string ApplicationNameShort = Name + " v" + Version;
|
||||
internal static readonly string ApplicationExecutable = Name + ".exe"; // should be the same as in .csproj
|
||||
#endif
|
||||
|
||||
internal static readonly Assembly EntryAssembly = Assembly.GetEntryAssembly();
|
||||
|
@ -59,7 +68,7 @@ internal static class Program
|
|||
[STAThread]
|
||||
private static void Main()
|
||||
{
|
||||
using Mutex mutex = new(true, "CreamInstaller", out bool createdNew);
|
||||
using Mutex mutex = new(true, Name, out bool createdNew);
|
||||
if (createdNew)
|
||||
{
|
||||
_ = Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
|
|
|
@ -7,8 +7,9 @@ namespace CreamInstaller.Utility;
|
|||
|
||||
internal static class ExceptionHandler
|
||||
{
|
||||
internal static bool HandleException(this Exception e, Form form = null, string caption = "CreamInstaller encountered an exception", string acceptButtonText = "Retry", string cancelButtonText = "Cancel")
|
||||
internal static bool HandleException(this Exception e, Form form = null, string caption = null, string acceptButtonText = "Retry", string cancelButtonText = "Cancel")
|
||||
{
|
||||
caption ??= Program.Name + " encountered a fatal exception";
|
||||
while (e.InnerException is not null) // we usually don't need the outer exceptions
|
||||
e = e.InnerException;
|
||||
StringBuilder output = new();
|
||||
|
@ -53,7 +54,7 @@ internal static class ExceptionHandler
|
|||
|
||||
internal static void HandleFatalException(this Exception e)
|
||||
{
|
||||
bool? restart = e?.HandleException(caption: "CreamInstaller encountered a fatal exception", acceptButtonText: "Restart");
|
||||
bool? restart = e?.HandleException(acceptButtonText: "Restart");
|
||||
if (restart.HasValue && restart.Value)
|
||||
Application.Restart();
|
||||
Application.Exit();
|
||||
|
|
|
@ -14,7 +14,7 @@ internal static class HttpClientManager
|
|||
internal static void Setup()
|
||||
{
|
||||
HttpClient = new();
|
||||
HttpClient.DefaultRequestHeaders.Add("User-Agent", $"CI{Application.ProductVersion.Replace(".", "")}");
|
||||
HttpClient.DefaultRequestHeaders.Add("User-Agent", $"CI{Program.Version.Replace(".", "")}");
|
||||
}
|
||||
|
||||
internal static async Task<string> EnsureGet(string url)
|
||||
|
|
|
@ -41,7 +41,7 @@ internal static class ProgramData
|
|||
{
|
||||
if (Directory.Exists(AppInfoPath)) Directory.Delete(AppInfoPath, true);
|
||||
_ = Directory.CreateDirectory(AppInfoPath);
|
||||
File.WriteAllText(AppInfoVersionPath, Application.ProductVersion, Encoding.UTF8);
|
||||
File.WriteAllText(AppInfoVersionPath, Program.Version, Encoding.UTF8);
|
||||
}
|
||||
if (!Directory.Exists(CooldownPath))
|
||||
_ = Directory.CreateDirectory(CooldownPath);
|
||||
|
|
Loading…
Reference in a new issue