NodeSmartReference ModelResource_load(ModelLoader* loader, const char* name) { ScopeDisableScreenUpdates disableScreenUpdates(path_get_filename_start(name), "Loading Model"); NodeSmartReference model(g_nullModel); { ArchiveFile* file = GlobalFileSystem().openFile(name); if(file != 0) { globalOutputStream() << "Loaded Model: \"" << name << "\"\n"; model = loader->loadModel(*file); file->release(); } else { globalErrorStream() << "Model load failed: \"" << name << "\"\n"; } } model.get().m_isRoot = true; return model; }
bool MapResource_saveFile(const MapFormat& format, scene::Node& root, GraphTraversalFunc traverse, const char* filename) { //ASSERT_MESSAGE(path_is_absolute(filename), "MapResource_saveFile: path is not absolute: " << makeQuoted(filename)); globalOutputStream() << "Open file " << filename << " for write..."; TextFileOutputStream file(filename); if(!file.failed()) { globalOutputStream() << "success\n"; ScopeDisableScreenUpdates disableScreenUpdates(path_get_filename_start(filename), "Saving Map"); format.writeGraph(root, traverse, file); return true; } globalErrorStream() << "failure\n"; return false; }
bool MapResource_loadFile(const MapFormat& format, scene::Node& root, const char* filename) { globalOutputStream() << "Open file " << filename << " for read..."; TextFileInputStream file(filename); if(!file.failed()) { globalOutputStream() << "success\n"; ScopeDisableScreenUpdates disableScreenUpdates(path_get_filename_start(filename), "Loading Map"); ASSERT_NOTNULL(g_entityCreator); format.readGraph(root, file, *g_entityCreator); return true; } else { globalErrorStream() << "failure\n"; return false; } }
bool Map::saveSelected(const std::string& filename) { if (_saveInProgress) return false; // safeguard // Disable screen updates for the scope of this function ui::ScreenUpdateBlocker blocker(_("Processing..."), path_get_filename_start(filename.c_str())); _saveInProgress = true; bool success = MapResource::saveFile( *getFormatForFile(filename), GlobalSceneGraph().root(), map::traverseSelected, // TraversalFunc filename ); _saveInProgress = false; return success; }
void RunBSP(const char* name) { // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=503 // make sure we don't attempt to region compile a map with the camera outside the region if (region_active && !Region_cameraValid()) { globalErrorStream() << "The camera must be in the region to start a region compile.\n"; return; } SaveMap(); if(Map_Unnamed(g_map)) { globalOutputStream() << "build cancelled\n"; return; } if (g_SnapShots_Enabled && !Map_Unnamed(g_map) && Map_Modified(g_map)) { Map_Snapshot(); } if (region_active) { const char* mapname = Map_Name(g_map); StringOutputStream name(256); name << StringRange(mapname, path_get_filename_base_end(mapname)) << ".reg"; Map_SaveRegion(name.c_str()); } Pointfile_Delete(); bsp_init(); if (g_WatchBSP_Enabled) { ArrayCommandListener listener; build_run(name, listener); // grab the file name for engine running const char* fullname = Map_Name(g_map); StringOutputStream bspname(64); bspname << StringRange(path_get_filename_start(fullname), path_get_filename_base_end(fullname)); BuildMonitor_Run( listener.array(), bspname.c_str() ); } else { char junkpath[PATH_MAX]; strcpy(junkpath, SettingsPath_get()); strcat(junkpath, "junk.txt"); char batpath[PATH_MAX]; #if defined(POSIX) strcpy(batpath, SettingsPath_get()); strcat(batpath, "qe3bsp.sh"); #elif defined(WIN32) strcpy(batpath, SettingsPath_get()); strcat(batpath, "qe3bsp.bat"); #else #error "unsupported platform" #endif bool written = false; { TextFileOutputStream batchFile(batpath); if(!batchFile.failed()) { #if defined (POSIX) batchFile << "#!/bin/sh \n\n"; #endif BatchCommandListener listener(batchFile, junkpath); build_run(name, listener); written = true; } } if(written) { #if defined (POSIX) chmod (batpath, 0744); #endif globalOutputStream() << "Writing the compile script to '" << batpath << "'\n"; globalOutputStream() << "The build output will be saved in '" << junkpath << "'\n"; Q_Exec(batpath, NULL, NULL, true); } } bsp_shutdown(); }