Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************
- * AGSUtility *
- * *
- * Author: Steven Poulton *
- * *
- * Date: 09/01/2011 *
- * *
- * Description: An AGS Plugin to allow FMOD Integration *
- * *
- ***********************************************************/
- #pragma region Defines_and_Includes
- #define MIN_EDITOR_VERSION 1
- #define MIN_ENGINE_VERSION 3
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
- #define REGISTER(x) engine->RegisterScriptFunction(#x, (void *) (x));
- #define STRINGIFY(s) STRINGIFY_X(s)
- #define STRINGIFY_X(s) #s
- #define THIS_IS_THE_PLUGIN
- #include "agsplugin.h"
- #include "AGSDelegate.h"
- #pragma endregion
- // The standard Windows DLL entry point
- BOOL APIENTRY DllMain( HANDLE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved) {
- switch (ul_reason_for_call) {
- case DLL_PROCESS_ATTACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
- //define engine
- IAGSEngine *engine = 0;
- ManagedAGSDelegateInterface *gAGSDelInterface;
- ManagedAGSDelegateReader *gAGSDelReader;
- //==============================================================================
- // ***** Design time *****
- IAGSEditor *editor; // Editor interface
- const char *ourScriptHeader =
- "managed struct Delegate {\r\n"
- " import void Run();\r\n"
- " import static Delegate* Create(String name);\r\n"
- "};\r\n";
- #pragma region Editor Interop
- LPCSTR AGS_GetPluginName()
- {
- return ("AGSDelegates");
- }
- int AGS_EditorStartup(IAGSEditor *lpEditor)
- {
- // User has checked the plugin to use it in their game
- if (lpEditor->version < MIN_EDITOR_VERSION)
- return (-1);
- editor = lpEditor;
- editor->RegisterScriptHeader(ourScriptHeader);
- // Return 0 to indicate success
- return (0);
- }
- void AGS_EditorShutdown()
- {
- editor->UnregisterScriptHeader(ourScriptHeader);
- }
- void AGS_EditorProperties(HWND parent) //*** optional ***
- {
- }
- int AGS_EditorSaveGame(char *buffer, int bufsize) //*** optional ***
- {
- return (0);
- }
- void AGS_EditorLoadGame(char *buffer, int bufsize) //*** optional ***
- {
- }
- #pragma endregion
- AGSDelegate *CreateDelegate(const char *name)
- {
- AGSDelegate *del = new AGSDelegate(engine, name);
- engine->RegisterManagedObject(del, gAGSDelInterface);
- return del;
- }
- void RunDelegate(AGSDelegate *obj)
- {
- obj->Run();
- }
- #pragma region Engine
- void InitInterfaces()
- {
- gAGSDelInterface = new ManagedAGSDelegateInterface();
- gAGSDelReader = new ManagedAGSDelegateReader(engine, gAGSDelInterface);
- }
- void AGS_EngineStartup(IAGSEngine *lpEngine)
- {
- engine = lpEngine;
- // Make sure it's got the version with the features we need
- if (engine->version < MIN_ENGINE_VERSION)
- engine->AbortGame("Plugin needs engine version " STRINGIFY(MIN_ENGINE_VERSION) " or newer.");
- InitInterfaces();
- //engine->RequestEventHook(AGSE_SAVEGAME);
- //register functions
- engine->AddManagedObjectReader(ManagedAGSDelegateInterface::typeName, gAGSDelReader);
- engine->RegisterScriptFunction("Delegate::Create^1", CreateDelegate);
- engine->RegisterScriptFunction("Delegate::Run", RunDelegate);
- }
- void AGS_EngineShutdown()
- {
- }
- int AGS_EngineOnEvent(int event, int data) //*** optional ***
- {
- // Return 1 to stop event from processing further (when needed)
- return (0);
- }
- //int AGS_EngineDebugHook(const char *scriptName,
- // int lineNum, int reserved) //*** optional ***
- //{
- // // Can be used to debug scripts, see documentation
- //}
- //
- //void AGS_EngineInitGfx(const char *driverID, void *data) //*** optional ***
- //{
- // // This allows you to make changes to how the graphics driver starts up.
- // // See documentation
- //}
- #pragma endregion
Add Comment
Please, Sign In to add comment