better exception handling, fix error for outdated creamAPI files
This commit is contained in:
parent
ace422e051
commit
2c9943fe92
8 changed files with 42 additions and 24 deletions
|
@ -6,7 +6,7 @@
|
|||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ApplicationIcon>ini.ico</ApplicationIcon>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<Version>1.0.6.3</Version>
|
||||
<Version>1.0.6.4</Version>
|
||||
<PackageIcon>ini.ico</PackageIcon>
|
||||
<PackageIconUrl />
|
||||
<Description>Automatically downloads and installs CreamAPI files for programs/games.</Description>
|
||||
|
@ -26,8 +26,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>none</DebugType>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -21,4 +21,4 @@ namespace CreamInstaller
|
|||
return ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,6 +10,19 @@ using System.Windows.Forms;
|
|||
|
||||
namespace CreamInstaller
|
||||
{
|
||||
public class CustomMessageException : Exception
|
||||
{
|
||||
private string message;
|
||||
public override string Message => message ?? "CustomMessageException";
|
||||
|
||||
public override string ToString() => Message;
|
||||
|
||||
public CustomMessageException(string message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class InstallForm : Form
|
||||
{
|
||||
public bool Reselecting = false;
|
||||
|
@ -25,6 +38,7 @@ namespace CreamInstaller
|
|||
|
||||
private int OperationsCount;
|
||||
private int CompleteOperationsCount;
|
||||
|
||||
public void UpdateProgress(int progress)
|
||||
{
|
||||
int value = (int)((float)(CompleteOperationsCount / (float)OperationsCount) * 100) + (progress / OperationsCount);
|
||||
|
@ -59,7 +73,7 @@ namespace CreamInstaller
|
|||
}
|
||||
catch
|
||||
{
|
||||
throw new Exception($"Unable to delete old archive file: {Program.OutputFile}");
|
||||
throw new CustomMessageException($"Unable to delete old archive file: {Program.OutputFile}");
|
||||
}
|
||||
}
|
||||
Progress<double> progress = new Progress<double>(delegate (double progress)
|
||||
|
@ -101,7 +115,7 @@ namespace CreamInstaller
|
|||
}
|
||||
if (resources.Count < 1)
|
||||
{
|
||||
throw new Exception($"Unable to find CreamAPI files in downloaded archive: {Program.OutputFile}");
|
||||
throw new CustomMessageException($"Unable to find CreamAPI files in downloaded archive: {Program.OutputFile}");
|
||||
}
|
||||
if (!Program.IsProgramRunningDialog(this, selection))
|
||||
{
|
||||
|
@ -151,7 +165,7 @@ namespace CreamInstaller
|
|||
UpdateUser("Reversed changes to Steam API file: " + file, LogColor.Warning);
|
||||
}
|
||||
}
|
||||
throw new Exception($"Unable to overwrite Steam API file: {file}");
|
||||
throw new CustomMessageException($"Unable to overwrite Steam API file: {file}");
|
||||
}
|
||||
UpdateUser("Installed file: " + file, LogColor.Resource);
|
||||
UpdateProgress((currentFileCount / (resources.Count * selection.SteamApiDllDirectories.Count)) * 100);
|
||||
|
@ -199,7 +213,7 @@ namespace CreamInstaller
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UpdateUser($"Operation failed for {selection.ProgramName}: " + exception.Message, LogColor.Error);
|
||||
UpdateUser($"Operation failed for {selection.ProgramName}: " + exception.ToString(), LogColor.Error);
|
||||
}
|
||||
|
||||
++CompleteOperationsCount;
|
||||
|
@ -212,11 +226,11 @@ namespace CreamInstaller
|
|||
{
|
||||
if (FailedSelections.Count == 1)
|
||||
{
|
||||
throw new Exception($"Operation failed for {FailedSelections.First().ProgramName}.");
|
||||
throw new CustomMessageException($"Operation failed for {FailedSelections.First().ProgramName}.");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Operation failed for {FailedSelections.Count} programs.");
|
||||
throw new CustomMessageException($"Operation failed for {FailedSelections.Count} programs.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +252,7 @@ namespace CreamInstaller
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UpdateUser("CreamAPI download and/or installation failed: " + exception.Message, LogColor.Error);
|
||||
UpdateUser("CreamAPI download and/or installation failed: " + exception.ToString(), LogColor.Error);
|
||||
retryButton.Enabled = true;
|
||||
}
|
||||
userProgressBar.Value = userProgressBar.Maximum;
|
||||
|
@ -278,4 +292,4 @@ namespace CreamInstaller
|
|||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,4 +22,4 @@ namespace CreamInstaller
|
|||
logTextBox.SelectionColor = logTextBox.ForeColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -171,4 +171,4 @@ namespace CreamInstaller
|
|||
updateManager = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -138,4 +138,4 @@ namespace CreamInstaller
|
|||
Cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,4 +38,4 @@ namespace CreamInstaller
|
|||
this.Enabled = Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -99,6 +99,7 @@ namespace CreamInstaller
|
|||
}
|
||||
|
||||
private readonly List<CheckBox> checkBoxes = new();
|
||||
|
||||
private void GetCreamApiApplicablePrograms(IProgress<int> progress)
|
||||
{
|
||||
if (Program.Canceled) { return; }
|
||||
|
@ -152,21 +153,24 @@ namespace CreamInstaller
|
|||
{
|
||||
if (Program.Canceled) { return; }
|
||||
|
||||
ProgramSelection selection = new();
|
||||
selection.ProgramName = node.Name;
|
||||
selection.ProgramDirectory = rootDirectory;
|
||||
selection.SteamApiDllDirectories = new();
|
||||
selection.SteamApiDllDirectories.AddRange(directories);
|
||||
|
||||
INode downloadNode = null;
|
||||
foreach (INode _node in fileNodes)
|
||||
{
|
||||
if (_node.Type == NodeType.File && _node.ParentId == node.Id)
|
||||
{
|
||||
selection.DownloadNode = _node;
|
||||
downloadNode = _node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadNode is null) return;
|
||||
ProgramSelection selection = new();
|
||||
selection.DownloadNode = downloadNode;
|
||||
selection.ProgramName = node.Name;
|
||||
selection.ProgramDirectory = rootDirectory;
|
||||
selection.SteamApiDllDirectories = new();
|
||||
selection.SteamApiDllDirectories.AddRange(directories);
|
||||
|
||||
CheckBox checkBox = new();
|
||||
checkBoxes.Add(checkBox);
|
||||
checkBox.AutoSize = true;
|
||||
|
@ -324,4 +328,4 @@ namespace CreamInstaller
|
|||
allCheckBox.Checked = shouldCheck;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue