guiDecalEditorCtrl.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUIDECALEDITORCTRL_H_
  23. #define _GUIDECALEDITORCTRL_H_
  24. #ifndef _EDITTSCTRL_H_
  25. #include "gui/worldEditor/editTSCtrl.h"
  26. #endif
  27. #ifndef _UNDO_H_
  28. #include "util/undo.h"
  29. #endif
  30. #ifndef _DECALINSTANCE_H_
  31. #include "T3D/decal/decalInstance.h"
  32. #endif
  33. class GameBase;
  34. class Gizmo;
  35. struct RayInfo;
  36. class DecalInstance;
  37. class DecalData;
  38. class GuiDecalEditorCtrl : public EditTSCtrl
  39. {
  40. typedef EditTSCtrl Parent;
  41. public:
  42. GuiDecalEditorCtrl();
  43. ~GuiDecalEditorCtrl();
  44. DECLARE_CONOBJECT(GuiDecalEditorCtrl);
  45. // SimObject
  46. bool onAdd();
  47. static void initPersistFields();
  48. static void consoleInit();
  49. void onEditorDisable();
  50. // GuiControl
  51. virtual bool onWake();
  52. virtual void onSleep();
  53. virtual void onRender(Point2I offset, const RectI &updateRect);
  54. // EditTSCtrl
  55. void get3DCursor( GuiCursor *&cursor, bool &visible, const Gui3DMouseEvent &event_ );
  56. void on3DMouseDown(const Gui3DMouseEvent & event);
  57. void on3DMouseUp(const Gui3DMouseEvent & event);
  58. void on3DMouseMove(const Gui3DMouseEvent & event);
  59. void on3DMouseDragged(const Gui3DMouseEvent & event);
  60. void on3DMouseEnter(const Gui3DMouseEvent & event);
  61. void on3DMouseLeave(const Gui3DMouseEvent & event);
  62. void on3DRightMouseDown(const Gui3DMouseEvent & event);
  63. void on3DRightMouseUp(const Gui3DMouseEvent & event);
  64. void updateGuiInfo();
  65. void renderScene(const RectI & updateRect);
  66. void renderGui(Point2I offset, const RectI &updateRect);
  67. /// Find clicked point on "static collision" objects.
  68. bool getRayInfo( const Gui3DMouseEvent &event, RayInfo *rInfo );
  69. void selectDecal( DecalInstance *inst );
  70. void deleteSelectedDecal();
  71. void deleteDecalDatablock( String lookupName );
  72. void retargetDecalDatablock( String dbFrom, String dbTo );
  73. void setMode( String mode, bool sourceShortcut );
  74. void forceRedraw( DecalInstance * decalInstance );
  75. void setGizmoFocus( DecalInstance * decalInstance );
  76. public:
  77. String mMode;
  78. DecalInstance *mSELDecal;
  79. DecalInstance *mHLDecal;
  80. static bool smRenderDecalPixelSize;
  81. protected:
  82. bool mPerformedDragCopy;
  83. DecalData *mCurrentDecalData;
  84. Vector<Point3F> mSELEdgeVerts;
  85. Vector<Point3F> mHLEdgeVerts;
  86. void _renderDecalEdge( const Vector<Point3F> &verts, const ColorI &color );
  87. };
  88. //Decal Instance Create Undo Actions
  89. class DICreateUndoAction : public UndoAction
  90. {
  91. typedef UndoAction Parent;
  92. public:
  93. GuiDecalEditorCtrl *mEditor;
  94. protected:
  95. /// The captured object state.
  96. DecalInstance mDecalInstance;
  97. S32 mDatablockId;
  98. public:
  99. DECLARE_CONOBJECT( DICreateUndoAction );
  100. static void initPersistFields();
  101. DICreateUndoAction( const UTF8* actionName = "Create Decal " );
  102. virtual ~DICreateUndoAction();
  103. void addDecal(const DecalInstance& decal);
  104. // UndoAction
  105. virtual void undo();
  106. virtual void redo();
  107. };
  108. //Decal Instance Delete Undo Actions
  109. class DIDeleteUndoAction : public UndoAction
  110. {
  111. typedef UndoAction Parent;
  112. public:
  113. GuiDecalEditorCtrl *mEditor;
  114. protected:
  115. /// The captured object state.
  116. DecalInstance mDecalInstance;
  117. S32 mDatablockId;
  118. public:
  119. DECLARE_CONOBJECT( DIDeleteUndoAction );
  120. static void initPersistFields();
  121. DIDeleteUndoAction( const UTF8* actionName = "Delete Decal" );
  122. virtual ~DIDeleteUndoAction();
  123. ///
  124. void deleteDecal(const DecalInstance& decal);
  125. // UndoAction
  126. virtual void undo();
  127. virtual void redo();
  128. };
  129. //Decal Datablock Delete Undo Actions
  130. class DBDeleteUndoAction : public UndoAction
  131. {
  132. typedef UndoAction Parent;
  133. public:
  134. GuiDecalEditorCtrl *mEditor;
  135. S32 mDatablockId;
  136. protected:
  137. // The captured decalInstance states
  138. Vector<DecalInstance> mDecalInstanceVec;
  139. public:
  140. DECLARE_CONOBJECT( DBDeleteUndoAction );
  141. static void initPersistFields();
  142. DBDeleteUndoAction( const UTF8* actionName = "Delete Decal Datablock" );
  143. virtual ~DBDeleteUndoAction();
  144. void deleteDecal(const DecalInstance& decal);
  145. // UndoAction
  146. virtual void undo();
  147. virtual void redo();
  148. };
  149. //Decal Datablock Retarget Undo Actions
  150. class DBRetargetUndoAction : public UndoAction
  151. {
  152. typedef UndoAction Parent;
  153. public:
  154. GuiDecalEditorCtrl *mEditor;
  155. S32 mDBFromId;
  156. S32 mDBToId;
  157. protected:
  158. // The captured decalInstance states
  159. Vector<DecalInstance*> mDecalInstanceVec;
  160. public:
  161. DECLARE_CONOBJECT( DBRetargetUndoAction );
  162. static void initPersistFields();
  163. DBRetargetUndoAction( const UTF8* actionName = "Retarget Decal Datablock" );
  164. virtual ~DBRetargetUndoAction();
  165. void retargetDecal( DecalInstance* decal );
  166. // UndoAction
  167. virtual void undo();
  168. virtual void redo();
  169. };
  170. #endif // _GUIDECALEDITORCTRL_H_