Giter Club home page Giter Club logo

Comments (3)

rr- avatar rr- commented on July 19, 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).

from tr1x.

rr- avatar rr- commented on July 19, 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

from tr1x.

Richard-L avatar Richard-L commented on July 19, 2024

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.

from tr1x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.