mirror of
https://github.com/ncblakely/GiantsTools
synced 2024-11-24 23:25:37 +01:00
Fix version check for launcher.
This commit is contained in:
parent
006612a655
commit
dcf44ec7d0
@ -78,6 +78,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="ApplicationNames.cs" />
|
||||
<Compile Include="Updater\ApplicationType.cs" />
|
||||
<Compile Include="VersionHelper.cs" />
|
||||
<Compile Include="WindowType.cs" />
|
||||
<Compile Include="GameSettings.cs" />
|
||||
<Compile Include="ImageButton.cs">
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
@ -102,26 +103,23 @@ namespace Giants.Launcher
|
||||
|
||||
if ((int)GameSettings.Get("NoAutoUpdate") == 0)
|
||||
{
|
||||
Version gameVersion = null;
|
||||
try
|
||||
{
|
||||
|
||||
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(this.gamePath);
|
||||
gameVersion = new Version(fvi.FileVersion.Replace(',', '.'));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Version gameVersion = VersionHelper.GetGameVersion(this.gamePath);
|
||||
if (gameVersion == null)
|
||||
{
|
||||
string message = string.Format(Resources.AppNotFound, GAME_NAME);
|
||||
MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
|
||||
var appVersions = new Dictionary<ApplicationType, Version>()
|
||||
{
|
||||
[ApplicationType.Game] = gameVersion,
|
||||
[ApplicationType.Launcher] = VersionHelper.GetLauncherVersion()
|
||||
};
|
||||
|
||||
// Check for updates
|
||||
this.updater = new Updater(
|
||||
appVersion: gameVersion,
|
||||
appVersions: appVersions,
|
||||
updateCompletedCallback: this.LauncherForm_DownloadCompletedCallback,
|
||||
updateProgressCallback: this.LauncherForm_DownloadProgressCallback);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
@ -10,16 +11,16 @@ namespace Giants.Launcher
|
||||
{
|
||||
public class Updater
|
||||
{
|
||||
private readonly Version appVersion;
|
||||
private readonly IDictionary<ApplicationType, Version> appVersions;
|
||||
private readonly AsyncCompletedEventHandler updateCompletedCallback;
|
||||
private readonly DownloadProgressChangedEventHandler updateProgressCallback;
|
||||
|
||||
public Updater(
|
||||
Version appVersion,
|
||||
IDictionary<ApplicationType, Version> appVersions,
|
||||
AsyncCompletedEventHandler updateCompletedCallback,
|
||||
DownloadProgressChangedEventHandler updateProgressCallback)
|
||||
{
|
||||
this.appVersion = appVersion;
|
||||
this.appVersions = appVersions;
|
||||
this.updateCompletedCallback = updateCompletedCallback;
|
||||
this.updateProgressCallback = updateProgressCallback;
|
||||
}
|
||||
@ -28,7 +29,7 @@ namespace Giants.Launcher
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.ToVersion(versionInfo.Version) > this.appVersion)
|
||||
if (this.ToVersion(versionInfo.Version) > this.appVersions[applicationType])
|
||||
{
|
||||
this.StartApplicationUpdate(applicationType, versionInfo);
|
||||
}
|
||||
|
27
Giants.Launcher/VersionHelper.cs
Normal file
27
Giants.Launcher/VersionHelper.cs
Normal file
@ -0,0 +1,27 @@
|
||||
namespace Giants.Launcher
|
||||
{
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public static class VersionHelper
|
||||
{
|
||||
public static Version GetGameVersion(string gamePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(gamePath);
|
||||
return new Version(fvi.FileVersion.Replace(',', '.'));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Version GetLauncherVersion()
|
||||
{
|
||||
return new Version(Application.ProductVersion);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user