mirror of
https://github.com/ncblakely/GiantsTools
synced 2024-11-22 06:05:38 +01:00
Compare commits
No commits in common. "31625f7466042c8705c392d75fcf3a973eca0e68" and "90296b25853e984707d60c08a955318a3002a4e3" have entirely different histories.
31625f7466
...
90296b2585
@ -3,6 +3,7 @@
|
|||||||
public static class ConfigKeys
|
public static class ConfigKeys
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
|
public const string BranchName = "branchName";
|
||||||
public const string EnableBranchSelection = "enableBranchSelection";
|
public const string EnableBranchSelection = "enableBranchSelection";
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
|
@ -29,7 +29,6 @@ namespace Giants.Launcher
|
|||||||
private string gamePath = null;
|
private string gamePath = null;
|
||||||
private Updater updater;
|
private Updater updater;
|
||||||
private readonly Config config;
|
private readonly Config config;
|
||||||
private Version localGameVersion;
|
|
||||||
private string branchName;
|
private string branchName;
|
||||||
private string communityAppUri;
|
private string communityAppUri;
|
||||||
|
|
||||||
@ -51,6 +50,9 @@ namespace Giants.Launcher
|
|||||||
this.config.Read();
|
this.config.Read();
|
||||||
|
|
||||||
this.config.TryGetString(ConfigSections.Network, ConfigKeys.MasterServerHostName, ConfigDefaults.MasterServerHostNameDefault, out string baseUrl);
|
this.config.TryGetString(ConfigSections.Network, ConfigKeys.MasterServerHostName, ConfigDefaults.MasterServerHostNameDefault, out string baseUrl);
|
||||||
|
this.config.TryGetString(ConfigSections.Update, ConfigKeys.BranchName, defaultValue: ConfigDefaults.BranchNameDefault, out string branchName);
|
||||||
|
|
||||||
|
this.branchName = branchName;
|
||||||
|
|
||||||
this.httpClient = new HttpClient(
|
this.httpClient = new HttpClient(
|
||||||
new HttpClientHandler()
|
new HttpClientHandler()
|
||||||
@ -123,11 +125,14 @@ namespace Giants.Launcher
|
|||||||
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(form.SelectedBranch))
|
this.config.TryGetBool(ConfigSections.Update, ConfigKeys.EnableBranchSelection, defaultValue: false, out bool enableBranchSelection);
|
||||||
|
if (enableBranchSelection)
|
||||||
{
|
{
|
||||||
if (!this.branchName.Equals(form.SelectedBranch))
|
this.config.TryGetString(ConfigSections.Update, ConfigKeys.BranchName, defaultValue: ConfigDefaults.BranchNameDefault, out string branchName);
|
||||||
|
|
||||||
|
if (!this.branchName.Equals(branchName))
|
||||||
{
|
{
|
||||||
this.branchName = form.SelectedBranch;
|
this.branchName = branchName;
|
||||||
|
|
||||||
VersionInfo gameVersionInfo = await this.GetVersionInfo(
|
VersionInfo gameVersionInfo = await this.GetVersionInfo(
|
||||||
GetApplicationName(ApplicationType.Game), this.branchName);
|
GetApplicationName(ApplicationType.Game), this.branchName);
|
||||||
@ -158,18 +163,8 @@ namespace Giants.Launcher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!VersionHelper.TryGetGameVersion(this.gamePath, out Version localGameVersion, out string branch))
|
// Read game settings from registry
|
||||||
{
|
GameSettings.Load(this.gamePath);
|
||||||
string message = string.Format(Resources.AppNotFound, Resources.AppName);
|
|
||||||
MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.localGameVersion = localGameVersion;
|
|
||||||
this.branchName = branch;
|
|
||||||
|
|
||||||
// Read game settings from registry
|
|
||||||
GameSettings.Load(this.gamePath);
|
|
||||||
|
|
||||||
if (GameSettings.Get<int>("NoAutoUpdate") == 0)
|
if (GameSettings.Get<int>("NoAutoUpdate") == 0)
|
||||||
{
|
{
|
||||||
@ -204,6 +199,7 @@ namespace Giants.Launcher
|
|||||||
Task<VersionInfo> launcherVersionInfo = this.GetVersionInfo(
|
Task<VersionInfo> launcherVersionInfo = this.GetVersionInfo(
|
||||||
GetApplicationName(ApplicationType.Launcher), this.branchName);
|
GetApplicationName(ApplicationType.Launcher), this.branchName);
|
||||||
|
|
||||||
|
Version localGameVersion = VersionHelper.GetGameVersion(this.gamePath);
|
||||||
Version localLauncherVersion = VersionHelper.GetLauncherVersion();
|
Version localLauncherVersion = VersionHelper.GetLauncherVersion();
|
||||||
|
|
||||||
await Task.WhenAll(gameVersionInfo, launcherVersionInfo);
|
await Task.WhenAll(gameVersionInfo, launcherVersionInfo);
|
||||||
@ -319,6 +315,12 @@ namespace Giants.Launcher
|
|||||||
|
|
||||||
updaterProcess.Start();
|
updaterProcess.Start();
|
||||||
|
|
||||||
|
this.config.TryGetBool(ConfigSections.Update, ConfigKeys.EnableBranchSelection, defaultValue: false, out bool enableBranchSelection);
|
||||||
|
if (enableBranchSelection)
|
||||||
|
{
|
||||||
|
this.config.SetValue(ConfigSections.Update, ConfigKeys.BranchName, this.branchName);
|
||||||
|
}
|
||||||
|
|
||||||
this.config.Write();
|
this.config.Write();
|
||||||
|
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
|
@ -17,8 +17,6 @@ namespace Giants.Launcher
|
|||||||
private readonly bool enableBranchSelection;
|
private readonly bool enableBranchSelection;
|
||||||
private readonly BranchesClient branchesClient;
|
private readonly BranchesClient branchesClient;
|
||||||
|
|
||||||
public string SelectedBranch { get; set; }
|
|
||||||
|
|
||||||
public OptionsForm(
|
public OptionsForm(
|
||||||
string title,
|
string title,
|
||||||
string gamePath,
|
string gamePath,
|
||||||
@ -286,7 +284,7 @@ namespace Giants.Launcher
|
|||||||
string newBranch = this.cmbBranch.SelectedItem?.ToString();
|
string newBranch = this.cmbBranch.SelectedItem?.ToString();
|
||||||
if (!string.IsNullOrEmpty(newBranch) && !newBranch.Equals(this.currentBranchName, StringComparison.OrdinalIgnoreCase))
|
if (!string.IsNullOrEmpty(newBranch) && !newBranch.Equals(this.currentBranchName, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
this.SelectedBranch = newBranch;
|
this.config.SetValue(ConfigSections.Update, ConfigKeys.BranchName, newBranch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,38 +1,25 @@
|
|||||||
namespace Giants.Launcher
|
namespace Giants.Launcher
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
public static class VersionHelper
|
public static class VersionHelper
|
||||||
{
|
{
|
||||||
public static bool TryGetGameVersion(string gamePath, out Version version, out string branch)
|
public static Version GetGameVersion(string gamePath)
|
||||||
{
|
{
|
||||||
version = default;
|
|
||||||
branch = string.Empty;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(gamePath);
|
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(gamePath);
|
||||||
version = new Version(fvi.FileVersion.Replace(',', '.'));
|
return new Version(fvi.FileVersion.Replace(',', '.'));
|
||||||
|
|
||||||
Dictionary<string, string> commentSettings = GetCommentSettings(fvi.Comments);
|
|
||||||
if (commentSettings.ContainsKey("Branch"))
|
|
||||||
{
|
|
||||||
branch = commentSettings["Branch"];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
branch = "Release";
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
return false;
|
string message = string.Format(Resources.AppNotFound, Resources.AppName);
|
||||||
|
MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
Application.Exit();
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,32 +27,5 @@
|
|||||||
{
|
{
|
||||||
return new Version(Application.ProductVersion);
|
return new Version(Application.ProductVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<string, string> GetCommentSettings(string comments)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> commentSettingsDictionary = new Dictionary<string, string>();
|
|
||||||
string[] commentSettings = comments.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
|
|
||||||
if (!commentSettings.Any())
|
|
||||||
{
|
|
||||||
return commentSettingsDictionary;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var keyValuePair in commentSettings)
|
|
||||||
{
|
|
||||||
string[] commentKeyValuePairs = keyValuePair.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (commentKeyValuePairs.Length != 2)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!commentSettingsDictionary.ContainsKey(commentKeyValuePairs[0]))
|
|
||||||
{
|
|
||||||
commentSettingsDictionary.Add(commentKeyValuePairs[0], commentKeyValuePairs[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return commentSettingsDictionary;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user