Writing Plugins that Interface With the Virindi Bundle

From VirindiPlugins
Revision as of 12:51, 3 January 2014 by Virindi (talk | contribs)
Jump to: navigation, search

Note: This page is designed for developers writing a Decal plugin.

Plugins in the Virindi Plugin Bundle are designed to be easy to extend by other plugins. Many addon functions have wrappers for your convenience provided in the Virindi Public Code Repo.

For plugins, functionality is typically exposed by an instance of the plugin's PluginCore object. Properly calling in requires referencing the target plugin, then verifying at runtime that the target assembly is loaded and the plugin is running. To avoid a JIT exception if the user is not running the target plugin, no types from the target assembly should be referenced in an executing method or instantiated class until it is known that the target assembly is already loaded. The example wrappers do this check for you.


Virindi Views

There are two approaches you can use to support Virindi Views: require them, or support them optionally with fallback to Decal views.

Most Bundle components have fallback functionality. Fallback functionality is achieved using the MetaViewWrappers. The MetaViewWrappers abstract the concept of a view provider with a set of classes for VVS and Decal views which implement a common interface set. When you ask the ViewSystemSelector to create a new view, it returns the implementation that corresponds to what is currently running. The MetaViewWrapper interfaces are designed to be as identical as possible to the builtin Decal.Adapter classes to facilitate porting. Wrapper_WireupHelper.cs contains a helper class you can call to emulate Decal's attribute-based wireup.

The MetaViewWrapper files are licensed under the MIT License so you can easily include them in any plugin.

Note that when using the MetaViewWrappers, you must add VVS_REFERENCED as a conditional compilation symbol under Project Properties/Build.


Applicable source files:

  • ViewSystemSelector.cs (Determines what is running and constructs views)
  • Wrapper.cs (Interface definitions)
  • Wrapper_Decal.cs (Implementation for Decal views)
  • Wrapper_MyHuds.cs (Implementation for VVS views)
  • Wrapper_WireupHelper.cs (Attribute wireup helper)


Example plugins which use VVS with fallback:


Example plugins which construct VVS views directly:


Virindi Hotkey System

HotkeyWrappers.cs and VHS_Connector.cs are provided to abstract providing hotkeys to both DHS and VHS. Include them in your project, add VirindiHotkeySystem as a reference, then call HotkeyWrapperManager.Startup() and HotkeyWrapperManager.Shutdown() from your plugin's Startup and Shutdown methods. Once you call Startup() you can define hotkeys with HotkeyWrapperManager.AddHotkey() and they will be added to any hotkey system the user is running.


Example plugins which implement VHS hotkeys using HotkeyWrapperManager:


Example plugins which implement VHS hotkeys directly: