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

Method saveSelection

Engine/source/gui/editor/guiEditCtrl.cpp:1380–1436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1378//-----------------------------------------------------------------------------
1379
1380void GuiEditCtrl::saveSelection( const char* filename )
1381{
1382 // If there are no selected objects, then don't save.
1383
1384 if( mSelectedControls.size() == 0 )
1385 return;
1386
1387 // Open the stream.
1388
1389 Stream* stream;
1390 if( filename )
1391 {
1392 stream = FileStream::createAndOpen( filename, Torque::FS::File::Write );
1393 if( !stream )
1394 {
1395 Con::errorf( "GuiEditCtrl::saveSelection - could not open '%s' for writing", filename );
1396 return;
1397 }
1398 }
1399 else
1400 stream = new MemStream( 4096 );
1401
1402 // Create a temporary SimSet.
1403
1404 SimSet* clipboardSet = new SimSet;
1405 clipboardSet->registerObject();
1406 Sim::getRootGroup()->addObject( clipboardSet, "guiClipboard" );
1407
1408 // Add the selected controls to the set.
1409
1410 for( Vector< GuiControl* >::iterator i = mSelectedControls.begin();
1411 i != mSelectedControls.end(); ++ i )
1412 {
1413 GuiControl* ctrl = *i;
1414 if( !selectionContainsParentOf( ctrl ) )
1415 clipboardSet->addObject( ctrl );
1416 }
1417
1418 // Write the SimSet. Use the IgnoreCanSave to ensure the controls
1419 // get actually written out (also disables the default parent inheritance
1420 // behavior for the flag).
1421
1422 clipboardSet->write( *stream, 0, IgnoreCanSave );
1423 clipboardSet->deleteObject();
1424
1425 // If we were writing to a memory stream, copy to clipboard
1426 // now.
1427
1428 if( !filename )
1429 {
1430 MemStream* memStream = static_cast< MemStream* >( stream );
1431 memStream->write( U8( 0 ) );
1432 Platform::setClipboard( ( const char* ) memStream->getBuffer() );
1433 }
1434
1435 delete stream;
1436}
1437

Callers 1

guiEditCtrl.cppFile · 0.80

Calls 10

getRootGroupFunction · 0.85
errorfFunction · 0.50
sizeMethod · 0.45
registerObjectMethod · 0.45
addObjectMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
writeMethod · 0.45
deleteObjectMethod · 0.45
getBufferMethod · 0.45

Tested by

no test coverage detected