OS-aware Proof-of-Concept

aidancheddar

Active Member
Having fiddled with processors on my own repository, I decided to try out on @francot514's TSOCategorizer. I know he barely touches it but since it makes use of PD's APIs, it makes for excellent way to get your hands dirty in the TSO.Files APIs. So, I wondered, would it be possible to have TSOCategorizer work on Linux? Right now, it can but not without Wine. This is because of the Microsoft.Win32 package. Thankfully, it only makes use of it once. So, after much trial and error, it worked! Unfortunately, I don't have a Linux VM on me at the moment but if you swap !UNIX with UNIX and vice verse, yeah. I also used the if (Environment.Is64BitOperatingSystem && Environment.Is64BitProcess) logic from PD itself for detecting systems on 32bit installations. Apparently, Mono doesn't have those Unix processors. Created a simpler implantation below.

Code:
#if !UNIX
using Microsoft.Win32;
#endif
Code:
#if !UNIX
            string autoRegSoft;

            if (Environment.Is64BitOperatingSystem && Environment.Is64BitProcess){
                autoRegSoft = "SOFTWARE";
            } else {
                autoRegSoft = "SOFTWARE\\Wow6432Node";

            }

            if (Registry.GetValue("HKEY_LOCAL_MACHINE\\" + autoRegSoft + "\\Maxis\\The Sims Online", "InstallDir", null) == null)
            {


                // Displays a message box with the yes and no options.
                DialogResult Response = MessageBox.Show("Please select TSO Game Folder", "TSO Game Installation", MessageBoxButtons.OKCancel);

                // If statement to check if the yes button was selected.
                if (Response == DialogResult.OK)
                {
                    folderBrowserDialog1.ShowDialog();
                    Properties.Settings.Default.Gamepath = folderBrowserDialog1.SelectedPath;
                    Properties.Settings.Default.Save();
                    gamedir = folderBrowserDialog1.SelectedPath;

                }
                else
                {
                    // The no button was selected.
                    MessageBox.Show("Now you cannot preview files");
                    Application.Exit();
                }

            }
            else
            {
                regvalue = Registry.GetValue("HKEY_LOCAL_MACHINE\\" + autoRegSoft + "\\Maxis\\The Sims Online", "InstallDir", null).ToString();
                Properties.Settings.Default.Gamepath = regvalue;
                Properties.Settings.Default.Save();
                gamedir = regvalue;

            }

#elif UNIX
            // Displays a message box with the yes and no options.
            DialogResult Response = MessageBox.Show("Please select TSO Game Folder", "TSO Game Installation", MessageBoxButtons.OKCancel);
            if(Response == DialogResult.OK)
            {
                folderBrowserDialog1.ShowDialog();

                Properties.Settings.Default.Gamepath = folderBrowserDialog1.SelectedPath;

                gamedir = folderBrowserDialog1.SelectedPath;
            }
            else
            {
                MessageBox.Show("Now you cannot preview files");
                Application.Exit();
            }
#endif
 
Last edited:
For use it with linux i have installed Mono for linux, dont know which version of unix youre using... and which compiller debugger way you tried...
 
It's generic and refers to OS X or Linux. I was only able to try with Visual Studio but the preprocessors work as they should.
 
