Misc cleanup. Handle download failures appropriately and ensure GPatch closes launcher/game.

This commit is contained in:
Nick Blakely 2020-09-10 22:50:39 -07:00
parent d2bc9454ed
commit d621c45a9d
10 changed files with 40 additions and 17 deletions

View File

@ -1,5 +1,6 @@
xcopy "%GIANTS_PATH%\gg_dx7r.dll" "Files\" /Y
xcopy "%GIANTS_PATH%\gg_dx9r.dll" "Files\" /Y
xcopy "%GIANTS_PATH%\gg_null.dll" "Files\" /Y
xcopy "%GIANTS_PATH%\dedicated.exe" "Files\" /Y
xcopy "%GIANTS_PATH%\Giants.exe" "Files\" /Y
xcopy "%GIANTS_PATH%\GiantsMain.exe" "Files\" /Y

View File

@ -42,7 +42,7 @@ SetCompressor /SOLID lzma
; MUI end ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Output\GPatch1_498_206_0.exe"
OutFile "Output\GPatch1_498_209_0.exe"
InstallDir "$PROGRAMFILES\Giants\"
InstallDirRegKey HKCU "SOFTWARE\PlanetMoon\Giants" "DestDir"
ShowInstDetails hide
@ -55,6 +55,9 @@ Section
SectionIn RO
SetOverwrite on
nsExec::Exec "taskkill /F /IM Giants.exe"
nsExec::Exec "taskkill /F /IM GiantsMain.exe"
; Install DX redist for DX9 renderer
SetOutPath "$INSTDIR\Redist"
File /r "Files\Redist\*.*"
@ -76,6 +79,7 @@ Section
Delete $INSTDIR\gg_dx7r.dll
Delete $INSTDIR\gg_dx8r.dll
Delete $INSTDIR\gg_dx9r.dll
Delete $INSTDIR\gg_null.dll
Delete $INSTDIR\Giants.exe
Delete $INSTDIR\BugTrap.dll
Delete $INSTDIR\GiantsMain.exe

View File

@ -137,6 +137,8 @@
Offset = checked((int)binaryWriter.BaseStream.Position)
};
logger.Info($"Compiling {tokens[1]}");
tableOfContentsSize += contentEntry.Name.Length + 1 + sizeof(int);
tableOfContents.Add(contentEntry);

View File

@ -94,6 +94,7 @@
{
foreach (var kvp in this.tableOfContents)
{
this.WriteHeader(fileStream);
this.ProcessEffect(binaryReader, fileStream, kvp.Key, kvp.Value);
}
}
@ -104,6 +105,11 @@
}
}
private void WriteHeader(IndentedTextWriter fileStream)
{
fileStream.WriteLine("; Generated by FX Compiler. Comments will be lost.");
}
private void ProcessEffect(
BinaryReader reader,
IndentedTextWriter fileStream,

View File

@ -4,6 +4,8 @@
{
public const string Giants = nameof(Giants);
public const string GiantsBeta = nameof(GiantsBeta);
public const string GiantsLauncher = nameof(GiantsLauncher);
}
}

View File

@ -40,13 +40,20 @@ namespace Giants.Launcher
// Set window title
this.Text = GameName;
this.httpClient = new HttpClient();
this.versionHttpClient = new VersionClient(this.httpClient);
this.versionHttpClient.BaseUrl = BaseUrl;
this.communityHttpClient = new CommunityClient(this.httpClient);
this.communityHttpClient.BaseUrl = BaseUrl;
}
this.httpClient = new HttpClient(
new HttpClientHandler()
{
UseProxy = false
});
this.versionHttpClient = new VersionClient(this.httpClient)
{
BaseUrl = BaseUrl
};
this.communityHttpClient = new CommunityClient(this.httpClient)
{
BaseUrl = BaseUrl
};
}
private void btnExit_Click(object sender, EventArgs e)
{
@ -153,7 +160,6 @@ namespace Giants.Launcher
}
}
private async Task CheckForUpdates(Dictionary<ApplicationType, Version> appVersions)
{
this.updater = new Updater(
@ -202,7 +208,6 @@ namespace Giants.Launcher
NativeMethods.ReleaseCapture();
NativeMethods.SendMessage(this.Handle, NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HT_CAPTION, 0);
}
}
private void LauncherForm_Shown(object sender, EventArgs e)

View File

@ -16,6 +16,7 @@ namespace Giants.Launcher
public int priority;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string rendererName;
public int interfaceVersion;
};
#pragma warning restore 649
@ -60,7 +61,7 @@ namespace Giants.Launcher
// Make interop call to native renderer DLLs to get capability info
var interopCaps = new RendererInterop.GFXCapabilityInfo();
string path = Path.Combine(file.DirectoryName, file.Name);
if (GetRendererCapabilities(path, ref interopCaps))
if (GetRendererCapabilities(path, ref interopCaps) && interopCaps.priority >= 0)
{
RendererInfo caps = new RendererInfo(path, ref interopCaps);
capabilities.Add(caps);

View File

@ -287,7 +287,7 @@ namespace Giants.Launcher {
}
/// <summary>
/// Looks up a localized string similar to An update is available: version {0}. Download it?.
/// Looks up a localized string similar to An update is available to version {0}. Download it?.
/// </summary>
internal static string UpdateAvailableText {
get {
@ -305,7 +305,7 @@ namespace Giants.Launcher {
}
/// <summary>
/// Looks up a localized string similar to Failed to download update. Please visit www.giantswd.org and download the update manually. The error was: {0}.
/// Looks up a localized string similar to Failed to download update. Please visit www.giantswd.org and download the update manually.\nThe error was: {0}.
/// </summary>
internal static string UpdateDownloadFailedText {
get {

View File

@ -155,13 +155,13 @@
<value>Could not locate an installation of {0}. The launcher will now exit.</value>
</data>
<data name="UpdateAvailableText" xml:space="preserve">
<value>An update is available: version {0}. Download it?</value>
<value>An update is available to version {0}. Download it?</value>
</data>
<data name="UpdateAvailableTitle" xml:space="preserve">
<value>Update Available</value>
</data>
<data name="UpdateDownloadFailedText" xml:space="preserve">
<value>Failed to download update. Please visit www.giantswd.org and download the update manually. The error was: {0}</value>
<value>Failed to download update. Please visit www.giantswd.org and download the update manually.\nThe error was: {0}</value>
</data>
<data name="UpdateDownloadFailedTitle" xml:space="preserve">
<value>Update Failed</value>

View File

@ -34,8 +34,10 @@ namespace Giants.Launcher
this.StartApplicationUpdate(applicationType, versionInfo);
}
}
catch (Exception)
catch (Exception e)
{
string errorMsg = string.Format(Resources.UpdateDownloadFailedText, e.Message);
MessageBox.Show(errorMsg, Resources.UpdateDownloadFailedTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return Task.CompletedTask;
@ -66,7 +68,7 @@ namespace Giants.Launcher
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) == DialogResult.No)
if (MessageBox.Show(updateMsg, Resources.UpdateAvailableTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
{
return; // User declined update
}