moved resources group creation from Engine to bsa component

actorid
Marc Zinnschlag 11 years ago
parent 072dc6d438
commit 2de862126a

@ -12,7 +12,7 @@
#include <components/compiler/extensions0.hpp>
#include <components/bsa/bsa_archive.hpp>
#include <components/bsa/resources.hpp>
#include <components/files/configurationmanager.hpp>
#include <components/translation/translation.hpp>
#include <components/nif/niffile.hpp>
@ -192,50 +192,6 @@ OMW::Engine::~Engine()
SDL_Quit();
}
// Load BSA files
void OMW::Engine::loadBSA()
{
// We use separate resource groups to handle location priority.
const Files::PathContainer& dataDirs = mFileCollections.getPaths();
int i=0;
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter)
{
// Last data dir has the highest priority
std::string groupName = "Data" + Ogre::StringConverter::toString(dataDirs.size()-i, 8, '0');
Ogre::ResourceGroupManager::getSingleton ().createResourceGroup (groupName);
std::string dataDirectory = iter->string();
std::cout << "Data dir " << dataDirectory << std::endl;
Bsa::addDir(dataDirectory, mFSStrict, groupName);
++i;
}
i=0;
for (std::vector<std::string>::const_iterator archive = mArchives.begin(); archive != mArchives.end(); ++archive)
{
if (mFileCollections.doesExist(*archive))
{
// Last BSA has the highest priority
std::string groupName = "DataBSA" + Ogre::StringConverter::toString(mArchives.size()-i, 8, '0');
Ogre::ResourceGroupManager::getSingleton ().createResourceGroup (groupName);
const std::string archivePath = mFileCollections.getPath(*archive).string();
std::cout << "Adding BSA archive " << archivePath << std::endl;
Bsa::addBSA(archivePath, groupName);
++i;
}
else
{
std::stringstream message;
message << "Archive '" << *archive << "' not found";
throw std::runtime_error(message.str());
}
}
}
// add resources directory
// \note This function works recursively.
@ -385,8 +341,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
mOgre->createWindow("OpenMW", windowSettings);
loadBSA();
Bsa::registerResources (mFileCollections, mArchives, true, mFSStrict);
// Create input and UI first to set up a bootstrapping environment for
// showing a loading screen and keeping the window responsive while doing so

@ -101,9 +101,6 @@ namespace OMW
/// add a .zip resource
void addZipResource (const boost::filesystem::path& path);
/// Load BSA files
void loadBSA();
void executeLocalScripts();
virtual bool frameRenderingQueued (const Ogre::FrameEvent& evt);

@ -15,7 +15,7 @@ add_component_dir (nifoverrides
)
add_component_dir (bsa
bsa_archive bsa_file
bsa_archive bsa_file resources
)
add_component_dir (nif

@ -0,0 +1,53 @@
#include "resources.hpp"
#include <iostream>
#include <OgreResourceGroupManager.h>
#include <OgreStringConverter.h>
#include "bsa_archive.hpp"
void Bsa::registerResources (const Files::Collections& collections,
const std::vector<std::string>& archives, bool useLooseFiles, bool fsStrict)
{
const Files::PathContainer& dataDirs = collections.getPaths();
int i=0;
if (useLooseFiles)
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter)
{
// Last data dir has the highest priority
std::string groupName = "Data" + Ogre::StringConverter::toString(dataDirs.size()-i, 8, '0');
Ogre::ResourceGroupManager::getSingleton ().createResourceGroup (groupName);
std::string dataDirectory = iter->string();
std::cout << "Data dir " << dataDirectory << std::endl;
Bsa::addDir(dataDirectory, fsStrict, groupName);
++i;
}
i=0;
for (std::vector<std::string>::const_iterator archive = archives.begin(); archive != archives.end(); ++archive)
{
if (collections.doesExist(*archive))
{
// Last BSA has the highest priority
std::string groupName = "DataBSA" + Ogre::StringConverter::toString(archives.size()-i, 8, '0');
Ogre::ResourceGroupManager::getSingleton ().createResourceGroup (groupName);
const std::string archivePath = collections.getPath(*archive).string();
std::cout << "Adding BSA archive " << archivePath << std::endl;
Bsa::addBSA(archivePath, groupName);
++i;
}
else
{
std::stringstream message;
message << "Archive '" << *archive << "' not found";
throw std::runtime_error(message.str());
}
}
}

@ -0,0 +1,16 @@
#ifndef BSA_BSA_RESOURCES_H
#define BSA_BSA_RESOURCES_H
#include <vector>
#include <string>
#include "../files/collections.hpp"
namespace Bsa
{
void registerResources (const Files::Collections& collections,
const std::vector<std::string>& archives, bool useLooseFiles, bool fsStrict);
///< Register resources directories and archives as OGRE resources groups
}
#endif
Loading…
Cancel
Save