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

Method loadSelection

Engine/source/gui/editor/guiEditCtrl.cpp:1303–1363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1301//-----------------------------------------------------------------------------
1302
1303void GuiEditCtrl::loadSelection( const char* filename )
1304{
1305 // Set redefine behavior to rename.
1306
1307 const char* oldRedefineBehavior = Con::getVariable( "$Con::redefineBehavior" );
1308 Con::setVariable( "$Con::redefineBehavior", "renameNew" );
1309
1310 // Exec the file or clipboard contents with the saved selection set.
1311
1312 if( filename )
1313 Con::executef( "exec", filename );
1314 else
1315 Con::evaluate( Platform::getClipboard() );
1316
1317 SimSet* set;
1318 if( !Sim::findObject( "guiClipboard", set ) )
1319 {
1320 if( filename )
1321 Con::errorf( "GuiEditCtrl::loadSelection() - could not find 'guiClipboard' in '%s'", filename );
1322 else
1323 Con::errorf( "GuiEditCtrl::loadSelection() - could not find 'guiClipboard'" );
1324 return;
1325 }
1326
1327 // Restore redefine behavior.
1328
1329 Con::setVariable( "$Con::redefineBehavior", oldRedefineBehavior );
1330
1331 // Add the objects in the set.
1332
1333 if( set->size() )
1334 {
1335 clearSelection();
1336
1337 GuiControlVector ctrls;
1338 for( U32 i = 0, num = set->size(); i < num; ++ i )
1339 {
1340 GuiControl *ctrl = dynamic_cast< GuiControl* >( ( *set )[ i ] );
1341 if( ctrl )
1342 {
1343 getCurrentAddSet()->addObject( ctrl );
1344 ctrls.push_back( ctrl );
1345 }
1346 }
1347
1348 // Select all controls. We need to perform this here rather than in the
1349 // loop above as addSelection() will modify the current add set.
1350 for( U32 i = 0; i < ctrls.size(); ++ i )
1351 {
1352 addSelection( ctrls[i] );
1353 }
1354
1355 // Undo
1356 onAddNewCtrlSet_callback( getSelectedSet() );
1357
1358 // Notify the script it needs to update its treeview.
1359
1360 onHierarchyChanged_callback();

Callers 1

guiEditCtrl.cppFile · 0.80

Calls 11

getVariableFunction · 0.85
setVariableFunction · 0.85
executefFunction · 0.85
evaluateFunction · 0.85
errorfFunction · 0.85
getSelectedSetFunction · 0.85
findObjectFunction · 0.50
sizeMethod · 0.45
addObjectMethod · 0.45
push_backMethod · 0.45
deleteObjectMethod · 0.45

Tested by

no test coverage detected