1
0
mirror of https://github.com/ncblakely/GiantsTools synced 2024-11-21 13:45:37 +01:00

Disable play button while updating.

This commit is contained in:
Nick Blakely 2020-10-17 23:44:41 -07:00
parent eb04aed5ca
commit e18ebaf0bf
3 changed files with 114 additions and 16 deletions

View File

@ -178,8 +178,17 @@ namespace Giants.Launcher
await Task.WhenAll(gameVersionInfo, launcherVersionInfo);
await this.updater.UpdateApplication(ApplicationType.Game, gameVersionInfo.Result);
await this.updater.UpdateApplication(ApplicationType.Launcher, launcherVersionInfo.Result);
if (this.updater.IsUpdateRequired(ApplicationType.Game, gameVersionInfo.Result))
{
this.btnPlay.Enabled = false;
await this.updater.UpdateApplication(ApplicationType.Game, gameVersionInfo.Result);
}
if (this.updater.IsUpdateRequired(ApplicationType.Launcher, launcherVersionInfo.Result))
{
this.btnPlay.Enabled = false;
await this.updater.UpdateApplication(ApplicationType.Launcher, launcherVersionInfo.Result);
}
}
private async Task<VersionInfo> GetVersionInfo(string appName)
@ -229,6 +238,8 @@ namespace Giants.Launcher
private void LauncherForm_DownloadCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
this.btnPlay.Enabled = true;
if (e.Cancelled)
{
return;

View File

@ -25,14 +25,29 @@ namespace Giants.Launcher
this.updateProgressCallback = updateProgressCallback;
}
public bool IsUpdateRequired(ApplicationType applicationType, VersionInfo versionInfo)
{
if (this.ToVersion(versionInfo.Version) > this.appVersions[applicationType])
{
// Display update prompt
string updateMsg = applicationType == ApplicationType.Game ?
string.Format(Resources.UpdateAvailableText, this.ToVersion(versionInfo.Version).ToString()) :
string.Format(Resources.LauncherUpdateAvailableText, this.ToVersion(versionInfo.Version).ToString());
if (MessageBox.Show(updateMsg, Resources.UpdateAvailableTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
return true;
}
}
return false;
}
public Task UpdateApplication(ApplicationType applicationType, VersionInfo versionInfo)
{
try
{
if (this.ToVersion(versionInfo.Version) > this.appVersions[applicationType])
{
this.StartApplicationUpdate(applicationType, versionInfo);
}
this.StartApplicationUpdate(applicationType, versionInfo);
}
catch (Exception e)
{
@ -63,16 +78,6 @@ namespace Giants.Launcher
private void StartApplicationUpdate(ApplicationType applicationType, VersionInfo versionInfo)
{
// Display update prompt
string updateMsg = applicationType == ApplicationType.Game ?
string.Format(Resources.UpdateAvailableText, this.ToVersion(versionInfo.Version).ToString()) :
string.Format(Resources.LauncherUpdateAvailableText, this.ToVersion(versionInfo.Version).ToString());
if (MessageBox.Show(updateMsg, Resources.UpdateAvailableTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
{
return; // User declined update
}
string patchFileName = Path.GetFileName(versionInfo.InstallerUri.AbsoluteUri);
string localPath = Path.Combine(Path.GetTempPath(), patchFileName);

View File

@ -21,11 +21,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Giants.EffectCompiler", "Gi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Giants.EffectCompiler.Tests", "Giants.EffectCompiler.Tests\Giants.EffectCompiler.Tests.csproj", "{49423BA5-4A9F-47A3-9D2D-E83936272DD0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{08011335-C6A1-417B-ACBF-09F8F0D0EA09}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imp_gbs", "Plugins\imp_gbs\imp_gbs.vcxproj", "{448F061E-AE05-4E06-84A1-C95660FD048C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Hybrid|Any CPU = Hybrid|Any CPU
Hybrid|x64 = Hybrid|x64
Hybrid|x86 = Hybrid|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
@ -37,6 +44,12 @@ Global
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Debug|x64.Build.0 = Debug|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Debug|x86.ActiveCfg = Debug|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Debug|x86.Build.0 = Debug|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Hybrid|Any CPU.ActiveCfg = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Hybrid|Any CPU.Build.0 = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Hybrid|x64.ActiveCfg = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Hybrid|x64.Build.0 = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Hybrid|x86.ActiveCfg = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Hybrid|x86.Build.0 = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Release|Any CPU.Build.0 = Release|Any CPU
{0CD61424-4E74-4A48-A726-729FEA32C50C}.Release|x64.ActiveCfg = Release|Any CPU
@ -49,6 +62,12 @@ Global
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Debug|x64.Build.0 = Debug|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Debug|x86.ActiveCfg = Debug|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Debug|x86.Build.0 = Debug|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Hybrid|Any CPU.ActiveCfg = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Hybrid|Any CPU.Build.0 = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Hybrid|x64.ActiveCfg = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Hybrid|x64.Build.0 = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Hybrid|x86.ActiveCfg = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Hybrid|x86.Build.0 = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Release|Any CPU.Build.0 = Release|Any CPU
{D426FE47-231B-41F0-AC78-293D12EF66A0}.Release|x64.ActiveCfg = Release|Any CPU
@ -61,6 +80,12 @@ Global
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Debug|x64.Build.0 = Debug|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Debug|x86.ActiveCfg = Debug|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Debug|x86.Build.0 = Debug|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Hybrid|Any CPU.ActiveCfg = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Hybrid|Any CPU.Build.0 = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Hybrid|x64.ActiveCfg = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Hybrid|x64.Build.0 = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Hybrid|x86.ActiveCfg = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Hybrid|x86.Build.0 = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Release|Any CPU.Build.0 = Release|Any CPU
{9A284C34-8F4B-4E20-B74B-1A0AF04EDBD1}.Release|x64.ActiveCfg = Release|Any CPU
@ -73,6 +98,12 @@ Global
{612FD606-F072-4A04-9054-65BC592E9D3E}.Debug|x64.Build.0 = Debug|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Debug|x86.ActiveCfg = Debug|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Debug|x86.Build.0 = Debug|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Hybrid|Any CPU.ActiveCfg = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Hybrid|Any CPU.Build.0 = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Hybrid|x64.ActiveCfg = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Hybrid|x64.Build.0 = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Hybrid|x86.ActiveCfg = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Hybrid|x86.Build.0 = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Release|Any CPU.Build.0 = Release|Any CPU
{612FD606-F072-4A04-9054-65BC592E9D3E}.Release|x64.ActiveCfg = Release|Any CPU
@ -85,6 +116,12 @@ Global
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Debug|x64.Build.0 = Debug|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Debug|x86.ActiveCfg = Debug|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Debug|x86.Build.0 = Debug|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Hybrid|Any CPU.ActiveCfg = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Hybrid|Any CPU.Build.0 = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Hybrid|x64.ActiveCfg = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Hybrid|x64.Build.0 = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Hybrid|x86.ActiveCfg = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Hybrid|x86.Build.0 = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Release|Any CPU.Build.0 = Release|Any CPU
{D4C21170-82D4-4D1F-81EC-036835AC1238}.Release|x64.ActiveCfg = Release|Any CPU
@ -97,6 +134,12 @@ Global
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x64.Build.0 = Debug|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x86.ActiveCfg = Debug|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Debug|x86.Build.0 = Debug|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Hybrid|Any CPU.ActiveCfg = Release|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Hybrid|Any CPU.Build.0 = Release|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Hybrid|x64.ActiveCfg = Release|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Hybrid|x64.Build.0 = Release|x64
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Hybrid|x86.ActiveCfg = Release|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Hybrid|x86.Build.0 = Release|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|Any CPU.ActiveCfg = Release|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|Any CPU.Build.0 = Release|Win32
{9A0AF60B-3C3B-45B7-B5E1-4C9997A68EBB}.Release|x64.ActiveCfg = Release|x64
@ -109,6 +152,12 @@ Global
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Debug|x64.Build.0 = Debug|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Debug|x86.ActiveCfg = Debug|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Debug|x86.Build.0 = Debug|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Hybrid|Any CPU.ActiveCfg = Release|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Hybrid|Any CPU.Build.0 = Release|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Hybrid|x64.ActiveCfg = Release|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Hybrid|x64.Build.0 = Release|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Hybrid|x86.ActiveCfg = Release|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Hybrid|x86.Build.0 = Release|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Release|Any CPU.Build.0 = Release|Any CPU
{6286A2C7-15F0-4D87-B928-4B012F9E0FFE}.Release|x64.ActiveCfg = Release|Any CPU
@ -121,6 +170,12 @@ Global
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Debug|x64.Build.0 = Debug|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Debug|x86.ActiveCfg = Debug|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Debug|x86.Build.0 = Debug|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Hybrid|Any CPU.ActiveCfg = Release|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Hybrid|Any CPU.Build.0 = Release|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Hybrid|x64.ActiveCfg = Release|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Hybrid|x64.Build.0 = Release|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Hybrid|x86.ActiveCfg = Release|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Hybrid|x86.Build.0 = Release|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Release|Any CPU.Build.0 = Release|Any CPU
{F5F3D216-9787-4CFF-88DF-8259CF667F88}.Release|x64.ActiveCfg = Release|Any CPU
@ -133,16 +188,43 @@ Global
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Debug|x64.Build.0 = Debug|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Debug|x86.ActiveCfg = Debug|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Debug|x86.Build.0 = Debug|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Hybrid|Any CPU.ActiveCfg = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Hybrid|Any CPU.Build.0 = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Hybrid|x64.ActiveCfg = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Hybrid|x64.Build.0 = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Hybrid|x86.ActiveCfg = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Hybrid|x86.Build.0 = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Release|Any CPU.Build.0 = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Release|x64.ActiveCfg = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Release|x64.Build.0 = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Release|x86.ActiveCfg = Release|Any CPU
{49423BA5-4A9F-47A3-9D2D-E83936272DD0}.Release|x86.Build.0 = Release|Any CPU
{448F061E-AE05-4E06-84A1-C95660FD048C}.Debug|Any CPU.ActiveCfg = Debug|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Debug|Any CPU.Build.0 = Debug|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Debug|x64.ActiveCfg = Debug|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Debug|x64.Build.0 = Debug|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Debug|x86.ActiveCfg = Debug|Win32
{448F061E-AE05-4E06-84A1-C95660FD048C}.Debug|x86.Build.0 = Debug|Win32
{448F061E-AE05-4E06-84A1-C95660FD048C}.Hybrid|Any CPU.ActiveCfg = Hybrid|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Hybrid|Any CPU.Build.0 = Hybrid|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Hybrid|x64.ActiveCfg = Hybrid|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Hybrid|x64.Build.0 = Hybrid|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Hybrid|x86.ActiveCfg = Hybrid|Win32
{448F061E-AE05-4E06-84A1-C95660FD048C}.Hybrid|x86.Build.0 = Hybrid|Win32
{448F061E-AE05-4E06-84A1-C95660FD048C}.Release|Any CPU.ActiveCfg = Release|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Release|Any CPU.Build.0 = Release|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Release|x64.ActiveCfg = Release|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Release|x64.Build.0 = Release|x64
{448F061E-AE05-4E06-84A1-C95660FD048C}.Release|x86.ActiveCfg = Release|Win32
{448F061E-AE05-4E06-84A1-C95660FD048C}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{448F061E-AE05-4E06-84A1-C95660FD048C} = {08011335-C6A1-417B-ACBF-09F8F0D0EA09}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5B1F49CA-E8B9-4763-8476-FC8FB7A944E6}
EndGlobalSection