| Developers > SimPE Expansion Management (PathProvider) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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:
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. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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]. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Member Controls
| Developers > SimPE Expansion Management (PathProvider) | ||
| quaxi | ||
Member since: 2006-04-28 Posts: 3154 | ||
| quaxi | ||
Member since: 2006-04-28 Posts: 3154 | ||
| pljones | ||
Member since: 2005-04-02 From: London, UK Posts: 610 | ||
| quaxi | ||
Member since: 2006-04-28 Posts: 3154 | ||
| pljones | ||
Member since: 2005-04-02 From: London, UK Posts: 610 | ||
| pljones | ||
Member since: 2005-04-02 From: London, UK Posts: 610 | ||
viewthread, 0, 0, SimPE-Expansion-Management-PathProvider
