Convert OverlaySystem to a OpenCS style singleton.

loadfix
cc9cii 10 years ago
parent aff6f6fdb2
commit 094f046087

@ -82,7 +82,7 @@ opencs_units (view/render
opencs_units_noqt (view/render
navigation navigation1st navigationfree navigationorbit lighting lightingday lightingnight
lightingbright object cell terrainstorage textoverlay overlaymask
lightingbright object cell terrainstorage textoverlay overlaymask overlaysystem
)
opencs_hdrs_noqt (view/render

@ -18,7 +18,6 @@
#include "model/doc/document.hpp"
#include "model/world/data.hpp"
#include "view/render/overlaysystem.hpp"
CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
: mUserSettings (mCfgMgr), mDocumentManager (mCfgMgr), mViewManager (mDocumentManager),
@ -276,7 +275,7 @@ std::auto_ptr<sh::Factory> CS::Editor::setupGraphics()
Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName(renderSystem));
// Initialise Ogre::OverlaySystem after Ogre::Root but before initialisation
CSVRender::OverlaySystem::instance();
mOverlaySystem.get();
Ogre::Root::getSingleton().initialise(false);

@ -27,6 +27,7 @@
#include "view/doc/newgame.hpp"
#include "view/settings/dialog.hpp"
#include "view/render/overlaysystem.hpp"
namespace OgreInit
{
@ -42,6 +43,7 @@ namespace CS
Nif::Cache mNifCache;
Files::ConfigurationManager mCfgMgr;
CSMSettings::UserSettings mUserSettings;
CSVRender::OverlaySystem mOverlaySystem;
CSMDoc::DocumentManager mDocumentManager;
CSVDoc::ViewManager mViewManager;
CSVDoc::StartupDialogue mStartup;

@ -0,0 +1,40 @@
#include "overlaysystem.hpp"
#include <OgreOverlaySystem.h>
namespace CSVRender
{
OverlaySystem *OverlaySystem::mOverlaySystemInstance = 0;
OverlaySystem::OverlaySystem() : mOverlaySystem(NULL)
{
assert(!mOverlaySystemInstance);
mOverlaySystemInstance = this;
}
OverlaySystem::~OverlaySystem()
{
if(mOverlaySystem)
delete mOverlaySystem;
}
OverlaySystem &OverlaySystem::instance()
{
assert(mOverlaySystemInstance);
return *mOverlaySystemInstance;
}
Ogre::OverlaySystem *OverlaySystem::get()
{
if(!mOverlaySystem)
mOverlaySystem = new Ogre::OverlaySystem();
return mOverlaySystem;
}
void OverlaySystem::destroy()
{
delete mOverlaySystem;
mOverlaySystem = NULL;
}
}

@ -1,40 +1,26 @@
#ifndef OPENCS_VIEW_OVERLAYSYSTEM_H
#define OPENCS_VIEW_OVERLAYSYSTEM_H
#include <OgreOverlaySystem.h>
namespace Ogre
{
class OverlaySystem;
}
namespace CSVRender
{
class OverlaySystem
{
Ogre::OverlaySystem *mOverlaySystem;
OverlaySystem() {
mOverlaySystem = new Ogre::OverlaySystem();
}
~OverlaySystem() {
if(mOverlaySystem) delete mOverlaySystem;
}
OverlaySystem(OverlaySystem const&);
void operator=(OverlaySystem const&);
static OverlaySystem *mOverlaySystemInstance;
public:
static OverlaySystem &instance() {
static OverlaySystem mInstance;
return mInstance;
}
Ogre::OverlaySystem *get() {
return mOverlaySystem;
}
OverlaySystem();
~OverlaySystem();
static OverlaySystem &instance();
void destroy() {
delete mOverlaySystem;
mOverlaySystem = NULL;
}
Ogre::OverlaySystem *get();
void destroy();
};
}

@ -11,6 +11,7 @@
#include <OgreCamera.h>
#include <OgreSceneNode.h>
#include <OgreViewport.h>
#include <OgreOverlaySystem.h>
#include "../widget/scenetoolmode.hpp"
#include "../../model/settings/usersettings.hpp"

Loading…
Cancel
Save