guiMissionAreaEditor.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. #include "gui/worldEditor/guiMissionAreaEditor.h"
  23. #include "gui/core/guiCanvas.h"
  24. #include "console/engineAPI.h"
  25. IMPLEMENT_CONOBJECT(GuiMissionAreaEditorCtrl);
  26. ConsoleDocClass( GuiMissionAreaEditorCtrl,
  27. "@brief Specialized GUI used for editing the MissionArea in a level\n\n"
  28. "Editor use only.\n\n"
  29. "@internal"
  30. );
  31. GuiMissionAreaEditorCtrl::GuiMissionAreaEditorCtrl()
  32. {
  33. }
  34. GuiMissionAreaEditorCtrl::~GuiMissionAreaEditorCtrl()
  35. {
  36. }
  37. bool GuiMissionAreaEditorCtrl::onAdd()
  38. {
  39. if( !Parent::onAdd() )
  40. return false;
  41. return true;
  42. }
  43. void GuiMissionAreaEditorCtrl::initPersistFields()
  44. {
  45. docsURL;
  46. Parent::initPersistFields();
  47. }
  48. void GuiMissionAreaEditorCtrl::get3DCursor( GuiCursor *&cursor,
  49. bool &visible,
  50. const Gui3DMouseEvent &event_ )
  51. {
  52. //cursor = mAddNodeCursor;
  53. //visible = false;
  54. cursor = NULL;
  55. visible = false;
  56. GuiCanvas *root = getRoot();
  57. if ( !root )
  58. return;
  59. S32 currCursor = PlatformCursorController::curArrow;
  60. if ( root->mCursorChanged == currCursor )
  61. return;
  62. PlatformWindow *window = root->getPlatformWindow();
  63. PlatformCursorController *controller = window->getCursorController();
  64. // We've already changed the cursor,
  65. // so set it back before we change it again.
  66. if( root->mCursorChanged != -1)
  67. controller->popCursor();
  68. // Now change the cursor shape
  69. controller->pushCursor(currCursor);
  70. root->mCursorChanged = currCursor;
  71. }
  72. void GuiMissionAreaEditorCtrl::setSelectedMissionArea( MissionArea *missionArea )
  73. {
  74. mSelMissionArea = missionArea;
  75. if ( mSelMissionArea != NULL )
  76. Con::executef( this, "onMissionAreaSelected", missionArea->getIdString() );
  77. else
  78. Con::executef( this, "onMissionAreaSelected" );
  79. }
  80. DefineEngineMethod( GuiMissionAreaEditorCtrl, setSelectedMissionArea, void, (const char * missionAreaName), (""), "" )
  81. {
  82. if ( String::compare( missionAreaName, "" )==0 )
  83. object->setSelectedMissionArea(NULL);
  84. else
  85. {
  86. MissionArea *missionArea = NULL;
  87. if ( Sim::findObject( missionAreaName, missionArea ) )
  88. object->setSelectedMissionArea(missionArea);
  89. }
  90. }
  91. DefineEngineMethod( GuiMissionAreaEditorCtrl, getSelectedMissionArea, const char*, (), , "" )
  92. {
  93. MissionArea *missionArea = object->getSelectedMissionArea();
  94. if ( !missionArea )
  95. return NULL;
  96. return missionArea->getIdString();
  97. }