Closed Richard-L closed 8 months ago
As it's been years since I last had a disk drive, I won't be able to implement this myself. But to anyone who's willing to work on it – the best way to implement it is to create a new InstallSource
in the Installers
namespace, such as GOGInstallSource
or SteamInstallSource
. It shouldn't hardcode the D:\
drive and instead use windows APIs to get the first disk drive (https://learn.microsoft.com/en-us/dotnet/api/system.io.driveinfo.getdrives?view=net-8.0 + System.IO.DriveType.CDRom
).
Example untested patch
diff --git a/tools/installer/Installer/Installers/CDRomInstallSource.cs b/tools/installer/Installer/Installers/CDRomInstallSource.cs
new file mode 100644
index 00000000..90f64998
--- /dev/null
+++ b/tools/installer/Installer/Installers/CDRomInstallSource.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+namespace Installer.Installers;
+
+public class CDRomInstallSource : BaseInstallSource
+{
+ public override IEnumerable<string> DirectoriesToTry
+ {
+ get
+ {
+ DriveInfo[] allDrives = DriveInfo.GetDrives();
+ foreach (var drive in allDrives)
+ {
+ if (drive.DriveType == DriveType.CDRom && drive.IsReady) {
+ yield return drive.RootDirectory.FullName;
+ yield return Path.Combine(drive.RootDirectory.FullName, "TOMBENG"); // REMOVE IF NOT NEEDED
+ }
+ }
+ }
+ }
+
+ public override bool IsImportingSavesSupported => false;
+ public override string SourceName => "CDRom";
+
+ public override async Task CopyOriginalGameFiles(
+ string sourceDirectory,
+ string targetDirectory,
+ IProgress<InstallProgress> progress,
+ bool importSaves
+ )
+ {
+ var filterRegex = new Regex(@"(data|fmv|music)[\\/]", RegexOptions.IgnoreCase);
+ await InstallUtils.CopyDirectoryTree(
+ sourceDirectory,
+ targetDirectory,
+ progress,
+ file => filterRegex.IsMatch(file)
+ );
+ }
+
+ public override bool IsDownloadingMusicNeeded(string sourceDirectory)
+ {
+ return true;
+ }
+
+ public override bool IsDownloadingUnfinishedBusinessNeeded(string sourceDirectory)
+ {
+ return true;
+ }
+
+ public override bool IsGameFound(string sourceDirectory)
+ {
+ return Directory.Exists(Path.Combine(sourceDirectory, "DATA"))
+ && Directory.Exists(Path.Combine(sourceDirectory, "FMV"))
+ && File.Exists(Path.Combine(sourceDirectory, "dos4gw.exe"))
+ && File.Exists(Path.Combine(sourceDirectory, "tomb.exe"));
+ }
+}
diff --git a/tools/installer/Installer/Models/SourceStep.cs b/tools/installer/Installer/Models/SourceStep.cs
index 5af1700b..06f5d47c 100644
--- a/tools/installer/Installer/Models/SourceStep.cs
+++ b/tools/installer/Installer/Models/SourceStep.cs
@@ -15,6 +15,7 @@ public class SourceStep : BaseNotifyPropertyChanged, IStep
new InstallSourceViewModel(new GOGInstallSource()),
new InstallSourceViewModel(new TombATIInstallSource()),
new InstallSourceViewModel(new TR1XInstallSource()),
+ new InstallSourceViewModel(new CDRomInstallSource()),
};
foreach (var installationSource in InstallationSources)
diff --git a/tools/installer/Installer/Resources/CDRom.png b/tools/installer/Installer/Resources/CDRom.png
new file mode 100644
index 00000000..32878026
Binary files /dev/null and b/tools/installer/Installer/Resources/CDRom.png differ
Thanks a lot @rr- . Very much appreciated 🙏, and the icon looks beautiful.
In fact all my drives are virtual. I had thought it's a common thing to do among retro gamers, to keep their old games from dying over the decades.
It strikes me as odd that even though you can provide the original CD inserted in your system, none of installer source options support it. I also tried tricking it by providing the CD path as a TR1X or TombATI source, and then when it didn't like that also to the respective
\DATA
on both, but it still doesn't let you proceed.