Skip to content

Commit 5173498

Browse files
committed
Spore ModAPI Easy Installer: exit with ResultType on uninstall
1 parent f5e2820 commit 5173498

4 files changed

Lines changed: 31 additions & 19 deletions

File tree

ModAPI Installers/ModAPI Installers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<Compile Include="Permissions.cs" />
5555
<Compile Include="Properties\AssemblyInfo.cs" />
5656
<Compile Include="SporePath.cs" />
57+
<Compile Include="Types.cs" />
5758
</ItemGroup>
5859
<ItemGroup>
5960
<EmbeddedResource Include="CommonStrings.resx">

ModAPI Installers/Types.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace ModAPI_Installers.Types
2+
{
3+
public enum ResultType
4+
{
5+
Success = 0,
6+
InstallerExecuted, // we have found a custom installer, close Easy installer and execute that one
7+
UnsupportedFile,
8+
GalacticAdventuresNotFound,
9+
UnauthorizedAccess,
10+
InvalidPath,
11+
ModNotInstalled,
12+
NoInstallerFound
13+
}
14+
}

Spore ModAPI Easy Installer/EasyInstaller.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System.Runtime.InteropServices;
1818
using System.Xml;
1919
using ModApi.UpdateManager;
20+
using ModAPI_Installers.Types;
2021

2122
namespace Spore_ModAPI_Easy_Installer
2223
{
@@ -38,17 +39,6 @@ enum FileType
3839
Spore_Package // a .package that goes to the Spore data folder instead of the EP1 one
3940
}
4041

41-
public enum ResultType
42-
{
43-
Success,
44-
InstallerExecuted, // we have found a custom installer, close Easy installer and execute that one
45-
UnsupportedFile,
46-
GalacticAdventuresNotFound,
47-
UnauthorizedAccess,
48-
InvalidPath,
49-
ModNotInstalled,
50-
NoInstallerFound
51-
}
5242
//// Show a file chooser and returns the path selected. It can ask for files or directories.
5343
//static string ShowFileChooser(FileChooserType type, string title, string filter);
5444

Spore ModAPI Easy Installer/XmlInstallerWindow.xaml.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.Windows.Media.Imaging;
1616
using System.Windows.Threading;
1717
using System.Xml;
18+
using ModAPI_Installers.Types;
1819

1920
namespace Spore_ModAPI_Easy_Installer
2021
{
@@ -62,7 +63,7 @@ public partial class XmlInstallerWindow : DecoratableWindow
6263

6364
public static string SporeDataPath = SporePath.MoveToData(SporePath.Game.Spore, SporePath.GetRealParent(PathDialogs.ProcessSpore()));
6465

65-
private EasyInstaller.ResultType _result = EasyInstaller.ResultType.ModNotInstalled;
66+
private ResultType _result = ResultType.ModNotInstalled;
6667

6768
public XmlInstallerWindow(string modName, bool configure, bool uninstall)
6869
{
@@ -96,7 +97,7 @@ public XmlInstallerWindow(string modName, bool configure, bool uninstall)
9697
}
9798
}
9899

99-
public EasyInstaller.ResultType GetResult()
100+
public ResultType GetResult()
100101
{
101102
return _result;
102103
}
@@ -690,7 +691,7 @@ await Dispatcher.BeginInvoke(new Action(() =>
690691
XmlInstallerCancellation.Cancellation[ModName] = true;
691692
_installerState = 2;
692693
_installerMode = 1;
693-
_result = EasyInstaller.ResultType.ModNotInstalled;
694+
_result = ResultType.ModNotInstalled;
694695
Close();
695696
}
696697

@@ -879,19 +880,19 @@ await Task.Run(() =>
879880
if (_installerMode == 1)
880881
{
881882
_installerState = 2;
882-
_result = EasyInstaller.ResultType.Success;
883+
_result = ResultType.Success;
883884
Close();
884885
}
885886
else
886887
{
887888
CyclePage(0, 1);
888-
_result = EasyInstaller.ResultType.Success;
889+
_result = ResultType.Success;
889890
_installerState = 2;
890891
}
891892
}
892893
catch (Exception ex)
893894
{
894-
_result = EasyInstaller.ResultType.ModNotInstalled;
895+
_result = ResultType.ModNotInstalled;
895896
ErrorInfoTextBlock.Text = ex.ToString();
896897
CyclePage(0, 3);
897898
}
@@ -1046,12 +1047,18 @@ await Task.Run(() =>
10461047

10471048
if (_isUninstallingOnly)
10481049
{
1050+
_result = ResultType.Success;
10491051
Close();
10501052
}
1051-
//Process.GetCurrentProcess().Kill();
10521053
}
10531054
catch (Exception ex)
10541055
{
1056+
// dummy error so that the uninstaller
1057+
// knows this mod failed to uninstall
1058+
if (_isUninstallingOnly)
1059+
{
1060+
_result = ResultType.UnsupportedFile;
1061+
}
10551062
ErrorInfoTextBlock.Text = ex.ToString();
10561063
CyclePage(0, 3);
10571064
}
@@ -1397,7 +1404,7 @@ private void XmlInstallerWindow_Closed(object sender, EventArgs e)
13971404
if (installerWindows.Contains(this))
13981405
installerWindows.Remove(this);
13991406
if (_isConfigurator)
1400-
Process.GetCurrentProcess().Kill();
1407+
Environment.Exit((int)_result);
14011408
}
14021409

14031410
private void SplashBorder_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)

0 commit comments

Comments
 (0)