MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / pasteSelection

Method pasteSelection

Engine/source/gui/worldEditor/worldEditor.cpp:449–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447}
448
449bool WorldEditor::pasteSelection( bool dropSel )
450{
451 clearSelection();
452
453 // Grab the world editor undo manager.
454 UndoManager *undoMan = NULL;
455 if ( !Sim::findObject( "EUndoManager", undoMan ) )
456 {
457 Con::errorf( "WorldEditor::pasteSelection() - EUndoManager not found!" );
458 return false;
459 }
460
461 SimGroup *targetGroup = NULL;
462 if( isMethod( "getNewObjectGroup" ) )
463 {
464 ConsoleValue cValue = Con::executef( this, "getNewObjectGroup" );
465 const char* targetGroupName = cValue.getString();
466
467 if( targetGroupName && targetGroupName[ 0 ] && !Sim::findObject( targetGroupName, targetGroup) )
468 Con::errorf( "WorldEditor::pasteSelection() - no SimGroup called '%s'", targetGroupName );
469 }
470
471 if( !targetGroup)
472 {
473 targetGroup = Scene::getRootScene();
474 if( !targetGroup)
475 {
476 Con::errorf( "WorldEditor::pasteSelection() - Scene not found" );
477 return false;
478 }
479 }
480
481 // Setup the action.
482 MECreateUndoAction *action = new MECreateUndoAction( "Paste" );
483
484 for( U32 i = 0; i < mCopyBuffer.size(); i++ )
485 {
486 SimObject* obj = mCopyBuffer[i].restore();
487 if ( !obj )
488 continue;
489
490 if (targetGroup)
491 targetGroup->addObject( obj );
492
493 action->addObject( obj );
494
495 if ( !mSelectionLocked )
496 {
497 mSelected->addObject( obj );
498 Con::executef( this, "onSelect", obj->getIdString() );
499 }
500 }
501
502 // Its safe to submit the action before the selection
503 // is dropped below because the state of the objects
504 // are not stored until they are first undone.
505 undoMan->addAction( action );
506

Callers 1

DefineEngineMethodFunction · 0.45

Calls 11

executefFunction · 0.85
dSprintfFunction · 0.85
getIdStringMethod · 0.80
getIdMethod · 0.65
findObjectFunction · 0.50
errorfFunction · 0.50
getStringMethod · 0.45
sizeMethod · 0.45
restoreMethod · 0.45
addObjectMethod · 0.45
addActionMethod · 0.45

Tested by

no test coverage detected