-
Notifications
You must be signed in to change notification settings - Fork 12
Plugin Development
EditorCore can be extended through plugins, plugins can add three different kinds of functionality:
- A Game Module allows to edit the levels for a game, it includes all the logic to handle its file formats
- A FileHandler allows to open file formats that aren't levels, such as archives or textures, it can be called by other plugins as well.
- A MenuExtension adds buttons to the various menus in the application with custom logic, these can't be called by other extensions.
A dll can include an unlimited number of extensions but the editor can use a single Game module per instance. There is no limit for other kinds of extensions.
With visual studio create a new classes library (.net dll) you might want to call the project "*something*Ext" because the final dll name must end with "Ext.dll" this way the editor can quickly load only its extensions.
Once you created the project add a reference to EditorCoreCommon.dll and create a new extension manifest:
using EditorCore.Interfaces;
...
class MyExtension: ExtensionManifest
{
public string ModuleName => "MyExtension";
public string Author => "";
public string ExtraText => null;
public IMenuExtension MenuExt => null
public IClipboardExtension ClipboardExt => null;
public bool HasGameModule => false;
public IGameModule GetNewGameModule() => null;
public IFileHander[] Handlers => null;
public void CheckForUpdates()
{
return;
}
}
The manifest doesn't need to be public as it will be loaded through reflection. You can include multiple manifests but it's not recommended.
This class will be instantiated once and shared among multiple editor windows, this means that Handlers, ClipboardExt and MenuExt may be called multiple times, to reduce the memory usage it's adviced to use instantiate only once the values. Examples from ByamlExt.cs:
public IFileHander[] Handlers { get; } = new IFileHander[] { new BymlFileHandler() };
or
MenuExt _menuExt = new MenuExt();
public IMenuExtension MenuExt => _menuExt;
GetNewGameModule() instead can return a new module every time, depending on its implementation, if it's not needed avoid allocating multiple objects.