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