MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / LoadFile

Method LoadFile

neo/tools/guied/GEWorkspaceFile.cpp:296–360  ·  view source on GitHub ↗

================ rvGEWorkspace::LoadFile Loads the given gui file. ================ */

Source from the content-addressed store, hash-verified

294================
295*/
296bool 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 }

Callers 1

OpenFileMethod · 0.45

Calls 4

RelativePathToOSPathMethod · 0.80
FindGuiMethod · 0.80
GetDesktopMethod · 0.80
ExpandMethod · 0.45

Tested by

no test coverage detected