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

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_dx7r.dll" "Files\" /Y
xcopy "%GIANTS_PATH%\gg_dx9r.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%\dedicated.exe" "Files\" /Y
xcopy "%GIANTS_PATH%\Giants.exe" "Files\" /Y xcopy "%GIANTS_PATH%\Giants.exe" "Files\" /Y
xcopy "%GIANTS_PATH%\GiantsMain.exe" "Files\" /Y xcopy "%GIANTS_PATH%\GiantsMain.exe" "Files\" /Y

View File

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

View File

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

View File

@ -94,6 +94,7 @@
{ {
foreach (var kvp in this.tableOfContents) foreach (var kvp in this.tableOfContents)
{ {
this.WriteHeader(fileStream);
this.ProcessEffect(binaryReader, fileStream, kvp.Key, kvp.Value); 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( private void ProcessEffect(
BinaryReader reader, BinaryReader reader,
IndentedTextWriter fileStream, IndentedTextWriter fileStream,

View File

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

View File

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

View File

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

View File

@ -287,7 +287,7 @@ namespace Giants.Launcher {
} }
/// <summary> /// <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> /// </summary>
internal static string UpdateAvailableText { internal static string UpdateAvailableText {
get { get {
@ -305,7 +305,7 @@ namespace Giants.Launcher {
} }
/// <summary> /// <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> /// </summary>
internal static string UpdateDownloadFailedText { internal static string UpdateDownloadFailedText {
get { get {

View File

@ -155,13 +155,13 @@
<value>Could not locate an installation of {0}. The launcher will now exit.</value> <value>Could not locate an installation of {0}. The launcher will now exit.</value>
</data> </data>
<data name="UpdateAvailableText" xml:space="preserve"> <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>
<data name="UpdateAvailableTitle" xml:space="preserve"> <data name="UpdateAvailableTitle" xml:space="preserve">
<value>Update Available</value> <value>Update Available</value>
</data> </data>
<data name="UpdateDownloadFailedText" xml:space="preserve"> <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>
<data name="UpdateDownloadFailedTitle" xml:space="preserve"> <data name="UpdateDownloadFailedTitle" xml:space="preserve">
<value>Update Failed</value> <value>Update Failed</value>

View File

@ -34,8 +34,10 @@ namespace Giants.Launcher
this.StartApplicationUpdate(applicationType, versionInfo); 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; return Task.CompletedTask;
@ -66,7 +68,7 @@ namespace Giants.Launcher
string.Format(Resources.UpdateAvailableText, this.ToVersion(versionInfo.Version).ToString()) : string.Format(Resources.UpdateAvailableText, this.ToVersion(versionInfo.Version).ToString()) :
string.Format(Resources.LauncherUpdateAvailableText, 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 return; // User declined update
} }