Пример #1
0
		void realise (void)
		{
			if (--m_unrealised == 0) {
				GlobalFileSystem().initDirectory(GlobalRadiant().getFullGamePath());
				GlobalFileSystem().initialise();
			}
		}
void Doom3MapCompiler::dmapCmd(const cmd::ArgumentList& args)
{
	if (args.size() != 1)
	{
		rWarning() << "Usage: dmap <mapFile>" << std::endl;
		return;
	}

	std::string mapFile = args[0].getString();
	
	if (!boost::algorithm::iends_with(mapFile, ".map"))
	{
		mapFile.append(".map");
	}

	std::string mapPath = mapFile;

	// Find the map file
	if (!path_is_absolute(mapPath.c_str()))
	{
		mapPath = GlobalFileSystem().findFile(mapFile);

		if (mapPath.empty())
		{
			// Try again with maps/ prepended
			mapFile = "maps/" + mapFile;
			mapPath = GlobalFileSystem().findFile(mapFile);
		}

		mapPath += mapFile;
	}

	// Start the sequence
	runDmap(mapPath);
}
Пример #3
0
bool SoundManager::playSound(const std::string& fileName, bool loopSound)
{
	// Make a copy of the filename
	std::string name = fileName;

	// Try to open the file as it is
	ArchiveFilePtr file = GlobalFileSystem().openFile(name);
    rConsole() << "Trying: " << name << std::endl;

	if (file) 
	{
		// File found, play it
        rConsole() << "Found file: " << name << std::endl;
		if (_soundPlayer) _soundPlayer->play(*file, loopSound);
		return true;
	}

	std::string root = name;

	// File not found, try to strip the extension
	if (name.rfind(".") != std::string::npos)
	{
		root = name.substr(0, name.rfind("."));
	}

	// Try to open the .ogg variant
	name = root + ".ogg";

    rConsole() << "Trying: " << name << std::endl;

	file = GlobalFileSystem().openFile(name);

	if (file) 
	{
        rConsole() << "Found file: " << name << std::endl;
		if (_soundPlayer) _soundPlayer->play(*file, loopSound);
		return true;
	}

	// Try to open the file with .wav extension
	name = root + ".wav";
    rConsole() << "Trying: " << name << std::endl;

	file = GlobalFileSystem().openFile(name);

	if (file)
	{
        rConsole() << "Found file: " << name << std::endl;
		if (_soundPlayer) _soundPlayer->play(*file, loopSound);
		return true;
	}

	// File not found
	return false;
}
Пример #4
0
	void ModelSelector::loadDirectory(const std::string& path) {
		if (path.empty())
			return;

		// Modal dialog window to display progress
		gtkutil::ModalProgressDialog dialog(GlobalRadiant().getMainWindow(), string::format(_("Loading models %s"), path.c_str()));

		// Populate the treestore using the VFS callback functor
		ModelFileFunctor functor(_treeStore, dialog, DirectoryCleaned(path), _dirIterMap);
		functor.setDirectory(true);
		GlobalFileSystem().forEachDirectory(path, makeCallback1(functor), 1);
		functor.setDirectory(false);
		GlobalFileSystem().forEachFile(path, "*", makeCallback1(functor), 1);
	}
