SimPE - Plugin Development
Getting started
SimPE itself can only handle basic Pacakge actions like open the Package and listing the packed Files. Nearly everything beyond those taks is provided by Plugins. The most commonly used are builtin Plugins (yes that is a paradox I know) like the SDSC Wrapper, all other Plugins are simple dll’s (with the extension plugin.dll!) stored in the Plugins Folder (like the BHAV Wrapper).
To get the Plugin Development started you need the SimPE Plugin Developer Edition form the Download Section. It contains a sepcial Build of SimPe and the Source Code for a example Wrapper.
The Concept
Before you start developing a Plugin for SimPE you need to understand the concept how SimPE uses the Plugins.
When a user selects a File in the FileList, SimPE tries to determin which Plugin it should start. There are two basic Concepts in use. First SimPE will ask the WrapperRegistry If it knows about a Wrapper that can handle the selected FileType (Is there a wrapper that can handle BHAV Files? AssignableTypes, MyPackedFileWrapper.cs), if none was found checks if a Wrapper was registred for the Signatre of the current File (Is there a Wrapper that can handle a File starting with a given Byte Sequence FileSignature, MyPackedFileWrapper.cs). If one of the test succeeds SimPE will load the matching Wrapper.
Have a look at the Sequence Diagram below, it will give you a general Idea of the Lifecycle of a Plugin. The two Objects on the Left are built into SimPE, the ones on the right are Objects your Plugin has to provide.
SimPE has a builtin WrapperRegistry it querries when it needs to find a PackedFile Wrapper. The builtin Plugins are allways registred there. All third Party Plugins have to be stored in the Plugins Folder and must have the extension plugin.dll.
SimPE will scan that Folder and look for all Files implementing the IWrapperFactory (In the Example Plugin this is done in MyWrapperFactory.cs (which implements the Interfaces through AbstractWrapperFactory).
When a Factory was found SimPE will create an Instance of it and set the LinkedRegistry and LinkedProvider Attributes. After that it will use the KnownWrappers Getter (you need to implement) to receive a List of Wrappers this Library provides. All those Wrappers will be registred.
Executing a registred Wrapper
The Section above already described how SimPE determins which registred Wrapper it should start. If it recives a valid Wrapper it will create an Instance of the Wrapper (In the example Plugin this would be the class stored in MyPackedFileWrapper.cs).
After that SimPE needs to know which GUI it should display for the File. Therfore it will call the UIHandler Getter (already implemented) which uses the CreateDefaultUIHandler Method to create a new Instance of the UI-Class (stored in MyPackedFileUI.cs).
When the Instance of the UI-Class was created it’s GUIHandle Getter will be used to determin the Panel that should be displayed as GUI.
If all this worked without Problems the ProcessData Method will be issued (already implemented). This Method will create a BinaryStream from the Data of the Packed File and send it to the Unserialize Method of the Wrapper. This ethod should process the Data and set the Attributes of the Wrapper Object to the Vlues stored in the File.
Show the Wrapper’s GUI
When the Files Data was processed by the Wrapper it needs to be presented to the User. SimPE Already has a Pointer to the GUI Panel that can be used from the previous steps. To fill this Form with Data, SimPE issues the UpdateGUI Method of the WrapperUI class (stored in MyPackedFileUI.cs). The class receives the Wrapper Object that stores the Data as Argument and should Update the GUI Elements with that Data.
After that, SimPE will show the GUI-Panel.
Commit the Wrapper Data
After the user changed the File’s Data on the GUI, the changes must be stored to the packed File. Therfor I usually use the Commit Button. Which simply writes the UI Data into the Attributes of the Wrapper. That is not sufficiant to really commit the changes to the Package. In order to really store the Data you need to call the SynchronizeUserData Method of that Wrapper. This will tell SimPE, that the User has changed the Data stored in the current File.
The SynchronizeUserData Method will inetrnaly call the Serialize Method of the Wrapper. This Method will write all Attributes back into a BinaryStream (The inverse Operation to Unserialize!). So this Method has to create a valid File again.
In the End
This Tutorial showed you how a simple SimPE Plugin works and which Methods you need to implement in the Example Plugin. So have fun developing Plugins and let me know if you need Help.



![Subscribe RSS feed [Valid RSS]](http://sims.ambertation.de/en/../img/rss2.gif)

