Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mounted TR1 CD (or physical) as installer game file source #1144

Closed
Richard-L opened this issue Jan 20, 2024 · 3 comments · Fixed by #1147
Closed

Allow mounted TR1 CD (or physical) as installer game file source #1144

Richard-L opened this issue Jan 20, 2024 · 3 comments · Fixed by #1147
Assignees
Labels
Enhancement Improvement of an existing feature
Milestone

Comments

@Richard-L
Copy link
Collaborator

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.

@rr-
Copy link
Collaborator

rr- commented Jan 25, 2024

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).

@rr-
Copy link
Collaborator

rr- commented Jan 25, 2024

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

CDRom

@Richard-L
Copy link
Collaborator Author

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.

lahm86 added a commit to lahm86/TR1X that referenced this issue Jan 25, 2024
Adds the ability to install from a physical CD.
Removes some additional VS compiler noise.

Resolves LostArtefacts#1144.
@lahm86 lahm86 self-assigned this Jan 25, 2024
@lahm86 lahm86 added the Enhancement Improvement of an existing feature label Jan 25, 2024
@lahm86 lahm86 added this to the 3.2 milestone Jan 25, 2024
lahm86 added a commit to lahm86/TR1X that referenced this issue Feb 3, 2024
Adds the ability to install from a physical CD.
Removes some additional VS compiler noise.

Resolves LostArtefacts#1144.
lahm86 added a commit that referenced this issue Feb 3, 2024
Adds the ability to install from a physical CD.
Removes some additional VS compiler noise.

Resolves #1144.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants