editor.cpp
Engine/source/gui/worldEditor/editor.cpp
Public Variables
bool
For frame signal.
Public Functions
ConsoleDocClass(EditManager , "@brief For Editor use only, <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">deprecated\n\n</a>" " @internal" )
DefineEngineMethod(EditManager , editorDisabled , void , () , "Perform the onEditorDisabled callback on all SimObjects and set <a href="/coding/file/tsstatic_8cpp/#tsstatic_8cpp_1acc4adbf4fd0b9138fdac4c9943fea14e">gEditingMission</a> false" )
DefineEngineMethod(EditManager , editorEnabled , void , () , "Perform the onEditorEnabled callback on all SimObjects and set <a href="/coding/file/tsstatic_8cpp/#tsstatic_8cpp_1acc4adbf4fd0b9138fdac4c9943fea14e">gEditingMission</a> true" )
DefineEngineMethod(EditManager , gotoBookmark , void , (S32 val) , "(int slot)" )
DefineEngineMethod(EditManager , isEditorEnabled , bool , () , "Return the <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of gEditingMission." )
DefineEngineMethod(EditManager , setBookmark , void , (S32 val) , "(int slot)" )
Detailed Description
Public Variables
bool gEditingMission
For frame signal.
Public Functions
ConsoleDocClass(EditManager , "@brief For Editor use only, <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">deprecated\n\n</a>" " @internal" )
DefineEngineMethod(EditManager , editorDisabled , void , () , "Perform the onEditorDisabled callback on all SimObjects and set <a href="/coding/file/tsstatic_8cpp/#tsstatic_8cpp_1acc4adbf4fd0b9138fdac4c9943fea14e">gEditingMission</a> false" )
DefineEngineMethod(EditManager , editorEnabled , void , () , "Perform the onEditorEnabled callback on all SimObjects and set <a href="/coding/file/tsstatic_8cpp/#tsstatic_8cpp_1acc4adbf4fd0b9138fdac4c9943fea14e">gEditingMission</a> true" )
DefineEngineMethod(EditManager , gotoBookmark , void , (S32 val) , "(int slot)" )
DefineEngineMethod(EditManager , isEditorEnabled , bool , () , "Return the <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of gEditingMission." )
DefineEngineMethod(EditManager , setBookmark , void , (S32 val) , "(int slot)" )
getControlObj()
IMPLEMENT_CONOBJECT(EditManager )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "gui/worldEditor/editor.h" 25#include "console/console.h" 26#include "console/consoleInternal.h" 27#include "console/engineAPI.h" 28#include "gui/controls/guiTextListCtrl.h" 29#include "T3D/shapeBase.h" 30#include "T3D/gameBase/gameConnection.h" 31 32#ifndef TORQUE_PLAYER 33// See matching #ifdef in app/game.cpp 34bool gEditingMission = false; 35#endif 36 37//------------------------------------------------------------------------------ 38// Class EditManager 39//------------------------------------------------------------------------------ 40 41IMPLEMENT_CONOBJECT(EditManager); 42 43ConsoleDocClass( EditManager, 44 "@brief For Editor use only, deprecated\n\n" 45 "@internal" 46); 47 48EditManager::EditManager() 49{ 50 for(U32 i = 0; i < 10; i++) 51 mBookmarks[i] = MatrixF(true); 52} 53 54EditManager::~EditManager() 55{ 56} 57 58//------------------------------------------------------------------------------ 59 60bool EditManager::onWake() 61{ 62 if(!Parent::onWake()) 63 return(false); 64 65 return(true); 66} 67 68void EditManager::onSleep() 69{ 70 Parent::onSleep(); 71} 72 73//------------------------------------------------------------------------------ 74 75bool EditManager::onAdd() 76{ 77 if(!Parent::onAdd()) 78 return(false); 79 80 // hook the namespace 81 const char * name = getName(); 82 if(name && name[0] && getClassRep()) 83 { 84 Namespace * parent = getClassRep()->getNameSpace(); 85 Con::linkNamespaces(parent->mName, name); 86 mNameSpace = Con::lookupNamespace(name); 87 } 88 89 return(true); 90} 91 92//------------------------------------------------------------------------------ 93 94// NOTE: since EditManager is not actually used as a gui anymore, onWake/Sleep 95// were never called, which broke anyone hooking into onEditorEnable/onEditorDisable 96// and gEditingMission. So, moved these to happen in response to console methods 97// which should be called at the appropriate time. 98// 99// This is a quick fix and this system is still "begging" for a remake. 100 101void EditManager::editorEnabled() 102{ 103 for(SimGroupIterator itr(Sim::getRootGroup()); *itr; ++itr) 104 (*itr)->onEditorEnable(); 105 106 gEditingMission = true; 107} 108 109void EditManager::editorDisabled() 110{ 111 for(SimGroupIterator itr(Sim::getRootGroup()); *itr; ++itr) 112 { 113 SimObject *so = *itr; 114 AssertFatal(so->isProperlyAdded() && !so->isRemoved(), "bad"); 115 so->onEditorDisable(); 116 } 117 118 gEditingMission = false; 119} 120 121//------------------------------------------------------------------------------ 122 123static GameBase * getControlObj() 124{ 125 GameConnection * connection = GameConnection::getLocalClientConnection(); 126 GameBase* control = 0; 127 if(connection) 128 control = connection->getControlObject(); 129 return(control); 130} 131 132DefineEngineMethod( EditManager, setBookmark, void, (S32 val), , "(int slot)") 133{ 134 if(val < 0 || val > 9) 135 return; 136 137 GameBase * control = getControlObj(); 138 if(control) 139 object->mBookmarks[val] = control->getTransform(); 140} 141 142DefineEngineMethod( EditManager, gotoBookmark, void, (S32 val), , "(int slot)") 143{ 144 if(val < 0 || val > 9) 145 return; 146 147 GameBase * control = getControlObj(); 148 if(control) 149 control->setTransform(object->mBookmarks[val]); 150} 151 152DefineEngineMethod( EditManager, editorEnabled, void, (), , "Perform the onEditorEnabled callback on all SimObjects and set gEditingMission true" ) 153{ 154 object->editorEnabled(); 155} 156 157DefineEngineMethod( EditManager, editorDisabled, void, (), , "Perform the onEditorDisabled callback on all SimObjects and set gEditingMission false" ) 158{ 159 object->editorDisabled(); 160} 161 162DefineEngineMethod( EditManager, isEditorEnabled, bool, (), , "Return the value of gEditingMission." ) 163{ 164 return gEditingMission; 165} 166