DO/Modding/Tools/Wh32Edit/Plugins

From Dark Omen Wiki

Jump to: navigation, search

Contents

Introduction

This page just contains some thoughts and is subject to change. Revision 25 implements the first version of a Regiment Plugin Loader.

Because Qt has an integrated Multi Plattform Plugin Loader I had some thoughts about improving Wh32Edit by supporting custom C++ plugins.

Possible Plugin Apis

Export Plugins

Plugins integrated at File->Export->-Menu. As an example see the Smf Clipboard Export in the old Wh32Edit version. Such export jobs could be expanded by using Plugins.

Regiment Panel Plugins

Plugins that add new panels when editing regiments (new Panels besides General, Leader/Unit and Attributes) or plugins that replace the old...

Header Panel Plugins

Same as for Regiment but for Header editing

Savegame Panel Plugins

Same as for Regiment but for Savegame Header and Footer editing

Interface

Export Plugins

class ExportPluginInterface : public QObject
{   
public:
    ExportPluginInterface() {}
    ~ExportPluginInterface() {}
 
    /**
     * Called if the Menu Entry of the Plugin the Export menu has been clicked.
     * It should do things like exporting things to the clipboard (and display
     * a MsgBox e.g.)
     * @param armParser ARMParser used by the current active army
     * @param selectedRegiment Current selected regiment in the Wh32Edit listview.
     * @param database Database associated with the current army
     * @return <0 Error during export
     */
    virtual int export(ARMParser &armParser, arm::Regiment& selectedRegiment, 
                           Database &database) = 0;
};

The Export Plugins should overload setName() of QObject, this name will be displayed in the Menu.

Regiment Panel Plugins

class RegimentPanelInterface : public QWidget
{
 
public:
    RegimentPanelInterface (QWidget *parent = 0) {}
    ~RegimentPanelInterface () {}
 
    /**
     * Called if a new Regiment has been selected.
     * The Widget should update all of it's controls.
     * @param selectedRegiment Current selected regiments in the Wh32Edit listview.
     */
    virtual void setRegiment(arm::Regiment& selectedRegiment) = 0;
 
    /**
     * Called if the Database has been changed.
     * All controls on this widget supporting databases (ComboBox) should update
     * there lists.
     * @param db The new database
     */
    virtual void setDatabase(Database& db) {}
 
    /**
     * Called by the Plugin Loader on creation.
     * The implementation should return a new instance of the Panel.
     */
    virtual RegimentPanelInterface* createInstance(QWidget *parent = 0) = 0;
};

The name returned by widgetName() will be used as the Label for the Tab.

Special LineEdit- (TextFields), SpinBox- and ComboBox classes are provided by Wh32Edit to make managing Armies easier.

See also

QPluginLoader

How to create Qt Plugins

Echo plugin example

Personal tools
communication