-
Notifications
You must be signed in to change notification settings - Fork 9
EnginePluginDesign timeAPI
Since the AGS Editor is currently windows only, you can use a macro to not include the design-time parts when building the plugin for other platforms.
Your DLL should have the following entry points:
The standard Windows DLL entry point, you know how to use this.
This will get called once when the editor first starts up, and once when it finally shuts down. The plugins are kept in memory at all times, so you will not get lots of load-unloads during the editor's lifetime.
DLLEXPORT LPCSTR AGS_GetPluginName ();
Called by the editor to retrieve a user-friendly name for the plugin. This is the very first function the editor calls as soon as it starts up, in order to build its list of plugins.
Normally, you will implement this as a simple one-line function that returns a static string with the plugin description.
DLLEXPORT int AGS_EditorStartup (IAGSEditor *lpEditor);
Called by the editor when the user selects to add the plugin to their game. This function should perform any initialization necessary for design-time operation.
The parameter passed to the function is a pointer to the editor interface, which your plugin can execute various methods on to communicate with the editor.
In particular, this function should register any additions to the script header files that it uses.
You should return 0 to indicate success; any other value indicates that a problem occurred, and the editor will not attempt any further communication with the plugin unless the user tries to start it again.
DLLEXPORT void AGS_EditorShutdown ();
Called by the editor when the user elects to remove the plugin from their game. The plugin should un-register anything that it registered at startup, since if the user later decides to add the plugin again, the Startup function will be run again.
DLLEXPORT void AGS_EditorProperties (HWND parent);
(Optional - plugin does not have to have this function)
Called by the editor when the user highlights the plugin and clicks the Properties button. You can use this to display a copyright message, or allow the user to set options for your plugin, for instance. This will only be called when the plugin is selected (i.e. EditorStartup
has been called).
The parameter gives you the parent window handle you should use if you want to pop up a dialog. You should make any dialogs modal so that this function does not return until they are dismissed.
DLLEXPORT int AGS_EditorSaveGame (char *buffer, int bufsize);
(Optional - plugin does not have to have this function)
Called by the editor when the current game is saved to disk. This will only be called if your plugin is selected into the current game.
buffer
is a byte array of size bufsize
, which you can write any data to as you see fit. The buffer will then be written into the user's game file. You must return the number of bytes actually used, which can be up to and including bufsize
.
If you need more storage space than bufsize
provides, you will have to write your own separate file out to disk, store in the registry, or do some compression.
The current version of AGS gives you a 5120 byte buffer, but future versions may increase or decrease this amount, so be sure to check bufsize
before using it.
You will probably only need this function if you have some options in the Properties that the user can set, otherwise there's no need to use it.
DLLEXPORT void AGS_EditorLoadGame (char *buffer, int bufsize);
(Optional - plugin does not have to have this function)
Called by the editor when a game is loaded from disk. This will only be called if your plugin is selected into the new game.
buffer
is a byte array of size bufsize
, which contains any data you wrote out in a previous session with AGS_EditorSaveGame
. Note that the buffer is not persistent - when your function returns, the buffer is freed, so you should copy any important data you need to elsewhere.
DLLEXPORT int AGS_PluginV2 ();
This entry point is never called by AGS, but it must be present and exported from your DLL in order to let AGS know that it is a valid plugin that supports version 5 and later of the engine interface. If you don't export this, AGS won't load the plugin.
This interface is provided to the plugin as the way of calling back to the editor. It provides these members:
int version;
Specifies the interface version. You should check this to determine what version of the editor is being used, because certain interface methods will have been added in later versions, and attempting to use them with an earlier version will crash the system.
The current version number for the latest version of AGS is 1.
HWND GetEditorHandle ();
Returns the window handle to the AGS Editor's main frame. This might be useful if you wanted to add extra menu options to the editor, for example.
Added in version: 1
HWND GetWindowHandle ();
Returns the window handle to the current active window. If you want to pop up a messagebox, for instance, you should always use this handle as the parent, because using the main frame's handle would un-modal any dialog boxes currently displayed.
Added in version: 1
void RegisterScriptHeader (const char * header);
Adds the contents of header
to the built-in script header, which is compiled into every script in the game. The idea here is that you would use this to register your text script functions, for example:
char *header = "import int Add (int, int);
import int Substract(int, int); ";
RegisterScriptHeader (header);
Note that the editor only keeps a reference to this string rather than a copy, so do not overwrite or destroy the string after calling this function.
Added in version: 1
void UnregisterScriptHeader (const char *header);
Unregisters the specified script header, which you earlier used with RegisterScriptHeader
.
Added in version: 1
Getting Started in AGS
Editor
- New Game templates
- Editor Preferences
- General Settings
- Default Setup
- Colours Editor
- Room Editor
- Character Editor
- Cursor Editor
- Dialog Editor
- Font Preview
- GUI Editor
- Inventory Items Editor
- View Editor
- Sprite Manager
- Music and sound
- Voice speech
- Script Modules
- System limits
- Log Panel
- Plugins
- Other Features
Engine
Scripting
- Scripting Tutorial
- Scripting Language
-
Scripting API
- Script API Overview
- Standard Constants
- Standard Enumerated Types
- Standard Types
- Game variables
- Global arrays
- Global event handlers
- repeatedly_execute / repeatedly_execute_always
- Custom dialog options rendering
- Global functions: general
- Global functions: message display
- Global functions: multimedia actions
- Global functions: palette operations
- Global functions: room actions
- Global functions: screen effects
- Global functions: wait
- AudioChannel functions and properties
- AudioClip functions and properties
- Camera functions and properties
- Character functions and properties
- DateTime functions and properties
- Dialog functions and properties
- DialogOptionsRenderingInfo functions and properties
- Dictionary functions and properties
- DrawingSurface functions and properties
- DynamicSprite functions and properties
- File functions and properties
- Game functions and properties
- GUI functions and properties
- GUI control functions and properties
- GUI Button functions and properties
- GUI InvWindow functions and properties
- GUI Label functions and properties
- GUI List Box functions and properties
- GUI Slider properties
- GUI Text Box functions and properties
- Hotspot functions and properties
- Inventory item functions and properties
- Maths functions and properties
- Mouse functions and properties
- Object functions and properties
- Overlay functions and properties
- Parser functions
- Region functions and properties
- Room functions and properties
- Screen functions and properties
- Set functions and properties
- Speech functions and properties
- String functions
- System functions and properties
- TextWindowGUI functions and properties
- ViewFrame functions and properties
- Viewport functions and properties
- Obsolete Script API
- Event Types
- Key code table
- Audio in script
Legal Notice
Getting in touch
Misc