================ rvGEWorkspace::LoadFile Loads the given gui file. ================ */
| 294 | ================ |
| 295 | */ |
| 296 | bool rvGEWorkspace::LoadFile ( const char* filename, idStr* error ) |
| 297 | { |
| 298 | delete mInterface; |
| 299 | |
| 300 | idStr tempfile; |
| 301 | idStr ospath; |
| 302 | bool result; |
| 303 | |
| 304 | tempfile = "guis/temp.guied"; |
| 305 | //ospath = fileSystem->RelativePathToOSPath ( tempfile, "fs_basepath" ); DG: change from SteelStorm2 |
| 306 | ospath = fileSystem->RelativePathToOSPath ( tempfile, "fs_savepath" ); |
| 307 | |
| 308 | // Make sure the gui directory exists |
| 309 | idStr createDir = ospath; |
| 310 | createDir.StripFilename ( ); |
| 311 | CreateDirectory ( createDir, NULL ); |
| 312 | |
| 313 | SetFileAttributes ( ospath, FILE_ATTRIBUTE_NORMAL ); |
| 314 | DeleteFile ( ospath ); |
| 315 | if ( !CopyFile ( filename, ospath, FALSE ) ) |
| 316 | { |
| 317 | if ( error ) |
| 318 | { |
| 319 | *error = "File not found"; |
| 320 | } |
| 321 | return false; |
| 322 | } |
| 323 | |
| 324 | SetFileAttributes ( ospath, FILE_ATTRIBUTE_NORMAL ); |
| 325 | |
| 326 | mFilename = filename; |
| 327 | UpdateTitle ( ); |
| 328 | |
| 329 | // Let the real window system parse it first |
| 330 | mInterface = NULL; |
| 331 | result = true; |
| 332 | try |
| 333 | { |
| 334 | mInterface = reinterpret_cast< idUserInterfaceLocal* >( uiManager->FindGui( tempfile, true, true ) ); |
| 335 | if ( !mInterface && error ) |
| 336 | { |
| 337 | *error = "File not found"; |
| 338 | } |
| 339 | } |
| 340 | catch ( idException& e ) |
| 341 | { |
| 342 | result = false; |
| 343 | if ( error ) |
| 344 | { |
| 345 | *error = e.error; |
| 346 | } |
| 347 | return false; |
| 348 | } |
| 349 | |
| 350 | if ( result ) |
| 351 | { |
| 352 | rvGEWindowWrapper::GetWrapper ( mInterface->GetDesktop ( ) )->Expand ( ); |
| 353 | } |
no test coverage detected