BsScriptSelection.h 2.9 KB

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