2012-04-23 10:57:16 +02:00
|
|
|
#include "environment.hpp"
|
|
|
|
|
|
|
|
#include <cassert>
|
2017-08-30 21:26:30 +00:00
|
|
|
|
2020-12-29 21:45:59 +01:00
|
|
|
#include <components/resource/resourcesystem.hpp>
|
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
#include "world.hpp"
|
2012-08-08 15:18:55 +02:00
|
|
|
#include "scriptmanager.hpp"
|
2012-08-09 10:35:53 +02:00
|
|
|
#include "dialoguemanager.hpp"
|
2012-08-09 12:56:03 +02:00
|
|
|
#include "journal.hpp"
|
2012-08-09 14:33:21 +02:00
|
|
|
#include "soundmanager.hpp"
|
2012-08-11 17:30:55 +02:00
|
|
|
#include "mechanicsmanager.hpp"
|
2012-08-11 17:53:39 +02:00
|
|
|
#include "inputmanager.hpp"
|
2012-08-12 18:11:09 +02:00
|
|
|
#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"
|
2012-07-03 12:30:50 +02:00
|
|
|
|
2020-11-13 11:39:47 +04:00
|
|
|
MWBase::Environment *MWBase::Environment::sThis = nullptr;
|
2012-04-23 10:57:16 +02:00
|
|
|
|
|
|
|
MWBase::Environment::Environment()
|
|
|
|
{
|
2022-01-29 23:21:39 +02:00
|
|
|
assert(!sThis);
|
2012-04-23 10:57:16 +02:00
|
|
|
sThis = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
MWBase::Environment::~Environment()
|
|
|
|
{
|
2020-11-13 11:39:47 +04:00
|
|
|
sThis = nullptr;
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2022-01-29 23:21:39 +02:00
|
|
|
void MWBase::Environment::setWorld (std::unique_ptr<World>&& world)
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
2022-01-29 23:21:39 +02:00
|
|
|
mWorld = std::move(world);
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2022-01-29 23:21:39 +02:00
|
|
|
void MWBase::Environment::setSoundManager (std::unique_ptr<SoundManager>&& soundManager)
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
2022-01-29 23:21:39 +02:00
|
|
|
mSoundManager = std::move(soundManager);
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2022-01-29 23:21:39 +02:00
|
|
|
void MWBase::Environment::setScriptManager (std::unique_ptr<ScriptManager>&& scriptManager)
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
2022-01-29 23:21:39 +02:00
|
|
|
mScriptManager = std::move(scriptManager);
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2022-01-29 23:21:39 +02:00
|
|
|
void MWBase::Environment::setWindowManager (std::unique_ptr<WindowManager>&& windowManager)
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
2022-01-29 23:21:39 +02:00
|
|
|
mWindowManager = std::move(windowManager);
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2022-01-29 23:21:39 +02:00
|
|
|
void MWBase::Environment::setMechanicsManager (std::unique_ptr<MechanicsManager>&& mechanicsManager)
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
2022-01-29 23:21:39 +02:00
|
|
|
mMechanicsManager = std::move(mechanicsManager);
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2022-01-29 23:21:39 +02:00
|
|
|
void MWBase::Environment::setDialogueManager (std::unique_ptr<DialogueManager>&& dialogueManager)
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
2022-01-29 23:21:39 +02:00
|
|
|
mDialogueManager = std::move(dialogueManager);
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2022-01-29 23:21:39 +02:00
|
|
|
void MWBase::Environment::setJournal (std::unique_ptr<Journal>&& journal)
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
2022-01-29 23:21:39 +02:00
|
|
|
mJournal = std::move(journal);
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2022-01-29 23:21:39 +02:00
|
|
|
void MWBase::Environment::setInputManager (std::unique_ptr<InputManager>&& inputManager)
|
2012-04-23 15:27:03 +02:00
|
|
|
{
|
2022-01-29 23:21:39 +02:00
|
|
|
mInputManager = std::move(inputManager);
|
2012-04-23 15:27:03 +02:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-04-23 10:57:16 +02:00
|
|
|
void MWBase::Environment::setFrameDuration (float duration)
|
|
|
|
{
|
|
|
|
mFrameDuration = duration;
|
|
|
|
}
|
|
|
|
|
2017-08-30 21:26:30 +00:00
|
|
|
void MWBase::Environment::setFrameRateLimit(float limit)
|
|
|
|
{
|
|
|
|
mFrameRateLimit = limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
float MWBase::Environment::getFrameRateLimit() const
|
|
|
|
{
|
|
|
|
return mFrameRateLimit;
|
|
|
|
}
|
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
MWBase::World *MWBase::Environment::getWorld() const
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
|
|
|
assert (mWorld);
|
2022-01-29 23:21:39 +02:00
|
|
|
return mWorld.get();
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2012-08-09 14:33:21 +02:00
|
|
|
MWBase::SoundManager *MWBase::Environment::getSoundManager() const
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
|
|
|
assert (mSoundManager);
|
2022-01-29 23:21:39 +02:00
|
|
|
return mSoundManager.get();
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2012-08-08 15:18:55 +02:00
|
|
|
MWBase::ScriptManager *MWBase::Environment::getScriptManager() const
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
|
|
|
assert (mScriptManager);
|
2022-01-29 23:21:39 +02:00
|
|
|
return mScriptManager.get();
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2012-08-12 18:11:09 +02:00
|
|
|
MWBase::WindowManager *MWBase::Environment::getWindowManager() const
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
|
|
|
assert (mWindowManager);
|
2022-01-29 23:21:39 +02:00
|
|
|
return mWindowManager.get();
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2012-08-11 17:30:55 +02:00
|
|
|
MWBase::MechanicsManager *MWBase::Environment::getMechanicsManager() const
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
|
|
|
assert (mMechanicsManager);
|
2022-01-29 23:21:39 +02:00
|
|
|
return mMechanicsManager.get();
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2012-08-09 10:35:53 +02:00
|
|
|
MWBase::DialogueManager *MWBase::Environment::getDialogueManager() const
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
|
|
|
assert (mDialogueManager);
|
2022-01-29 23:21:39 +02:00
|
|
|
return mDialogueManager.get();
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2012-08-09 12:56:03 +02:00
|
|
|
MWBase::Journal *MWBase::Environment::getJournal() const
|
2012-04-23 10:57:16 +02:00
|
|
|
{
|
|
|
|
assert (mJournal);
|
2022-01-29 23:21:39 +02:00
|
|
|
return mJournal.get();
|
2012-04-23 10:57:16 +02:00
|
|
|
}
|
|
|
|
|
2012-08-11 17:53:39 +02:00
|
|
|
MWBase::InputManager *MWBase::Environment::getInputManager() const
|
2012-04-23 15:27:03 +02:00
|
|
|
{
|
|
|
|
assert (mInputManager);
|
2022-01-29 23:21:39 +02:00
|
|
|
return mInputManager.get();
|
2012-04-23 15:27:03 +02:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-04-23 10:57:16 +02:00
|
|
|
float MWBase::Environment::getFrameDuration() const
|
|
|
|
{
|
|
|
|
return mFrameDuration;
|
|
|
|
}
|
|
|
|
|
2012-05-04 17:20:57 +02:00
|
|
|
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;
|
2012-05-04 17:20:57 +02:00
|
|
|
}
|
|
|
|
|
2012-04-23 10:57:16 +02:00
|
|
|
const MWBase::Environment& MWBase::Environment::get()
|
|
|
|
{
|
|
|
|
assert (sThis);
|
|
|
|
return *sThis;
|
|
|
|
}
|
2020-05-22 00:11:23 +02:00
|
|
|
|
|
|
|
void MWBase::Environment::reportStats(unsigned int frameNumber, osg::Stats& stats) const
|
|
|
|
{
|
|
|
|
mMechanicsManager->reportStats(frameNumber, stats);
|
|
|
|
mWorld->reportStats(frameNumber, stats);
|
|
|
|
}
|