1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00
OpenMW/apps/openmw/engine.hpp

192 lines
5.7 KiB
C++
Raw Normal View History

#ifndef ENGINE_H
#define ENGINE_H
2010-07-03 12:12:13 +02:00
#include <components/compiler/extensions.hpp>
#include <components/files/collections.hpp>
#include <components/translation/translation.hpp>
#include <components/settings/settings.hpp>
#include <osgViewer/Viewer>
2017-11-09 18:26:27 +01:00
#include <osgViewer/ViewerEventHandlers>
#include "mwbase/environment.hpp"
#include "mwworld/ptr.hpp"
2010-07-04 10:43:34 +02:00
namespace Resource
{
class ResourceSystem;
}
2017-02-14 03:37:45 +01:00
namespace SceneUtil
{
class WorkQueue;
}
namespace VFS
{
class Manager;
}
2010-07-02 17:21:27 +02:00
namespace Compiler
{
class Context;
}
namespace Files
{
struct ConfigurationManager;
}
2015-06-03 17:25:18 +02:00
namespace osgViewer
{
class ScreenCaptureHandler;
}
struct SDL_Window;
2010-07-03 15:41:20 +02:00
namespace OMW
{
/// \brief Main engine class, that brings together all the components of OpenMW
2015-04-25 15:19:17 +02:00
class Engine
{
SDL_Window* mWindow;
std::unique_ptr<VFS::Manager> mVFS;
std::unique_ptr<Resource::ResourceSystem> mResourceSystem;
2017-02-14 03:37:45 +01:00
osg::ref_ptr<SceneUtil::WorkQueue> mWorkQueue;
MWBase::Environment mEnvironment;
2012-12-23 23:23:24 +04:00
ToUTF8::FromType mEncoding;
ToUTF8::Utf8Encoder* mEncoder;
Files::PathContainer mDataDirs;
std::vector<std::string> mArchives;
boost::filesystem::path mResDir;
2015-04-24 23:30:30 +02:00
osg::ref_ptr<osgViewer::Viewer> mViewer;
2015-06-03 17:25:18 +02:00
osg::ref_ptr<osgViewer::ScreenCaptureHandler> mScreenCaptureHandler;
2017-11-09 18:26:27 +01:00
osgViewer::ScreenCaptureHandler::CaptureOperation *mScreenCaptureOperation;
std::string mCellName;
std::vector<std::string> mContentFiles;
2020-01-12 11:42:47 +04:00
std::vector<std::string> mGroundcoverFiles;
2013-11-16 11:33:20 +01:00
bool mSkipMenu;
2010-08-18 11:16:15 +02:00
bool mUseSound;
2010-10-06 14:52:53 +02:00
bool mCompileAll;
bool mCompileAllDialogue;
2014-02-02 14:09:59 +01:00
int mWarningsMode;
std::string mFocusName;
bool mScriptConsoleMode;
2012-07-30 12:37:46 +02:00
std::string mStartupScript;
int mActivationDistanceOverride;
std::string mSaveGameFile;
// Grab mouse?
bool mGrab;
2014-08-11 20:37:29 +02:00
bool mExportFonts;
unsigned int mRandomSeed;
2014-08-11 20:37:29 +02:00
2010-07-03 12:12:13 +02:00
Compiler::Extensions mExtensions;
2010-07-02 17:21:27 +02:00
Compiler::Context *mScriptContext;
2012-03-05 16:56:14 +01:00
Files::Collections mFileCollections;
2011-05-05 19:56:16 +02:00
bool mFSStrict;
Translation::Storage mTranslationDataStorage;
2014-07-21 09:34:10 +02:00
std::vector<std::string> mScriptBlacklist;
bool mScriptBlacklistUse;
2014-09-01 11:55:12 +02:00
bool mNewGame;
// not implemented
Engine (const Engine&);
Engine& operator= (const Engine&);
void executeLocalScripts();
bool frame (float dt);
/// 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);
void createWindow(Settings::Manager& settings);
2015-05-13 15:03:21 +02:00
void setWindowIcon();
public:
Engine(Files::ConfigurationManager& configurationManager);
virtual ~Engine();
2011-05-05 19:56:16 +02:00
/// Enable strict filesystem mode (do not fold case)
///
/// \attention The strict mode must be specified before any path-related settings
/// are given to the engine.
void enableFSStrict(bool fsStrict);
2011-05-05 19:56:16 +02:00
/// Set data dirs
void setDataDirs(const Files::PathContainer& dataDirs);
/// Add BSA archive
void addArchive(const std::string& archive);
/// Set resource dir
void setResourceDir(const boost::filesystem::path& parResDir);
/// Set start cell name
void setCell(const std::string& cellName);
/**
* @brief addContentFile - Adds content file (ie. esm/esp, or omwgame/omwaddon) to the content files container.
* @param file - filename (extension is required)
*/
void addContentFile(const std::string& file);
2020-01-12 11:42:47 +04:00
void addGroundcoverFile(const std::string& file);
/// Disable or enable all sounds
void setSoundUsage(bool soundUsage);
2010-08-18 11:16:15 +02:00
2014-09-01 11:55:12 +02:00
/// Skip main menu and go directly into the game
///
/// \param newGame Start a new game instead off dumping the player into the game
/// (ignored if !skipMenu).
void setSkipMenu (bool skipMenu, bool newGame);
2013-11-16 11:33:20 +01:00
void setGrabMouse(bool grab) { mGrab = grab; }
/// Initialise and enter main loop.
void go();
2010-10-06 14:52:53 +02:00
/// Compile all scripts (excludign dialogue scripts) at startup?
void setCompileAll (bool all);
/// Compile all dialogue scripts at startup?
void setCompileAllDialogue (bool all);
/// Font encoding
2012-12-23 23:23:24 +04:00
void setEncoding(const ToUTF8::FromType& encoding);
/// Enable console-only script functionality
void setScriptConsoleMode (bool enabled);
2012-07-30 12:37:46 +02:00
/// Set path for a script that is run on startup in the console.
void setStartupScript (const std::string& path);
/// Override the game setting specified activation distance.
void setActivationDistanceOverride (int distance);
2014-02-02 14:09:59 +01:00
void setWarningsMode (int mode);
2014-07-21 09:34:10 +02:00
void setScriptBlacklist (const std::vector<std::string>& list);
void setScriptBlacklistUse (bool use);
2014-08-11 20:37:29 +02:00
void enableFontExport(bool exportFonts);
/// Set the save game file to load after initialising the engine.
void setSaveGameFile(const std::string& savegame);
void setRandomSeed(unsigned int seed);
private:
Files::ConfigurationManager& mCfgMgr;
};
}
#endif /* ENGINE_H */