After going over tones of Mono documentation and revisiting stack overflow, I created a much simpler solution.
Code:
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
         string autoRegSoft;

         if (Environment.Is64BitOperatingSystem && Environment.Is64BitProcess) {
           autoRegSoft = "SOFTWARE";
         } else {
           autoRegSoft = "SOFTWARE\\Wow6432Node";

         }

         if (Registry.GetValue ("HKEY_LOCAL_MACHINE\\" + autoRegSoft + "\\Maxis\\The Sims Online", "InstallDir", null) == null) {


           // Displays a message box with the yes and no options.
           DialogResult Response = MessageBox.Show ("Please select TSO Game Folder", "TSO Game Installation", MessageBoxButtons.OKCancel);

           // If statement to check if the yes button was selected.
           if (Response == DialogResult.OK) {
             folderBrowserDialog1.ShowDialog ();
             Properties.Settings.Default.Gamepath = folderBrowserDialog1.SelectedPath;
             Properties.Settings.Default.Save ();
             gamedir = folderBrowserDialog1.SelectedPath;

           } else {
             // The no button was selected.
             MessageBox.Show ("Now you cannot preview files");
             Application.Exit ();
           }

         } else {
           regvalue = Registry.GetValue ("HKEY_LOCAL_MACHINE\\" + autoRegSoft + "\\Maxis\\The Sims Online", "InstallDir", null).ToString ();
           Properties.Settings.Default.Gamepath = regvalue;
           Properties.Settings.Default.Save ();
           gamedir = regvalue;

         }

       } else {
         // Displays a message box with the yes and no options.
         DialogResult Response = MessageBox.Show ("Please select TSO Game Folder", "TSO Game Installation", MessageBoxButtons.OKCancel);
         if (Response == DialogResult.OK) {
           folderBrowserDialog1.ShowDialog ();

           Properties.Settings.Default.Gamepath = folderBrowserDialog1.SelectedPath;

           gamedir = folderBrowserDialog1.SelectedPath;
         } else {
           MessageBox.Show ("Now you cannot preview files");
           Application.Exit ();
         }
Ubuntu.png
Little crashy, though.
 
Last edited:
Ok, not doing the code for cross platform was my mistake, i was not thinking about be able to use it, just used the mono runtime, becuase is supposed to have better implementation that the net framework...
Good to know you can do it, also i have some extra code think youre missing from ObjectsData, youre change the implementation to sims 1??
 
Good to know you can do it, also i have some extra code think youre missing from ObjectsData, youre change the implementation to sims 1??
Same implementation. Just reading directly from TSO.Files source code itself instead of an pre-compiled platform-dependent DLL. It is having trouble reading the ObjectData, though, since it's using the newer TSO.Files.
 
Last edited:
Ok, whats your main objective?? recreate the application with your own code, or improve the current one and allow use of it for unix system?? I can always give you a hand if needed...
 
Ok, whats your main objective?? recreate the application with your own code, or improve the current one and allow use of it for unix system?? I can always give you a hand if needed...
Well, the purpose is the find the best way to get these applications and Project Dollhouse itself that are designed to normally look for The Sims or The Sims Online via registry to also have a fallback manual method if they're on Unix systems, such as Linux or Mac OS X. Now that the game has been fully ported to MonoGame, a method of locating The Sims Online non-Windows systems is needed.

Your applications makes a good test bed since it's not as complex as Project Dollhouse but still uses it's libraries and method of locating the game.
 
This was never going to be a problem for us, but it's good that you tried it out and got it working. For linux we would want to remember the directory the user first specifies, or better yet, download the game using the patcher itself (once it's not so buggy).
 
This was never going to be a problem for us, but it's good that you tried it out and got it working.
Thanks. Seeing as I much more prefer Linux then I do Windows, this is something I wanted to get off my chest and try it now. Both to see if I can get it working to begin with and as practice now that I'm throwing the books aside only for reference.
or better yet, download the game using the patcher itself (once it's not so buggy).
I've had that same idea. XD
 
Once we're ready for more distributed testing, I'll clean up the patcher as mentioned to both download the game and patch without randomly crashing. It'll also probably look like the original patcher, for that nostalgic feel. ;)
 
Thanks. Seeing as I much more prefer Linux then I do Windows

Programming for Linux is quite complicated, which compiler you will use???, also remember that for now only PD has some linux compatibilty, but for sims 1 it will not have a way to test your experimental tools...
 
Programming for Linux is quite complicated,
For C#? Not really. Especially with .NET Core (then official open source cross-platform version) and Microsoft giving the green light for anyone to implant any .NET 4.0 features that aren't in the C# standard. Meaning will be compatible with newer C# apps then innthe past.
which compiler you will use???,
Mono on Linux, .NET on Windows.
also remember that for now only PD has some linux compatibilty, but for sims 1 it will not have a way to test your experimental tools...
That's why the experimental projects are there. That and gain expreince. xD
 
Last edited:
Back
Top