mountingGroup.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 GUI_INSPECTOR_MOUNTINGGROUP_H
  23. #define GUI_INSPECTOR_MOUNTINGGROUP_H
  24. #include "gui/editor/inspector/group.h"
  25. #include "console/simFieldDictionary.h"
  26. #include "T3D/components/component.h"
  27. #include "gui/controls/guiPopUpCtrlEx.h"
  28. #ifndef _GUI_INSPECTOR_TYPES_H_
  29. #include "gui/editor/guiInspectorTypes.h"
  30. #endif
  31. #ifndef _ENTITY_H_
  32. #include "T3D/entity.h"
  33. #endif
  34. class GuiInspectorMountingGroup;
  35. class GuiInspectorNodeListField : public GuiInspectorField
  36. {
  37. typedef GuiInspectorField Parent;
  38. friend class GuiInspectorMountingGroup;
  39. public:
  40. GuiInspectorNodeListField( GuiInspector *inspector, GuiInspectorGroup* parent, SimFieldDictionary::Entry* field,
  41. SimObjectPtr<Entity> target );
  42. GuiInspectorNodeListField();
  43. ~GuiInspectorNodeListField() {};
  44. DECLARE_CONOBJECT( GuiInspectorNodeListField );
  45. virtual void setData( const char* data, bool callbacks = true );
  46. virtual const char* getData( U32 inspectObjectIndex = 0 );
  47. virtual void updateValue();
  48. virtual StringTableEntry getFieldName() { return StringTable->EmptyString(); }
  49. virtual void setDoc( const char* doc );
  50. virtual void setToolTip( StringTableEntry data );
  51. virtual bool onAdd();
  52. virtual void setInspectorField( AbstractClassRep::Field *field,
  53. StringTableEntry caption = NULL,
  54. const char *arrayIndex = NULL );
  55. virtual GuiControl* constructEditControl();
  56. virtual void setValue( const char* newValue );
  57. void setTargetEntity(SimObjectPtr<Entity> target);
  58. protected:
  59. virtual void _executeSelectedCallback();
  60. protected:
  61. String mCustomValue;
  62. StringTableEntry mDoc;
  63. GuiPopUpMenuCtrl *mMenu;
  64. SimObjectPtr<Entity> mTargetEntity;
  65. };
  66. class GuiInspectorMountingGroup : public GuiInspectorGroup
  67. {
  68. private:
  69. typedef GuiInspectorGroup Parent;
  70. GuiControl* mAddCtrl;
  71. GuiPopUpMenuCtrlEx* mAddBhvrList;
  72. GuiTextCtrl *persistText;
  73. GuiButtonCtrl *reloadFile;
  74. GuiButtonCtrl *saveFile;
  75. GuiButtonCtrl *overwriteFile;
  76. GuiButtonCtrl *mBrowseButton;
  77. GuiControl *filePath;
  78. GuiControl *targetMountCtrl;
  79. GuiTextCtrl *targetMountText;
  80. GuiPopUpMenuCtrl *targetMountNode;
  81. GuiControl *mountCtrl;
  82. GuiTextCtrl *mountText;
  83. GuiPopUpMenuCtrl *mountNode;
  84. GuiInspectorNodeListField* mountNodeList;
  85. GuiInspectorNodeListField* targetMountNodeList;
  86. SimObjectPtr<GuiInspector> mParentInspector;
  87. public:
  88. DECLARE_CONOBJECT(GuiInspectorMountingGroup);
  89. GuiInspectorMountingGroup() { /*mNeedScroll=false;*/ };
  90. GuiInspectorMountingGroup( StringTableEntry groupName, SimObjectPtr<GuiInspector> parent );
  91. //-----------------------------------------------------------------------------
  92. // inspectGroup is overridden in GuiInspectorMountingGroup to inspect an
  93. // objects FieldDictionary (dynamic fields) instead of regular persistent
  94. // fields.
  95. bool inspectGroup();
  96. virtual void updateAllFields();
  97. void onMouseMove(const GuiEvent &event);
  98. // For scriptable dynamic field additions
  99. void addDynamicField();
  100. // Clear our fields (delete them)
  101. void clearFields();
  102. virtual bool resize( const Point2I &newPosition, const Point2I &newExtent );
  103. // Find an already existent field by name in the dictionary
  104. virtual SimFieldDictionary::Entry* findDynamicFieldInDictionary( StringTableEntry fieldName );
  105. AbstractClassRep::Field* findObjectComponentField(Component* target, String fieldName);
  106. protected:
  107. // create our inner controls when we add
  108. virtual bool createContent();
  109. GuiControl* buildMenuCtrl();
  110. bool buildList(Entity* ent, GuiPopUpMenuCtrl* menu);
  111. };
  112. #endif