Пример #5
0
void EntityClassDoom3_destroy(){
	EntityClassDoom3_unrealise();

	g_EntityClassDoom3_bad->free( g_EntityClassDoom3_bad );

	GlobalFileSystem().detach( g_EntityClassDoom3 );
}
Пример #6
0
GlyphSetPtr GlyphSet::createFromDatFile(const std::string& vfsPath,
										const std::string& fontname,
										const std::string& language,
										Resolution resolution)
{
	ArchiveFilePtr file = GlobalFileSystem().openFile(vfsPath);

	// Check file size
	if (file->size() != sizeof(q3font::Q3FontInfo))
	{
		rWarning() << "FontLoader: invalid file size of file "
			<< vfsPath << ", expected " << sizeof(q3font::Q3FontInfo)
			<< ", found " << file->size() << std::endl;
		return GlyphSetPtr();
	}

	// Allocate a buffer with the Quake3 info structure
	q3font::Q3FontInfoPtr buf(new q3font::Q3FontInfo);

	InputStream& stream = file->getInputStream();
	stream.read(
		reinterpret_cast<StreamBase::byte_type*>(buf.get()),
		sizeof(q3font::Q3FontInfo)
	);

	// Construct a glyph set using the loaded info
	GlyphSetPtr glyphSet(new GlyphSet(*buf, fontname, language, resolution));

	rMessage() << "FontLoader: "  << vfsPath << " loaded successfully." << std::endl;

	return glyphSet;
}
Пример #7
0
void SoundManager::initialiseModule(const ApplicationContext& ctx) 
{
	globalOutputStream() << "SoundManager::initialiseModule called\n";
	// Pass a SoundFileLoader to the filesystem
	SoundFileLoader loader(*this);
	GlobalFileSystem().forEachFile(
		SOUND_FOLDER,			// directory
		"*", 				// required extension
		loader,				// loader callback
		99						// max depth
	);

 	globalOutputStream() << _soundFiles.size() << " sound files found." << std::endl;

    // Create the SoundPlayer if sound is not disabled
    const ApplicationContext::ArgumentList& args = ctx.getCmdLineArgs();
    ApplicationContext::ArgumentList::const_iterator found(
        std::find(args.begin(), args.end(), "--disable-sound")
    );
    if (found == args.end())
    {
        globalOutputStream() << "SoundManager: initialising sound playback"
                             << std::endl;
        _soundPlayer = boost::shared_ptr<SoundPlayer>(new SoundPlayer);
    }
    else
    {
        globalOutputStream() << "SoundManager: sound ouput disabled" 
                             << std::endl;
    }
}
Пример #8
0
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;
}
Пример #9
0
const char* misc_model_dialog(GtkWidget* parent)
{
  StringOutputStream buffer(1024);

  buffer << g_qeglobals.m_userGamePath.c_str() << "models/";

  if(!file_readable(buffer.c_str()))
  {
    // just go to fsmain
    buffer.clear();
    buffer << g_qeglobals.m_userGamePath.c_str() << "/";
  }

  const char *filename = file_dialog (parent, TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name());
  if (filename != 0)
  {
    // use VFS to get the correct relative path
    const char* relative = path_make_relative(filename, GlobalFileSystem().findRoot(filename));
    if(relative == filename)
    {
      globalOutputStream() << "WARNING: could not extract the relative path, using full path instead\n";
    }
    return relative;
  }
  return 0;
}
Пример #10
0
void ShaderFileLoader::parseFiles()
{
	for (std::size_t i = 0; i < _files.size(); ++i)
	{
		const std::string& fullPath = _files[i];

		if (_currentOperation)
		{
			_currentOperation->setMessage((boost::format(_("Parsing material file %s")) % fullPath).str());

			float progress = static_cast<float>(i) / _files.size();
			_currentOperation->setProgress(progress);
		}

		// Open the file
		ArchiveTextFilePtr file = GlobalFileSystem().openTextFile(fullPath);

		if (file != NULL)
		{
			std::istream is(&(file->getInputStream()));
			parseShaderFile(is, fullPath);
		}
		else
		{
			throw std::runtime_error("Unable to read shaderfile: " + fullPath);
		}
	}
}
Пример #11
0
void EntityClassScannerUFO::scanFile (EntityClassCollector& collector)
{
	const std::string& filename = getFilename();

	AutoPtr<ArchiveTextFile> file(GlobalFileSystem().openTextFile(filename));
	if (!file) {
		std::string buffer = "Could not load " + filename;
		gtkutil::errorDialog(buffer);
		return;
	}

	const std::size_t size = file->size();
	char* entities = (char*) malloc(size + 1);
	TextInputStream &stream = file->getInputStream();
	const std::size_t realsize = stream.read(entities, size);
	entities[realsize] = '\0';
	if (ED_Parse(entities) == ED_ERROR) {
		std::string buffer = "Parsing of entities definition file failed, returned error was " + std::string(
				ED_GetLastError());
		gtkutil::errorDialog(buffer);
	} else {
		for (int i = 0; i < numEntityDefs; i++) {
			EntityClass *e = initFromDefinition(&entityDefs[i]);
			if (e)
				collector.insert(e);
		}
	}
	free(entities);
	ED_Free();
}
Пример #12
0
// Populate the tree view with models
void ModelSelector::populateModels()
{
    // Clear the treestore first
    _treeStore->Clear();
    _treeStoreWithSkins->Clear();

    // Create a VFSTreePopulator for the treestore
    wxutil::VFSTreePopulator pop(_treeStore);
    wxutil::VFSTreePopulator popSkins(_treeStoreWithSkins);

    // Use a ModelFileFunctor to add paths to the populator
    ModelFileFunctor functor(pop, popSkins);
    GlobalFileSystem().forEachFile(MODELS_FOLDER,
                                   "*",
                                   [&](const std::string& filename) { functor(filename); },
                                   0);

    // Fill in the column data (TRUE = including skins)
    ModelDataInserter inserterSkins(_columns, true);
    popSkins.forEachNode(inserterSkins);

    // Insert data into second model (FALSE = without skins)
    ModelDataInserter inserter(_columns, false);
    pop.forEachNode(inserter);

	// Sort the models
	_treeStore->SortModelFoldersFirst(_columns.filename, _columns.isFolder);
	_treeStoreWithSkins->SortModelFoldersFirst(_columns.filename, _columns.isFolder);

    // Setup the tree view
    setupTreeView();

    // Set the flag, we're done
    _populated = true;
}
Пример #13
0
void EClassManager::initialiseModule(const ApplicationContext& ctx)
{
	rMessage() << "EntityClassDoom3::initialiseModule called." << std::endl;

	GlobalFileSystem().addObserver(*this);
	realise();
}
Пример #14
0
void Doom3ShaderSystem::loadMaterialFiles()
{
	// Get the shaders path and extension from the XML game file
	xml::NodeList nlShaderPath =
		GlobalGameManager().currentGame()->getLocalXPath("/filesystem/shaders/basepath");
	if (nlShaderPath.empty())
		throw xml::MissingXMLNodeException(MISSING_BASEPATH_NODE);

	xml::NodeList nlShaderExt =
		GlobalGameManager().currentGame()->getLocalXPath("/filesystem/shaders/extension");
	if (nlShaderExt.empty())
		throw xml::MissingXMLNodeException(MISSING_EXTENSION_NODE);

	// Load the shader files from the VFS
	std::string sPath = nlShaderPath[0].getContent();
	if (!boost::algorithm::ends_with(sPath, "/"))
		sPath += "/";

	std::string extension = nlShaderExt[0].getContent();

	// Load each file from the global filesystem
	ShaderFileLoader loader(sPath, _currentOperation);
	{
		ScopedDebugTimer timer("ShaderFiles parsed: ");
        GlobalFileSystem().forEachFile(sPath, extension, [&](const std::string& filename)
        {
            loader.addFile(filename);
        }, 0);
		loader.parseFiles();
	}

	rMessage() << _library->getNumShaders() << " shaders found." << std::endl;
}
Пример #15
0
  ReferenceAPI()
  {
    g_nullModel = NewNullModel();

    GlobalFileSystem().attach(g_referenceCache);

    m_reference = &GetReferenceCache();
  }
