Skip to content

Commit dab2c03

Browse files
committed
Spore ModAPI Easy Installer: remove need for RevealXmlInstaller.info
1 parent 34030b4 commit dab2c03

File tree

2 files changed

+15
-99
lines changed

2 files changed

+15
-99
lines changed

Spore ModAPI Easy Installer/EasyInstaller.cs

Lines changed: 11 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -543,44 +543,22 @@ static ResultType TryExecuteInstaller(string inputFile, string modName)
543543
return ResultType.ModNotInstalled;
544544
}
545545

546-
/*XmlDocument Document = new XmlDocument();
547-
archive.GetEntry("ModInfo.xml").Open();
548-
modName*/
549546
string modPath = Path.Combine(Directory.GetParent(System.Reflection.Assembly.GetEntryAssembly().Location).ToString(), "ModConfigs", modName);
550547
if (Directory.Exists(modPath))
551548
DeleteFolder(modPath);
552549

553550
Directory.CreateDirectory(modPath);
554551

555-
string revealInstallerInfoPath = Path.Combine(Directory.GetParent(System.Reflection.Assembly.GetEntryAssembly().Location).ToString(), "RevealXmlInstaller.info");
556-
if (File.Exists(revealInstallerInfoPath))
557-
File.Delete(revealInstallerInfoPath);
558552

559-
/*XmlInstallerWindow win = */
560-
//bool installCancelled = false;
561553
Thread installerThread = GetXmlInstaller(modName, false, false, true, out XmlInstallerWindow win);
562-
//_showXmlInstaller = true;//Thread showThread = new Thread(() => xmlWin.Show());// xmlWin.Dispatcher.Invoke(new Action(() => xmlWin.Show())));
563-
/*showThread.SetApartmentState(ApartmentState.STA);
564-
showThread.Start();
565-
showThread.Join();*/
566-
//if (archive.GetEntry("Theme.xaml"))
554+
567555
foreach (var fileEntry in archive.Entries)
568556
{
569557
fileEntry.ExtractToFile(Path.Combine(modPath, fileEntry.Name), true);
570-
/*if (Path.GetFileName(fileEntry.Name).ToLowerInvariant() == "theme.xaml")
571-
File.WriteAllText(themeInfoPath, string.Empty);*/
572558
}
573-
//win.InstallCancelled += (sneder, args) => installCancelled = true;
574-
File.WriteAllText(revealInstallerInfoPath, string.Empty);
575-
/*if (win != null)
576-
win.Closed += (sneder, args) =>
577-
{installCancelled = win.cancelled;
578-
installerThread.Abort();
579-
};
580-
else
581-
MessageBox.Show("win == null");*/
582-
//RevealXmlInstaller = true; //Thread revealThread = new Thread(() => xmlWin.RevealInstaller()); //xmlWin.Dispatcher.Invoke(new Action(() => xmlWin.RevealInstaller())));
583-
//revealThread.SetApartmentState(ApartmentState.STA); revealThread.Start(); xmlWin.Closed += (sneder, args) => System.Windows.Application.Current.Shutdown(); revealThread.Join();
559+
560+
win.SignalRevealInstaller();
561+
584562
installerThread.Join();
585563

586564
if (!XmlInstallerCancellation.Cancellation[modName.Trim('"')])
@@ -591,61 +569,11 @@ static ResultType TryExecuteInstaller(string inputFile, string modName)
591569
else if (entry != null)
592570
{
593571
return ResultType.UnsupportedFile;
594-
/*tempFile = Path.GetTempFileName();
595-
try
596-
{
597-
entry.ExtractToFile(tempFile, true);
598-
}
599-
catch (Exception ex)
600-
{
601-
// delete the temp file and propagate the exception
602-
File.Delete(tempFile);
603-
throw ex;
604-
}
605-
606-
string validInstaller = "!!!!!2017_DI_9_r_Beta2-1-6";
607-
bool modNameValid = modName == validInstaller;
608-
bool modInstallerSizeValid = new FileInfo(tempFile).Length == 13023232;
609-
//MessageBox.Show("modName: " + modName + "\ninputFile: " + inputFile + "\n\nmodNameValid: " + modNameValid + "\nmodInstallerSizeValid: " + modInstallerSizeValid);
610-
611-
if (modNameValid && modInstallerSizeValid)
612-
{
613-
var startInfo = new ProcessStartInfo()
614-
{
615-
UseShellExecute = false, // we need this to execute a temp file
616-
FileName = tempFile,
617-
Arguments =
618-
ConvertToArgument(inputFile) + " " +
619-
ConvertToArgument(GetOutputPath(FileType.DLL)) + " " +
620-
ConvertToArgument(GetOutputPath(FileType.Package)) + " " +
621-
ConvertToArgument(GetOutputPath(FileType.Spore_Package))
622-
};
623-
624-
var process = Process.Start(startInfo);
625-
process.WaitForExit();
626-
627-
File.Delete(tempFile);
628-
629-
return ResultType.InstallerExecuted;
630-
}
631-
else
632-
{
633-
MessageBox.Show("For security reasons, EXE custom installers have been disabled. If you believe this mod is safe, inform its developer of the issue, and tell them to look into \"XML Custom Installers\".");
634-
return ResultType.UnsupportedFile;
635-
}*/
636572
}
637573
else
638574
{
639575
return ResultType.Success;
640576
}
641-
642-
/*
643-
// there's no exe custom installer, check for an xml one
644-
if (xmlEntry == null)
645-
{
646-
// there's no custom installer of any kind
647-
return ResultType.Success;
648-
}*/
649577
}
650578
}
651579

@@ -680,10 +608,14 @@ static Thread GetXmlInstaller(string modName, bool configure, bool uninstall, bo
680608
});
681609
thread.SetApartmentState(ApartmentState.STA);
682610
thread.Start();
683-
//thread.Join();
611+
612+
// wait until xmlWin has been set
613+
while (xmlWin == null)
614+
{
615+
Thread.Sleep(10);
616+
}
617+
684618
win = xmlWin;
685-
686-
687619
return thread;
688620
}
689621

Spore ModAPI Easy Installer/XmlInstallerWindow.xaml.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,30 +93,14 @@ public XmlInstallerWindow(string modName, bool configure, bool uninstall)
9393
}));
9494
}
9595
}
96-
else
97-
{
98-
WaitForCue();
99-
}
10096
}
10197

102-
void WaitForCue()
98+
public void SignalRevealInstaller()
10399
{
104-
string indicatorPath = Path.Combine(Directory.GetParent(System.Reflection.Assembly.GetEntryAssembly().Location).ToString(), "RevealXmlInstaller.info");
105-
106-
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer()
107-
{
108-
Interval = 250
109-
};
110-
timer.Tick += (sneder, args) =>
100+
Dispatcher.Invoke(new Action(() =>
111101
{
112-
if (File.Exists(indicatorPath))
113-
{
114-
RevealInstaller();
115-
File.Delete(indicatorPath);
116-
timer.Stop();
117-
}
118-
};
119-
timer.Start();
102+
RevealInstaller();
103+
}));
120104
}
121105

122106
public void RevealInstaller()

0 commit comments

Comments
 (0)