1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 00:49:54 +00:00
openmw-tes3mp/game/main.cpp

123 lines
3 KiB
C++
Raw Normal View History

#include <iostream>
2010-06-11 17:53:00 +00:00
#include <string>
#include <fstream>
#include "boost/program_options.hpp"
#include "esm_store/cell_store.hpp"
#include "bsa/bsa_archive.hpp"
2010-06-03 19:51:59 +00:00
#include "ogre/renderer.hpp"
#include "tools/fileops.hpp"
2010-06-12 11:01:20 +00:00
#include "mwrender/interior.hpp"
#include "mwrender/mwscene.hpp"
#include "mwinput/inputmanager.hpp"
using namespace std;
void maintest (std::string dataDir, const std::string& cellName)
{
2010-06-11 17:53:00 +00:00
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";
2010-06-11 17:53:00 +00:00
cout << "Your data directory for today is: " << dataDir << "\n";
cout << "Initializing OGRE\n";
2010-06-03 19:51:59 +00:00
Render::OgreRenderer ogre;
ogre.configure(!isFile("ogre.cfg"), plugCfg, false);
cout << "Adding " << bsaFile << endl;
2010-06-11 17:53:00 +00:00
addBSA(dataDir + bsaFile);
cout << "Loading ESM " << esmFile << "\n";
ESM::ESMReader esm;
2010-05-17 18:59:15 +00:00
ESMS::ESMStore store;
ESMS::CellStore cell;
2010-06-06 10:52:21 +00:00
// This parses the ESM file and loads a sample cell
2010-06-11 17:53:00 +00:00
esm.open(dataDir + esmFile);
2010-05-17 18:59:15 +00:00
store.load(esm);
cell.loadInt(cellName, store, esm);
2010-06-06 10:52:21 +00:00
// Create the window
2010-06-03 19:51:59 +00:00
ogre.createWindow("OpenMW");
cout << "\nSetting up cell rendering\n";
// Sets up camera, scene manager etc
MWRender::MWScene scene(ogre);
// This connects the cell data with the rendering scene.
2010-06-12 11:01:20 +00:00
MWRender::InteriorCellRender rend(cell, scene);
// Load the cell and insert it into the renderer
rend.show();
2010-06-06 10:52:21 +00:00
cout << "Setting up input system\n";
// Sets up the input system
MWInput::MWInputManager input(ogre);
cout << "\nStart! Press Q/ESC or close window to exit.\n";
// Start the main rendering loop
ogre.start();
cout << "\nThat's all for now!\n";
}
int main(int argc, char**argv)
{
try
{
boost::program_options::options_description desc (
"Syntax: openmw <options>\nAllowed options");
desc.add_options()
2010-06-11 17:53:00 +00:00
("help", "print help message")
("data", boost::program_options::value<std::string>()->default_value ("data"),
"set data directory")
("start", boost::program_options::value<std::string>()->default_value ("Beshara"),
"set initial cell (only interior cells supported at the moment")
;
boost::program_options::variables_map variables;
2010-06-11 17:53:00 +00:00
std::ifstream configFile ("openmw.cfg");
boost::program_options::store (
boost::program_options::parse_command_line (argc, argv, desc), variables);
boost::program_options::notify (variables);
2010-06-11 17:53:00 +00:00
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 (variables["data"].as<std::string>(), variables["start"].as<std::string>());
}
}
catch(exception &e)
{
cout << "\nERROR: " << e.what() << endl;
return 1;
}
return 0;
}