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

Method saveSelection

Engine/source/gui/editor/guiEditCtrl.cpp:1367–1423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

guiEditCtrl.cppFile · 0.80

Calls 10

errorfFunction · 0.85
getRootGroupFunction · 0.85
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