Show error message if Goldberg could not be downloaded/extracted, prompting the user to do so manually.
Try to skip getting DLC from SteamDB on error.
This commit is contained in:
parent
19f460d12d
commit
8e62880e23
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
using GoldbergGUI.Core.Models;
|
using GoldbergGUI.Core.Models;
|
||||||
using GoldbergGUI.Core.Utils;
|
using GoldbergGUI.Core.Utils;
|
||||||
using MvvmCross.Logging;
|
using MvvmCross.Logging;
|
||||||
@ -85,7 +86,10 @@ namespace GoldbergGUI.Core.Services
|
|||||||
_log = log;
|
_log = log;
|
||||||
|
|
||||||
var download = await Download().ConfigureAwait(false);
|
var download = await Download().ConfigureAwait(false);
|
||||||
if (download) await Extract(_goldbergZipPath).ConfigureAwait(false);
|
if (download)
|
||||||
|
{
|
||||||
|
await Extract(_goldbergZipPath).ConfigureAwait(false);
|
||||||
|
}
|
||||||
return await GetGlobalSettings().ConfigureAwait(false);
|
return await GetGlobalSettings().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,6 +382,8 @@ namespace GoldbergGUI.Core.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task StartDownload(string downloadUrl)
|
private async Task StartDownload(string downloadUrl)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
_log.Debug(downloadUrl);
|
_log.Debug(downloadUrl);
|
||||||
@ -390,6 +396,13 @@ namespace GoldbergGUI.Core.Services
|
|||||||
_log.Info("Download finished!");
|
_log.Info("Download finished!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ShowErrorMessage();
|
||||||
|
_log.Error(e.ToString);
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Empty subfolder ./goldberg/
|
// Empty subfolder ./goldberg/
|
||||||
// Extract all from archive to subfolder ./goldberg/
|
// Extract all from archive to subfolder ./goldberg/
|
||||||
@ -397,13 +410,34 @@ namespace GoldbergGUI.Core.Services
|
|||||||
{
|
{
|
||||||
_log.Debug("Start extraction...");
|
_log.Debug("Start extraction...");
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Directory.Delete(_goldbergPath, true);
|
Directory.Delete(_goldbergPath, true);
|
||||||
ZipFile.ExtractToDirectory(archivePath, _goldbergPath);
|
ZipFile.ExtractToDirectory(archivePath, _goldbergPath);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ShowErrorMessage();
|
||||||
|
_log.Error(e.ToString);
|
||||||
|
Environment.Exit(1);
|
||||||
|
// throw;
|
||||||
|
}
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
_log.Debug("Extraction done!");
|
_log.Debug("Extraction done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShowErrorMessage()
|
||||||
|
{
|
||||||
|
if (Directory.Exists(_goldbergPath))
|
||||||
|
{
|
||||||
|
Directory.Delete(_goldbergPath, true);
|
||||||
|
}
|
||||||
|
Directory.CreateDirectory(_goldbergPath);
|
||||||
|
MessageBox.Show("Could not setup Goldberg Emulator!\n" +
|
||||||
|
"Please download it manually and extract its content into the \"goldberg\" subfolder!");
|
||||||
|
}
|
||||||
|
|
||||||
// https://gitlab.com/Mr_Goldberg/goldberg_emulator/-/blob/master/generate_interfaces_file.cpp
|
// https://gitlab.com/Mr_Goldberg/goldberg_emulator/-/blob/master/generate_interfaces_file.cpp
|
||||||
// (maybe) check DLL date first
|
// (maybe) check DLL date first
|
||||||
public async Task GenerateInterfacesFile(string filePath)
|
public async Task GenerateInterfacesFile(string filePath)
|
||||||
|
@ -218,6 +218,8 @@ namespace GoldbergGUI.Core.Services
|
|||||||
|
|
||||||
// ReSharper disable once InvertIf
|
// ReSharper disable once InvertIf
|
||||||
if (useSteamDb)
|
if (useSteamDb)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var steamDbUri = new Uri($"https://steamdb.info/app/{steamApp.AppId}/dlc/");
|
var steamDbUri = new Uri($"https://steamdb.info/app/{steamApp.AppId}/dlc/");
|
||||||
|
|
||||||
@ -268,6 +270,12 @@ namespace GoldbergGUI.Core.Services
|
|||||||
_log.Error("Could not get DLC from SteamDB!");
|
_log.Error("Could not get DLC from SteamDB!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_log.Error("Could not get DLC from SteamDB!");
|
||||||
|
_log.Error(e.ToString);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user