added data option and openmw.cfg file

actorid
Marc Zinnschlag 15 years ago
parent 293c7c29c4
commit 9a041d7c01

@ -81,6 +81,9 @@ configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.linux
"${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY) "${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY)
endif (WIN32) endif (WIN32)
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
"${OpenMW_BINARY_DIR}/openmw.cfg" COPYONLY)
# Main executable # Main executable
add_executable(openmw add_executable(openmw
${BSA} ${BSA_HEADER} ${BSA} ${BSA_HEADER}

@ -157,7 +157,7 @@ static void insertBSAFactory()
// The function below is the only publicly exposed part of this file // The function below is the only publicly exposed part of this file
void addBSA(const char* name, const char* group) void addBSA(const std::string& name, const std::string& group)
{ {
insertBSAFactory(); insertBSAFactory();
ResourceGroupManager::getSingleton(). ResourceGroupManager::getSingleton().

@ -21,11 +21,13 @@
*/ */
#include <string>
#ifndef _BSA_ARCHIVE_H_ #ifndef _BSA_ARCHIVE_H_
#define _BSA_ARCHIVE_H_ #define _BSA_ARCHIVE_H_
/// Add the given BSA file as an input archive in the Ogre resource /// Add the given BSA file as an input archive in the Ogre resource
/// system. /// system.
void addBSA(const char* file, const char* group="General"); void addBSA(const std::string& file, const std::string& group="General");
#endif #endif

@ -0,0 +1,2 @@
data=data

@ -1,5 +1,8 @@
#include <iostream> #include <iostream>
#include <string>
#include <fstream>
#include "boost/program_options.hpp" #include "boost/program_options.hpp"
#include "esm_store/cell_store.hpp" #include "esm_store/cell_store.hpp"
@ -13,21 +16,28 @@
using namespace std; using namespace std;
void maintest() void maintest (std::string dataDir)
{ {
const char* esmFile = "data/Morrowind.esm"; assert (!dataDir.empty());
const char* bsaFile = "data/Morrowind.bsa";
if (dataDir[dataDir.size()-1]!='/' && dataDir[dataDir.size()-1]!='\\')
dataDir += "/";
const char* esmFile = "Morrowind.esm";
const char* bsaFile = "Morrowind.bsa";
const char* plugCfg = "plugins.cfg"; const char* plugCfg = "plugins.cfg";
cout << "Hello, fellow traveler!\n"; cout << "Hello, fellow traveler!\n";
cout << "Your data directory for today is: " << dataDir << "\n";
cout << "Initializing OGRE\n"; cout << "Initializing OGRE\n";
Render::OgreRenderer ogre; Render::OgreRenderer ogre;
ogre.configure(!isFile("ogre.cfg"), plugCfg, false); ogre.configure(!isFile("ogre.cfg"), plugCfg, false);
cout << "Adding " << bsaFile << endl; cout << "Adding " << bsaFile << endl;
addBSA(bsaFile); addBSA(dataDir + bsaFile);
cout << "Loading ESM " << esmFile << "\n"; cout << "Loading ESM " << esmFile << "\n";
ESM::ESMReader esm; ESM::ESMReader esm;
@ -35,7 +45,7 @@ void maintest()
ESMS::CellStore cell; ESMS::CellStore cell;
// This parses the ESM file and loads a sample cell // This parses the ESM file and loads a sample cell
esm.open(esmFile); esm.open(dataDir + esmFile);
store.load(esm); store.load(esm);
cell.loadInt("Beshara", store, esm); cell.loadInt("Beshara", store, esm);
@ -75,20 +85,30 @@ int main(int argc, char**argv)
"Syntax: openmw <options>\nAllowed options"); "Syntax: openmw <options>\nAllowed options");
desc.add_options() desc.add_options()
("help", "print help message"); ("help", "print help message")
("data", boost::program_options::value<std::string>()->default_value ("data"),
"set data directory"
);
boost::program_options::variables_map variables; boost::program_options::variables_map variables;
std::ifstream configFile ("openmw.cfg");
boost::program_options::store ( boost::program_options::store (
boost::program_options::parse_command_line (argc, argv, desc), variables); boost::program_options::parse_command_line (argc, argv, desc), variables);
boost::program_options::notify (variables); boost::program_options::notify (variables);
if (configFile.is_open())
boost::program_options::store (
boost::program_options::parse_config_file (configFile, desc), variables);
if (variables.count ("help")) if (variables.count ("help"))
{ {
std::cout << desc << std::endl; std::cout << desc << std::endl;
} }
else else
{ {
maintest(); maintest (variables["data"].as<std::string>());
} }
} }
catch(exception &e) catch(exception &e)

Loading…
Cancel
Save