Exemplo n.º 1
0
        public NativePlugin(string fileName)
        {
            _editorInterface.version = 1;
            _editorInterface.pluginID = NextPluginID;
            NextPluginID++;
            _editorInterface.GetEditorHandle = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.GetEditorHandleDelegate);
            _editorInterface.GetWindowHandle = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.GetWindowHandleDelegate);
            _editorInterface.RegisterScriptHeader = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.RegisterScriptHeaderDelegate);
            _editorInterface.UnregisterScriptHeader = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.UnregisterScriptHeaderDelegate);

            _dllHandle = NativeProxy.LoadLibrary(fileName);
            if (_dllHandle == IntPtr.Zero)
            {
                throw new AGSEditorException("Unable to load plugin '" + fileName + "'. It may depend on another DLL that is missing.");
            }

            _getPluginName = (AGS_GetPluginName)GetManagedDelegateForFunction("AGS_GetPluginName", typeof(AGS_GetPluginName), true);
            _editorStartup = (AGS_EditorStartup)GetManagedDelegateForFunction("AGS_EditorStartup", typeof(AGS_EditorStartup), true);
            _editorShutdown = (AGS_EditorShutdown)GetManagedDelegateForFunction("AGS_EditorShutdown", typeof(AGS_EditorShutdown), true);
            _editorProperties = (AGS_EditorProperties)GetManagedDelegateForFunction("AGS_EditorProperties", typeof(AGS_EditorProperties), false);
            _editorSaveGame = (AGS_EditorSaveGame)GetManagedDelegateForFunction("AGS_EditorSaveGame", typeof(AGS_EditorSaveGame), false);
            _editorLoadGame = (AGS_EditorLoadGame)GetManagedDelegateForFunction("AGS_EditorLoadGame", typeof(AGS_EditorLoadGame), false);

			_pluginName = Marshal.PtrToStringAnsi(_getPluginName());
            _fileName = fileName;
            PluginLookup.Add(_editorInterface.pluginID, this);
        }
Exemplo n.º 2
0
        public NativePlugin(string fileName)
        {
            _editorInterface.version  = 1;
            _editorInterface.pluginID = NextPluginID;
            NextPluginID++;
            _editorInterface.GetEditorHandle        = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.GetEditorHandleDelegate);
            _editorInterface.GetWindowHandle        = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.GetWindowHandleDelegate);
            _editorInterface.RegisterScriptHeader   = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.RegisterScriptHeaderDelegate);
            _editorInterface.UnregisterScriptHeader = Marshal.GetFunctionPointerForDelegate(NativePluginCallbacks.UnregisterScriptHeaderDelegate);

            _dllHandle = NativeProxy.LoadLibrary(fileName);
            if (_dllHandle == IntPtr.Zero)
            {
                throw new AGSEditorException("Unable to load plugin '" + fileName + "'. It may depend on another DLL that is missing.");
            }

            _getPluginName    = (AGS_GetPluginName)GetManagedDelegateForFunction("AGS_GetPluginName", typeof(AGS_GetPluginName), true);
            _editorStartup    = (AGS_EditorStartup)GetManagedDelegateForFunction("AGS_EditorStartup", typeof(AGS_EditorStartup), true);
            _editorShutdown   = (AGS_EditorShutdown)GetManagedDelegateForFunction("AGS_EditorShutdown", typeof(AGS_EditorShutdown), true);
            _editorProperties = (AGS_EditorProperties)GetManagedDelegateForFunction("AGS_EditorProperties", typeof(AGS_EditorProperties), false);
            _editorSaveGame   = (AGS_EditorSaveGame)GetManagedDelegateForFunction("AGS_EditorSaveGame", typeof(AGS_EditorSaveGame), false);
            _editorLoadGame   = (AGS_EditorLoadGame)GetManagedDelegateForFunction("AGS_EditorLoadGame", typeof(AGS_EditorLoadGame), false);

            _pluginName = Marshal.PtrToStringAnsi(_getPluginName());
            _fileName   = fileName;
            PluginLookup.Add(_editorInterface.pluginID, this);
        }