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