Пример #16
0
void EntityClassDoom3_construct(){
	GlobalFileSystem().attach( g_EntityClassDoom3 );

	// start by creating the default unknown eclass
	g_EntityClassDoom3_bad = EClass_Create( "UNKNOWN_CLASS", Vector3( 0.0f, 0.5f, 0.0f ), "" );

	EntityClassDoom3_realise();
}
Пример #17
0
void Doom3ShaderSystem::construct()
{
	_library = ShaderLibraryPtr(new ShaderLibrary());
	_textureManager = GLTextureManagerPtr(new GLTextureManager());

	// Register this class as VFS observer
	GlobalFileSystem().addObserver(*this);
}
Пример #18
0
void MaterialSystem::importMaterialFile (const std::string& name)
{
	// Find the material
	AutoPtr<ArchiveTextFile> file(GlobalFileSystem().openTextFile(name));
	if (!file)
		return;

	showMaterialDefinitionAndAppend(file->getString());
}
Пример #19
0
void QE_InitVFS()
{
  // VFS initialization -----------------------
  // we will call GlobalFileSystem().initDirectory, giving the directories to look in (for files in pk3's and for standalone files)
  // we need to call in order, the mod ones first, then the base ones .. they will be searched in this order
  // *nix systems have a dual filesystem in ~/.q3a, which is searched first .. so we need to add that too

  const char* gamename = gamename_get();
  const char* basegame = basegame_get();
  const char* userRoot = g_qeglobals.m_userEnginePath.c_str();
  const char* globalRoot = EnginePath_get();

  // if we have a mod dir
  if(!string_equal(gamename, basegame))
  {
    // ~/.<gameprefix>/<fs_game>
	if ( userRoot ) {
      StringOutputStream userGamePath(256);
      userGamePath << userRoot << gamename << '/';
      GlobalFileSystem().initDirectory(userGamePath.c_str());
    }

    // <fs_basepath>/<fs_game>
    {
      StringOutputStream globalGamePath(256);
      globalGamePath << globalRoot << gamename << '/';
      GlobalFileSystem().initDirectory(globalGamePath.c_str());
    }
  }

  // ~/.<gameprefix>/<fs_main>
  if ( userRoot ) {
    StringOutputStream userBasePath(256);
    userBasePath << userRoot << basegame << '/';
    GlobalFileSystem().initDirectory(userBasePath.c_str());
  }

  // <fs_basepath>/<fs_main>
  {
    StringOutputStream globalBasePath(256);
    globalBasePath << globalRoot << basegame << '/';
    GlobalFileSystem().initDirectory(globalBasePath.c_str());
  }
}
Пример #20
0
		// Load the given model from the VFS path
		model::IModelPtr loadModelFromPath (const std::string& name)
		{
			// Open an ArchiveFile to load
			AutoPtr<ArchiveFile> file(GlobalFileSystem().openFile(name));
			if (file) {
				// Load the model and return the RenderablePtr
				return loadIModel(m_module, *file);
			}
			return model::IModelPtr();
		}
