BsScriptSelection.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include "BsScriptEditorPrerequisites.h"
  3. #include "BsScriptObject.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Interop class between C++ & CLR for Selection.
  8. */
  9. class BS_SCR_BED_EXPORT ScriptSelection : public ScriptObject<ScriptSelection>
  10. {
  11. public:
  12. SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "Selection");
  13. /**
  14. * @brief Hooks up selection callbacks. Must be called on library load.
  15. */
  16. static void startUp();
  17. /**
  18. * @brief Destroys selection callbacks. Must be called before library is unloaded.
  19. */
  20. static void shutDown();
  21. private:
  22. ScriptSelection(MonoObject* instance);
  23. /**
  24. * @brief Triggered when selection has changed.
  25. *
  26. * @param sceneObject Newly selected scene objects. This will be empty if no scene objects are
  27. * selected or if selection hasn't changed.
  28. * @param resPaths Paths to newly selected resources. This will be empty if no resources are
  29. * selected or if selection hasn't changed.
  30. */
  31. static void onSelectionChanged(const Vector<HSceneObject>& sceneObjects, const Vector<Path>& resPaths);
  32. /**
  33. * @brief Triggered when ping action is requested for the resource at the specified path.
  34. */
  35. static void onResourcePing(const Path& resPath);
  36. /**
  37. * @brief Triggered when ping action is requested for the specified scene object.
  38. */
  39. static void onSceneObjectPing(const HSceneObject& sceneObject);
  40. static HEvent OnSelectionChangedConn;
  41. static HEvent OnPingResourceConn;
  42. static HEvent OnPingSceneObjectConn;
  43. /************************************************************************/
  44. /* CLR HOOKS */
  45. /************************************************************************/
  46. typedef void(__stdcall *OnSelectionChangedThunkDef) (MonoArray*, MonoArray*, MonoException**);
  47. typedef void(__stdcall *OnPingResourceThunkDef) (MonoString*, MonoException**);
  48. typedef void(__stdcall *OnPingSceneObjectThunkDef) (MonoObject*, MonoException**);
  49. static OnSelectionChangedThunkDef OnSelectionChangedThunk;
  50. static OnPingResourceThunkDef OnPingResourceThunk;
  51. static OnPingSceneObjectThunkDef OnPingSceneObjectThunk;
  52. static void internal_GetSceneObjectSelection(MonoArray** selection);
  53. static void internal_SetSceneObjectSelection(MonoArray* selection);
  54. static void internal_GetResourceUUIDSelection(MonoArray** selection);
  55. static void internal_SetResourceUUIDSelection(MonoArray* selection);
  56. static void internal_GetResourcePathSelection(MonoArray** selection);
  57. static void internal_SetResourcePathSelection(MonoArray* selection);
  58. static void internal_PingResource(MonoString* resourcePath);
  59. static void internal_PingSceneObject(MonoObject* so);
  60. };
  61. }