Member Controls

Developers > SimPE Expansion Management (PathProvider)
quaxiLink to postposted: Sun Sep 24, 2006 6:47 pm
Avator for quaxi

Member since:
 2006-04-28
Posts:
 3154
Begining with SimPE 0.59n, I have introduced a brand new Expansion Management, thata is more flexible.

It is driven by the file Data/expansions.xreg, which defines some basic rules, that SimPE is reading in order to generate a matching FileTable. presenting Path Options in the Extra->Preferences etc.

This topic is of special interest for developers, because it renderssome existing Methods obsolete.

Here is a table of all functions that are now obsolete in SimPE 0.59n and afterwards:

Obsolete Method/Property
New Version

 SimPe.Helper.WindowsRegistry.RealEP1GamePath

 SimPe.PathProvider.Global[Expansions.University].RealInstallFolder

 SimPe.Helper.WindowsRegistry.RealEP2GamePath

 SimPe.PathProvider.Global[Expansions.Nightlife].RealInstallFolder

 SimPe.Helper.WindowsRegistry.RealEP3GamePath

 SimPe.PathProvider.Global[Expansions.Business].RealInstallFolder

 SimPe.Helper.WindowsRegistry.RealSP1GamePath

 SimPe.PathProvider.Global[Expansions.FamilyFun].RealInstallFolder

 SimPe.Helper.WindowsRegistry.RealSP2GamePath

 SimPe.PathProvider.Global[Expansions.Glamour].RealInstallFolder

 SimPe.Helper.WindowsRegistry.InstalledVersions

 No longer available

 SimPe.Helper.WindowsRegistry.GameVersion

 SimPe.PathProvider.Global.GameVersion

 SimPe.Helper.WindowsRegistry.EPInstalled

 SimPe.PathProvider.Global.EPInstalled

 SimPe.Helper.WindowsRegistry.SPInstalled

 SimPe.PathProvider.Global.SPInstalled

 SimPe.Helper.WindowsRegistry.RealSavegamePath

 SimPe.PathProvider.Global.RealSavegamePath

 SimPe.Helper.WindowsRegistry.RealGamePath

 SimPe.PathProvider.Global[Expansions.BaseGame].RealInstallFolder

 SimPe.Helper.WindowsRegistry.SimsPath

 SimPe.PathProvider.Global[Expansions.BaseGame].InstallFolder

 SimPe.Helper.WindowsRegistry.NvidiaDDSTool

 SimPe.PathProvider.Global.NvidiaDDSTool

 SimPe.Helper.WindowsRegistry.StartupCheatFile

 SimPe.PathProvider.Global.StartupCheatFil

 SimPe.Helper.WindowsRegistry.NeighborhoodFolder

 SimPe.PathProvider.Global.NeighborhoodFolder

 SimPe.Helper.WindowsRegistry.BackupFolder

 SimPe.PathProvider.Global.BackupFolder

 SimPe.Helper.WindowsRegistry.NvidiaDDSPath

 SimPe.PathProvider.Global.NvidiaDDSPath

 SimPe.Helper.WindowsRegistry.SimsEP1Path

 SimPe.PathProvider.Global[Expansions.University].InstallFolder

 SimPe.Helper.WindowsRegistry.SimsEP2Path

 SimPe.PathProvider.Global[Expansions.Nightlife].InstallFolder;

 SimPe.Helper.WindowsRegistry.SimsEP3Path

 SimPe.PathProvider.Global[Expansions.Business].InstallFolder

 SimPe.Helper.WindowsRegistry.SimsSP1Path

 SimPe.PathProvider.Global[Expansions.FamilyFun].InstallFolder

 SimPe.Helper.WindowsRegistry.SimsSP2Path

 SimPe.PathProvider.Global[Expansions.Glamour].InstallFolder

 SimPe.Registry.GetEpName

 SimPe.PathProvider.Global[].Name

 SimPe.Helper.CurrentEPName

 SimPe.PathProvider.Global.Latest.Name

 SimPe.Registry.GetExecutableName

 SimPe.PathProvider.Global[].ExeName

 SimPe.Helper.WindowsRegistry.GetExecutableFolder

 SimPe.PathProvider.Global[].InstallFolder

 SimPe.Helper.WindowsRegistry.SimsApplication

 SimPe.PathProvider.Global.SimsApplication

 SimPe.Helper.WindowsRegistry.SimSavegameFolder

 SimPe.PathProvider.Global.SimSavegameFolder


