Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

GameModules

exelix edited this page Aug 23, 2018 · 9 revisions

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 excange data with the editor window. This page will offer a limited explaination, it's better to use the Odyssey and other modules as examples

GameModule implementation

Here I'll explain the purpose of each property and function:

  • ModuleName is the module name shown in the credits
  • ModelsFolder should not contain spaces, it's the folder where the extracted models of this extension are saved
  • GetClassConverters Contains a list of Types and TypeConverters to correctly display custom types in the propertygrid
  • ReservedPropNames this is an array of properties (names) the editor won't allow to remove from objects
  • ModelFieldPropNames this is an array of properties (names) that will make the editor reload the model for the current object when changed
  • IsAddListSupported if the editor allows adding new object lists.
  • IsPropertyEditingSupported if the editor allows removing or adding properties
  • ViewForm is a reference to the editor window you should set it in the InitModule function.
  • AutoHideList an 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) and NewLevel(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 the ModelsFolder path.
  • 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 if IsAddListSupported is 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

IObjList implementation

Usually it's enough to implement List. It's constructor should handle tha game's format.
ApplyChanges() should be called when saving.

ILevel implementation

This class should be able of decoding and encoding the level format.

  • LevelFiles is a dictionary<name,data> of files included in the level, can be null if unused.
  • objs is a dictionary<list name, IObjList> and contains the objects
  • LoadedLevelData is never used by the editor, can be used to store the raw level data
  • FilePath is never used by the editor, can be used to store the file path
  • HighestID must 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.

Clone this wiki locally