Пример #21
0
void EClassManager::initialiseModule(const ApplicationContext& ctx)
{
	rMessage() << "EntityClassDoom3::initialiseModule called." << std::endl;

	GlobalFileSystem().addObserver(*this);
	realise();

	GlobalCommandSystem().addCommand("ReloadDefs", boost::bind(&EClassManager::reloadDefsCmd, this, _1));
	GlobalEventManager().addCommand("ReloadDefs", "ReloadDefs");
}
Пример #22
0
void ParticlesManager::initialiseModule(const ApplicationContext& ctx)
{
	globalOutputStream() << "ParticlesManager::initialiseModule called\n";
	
	// Use a ParticleFileLoader to load each file
	ParticleFileLoader loader(*this);

	ScopedDebugTimer timer("Particle definitions parsed: ");
	GlobalFileSystem().forEachFile(PARTICLES_DIR, PARTICLES_EXT, loader, 1);
}
Пример #23
0
bool UMPFile::load ()
{
    AutoPtr<ArchiveTextFile> file(GlobalFileSystem().openTextFile(map::getMapsPath() + _fileName));
    if (file) {
        AutoPtr<Tokeniser> reader(GlobalScriptLibrary().createScriptTokeniser(file->getInputStream()));
        parse(*reader);
        return true;
    }
    return false;
}
Пример #24
0
void GuiManager::findGuis()
{
	_errorList.clear();

	// Traverse the file system, using this class as callback
	GlobalFileSystem().forEachFile(GUI_DIR, GUI_EXT, *this, 99);

	rMessage() << "[GuiManager]: Found " << _guis.size()
		<< " guis." << std::endl;
}
Пример #25
0
void ParticlesManager::reloadParticleDefs()
{
	// Use a ParticleFileLoader to load each file
	ParticleFileLoader loader(*this);

	ScopedDebugTimer timer("Particle definitions parsed: ");
	GlobalFileSystem().forEachFile(PARTICLES_DIR, PARTICLES_EXT, loader, 1);

	// Notify observers about this event
    _particlesReloadedSignal.emit();
}
Пример #26
0
void MaterialSystem::loadMaterials ()
{
	if (GlobalMap().isUnnamed())
		return;

	AutoPtr<ArchiveTextFile> file(GlobalFileSystem().openTextFile(getMaterialFilename()));
	if (file) {
		_material = file->getString();
		_materialLoaded = true;
	}
}
Пример #27
0
void Doom3ShaderSystem::destroy() {
	// De-register this class as VFS Observer
	GlobalFileSystem().removeObserver(*this);

	// Free the shaders if we're in realised state
	if (_realised) {
		freeShaders();
	}

	// Don't destroy the GLTextureManager, it's called from
	// the CShader destructors.
}
Пример #28
0
void EClassManager::parseDefFiles()
{
	rMessage() << "searching vfs directory 'def' for *.def\n";

	// Increase the parse stamp for this run
	_curParseStamp++;

	{
		ScopedDebugTimer timer("EntityDefs parsed: ");
		GlobalFileSystem().forEachFile("def/", "def", *this);
	}
}
Пример #29
0
void RadiantModule::shutdownModule()
{
	rMessage() << "RadiantModule::shutdownModule called." << std::endl;

	GlobalFileSystem().shutdown();

	map::PointFile::Instance().destroy();
	ui::OverlayDialog::destroy();
	ui::TextureBrowser::destroy();

    _radiantShutdown.clear();
}
Пример #30
0
void EntityClassDoom3_loadFile( const char* filename ){
	globalOutputStream() << "parsing entity classes from " << makeQuoted( filename ) << "\n";

	StringOutputStream fullname( 256 );
	fullname << "def/" << filename;

	ArchiveTextFile* file = GlobalFileSystem().openTextFile( fullname.c_str() );
	if ( file != 0 ) {
		EntityClassDoom3_parse( file->getInputStream(), fullname.c_str() );
		file->release();
	}
}