IPlugin.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. // Description : To add plug-in to the Editor create a new DLL with class implementation derived from IPlugin
  9. #ifndef CRYINCLUDE_EDITOR_INCLUDE_IPLUGIN_H
  10. #define CRYINCLUDE_EDITOR_INCLUDE_IPLUGIN_H
  11. #pragma once
  12. #include <IEditor.h>
  13. // forbid plugins from loading across debug and release:
  14. #define SANDBOX_PLUGIN_SYSTEM_BASE_VERSION 1
  15. #if defined(_DEBUG)
  16. #define SANDBOX_PLUGIN_SYSTEM_VERSION (100000 + SANDBOX_PLUGIN_SYSTEM_BASE_VERSION)
  17. #else
  18. #define SANDBOX_PLUGIN_SYSTEM_VERSION SANDBOX_PLUGIN_SYSTEM_BASE_VERSION
  19. #endif
  20. // Interface for instantiating the plugin for the editor
  21. struct IPlugin
  22. {
  23. enum EError
  24. {
  25. eError_None = 0,
  26. eError_VersionMismatch = 1
  27. };
  28. virtual ~IPlugin() = default;
  29. // Releases plugin.
  30. virtual void Release() = 0;
  31. //! Show a modal about dialog / message box for the plugin
  32. virtual void ShowAbout() = 0;
  33. //! Return the GUID of the plugin
  34. virtual const char* GetPluginGUID() = 0;
  35. virtual DWORD GetPluginVersion() = 0;
  36. //! Return the human readable name of the plugin
  37. virtual const char* GetPluginName() = 0;
  38. //! Asks if the plugin can exit now. This might involve asking the user if he wants to save
  39. //! data. The plugin is only supposed to ask for unsaved data which is not serialize into
  40. //! the editor project file. When data is modified which is saved into the project file, the
  41. //! plugin should call IEditor::SetDataModified() to make the editor ask
  42. virtual bool CanExitNow() = 0;
  43. //! this method is called when there is an event triggered inside the editor
  44. virtual void OnEditorNotify(EEditorNotifyEvent aEventId) = 0;
  45. };
  46. // Initialization structure
  47. struct PLUGIN_INIT_PARAM
  48. {
  49. IEditor* pIEditorInterface;
  50. int pluginVersion;
  51. IPlugin::EError outErrorCode;
  52. };
  53. // Plugin Settings structure
  54. struct SPluginSettings
  55. {
  56. // note: the pluginVersion in PLUGIN_INIT_PARAM denotes the version of the plugin manager
  57. // whereas this denotes the version of the individual plugin.
  58. // future: manage plugin versions.
  59. int pluginVersion;
  60. bool autoLoad;
  61. };
  62. // Factory API
  63. extern "C"
  64. {
  65. PLUGIN_API IPlugin* CreatePluginInstance(PLUGIN_INIT_PARAM* pInitParam);
  66. PLUGIN_API void QueryPluginSettings(SPluginSettings& settings);
  67. }
  68. #endif // CRYINCLUDE_EDITOR_INCLUDE_IPLUGIN_H