1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00
OpenMW/apps/openmw/mwbase/environment.cpp

197 lines
4.4 KiB
C++
Raw Normal View History

#include "environment.hpp"
#include <cassert>
2020-12-29 21:45:59 +01:00
#include <components/resource/resourcesystem.hpp>
#include "world.hpp"
#include "scriptmanager.hpp"
#include "dialoguemanager.hpp"
#include "journal.hpp"
#include "soundmanager.hpp"
#include "mechanicsmanager.hpp"
#include "inputmanager.hpp"
#include "windowmanager.hpp"
2013-11-16 10:31:46 +01:00
#include "statemanager.hpp"
2020-12-18 23:21:10 +01:00
#include "luamanager.hpp"
2020-11-13 11:39:47 +04:00
MWBase::Environment *MWBase::Environment::sThis = nullptr;
MWBase::Environment::Environment()
{
2022-01-29 23:21:39 +02:00
assert(!sThis);
sThis = this;
}
MWBase::Environment::~Environment()
{
2020-11-13 11:39:47 +04:00
sThis = nullptr;
}
2022-01-29 23:21:39 +02:00
void MWBase::Environment::setWorld (std::unique_ptr<World>&& world)
{
2022-01-29 23:21:39 +02:00
mWorld = std::move(world);
}
2022-01-29 23:21:39 +02:00
void MWBase::Environment::setSoundManager (std::unique_ptr<SoundManager>&& soundManager)
{
2022-01-29 23:21:39 +02:00
mSoundManager = std::move(soundManager);
}
2022-01-29 23:21:39 +02:00
void MWBase::Environment::setScriptManager (std::unique_ptr<ScriptManager>&& scriptManager)
{
2022-01-29 23:21:39 +02:00
mScriptManager = std::move(scriptManager);
}
2022-01-29 23:21:39 +02:00
void MWBase::Environment::setWindowManager (std::unique_ptr<WindowManager>&& windowManager)
{
2022-01-29 23:21:39 +02:00
mWindowManager = std::move(windowManager);
}
2022-01-29 23:21:39 +02:00
void MWBase::Environment::setMechanicsManager (std::unique_ptr<MechanicsManager>&& mechanicsManager)
{
2022-01-29 23:21:39 +02:00
mMechanicsManager = std::move(mechanicsManager);
}
2022-01-29 23:21:39 +02:00
void MWBase::Environment::setDialogueManager (std::unique_ptr<DialogueManager>&& dialogueManager)
{
2022-01-29 23:21:39 +02:00
mDialogueManager = std::move(dialogueManager);
}
2022-01-29 23:21:39 +02:00
void MWBase::Environment::setJournal (std::unique_ptr<Journal>&& journal)
{
2022-01-29 23:21:39 +02:00
mJournal = std::move(journal);
}
2022-01-29 23:21:39 +02:00
void MWBase::Environment::setInputManager (std::unique_ptr<InputManager>&& inputManager)
{
2022-01-29 23:21:39 +02:00
mInputManager = std::move(inputManager);
}
2022-01-29 23:21:39 +02:00
void MWBase::Environment::setStateManager (std::unique_ptr<StateManager>&& stateManager)
2013-11-16 10:31:46 +01:00
{
2022-01-29 23:21:39 +02:00
mStateManager = std::move(stateManager);
2013-11-16 10:31:46 +01:00
}
2022-01-29 23:21:39 +02:00
void MWBase::Environment::setLuaManager (std::unique_ptr<LuaManager>&& luaManager)
2020-12-18 23:21:10 +01:00
{
2022-01-29 23:21:39 +02:00
mLuaManager = std::move(luaManager);
2020-12-18 23:21:10 +01:00
}
2020-12-29 21:45:59 +01:00
void MWBase::Environment::setResourceSystem (Resource::ResourceSystem *resourceSystem)
{
mResourceSystem = resourceSystem;
}
void MWBase::Environment::setFrameDuration (float duration)
{
mFrameDuration = duration;
}
void MWBase::Environment::setFrameRateLimit(float limit)
{
mFrameRateLimit = limit;
}
float MWBase::Environment::getFrameRateLimit() const
{
return mFrameRateLimit;
}
MWBase::World *MWBase::Environment::getWorld() const
{
assert (mWorld);
2022-01-29 23:21:39 +02:00
return mWorld.get();
}
MWBase::SoundManager *MWBase::Environment::getSoundManager() const
{
assert (mSoundManager);
2022-01-29 23:21:39 +02:00
return mSoundManager.get();
}
MWBase::ScriptManager *MWBase::Environment::getScriptManager() const
{
assert (mScriptManager);
2022-01-29 23:21:39 +02:00
return mScriptManager.get();
}
MWBase::WindowManager *MWBase::Environment::getWindowManager() const
{
assert (mWindowManager);
2022-01-29 23:21:39 +02:00
return mWindowManager.get();
}
MWBase::MechanicsManager *MWBase::Environment::getMechanicsManager() const
{
assert (mMechanicsManager);
2022-01-29 23:21:39 +02:00
return mMechanicsManager.get();
}
MWBase::DialogueManager *MWBase::Environment::getDialogueManager() const
{
assert (mDialogueManager);
2022-01-29 23:21:39 +02:00
return mDialogueManager.get();
}
MWBase::Journal *MWBase::Environment::getJournal() const
{
assert (mJournal);
2022-01-29 23:21:39 +02:00
return mJournal.get();
}
MWBase::InputManager *MWBase::Environment::getInputManager() const
{
assert (mInputManager);
2022-01-29 23:21:39 +02:00
return mInputManager.get();
}
2013-11-16 10:31:46 +01:00
MWBase::StateManager *MWBase::Environment::getStateManager() const
{
assert (mStateManager);
2022-01-29 23:21:39 +02:00
return mStateManager.get();
2013-11-16 10:31:46 +01:00
}
2020-12-18 23:21:10 +01:00
MWBase::LuaManager *MWBase::Environment::getLuaManager() const
{
assert (mLuaManager);
2022-01-29 23:21:39 +02:00
return mLuaManager.get();
2020-12-18 23:21:10 +01:00
}
2020-12-29 21:45:59 +01:00
Resource::ResourceSystem *MWBase::Environment::getResourceSystem() const
{
return mResourceSystem;
}
float MWBase::Environment::getFrameDuration() const
{
return mFrameDuration;
}
void MWBase::Environment::cleanup()
{
2022-01-29 23:21:39 +02:00
mMechanicsManager.reset();
mDialogueManager.reset();
mJournal.reset();
mScriptManager.reset();
mWindowManager.reset();
mWorld.reset();
mSoundManager.reset();
mInputManager.reset();
mStateManager.reset();
mLuaManager.reset();
mResourceSystem = nullptr;
}
const MWBase::Environment& MWBase::Environment::get()
{
assert (sThis);
return *sThis;
}
void MWBase::Environment::reportStats(unsigned int frameNumber, osg::Stats& stats) const
{
mMechanicsManager->reportStats(frameNumber, stats);
mWorld->reportStats(frameNumber, stats);
}