-
Notifications
You must be signed in to change notification settings - Fork 12
GameModules
GameModules are the hardest plugin to implement, their job is to open and save levels, instantiate new objects and properties. A GameModule to work needs at least three other classes: ILevelObj, ILevel and IObjList implementations. These interfaces are used to exchange data with the editor window. This page contains a brief explanation of the functions and properties of these interfaces, when implementing a class you should also use the Odyssey and other simpler modules as examples
Here I'll explain the purpose of each property and function:
-
ModuleNameis the module name shown in the credits -
ModelsFoldershould not contain spaces, it's the folder where the extracted models of this extension are saved -
GetClassConvertersContains a list of Types and TypeConverters to correctly display custom types in the propertygrid -
ReservedPropNamesthis is an array of properties (names) the editor won't allow to remove from objects -
ModelFieldPropNamesthis is an array of properties (names) that will make the editor reload the model for the current object when changed -
IsAddListSupportedif the editor allows adding new object lists. -
IsPropertyEditingSupportedif the editor allows removing or adding properties -
ViewFormis a reference to the editor window you should set it in the InitModule function. -
AutoHideListan array of list names that will automatically set to hidden when loading a level -
InitModule(...)called as soon as the editor window is initialized up, here you should set the ViewForm property and register MenuExtensions related to your module. -
FormLoaded()called after the editor window is shown, here you should do your startup checks like setup your base models -
ParseArgs(string[] Args)the editor form args are handled here -
LoadLevel(string path = null)andNewLevel(string path = null)open or create a level, if the path is null should show an OpenFileDialog, return your ILevel implementation or null if the user cancelled -
CreateObjList(string name, IList<dynamic> baseList)returns a new instance of your IObjList implementation, baseList is usually a list of objects -
NewObject()should show a dialog for creating a new instance of your implementation of ILevelObj, return null if the user cancels -
SaveLevel(ILevel level)save the level (you should have stored the path of the loaded level) -
SaveLevelAs(ILevel level)shows a SaveFileDialog and saves the level -
ConvertModelFile(string ObjName, string path)converts a model from the game's format to obj, ObjName is the name of the object, finding the actual model path is the extension's job. path is where the obj should be saved. Returns false if the conversion failed -
GetPlaceholderModel(string ObjName, string ListName)returns the name of a placeholder obj model for an object called ObjName and in the ListName list (the blue cubes in odyssey editor). Only the name is returned, the editor will assume the file is inside theModelsFolderpath. -
OpenLevelFile(string name, Stream file)open a file inside the level files (a property of ILevelObj) if returns false a FileHandler will be used. Return false if unimplemented. -
AddObjList(ILevel level)should show a dialog to add a new IObjList to the current level and return its name. Will never be called ifIsAddListSupportedis false -
EditChildrenNode(ILevelObj obj)Is called to edit the children objects of an object, should call IEditorFormContext.EditList() which will call GameModule.CreateObjList() -
GetNewProperty(dynamic target)returns a new property to be added to the target object (do not add it, it will be done by the editor). Item1 is the name Item2 is the property value
Usually it's enough to implement List. It's constructor should handle tha game's format.
ApplyChanges() should be called when saving.
This class should be able of decoding and encoding the level format.
-
LevelFilesis a dictionary<name,data> of files included in the level, can be null if unused. -
objsis a dictionary<list name, IObjList> and contains the objects -
LoadedLevelDatais never used by the editor, can be used to store the raw level data -
FilePathis never used by the editor, can be used to store the file path -
HighestIDmust be set to the highest id found in the level, it's used and incremented by the editor when adding new objects, if unused stub it in the ILevelObj implementation -
HasList(string name)usually returns objs.ContainsKey(name) -
FindListByObj(ILevelObj o)returns the ObjList that contains the object, can return null.
this class has to parse the object data and serve it in a way the editor can display.
-
ReadOnlyif is true the object is not actually part of the level, it can't be selected nor dragged (example: mario kart tracks aren't part of the level, are implicitly loaded by the game) -
Propa dictionary containing the properties of the object, to be properly shown in the PropertyGrid it needs this attribute:[TypeConverter(typeof(DictionaryConverter))] -
this[string name]a safe way of retrieving a property, if getting a non-existent property return null, if setting a non-existent property add it. -
PosRotandScalethe transform of the object in game units -
IDthe object's id as string -
ModelNamethe name that will be used for ConvertModelFile, can be different from Name in some games, if not just return Name. -
ID_intthe object's id as integer -
ModelView_PosModelView_RotModelView_Scalethe transform of the object in the 3d view coordinates -
transformthe transform of the object in game units
These classes can extend the GameModule functionality and are not needed for a basic module
This class is both an object and a list of objects, the objects it contains are its points, to draw the actual path the editor calls the Points getter which should return an array of points in the 3d view coordinates. Its children can be edited like a list from EditChildrenNode.
This shows a menu when clicking on the 3d view and pressing O.
-
InitOptionsMenu(ref ContextMenuStrip baseMenu)is called when the form is loaded, baseMenu is the options menu, you should add your buttons at the bottom -
OptionsMenuOpening(ILevelObj clickedObj)is called before opening the menu, the parameter is the selected object the other functions are not implemented in the current release.