Workbench Plugin – Arma Reforger

From Bohemia Interactive Community
Jump to navigation Jump to search
(Add tutorial link)
(Add OnResourceContextMenu)
Line 54: Line 54:
A '''Tool''' must be named {{hl|Classname'''Tool'''}}, and its file too.
A '''Tool''' must be named {{hl|Classname'''Tool'''}}, and its file too.


=== Plugin ===
 
== Plugin ==


A plugin inherits from {{hl|WorkbenchPlugin}} and is decorated with a {{hl|WorkbenchPluginAttribute}} attribute which signature is as follow:
A plugin inherits from {{hl|WorkbenchPlugin}} and is decorated with a {{hl|WorkbenchPluginAttribute}} attribute which signature is as follow:
Line 73: Line 74:
It can also, but is not mandatory, override the {{hl|Configure}} method to display a settings entry.
It can also, but is not mandatory, override the {{hl|Configure}} method to display a settings entry.


=== Tool ===
 
== Tool ==


A tool is a system that allows for direct manipulation with a config panel available on the side.
A tool is a system that allows for direct manipulation with a config panel available on the side.
Line 83: Line 85:
It is decorated with a {{hl|WorkbenchToolAttribute}} attribute which signature is identical to {{hl|WorkbenchPluginAttribute}} (see above).
It is decorated with a {{hl|WorkbenchToolAttribute}} attribute which signature is identical to {{hl|WorkbenchPluginAttribute}} (see above).


=== Scripting ===


==== Modules ====
== Scripting ==
 
=== Modules ===
 
A plugin has access to the currently loaded game/project resources, but in order to be as adaptable as possible it should also be generic.
A plugin has access to the currently loaded game/project resources, but in order to be as adaptable as possible it should also be generic.


Line 97: Line 101:
Each module has obviously a different API - see their classes for more information.
Each module has obviously a different API - see their classes for more information.


==== Plugins ====
=== Plugins ===
 
Other plugins can be accessed through <enforce inline>aWorkbenchModule.GetPlugin(TAG_ClassNamePlugin);</enforce>.
Other plugins can be accessed through <enforce inline>aWorkbenchModule.GetPlugin(TAG_ClassNamePlugin);</enforce>.
=== Common Methods ===
See {{Link/Enfusion|armaR|WorkbenchPlugin}}.
==== Run ====
The {{hl|Run}} method is called when clicking Plugins > ''Plugin Name'' or using its shortcut if any. If this method is not overridden with a non-empty code, the plugin does not appear in this menu.
{{Feature|informative|There is no way to distinguish between clicking the plugin in the menu or using the shortcut.}}
==== RunCommandline ====
The {{hl|RunCommandline}} method is called when calling the script from {{Link|Arma Reforger:Startup Parameters}}'s {{Link|Arma Reforger:Startup Parameters#plugin|plugin}} option, e.g:
ArmaReforgerWorkbenchSteam.exe -wbModule=ScriptEditor -plugin=TAG_MyPlugin pluginArguments
==== Configure ====
The {{hl|Configure}} method is called when clicking Plugins > Settings > ''Plugin Name''. If this method is not overridden with a non-empty code, the entry does not appear in this menu.
==== OnResourceContextMenu ====
The {{hl|OnResourceContextMenu}} method is called when clicking {{Link|Arma Reforger:Resource Manager}} Resource Browser Context Menu's Plugins > ''Plugin Name''.
{{Feature|important|For the plugin to appear, {{hl|WorkbenchPluginAttribute}}'s {{hl|resourceTypes}} parameter must be defined (e.g <enforce inline>resourceTypes: { "fbx", "xob", "et" }</enforce>)





Revision as of 16:32, 26 April 2024

Workbench Plugins are script files that can be triggered from within any editor (Resource Browser, World Editor, Script Editor, etc).

Existing plugins are listed in Data\Scripts\WorkbenchGame and are sorted by directories.

Editor Directory API Class
(Module Type)
Common Plugins Data\Scripts\WorkbenchGame N/A
Resource Manager Data\Scripts\WorkbenchGame\ResourceManager ResourceManager
World Editor (Tools and Plugins) Data\Scripts\WorkbenchGame\WorldEditor WorldEditor
Particle Editor N/A N/A
Animation Editor N/A N/A
Script Editor Data\Scripts\WorkbenchGame\ScriptEditor ScriptEditor
Audio Editor N/A N/A
Behavior Editor N/A N/A
String Editor Data\Scripts\WorkbenchGame\LocalizationEditor LocalizationEditor
Procedural Animation Editor N/A N/A

A Plugin must be named ClassnamePlugin, and its file too.

A Tool must be named ClassnameTool, and its file too.


Plugin

A plugin inherits from WorkbenchPlugin and is decorated with a WorkbenchPluginAttribute attribute which signature is as follow:

WorkbenchPluginAttribute(string name, string description = "", string shortcut = "", string icon = "", array<string> wbModules = null, string category = "", int awesomeFontCode = 0)

  • name is mandatory: it is the plugin's display name
  • description
  • shortcut: none (empty string) can be defined, the plugin will then need to be triggered from the Plugin top menu
  • icon
  • wbModules: to which editors does this plugin apply (e.g wbModules = { "ScriptEditor" })
  • category: the plugins menu entry in which this plugin will find itself (e.g Plugins > Text > TutorialPlugin)
    category accepts forward slash / to create sub-categories.
  • awesomeFontCode: the FontAwesome icon associated with the plugin (see FontAwesome's Cheatsheet)

A plugin must also override either or both Run or RunCommandLine methods in order to have an impact. It can also, but is not mandatory, override the Configure method to display a settings entry.


Tool

A tool is a system that allows for direct manipulation with a config panel available on the side.

For now, Tools are only available for the World Editor, and inherit from the WorldEditorTool class.

A tool inherits from the editor-related class (e.g World Editor: WorldEditorTool) in order to be found in said editor's Tools menu.

It is decorated with a WorkbenchToolAttribute attribute which signature is identical to WorkbenchPluginAttribute (see above).


Scripting

Modules

A plugin has access to the currently loaded game/project resources, but in order to be as adaptable as possible it should also be generic.

Each Workbench module (editor) API can be accessed through the following script:

ModuleType moduleType = Workbench.GetModule(ModuleType);

Where ModuleType can be one of the classes listed at the beginning of this document, all children of the WBModuleDef class).

Each module has obviously a different API - see their classes for more information.

Plugins

Other plugins can be accessed through aWorkbenchModule.GetPlugin(TAG_ClassNamePlugin);.

Common Methods

See WorkbenchPlugin.

Run

The Run method is called when clicking Plugins > Plugin Name or using its shortcut if any. If this method is not overridden with a non-empty code, the plugin does not appear in this menu.

There is no way to distinguish between clicking the plugin in the menu or using the shortcut.

RunCommandline

The RunCommandline method is called when calling the script from Startup Parameters's plugin option, e.g:

ArmaReforgerWorkbenchSteam.exe -wbModule=ScriptEditor -plugin=TAG_MyPlugin pluginArguments

Configure

The Configure method is called when clicking Plugins > Settings > Plugin Name. If this method is not overridden with a non-empty code, the entry does not appear in this menu.

OnResourceContextMenu

The OnResourceContextMenu method is called when clicking Resource Manager Resource Browser Context Menu's Plugins > Plugin Name. {{Feature|important|For the plugin to appear, WorkbenchPluginAttribute's resourceTypes parameter must be defined (e.g resourceTypes: { "fbx", "xob", "et" })


Tutorials

See Plugin/Tool tutorials.