BsScriptSelection.h 2.9 KB

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