guiMissionAreaEditor.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. Parent::initPersistFields();
  46. }
  47. void GuiMissionAreaEditorCtrl::get3DCursor( GuiCursor *&cursor,
  48. bool &visible,
  49. const Gui3DMouseEvent &event_ )
  50. {
  51. //cursor = mAddNodeCursor;
  52. //visible = false;
  53. cursor = NULL;
  54. visible = false;
  55. GuiCanvas *root = getRoot();
  56. if ( !root )
  57. return;
  58. S32 currCursor = PlatformCursorController::curArrow;
  59. if ( root->mCursorChanged == currCursor )
  60. return;
  61. PlatformWindow *window = root->getPlatformWindow();
  62. PlatformCursorController *controller = window->getCursorController();
  63. // We've already changed the cursor,
  64. // so set it back before we change it again.
  65. if( root->mCursorChanged != -1)
  66. controller->popCursor();
  67. // Now change the cursor shape
  68. controller->pushCursor(currCursor);
  69. root->mCursorChanged = currCursor;
  70. }
  71. void GuiMissionAreaEditorCtrl::setSelectedMissionArea( MissionArea *missionArea )
  72. {
  73. mSelMissionArea = missionArea;
  74. if ( mSelMissionArea != NULL )
  75. Con::executef( this, "onMissionAreaSelected", missionArea->getIdString() );
  76. else
  77. Con::executef( this, "onMissionAreaSelected" );
  78. }
  79. DefineEngineMethod( GuiMissionAreaEditorCtrl, setSelectedMissionArea, void, (const char * missionAreaName), (""), "" )
  80. {
  81. if ( String::compare( missionAreaName, "" )==0 )
  82. object->setSelectedMissionArea(NULL);
  83. else
  84. {
  85. MissionArea *missionArea = NULL;
  86. if ( Sim::findObject( missionAreaName, missionArea ) )
  87. object->setSelectedMissionArea(missionArea);
  88. }
  89. }
  90. DefineEngineMethod( GuiMissionAreaEditorCtrl, getSelectedMissionArea, const char*, (), , "" )
  91. {
  92. MissionArea *missionArea = object->getSelectedMissionArea();
  93. if ( !missionArea )
  94. return NULL;
  95. return missionArea->getIdString();
  96. }