factored out two function from OMW::Engine::go

The initialization code inside Engine::go is now in two function it
calls prior to running the main loop.
actorid
Nathan Jeffords 12 years ago
parent 274ff530dc
commit d469415e59

@ -240,18 +240,9 @@ void OMW::Engine::setNewGame(bool newGame)
mNewGame = newGame;
}
// Initialise and enter main loop.
void OMW::Engine::go()
std::string OMW::Engine::loadSettings (Settings::Manager & settings)
{
assert (!mCellName.empty());
assert (!mMaster.empty());
assert (!mOgre);
mOgre = new OEngine::Render::OgreRenderer;
// Create the settings manager and load default settings file
Settings::Manager settings;
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg";
const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/settings-default.cfg";
@ -272,10 +263,6 @@ void OMW::Engine::go()
else if (boost::filesystem::exists(globaldefault))
settings.loadUser(globaldefault);
// Get the path for the keybinder xml file
std::string keybinderUser = (mCfgMgr.getUserPath() / "input.xml").string();
bool keybinderUserExists = boost::filesystem::exists(keybinderUser);
mFpsLevel = settings.getInt("fps", "HUD");
// load nif overrides
@ -285,6 +272,11 @@ void OMW::Engine::go()
else if (boost::filesystem::exists(mCfgMgr.getGlobalPath().string() + "/transparency-overrides.cfg"))
nifOverrides.loadTransparencyOverrides(mCfgMgr.getGlobalPath().string() + "/transparency-overrides.cfg");
return settingspath;
}
void OMW::Engine::prepareEngine (Settings::Manager & settings)
{
std::string renderSystem = settings.getString("render system", "Video");
if (renderSystem == "")
{
@ -294,6 +286,9 @@ void OMW::Engine::go()
renderSystem = "OpenGL Rendering Subsystem";
#endif
}
mOgre = new OEngine::Render::OgreRenderer;
mOgre->configure(
mCfgMgr.getLogPath().string(),
renderSystem,
@ -365,6 +360,11 @@ void OMW::Engine::go()
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts, mTranslationDataStorage));
// Sets up the input system
// Get the path for the keybinder xml file
std::string keybinderUser = (mCfgMgr.getUserPath() / "input.xml").string();
bool keybinderUserExists = boost::filesystem::exists(keybinderUser);
mEnvironment.setInputManager (new MWInput::InputManager (*mOgre,
MWBase::Environment::get().getWorld()->getPlayer(),
*MWBase::Environment::get().getWindowManager(), mDebug, *this, keybinderUser, keybinderUserExists));
@ -388,13 +388,8 @@ void OMW::Engine::go()
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos);
}
std::cout << "\nPress Q/ESC or close window to exit.\n";
mOgre->getRoot()->addFrameListener (this);
// Play some good 'ol tunes
MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Explore"));
// scripts
if (mCompileAll)
{
@ -407,10 +402,31 @@ void OMW::Engine::go()
<< "%)"
<< std::endl;
}
}
// Initialise and enter main loop.
void OMW::Engine::go()
{
assert (!mCellName.empty());
assert (!mMaster.empty());
assert (!mOgre);
Settings::Manager settings;
std::string settingspath;
settingspath = loadSettings (settings);
prepareEngine (settings);
// Play some good 'ol tunes
MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Explore"));
if (!mStartupScript.empty())
MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript);
std::cout << "\nPress Q/ESC or close window to exit.\n";
// Start the main rendering loop
mOgre->start();

@ -6,6 +6,7 @@
#include <components/compiler/extensions.hpp>
#include <components/files/collections.hpp>
#include <components/translation/translation.hpp>
#include <components/settings/settings.hpp>
#include "mwbase/environment.hpp"
@ -103,6 +104,12 @@ namespace OMW
virtual bool frameRenderingQueued (const Ogre::FrameEvent& evt);
/// Load settings from various files, returns the path to the user settings file
std::string loadSettings (Settings::Manager & settings);
/// Prepare engine for game play
void prepareEngine (Settings::Manager & settings);
public:
Engine(Files::ConfigurationManager& configurationManager);
virtual ~Engine();

Loading…
Cancel
Save