Skip to content

Commit 2040fce

Browse files
committed
Spore ModAPI Easy Installer: make messages after install more consistent
1 parent a618df2 commit 2040fce

3 files changed

Lines changed: 24 additions & 44 deletions

File tree

Spore ModAPI Easy Installer/EasyInstaller.cs

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
namespace Spore_ModAPI_Easy_Installer
2222
{
23-
static class EasyInstaller
23+
public static class EasyInstaller
2424
{
2525
enum FileChooserType
2626
{
@@ -38,15 +38,16 @@ enum FileType
3838
Spore_Package // a .package that goes to the Spore data folder instead of the EP1 one
3939
}
4040

41-
enum ResultType
41+
public enum ResultType
4242
{
4343
Success,
4444
InstallerExecuted, // we have found a custom installer, close Easy installer and execute that one
4545
UnsupportedFile,
4646
GalacticAdventuresNotFound,
4747
UnauthorizedAccess,
4848
InvalidPath,
49-
ModNotInstalled
49+
ModNotInstalled,
50+
NoInstallerFound
5051
}
5152
//// Show a file chooser and returns the path selected. It can ask for files or directories.
5253
//static string ShowFileChooser(FileChooserType type, string title, string filter);
@@ -140,7 +141,6 @@ static void Main()
140141
catch (Exception ex)
141142
{
142143
errorStrings[i] = ex.Message; results.Add(ResultType.UnsupportedFile);
143-
MessageBox.Show(ex.ToString() + "\n" + ex.StackTrace, "AAA");
144144
}
145145
}
146146
for (int i = 0; i < results.Count; i++) //foreach (ResultType type in results)
@@ -149,7 +149,9 @@ static void Main()
149149
ResultType type = results[i];
150150
outcome += GetResultText(type, Path.GetFileNameWithoutExtension(inputPaths[i]), errorStrings[i]) + "\n";
151151
}
152-
WaitForExit();
152+
153+
ModList.Save();
154+
ShowExitMessageBox();
153155
}
154156
}
155157
}
@@ -467,9 +469,6 @@ private static ResultType ExtractSporemodZip(string inputFile, ModConfiguration
467469
return ResultType.Success;
468470
}
469471

470-
[DllImport("user32.dll", ExactSpelling = true)]
471-
static extern bool IsWindow(IntPtr hWnd);
472-
473472
private static bool CheckModCoreDllsVersion(ZipArchiveEntry xmlEntry)
474473
{
475474
try
@@ -524,9 +523,9 @@ static ResultType TryExecuteInstaller(string inputFile, string modName)
524523
win.SignalRevealInstaller();
525524

526525
installerThread.Join();
527-
526+
528527
if (!XmlInstallerCancellation.Cancellation[modName.Trim('"')])
529-
return ResultType.InstallerExecuted;
528+
return win.GetResult();
530529
else
531530
return ResultType.ModNotInstalled;
532531
}
@@ -536,7 +535,7 @@ static ResultType TryExecuteInstaller(string inputFile, string modName)
536535
}
537536
else
538537
{
539-
return ResultType.Success;
538+
return ResultType.NoInstallerFound;
540539
}
541540
}
542541
}
@@ -580,12 +579,7 @@ static ResultType InstallSporemod(string inputFile, string modName)
580579
{
581580
var result = TryExecuteInstaller(inputFile, modName);
582581

583-
if ((result == ResultType.InstallerExecuted) || (result == ResultType.ModNotInstalled))
584-
{
585-
// the custom installer executed, we don't need to do anything else
586-
return ResultType.InstallerExecuted;
587-
}
588-
else if (result == ResultType.Success)
582+
if (result == ResultType.NoInstallerFound)
589583
{
590584
// the custom installer just didn't exist, extract as ZIP file
591585

@@ -728,8 +722,6 @@ static string GetResultText(ResultType result, string modName, string errorStrin
728722
// show message to the user
729723
return Strings.ModInstalled1 + modName + Strings.ModInstalled2;
730724
}
731-
else if (result == ResultType.InstallerExecuted)
732-
return string.Empty;
733725
else if (result == ResultType.ModNotInstalled)
734726
{
735727
return Strings.ModInstalled1 + modName + Strings.InstallationCancelled;
@@ -746,25 +738,6 @@ static string GetResultText(ResultType result, string modName, string errorStrin
746738
}
747739
}
748740

749-
static void WaitForExit()
750-
{
751-
int counter = 0;
752-
System.Timers.Timer timer = new System.Timers.Timer(10);
753-
timer.Elapsed += (sneder, args) =>
754-
{
755-
if ((counter > 5) && (XmlInstallerWindow.installerWindows.Count == 0))
756-
{
757-
timer.Stop();
758-
ModList.Save();
759-
ShowExitMessageBox();
760-
}
761-
else
762-
counter++;
763-
};
764-
timer.Start();
765-
Application.Run();
766-
}
767-
768741
static void ShowExitMessageBox()
769742
{
770743
Thread thread = new Thread(() =>

Spore ModAPI Easy Installer/Strings.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@
133133
<value>Choose the mod to be installed</value>
134134
</data>
135135
<data name="InstallationCancelled" xml:space="preserve">
136-
<value>Installation cancelled</value>
136+
<value>" cancelled installation</value>
137137
</data>
138138
<data name="InstallationCompleted" xml:space="preserve">
139-
<value>Installation completed</value>
139+
<value>" completed installation</value>
140140
</data>
141141
<data name="InstallingModTitle" xml:space="preserve">
142142
<value>Installing mod...</value>

Spore ModAPI Easy Installer/XmlInstallerWindow.xaml.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public partial class XmlInstallerWindow : DecoratableWindow
6363

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

66+
private EasyInstaller.ResultType _result = EasyInstaller.ResultType.ModNotInstalled;
67+
6668
public XmlInstallerWindow(string modName, bool configure, bool uninstall)
6769
{
6870
InitializeComponent();
@@ -95,6 +97,11 @@ public XmlInstallerWindow(string modName, bool configure, bool uninstall)
9597
}
9698
}
9799

100+
public EasyInstaller.ResultType GetResult()
101+
{
102+
return _result;
103+
}
104+
98105
public void SignalRevealInstaller()
99106
{
100107
Dispatcher.Invoke(new Action(() =>
@@ -409,10 +416,6 @@ private void GetComponents()
409416
RemovalGames = game
410417
});
411418
}
412-
else
413-
{
414-
Debug.WriteLine("u w0t");
415-
}
416419
}
417420

418421
int _activeComponentCount = GetComponentCount();
@@ -688,6 +691,7 @@ await Dispatcher.BeginInvoke(new Action(() =>
688691
XmlInstallerCancellation.Cancellation[ModName] = true;
689692
_installerState = 2;
690693
_installerMode = 1;
694+
_result = EasyInstaller.ResultType.ModNotInstalled;
691695
Close();
692696
}
693697

@@ -870,16 +874,19 @@ await Task.Run(() =>
870874
if (_installerMode == 1)
871875
{
872876
_installerState = 2;
877+
_result = EasyInstaller.ResultType.Success;
873878
Close();
874879
}
875880
else
876881
{
877882
CyclePage(0, 1);
883+
_result = EasyInstaller.ResultType.Success;
878884
_installerState = 2;
879885
}
880886
}
881887
catch (Exception ex)
882888
{
889+
_result = EasyInstaller.ResultType.ModNotInstalled;
883890
ErrorInfoTextBlock.Text = ex.ToString();
884891
CyclePage(0, 3);
885892
}

0 commit comments

Comments
 (0)