guiMissionAreaEditor.cpp 3.5 KB

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