diff options
Diffstat (limited to 'linden/indra/newview/lltoolmgr.cpp')
-rw-r--r-- | linden/indra/newview/lltoolmgr.cpp | 217 |
1 files changed, 40 insertions, 177 deletions
diff --git a/linden/indra/newview/lltoolmgr.cpp b/linden/indra/newview/lltoolmgr.cpp index 0a4a99d..b7a5ab9 100644 --- a/linden/indra/newview/lltoolmgr.cpp +++ b/linden/indra/newview/lltoolmgr.cpp | |||
@@ -46,13 +46,12 @@ | |||
46 | #include "lltoolmorph.h" | 46 | #include "lltoolmorph.h" |
47 | #include "lltoolpie.h" | 47 | #include "lltoolpie.h" |
48 | #include "lltoolplacer.h" | 48 | #include "lltoolplacer.h" |
49 | #include "lltoolselect.h" | ||
50 | #include "lltoolselectland.h" | 49 | #include "lltoolselectland.h" |
51 | #include "lltoolobjpicker.h" | 50 | #include "lltoolobjpicker.h" |
52 | #include "lltoolpipette.h" | 51 | #include "lltoolpipette.h" |
52 | #include "llagent.h" | ||
53 | #include "llviewercontrol.h" | ||
53 | 54 | ||
54 | // Globals (created and destroyed by LLAgent) | ||
55 | LLToolMgr* gToolMgr = NULL; | ||
56 | 55 | ||
57 | // Used when app not active to avoid processing hover. | 56 | // Used when app not active to avoid processing hover. |
58 | LLTool* gToolNull = NULL; | 57 | LLTool* gToolNull = NULL; |
@@ -87,179 +86,34 @@ LLToolMgr::LLToolMgr() | |||
87 | 86 | ||
88 | void LLToolMgr::initTools() | 87 | void LLToolMgr::initTools() |
89 | { | 88 | { |
90 | // Initialize all the tools | 89 | static BOOL initialized = FALSE; |
91 | // Variables that are reused for each tool | 90 | if(initialized) |
92 | LLTool* tool = NULL; | 91 | { |
93 | 92 | return; | |
94 | // | 93 | } |
95 | // Pie tool (not visible in UI, implicit) | 94 | initialized = TRUE; |
96 | // | 95 | gBasicToolset->addTool( LLToolPie::getInstance() ); |
97 | gToolPie = new LLToolPie(); | 96 | gBasicToolset->addTool( LLToolCamera::getInstance() ); |
98 | 97 | gCameraToolset->addTool( LLToolCamera::getInstance() ); | |
99 | gBasicToolset->addTool( gToolPie ); | 98 | gBasicToolset->addTool( LLToolGrab::getInstance() ); |
100 | // gCameraToolset->addTool( gToolPie ); | 99 | gBasicToolset->addTool( LLToolCompTranslate::getInstance() ); |
101 | // gLandToolset->addTool( gToolPie ); | 100 | gBasicToolset->addTool( LLToolCompCreate::getInstance() ); |
102 | 101 | gBasicToolset->addTool( LLToolBrushLand::getInstance() ); | |
103 | // Camera tool | 102 | gMouselookToolset->addTool( LLToolCompGun::getInstance() ); |
104 | gToolCamera = new LLToolCamera(); | 103 | gBasicToolset->addTool( LLToolCompInspect::getInstance() ); |
105 | gBasicToolset ->addTool( gToolCamera ); | 104 | gFaceEditToolset->addTool( LLToolCamera::getInstance() ); |
106 | gCameraToolset->addTool( gToolCamera ); | ||
107 | |||
108 | // | ||
109 | // Grab tool | ||
110 | // | ||
111 | gToolGrab = new LLToolGrab(); | ||
112 | tool = gToolGrab; | ||
113 | |||
114 | gBasicToolset->addTool( tool ); | ||
115 | |||
116 | // | ||
117 | // Translation tool | ||
118 | // | ||
119 | gToolTranslate = new LLToolCompTranslate(); | ||
120 | tool = gToolTranslate; | ||
121 | |||
122 | gBasicToolset->addTool( tool ); | ||
123 | |||
124 | // | ||
125 | // Scale ("Stretch") tool | ||
126 | // | ||
127 | gToolStretch = new LLToolCompScale(); | ||
128 | tool = gToolStretch; | ||
129 | |||
130 | |||
131 | // | ||
132 | // Rotation tool | ||
133 | // | ||
134 | gToolRotate = new LLToolCompRotate(); | ||
135 | tool = gToolRotate; | ||
136 | |||
137 | |||
138 | // | ||
139 | // Face tool | ||
140 | // | ||
141 | gToolFace = new LLToolFace(); | ||
142 | tool = gToolFace; | ||
143 | |||
144 | // | ||
145 | // Pipette tool | ||
146 | // | ||
147 | gToolPipette = new LLToolPipette(); | ||
148 | |||
149 | // | ||
150 | // Individual object selector | ||
151 | // | ||
152 | gToolIndividual = new LLToolIndividual(); | ||
153 | |||
154 | |||
155 | // | ||
156 | // Create object tool | ||
157 | // | ||
158 | gToolCreate = new LLToolCompCreate(); | ||
159 | tool = gToolCreate; | ||
160 | |||
161 | gBasicToolset->addTool( tool ); | ||
162 | |||
163 | // | ||
164 | // Land brush tool | ||
165 | // | ||
166 | gToolLand = new LLToolBrushLand(); | ||
167 | tool = gToolLand; | ||
168 | |||
169 | gBasicToolset->addTool( tool ); | ||
170 | |||
171 | |||
172 | // | ||
173 | // Land select tool | ||
174 | // | ||
175 | gToolParcel = new LLToolSelectLand(); | ||
176 | tool = gToolParcel; | ||
177 | |||
178 | // | ||
179 | // Gun tool | ||
180 | // | ||
181 | gToolGun = new LLToolCompGun(); | ||
182 | gMouselookToolset->addTool( gToolGun ); | ||
183 | |||
184 | // | ||
185 | // Inspect tool | ||
186 | // | ||
187 | gToolInspect = new LLToolCompInspect(); | ||
188 | gBasicToolset->addTool( gToolInspect ); | ||
189 | |||
190 | // | ||
191 | // Face edit tool | ||
192 | // | ||
193 | // gToolMorph = new LLToolMorph(); | ||
194 | // gFaceEditToolset->addTool( gToolMorph ); | ||
195 | gFaceEditToolset->addTool( gToolCamera ); | ||
196 | |||
197 | // Drag and drop tool | ||
198 | gToolDragAndDrop = new LLToolDragAndDrop(); | ||
199 | |||
200 | gToolObjPicker = new LLToolObjPicker(); | ||
201 | 105 | ||
202 | // On startup, use "select" tool | 106 | // On startup, use "select" tool |
203 | setCurrentToolset(gBasicToolset); | 107 | setCurrentToolset(gBasicToolset); |
204 | gBasicToolset->selectTool( gToolPie ); | 108 | |
109 | gBasicToolset->selectTool( LLToolPie::getInstance() ); | ||
205 | } | 110 | } |
206 | 111 | ||
207 | LLToolMgr::~LLToolMgr() | 112 | LLToolMgr::~LLToolMgr() |
208 | { | 113 | { |
209 | delete gToolPie; | ||
210 | gToolPie = NULL; | ||
211 | |||
212 | delete gToolInspect; | ||
213 | gToolInspect = NULL; | ||
214 | |||
215 | delete gToolGun; | ||
216 | gToolGun = NULL; | ||
217 | |||
218 | delete gToolCamera; | ||
219 | gToolCamera = NULL; | ||
220 | |||
221 | // delete gToolMorph; | ||
222 | // gToolMorph = NULL; | ||
223 | |||
224 | delete gToolDragAndDrop; | ||
225 | gToolDragAndDrop = NULL; | ||
226 | |||
227 | delete gBasicToolset; | 114 | delete gBasicToolset; |
228 | gBasicToolset = NULL; | 115 | gBasicToolset = NULL; |
229 | 116 | ||
230 | delete gToolGrab; | ||
231 | gToolGrab = NULL; | ||
232 | |||
233 | delete gToolRotate; | ||
234 | gToolRotate = NULL; | ||
235 | |||
236 | delete gToolTranslate; | ||
237 | gToolTranslate = NULL; | ||
238 | |||
239 | delete gToolStretch; | ||
240 | gToolStretch = NULL; | ||
241 | |||
242 | delete gToolIndividual; | ||
243 | gToolIndividual = NULL; | ||
244 | |||
245 | delete gToolPipette; | ||
246 | gToolPipette = NULL; | ||
247 | |||
248 | delete gToolCreate; | ||
249 | gToolCreate = NULL; | ||
250 | |||
251 | delete gToolFace; | ||
252 | gToolFace = NULL; | ||
253 | |||
254 | delete gToolLand; | ||
255 | gToolLand = NULL; | ||
256 | |||
257 | delete gToolParcel; | ||
258 | gToolParcel = NULL; | ||
259 | |||
260 | delete gToolObjPicker; | ||
261 | gToolObjPicker = NULL; | ||
262 | |||
263 | delete gMouselookToolset; | 117 | delete gMouselookToolset; |
264 | gMouselookToolset = NULL; | 118 | gMouselookToolset = NULL; |
265 | 119 | ||
@@ -372,7 +226,20 @@ void LLToolMgr::updateToolStatus() | |||
372 | 226 | ||
373 | BOOL LLToolMgr::inEdit() | 227 | BOOL LLToolMgr::inEdit() |
374 | { | 228 | { |
375 | return mBaseTool != gToolPie && mBaseTool != gToolNull; | 229 | return mBaseTool != LLToolPie::getInstance() && mBaseTool != gToolNull; |
230 | } | ||
231 | |||
232 | bool LLToolMgr::inBuildMode() | ||
233 | { | ||
234 | // when entering mouselook inEdit() immediately returns true before | ||
235 | // cameraMouselook() actually starts returning true. Also, appearance edit | ||
236 | // sets build mode to true, so let's exclude that. | ||
237 | bool b=(inEdit() | ||
238 | && gSavedSettings.getBOOL("BuildBtnState") | ||
239 | && !gAgent.cameraMouselook() | ||
240 | && mCurrentToolset != gFaceEditToolset); | ||
241 | |||
242 | return b; | ||
376 | } | 243 | } |
377 | 244 | ||
378 | void LLToolMgr::setTransientTool(LLTool* tool) | 245 | void LLToolMgr::setTransientTool(LLTool* tool) |
@@ -449,7 +316,7 @@ void LLToolset::addTool(LLTool* tool) | |||
449 | void LLToolset::selectTool(LLTool* tool) | 316 | void LLToolset::selectTool(LLTool* tool) |
450 | { | 317 | { |
451 | mSelectedTool = tool; | 318 | mSelectedTool = tool; |
452 | gToolMgr->setCurrentTool( mSelectedTool ); | 319 | LLToolMgr::getInstance()->setCurrentTool( mSelectedTool ); |
453 | } | 320 | } |
454 | 321 | ||
455 | 322 | ||
@@ -459,7 +326,7 @@ void LLToolset::selectToolByIndex( S32 index ) | |||
459 | if (tool) | 326 | if (tool) |
460 | { | 327 | { |
461 | mSelectedTool = tool; | 328 | mSelectedTool = tool; |
462 | gToolMgr->setCurrentTool( tool ); | 329 | LLToolMgr::getInstance()->setCurrentTool( tool ); |
463 | } | 330 | } |
464 | } | 331 | } |
465 | 332 | ||
@@ -473,10 +340,7 @@ BOOL LLToolset::isToolSelected( S32 index ) | |||
473 | void LLToolset::selectFirstTool() | 340 | void LLToolset::selectFirstTool() |
474 | { | 341 | { |
475 | mSelectedTool = (0 < mToolList.size()) ? mToolList[0] : NULL; | 342 | mSelectedTool = (0 < mToolList.size()) ? mToolList[0] : NULL; |
476 | if (gToolMgr) | 343 | LLToolMgr::getInstance()->setCurrentTool( mSelectedTool ); |
477 | { | ||
478 | gToolMgr->setCurrentTool( mSelectedTool ); | ||
479 | } | ||
480 | } | 344 | } |
481 | 345 | ||
482 | 346 | ||
@@ -497,7 +361,7 @@ void LLToolset::selectNextTool() | |||
497 | if( next ) | 361 | if( next ) |
498 | { | 362 | { |
499 | mSelectedTool = next; | 363 | mSelectedTool = next; |
500 | gToolMgr->setCurrentTool( mSelectedTool ); | 364 | LLToolMgr::getInstance()->setCurrentTool( mSelectedTool ); |
501 | } | 365 | } |
502 | else | 366 | else |
503 | { | 367 | { |
@@ -522,17 +386,16 @@ void LLToolset::selectPrevTool() | |||
522 | if( prev ) | 386 | if( prev ) |
523 | { | 387 | { |
524 | mSelectedTool = prev; | 388 | mSelectedTool = prev; |
525 | gToolMgr->setCurrentTool( mSelectedTool ); | 389 | LLToolMgr::getInstance()->setCurrentTool( mSelectedTool ); |
526 | } | 390 | } |
527 | else if (mToolList.size() > 0) | 391 | else if (mToolList.size() > 0) |
528 | { | 392 | { |
529 | selectToolByIndex((S32)mToolList.size()-1); | 393 | selectToolByIndex((S32)mToolList.size()-1); |
530 | } | 394 | } |
531 | |||
532 | } | 395 | } |
533 | 396 | ||
534 | void select_tool( void *tool_pointer ) | 397 | void select_tool( void *tool_pointer ) |
535 | { | 398 | { |
536 | LLTool *tool = (LLTool *)tool_pointer; | 399 | LLTool *tool = (LLTool *)tool_pointer; |
537 | gToolMgr->getCurrentToolset()->selectTool( tool ); | 400 | LLToolMgr::getInstance()->getCurrentToolset()->selectTool( tool ); |
538 | } | 401 | } |