At the Moment all SimPe Releases still provide those Obsolete Methods, but you should think about migrating them to their new counteroparts as stated in the table above.

If you run a Debug buidl of SimPE, you will get a SimPe.Registry.ObsoleteWarning Exceptione for each call to an obsolete Method, that might help you find the places in your source that use obsolete calls.
quaxiLink to postposted: Sun Sep 24, 2006 7:22 pm
Avator for quaxi

Member since:
 2006-04-28
Posts:
 3154
This will explain some basic operations of the SimPe.PathProvider. You basically need it to read the folders for game/ep files.

The most simple way, is to just iterate through the Global instance of the Provider, to get all paths for the base Game and all EP's installed on the System. The following code example is doing exactly that, and prints the names of all available paths to the Console.

Code "Getting the base game Path and all EP-Paths":

foreach (string path in SimPe.PathProvider.Global)
{
    Console.WriteLine(path);
}

If a user has installe the original game, university and glamour, this code would print the install folders of thsoe three applications.


The following code will walk through all known EP's (including the base game) and print some details about them to the console.
Code "Reading more Informations known EP's":

foreach (SimPe.ExpansionItem ei in SimPe.PathProvider.Global.Expansions)
{
    Console.WriteLine(ei);
}

The above code will display informations about all known EP's on the console. That includes EP's not installed on the users system.
However the SimPe.ExpansionItem class provides a property called Exists, which is only true, if the EP was found on the users system.

The following code simply displayes informations about the EP's installed on the users system:
Code "Detailed Informations about installed EP's":

foreach (SimPe.ExpansionItem ei in SimPe.PathProvider.Global.Expansions)
{
    if (ei.Exists) {
        Console.WriteLine(ei);
        Console.WriteLine("    " + ei.InstallFolder);
    }
}

The above code displays infos about all installed EP's. The first line represents overall informations, the second one is the Installation folder of the current EP.

I think that should give you a brief overview about the PathProvider, and it's capabilities. If you have any questions, fell free to ask Smiley

pljonesLink to postposted: Sun Sep 24, 2006 10:00 pm
Avator for pljones

Member since:
 2005-04-02
From:
 London, UK
Posts:
 610
So if I just want to pick up the latest xP folder, can I just use SimPe.PathProvider.Global.Latest ?
quaxiLink to postposted: Sun Sep 24, 2006 10:47 pm
Avator for quaxi

Member since:
 2006-04-28
Posts:
 3154
That will return the latest installed EP Folder, yes.

If you are after the latest known EP (either installed or not), you would use SimPe.PathProvider.Global.Expansions[SimPe.Path:provider.Flobal.Expansions.Count].
pljonesLink to postposted: Sun Oct 15, 2006 1:12 pm
Avator for pljones

Member since:
 2005-04-02
From:
 London, UK
Posts:
 610
Okay, I think I need a way to iterate backwards through the list of ExpansionItems in PathProvider.Global.

FileTable.DefaultFolders still exists and contains the Ignore attribute.  I check this to ensure I comply with a user's wishes as to which EPs to ignore.  So to pick up the latest objects.package they want to use, I go backwards through the list, ignoring as appropriate, until I find one (or use the base game one).

PathProvider.Global[] has neither .Count or .Length attributes, so I can't do this.

Actually,  PathProvider.Global doesn't appear to implement System.Collections.ICollection, which is a shame.

Oh!  PathProvider.Global.Expansions...
pljonesLink to postposted: Sun Oct 15, 2006 2:20 pm
Avator for pljones

Member since:
 2005-04-02
From:
 London, UK
Posts:
 610
Okay, it seems fine.  I'll let Inge have a version with the new code to test.


viewthread, 0, 0, SimPE-Expansion-Management-PathProvider