forked from teamnwah/openmw-tes3coop
added data option and openmw.cfg file
This commit is contained in:
parent
293c7c29c4
commit
9a041d7c01
5 changed files with 36 additions and 9 deletions
|
@ -81,6 +81,9 @@ configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.linux
|
|||
"${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY)
|
||||
endif (WIN32)
|
||||
|
||||
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
|
||||
"${OpenMW_BINARY_DIR}/openmw.cfg" COPYONLY)
|
||||
|
||||
# Main executable
|
||||
add_executable(openmw
|
||||
${BSA} ${BSA_HEADER}
|
||||
|
|
|
@ -157,7 +157,7 @@ static void insertBSAFactory()
|
|||
|
||||
// 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();
|
||||
ResourceGroupManager::getSingleton().
|
||||
|
|
|
@ -21,11 +21,13 @@
|
|||
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef _BSA_ARCHIVE_H_
|
||||
#define _BSA_ARCHIVE_H_
|
||||
|
||||
/// Add the given BSA file as an input archive in the Ogre resource
|
||||
/// system.
|
||||
void addBSA(const char* file, const char* group="General");
|
||||
void addBSA(const std::string& file, const std::string& group="General");
|
||||
|
||||
#endif
|
||||
|
|
2
files/openmw.cfg
Normal file
2
files/openmw.cfg
Normal file
|
@ -0,0 +1,2 @@
|
|||
data=data
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#include "boost/program_options.hpp"
|
||||
|
||||
#include "esm_store/cell_store.hpp"
|
||||
|
@ -13,21 +16,28 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
void maintest()
|
||||
void maintest (std::string dataDir)
|
||||
{
|
||||
const char* esmFile = "data/Morrowind.esm";
|
||||
const char* bsaFile = "data/Morrowind.bsa";
|
||||
assert (!dataDir.empty());
|
||||
|
||||
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";
|
||||
|
||||
cout << "Hello, fellow traveler!\n";
|
||||
|
||||
cout << "Your data directory for today is: " << dataDir << "\n";
|
||||
|
||||
cout << "Initializing OGRE\n";
|
||||
Render::OgreRenderer ogre;
|
||||
ogre.configure(!isFile("ogre.cfg"), plugCfg, false);
|
||||
|
||||
cout << "Adding " << bsaFile << endl;
|
||||
addBSA(bsaFile);
|
||||
addBSA(dataDir + bsaFile);
|
||||
|
||||
cout << "Loading ESM " << esmFile << "\n";
|
||||
ESM::ESMReader esm;
|
||||
|
@ -35,7 +45,7 @@ void maintest()
|
|||
ESMS::CellStore cell;
|
||||
|
||||
// This parses the ESM file and loads a sample cell
|
||||
esm.open(esmFile);
|
||||
esm.open(dataDir + esmFile);
|
||||
store.load(esm);
|
||||
|
||||
cell.loadInt("Beshara", store, esm);
|
||||
|
@ -75,20 +85,30 @@ int main(int argc, char**argv)
|
|||
"Syntax: openmw <options>\nAllowed 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;
|
||||
|
||||
std::ifstream configFile ("openmw.cfg");
|
||||
|
||||
boost::program_options::store (
|
||||
boost::program_options::parse_command_line (argc, argv, desc), 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"))
|
||||
{
|
||||
std::cout << desc << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
maintest();
|
||||
maintest (variables["data"].as<std::string>());
|
||||
}
|
||||
}
|
||||
catch(exception &e)
|
||||
|
|
Loading…
Reference in a new issue