Cleanup fix

This commit is contained in:
scrawl 2015-04-24 23:30:30 +02:00
parent 42d6c6140c
commit 15164e20f7
5 changed files with 21 additions and 14 deletions

View file

@ -314,9 +314,9 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
settings.getBool("minimize on focus loss", "Video") ? "1" : "0"); settings.getBool("minimize on focus loss", "Video") ? "1" : "0");
// not handling fullscreen yet, we should figure this out when adding SDL to the mix // not handling fullscreen yet, we should figure this out when adding SDL to the mix
mViewer.setUpViewInWindow(0, 0, settings.getInt("resolution x", "Video"), settings.getInt("resolution y", "Video"), settings.getInt("screen", "Video")); mViewer->setUpViewInWindow(0, 0, settings.getInt("resolution x", "Video"), settings.getInt("resolution y", "Video"), settings.getInt("screen", "Video"));
osg::ref_ptr<osg::Group> rootNode (new osg::Group); osg::ref_ptr<osg::Group> rootNode (new osg::Group);
mViewer.setSceneData(rootNode); mViewer->setSceneData(rootNode);
mVFS.reset(new VFS::Manager(mFSStrict)); mVFS.reset(new VFS::Manager(mFSStrict));
@ -355,7 +355,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
std::string myguiResources = (mResDir / "mygui").string(); std::string myguiResources = (mResDir / "mygui").string();
osg::ref_ptr<osg::Group> guiRoot = new osg::Group; osg::ref_ptr<osg::Group> guiRoot = new osg::Group;
rootNode->addChild(guiRoot); rootNode->addChild(guiRoot);
MWGui::WindowManager* window = new MWGui::WindowManager(&mViewer, guiRoot, mResourceSystem->getTextureManager(), MWGui::WindowManager* window = new MWGui::WindowManager(mViewer, guiRoot, mResourceSystem->getTextureManager(),
mCfgMgr.getLogPath().string() + std::string("/"), myguiResources, mCfgMgr.getLogPath().string() + std::string("/"), myguiResources,
mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts, mFallbackMap); mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts, mFallbackMap);
mEnvironment.setWindowManager (window); mEnvironment.setWindowManager (window);
@ -371,7 +371,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
} }
// Create the world // Create the world
mEnvironment.setWorld( new MWWorld::World (mViewer, rootNode, mResourceSystem.get(), mEnvironment.setWorld( new MWWorld::World (*mViewer, rootNode, mResourceSystem.get(),
mFileCollections, mContentFiles, mEncoder, mFallbackMap, mFileCollections, mContentFiles, mEncoder, mFallbackMap,
mActivationDistanceOverride, mCellName, mStartupScript)); mActivationDistanceOverride, mCellName, mStartupScript));
MWBase::Environment::get().getWorld()->setupPlayer(); MWBase::Environment::get().getWorld()->setupPlayer();
@ -433,7 +433,8 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
void OMW::Engine::go() void OMW::Engine::go()
{ {
assert (!mContentFiles.empty()); assert (!mContentFiles.empty());
//assert (!mOgre);
mViewer = new osgViewer::Viewer;
Settings::Manager settings; Settings::Manager settings;
std::string settingspath; std::string settingspath;
@ -474,12 +475,12 @@ void OMW::Engine::go()
} }
// Start the main rendering loop // Start the main rendering loop
mViewer.setCameraManipulator(new osgGA::TrackballManipulator); mViewer->setCameraManipulator(new osgGA::TrackballManipulator);
mViewer.addEventHandler(new osgViewer::StatsHandler); mViewer->addEventHandler(new osgViewer::StatsHandler);
mViewer.realize(); mViewer->realize();
osg::Timer frameTimer; osg::Timer frameTimer;
while (!mViewer.done()) while (!mViewer->done())
{ {
double dt = frameTimer.time_s(); double dt = frameTimer.time_s();
frameTimer.setStartTick(); frameTimer.setStartTick();
@ -491,7 +492,7 @@ void OMW::Engine::go()
MWBase::Environment::get().getWorld()->advanceTime( MWBase::Environment::get().getWorld()->advanceTime(
dt*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600); dt*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);
mViewer.frame(/*simulationTime*/); mViewer->frame(/*simulationTime*/);
} }
// Save user settings // Save user settings

View file

@ -69,7 +69,7 @@ namespace OMW
Files::PathContainer mDataDirs; Files::PathContainer mDataDirs;
std::vector<std::string> mArchives; std::vector<std::string> mArchives;
boost::filesystem::path mResDir; boost::filesystem::path mResDir;
osgViewer::Viewer mViewer; osg::ref_ptr<osgViewer::Viewer> mViewer;
std::string mCellName; std::string mCellName;
std::vector<std::string> mContentFiles; std::vector<std::string> mContentFiles;
bool mVerboseScripts; bool mVerboseScripts;

View file

@ -561,7 +561,7 @@ void RenderManager::setViewSize(int width, int height)
mInfo.aspectCoef = float(mViewSize.height) / float(mViewSize.width); mInfo.aspectCoef = float(mViewSize.height) / float(mViewSize.width);
mInfo.pixScaleX = 1.0f / float(mViewSize.width); mInfo.pixScaleX = 1.0f / float(mViewSize.width);
mInfo.pixScaleY = 1.0f / float(mViewSize.height); mInfo.pixScaleY = 1.0f / float(mViewSize.height);
std::cout << "setviewsize " << width << " " << height << std::endl;
onResizeView(mViewSize); onResizeView(mViewSize);
mUpdate = true; mUpdate = true;
} }

View file

@ -173,8 +173,8 @@ namespace MWGui
, mCurrentModals() , mCurrentModals()
, mFallbackMap(fallbackMap) , mFallbackMap(fallbackMap)
{ {
Platform* platform = new Platform(viewer, guiRoot, textureManager); mGuiPlatform = new Platform(viewer, guiRoot, textureManager);
platform->initialise(resourcePath, logpath); mGuiPlatform->initialise(resourcePath, logpath);
MyGUI::Gui* gui = new MyGUI::Gui; MyGUI::Gui* gui = new MyGUI::Gui;
gui->initialise(""); gui->initialise("");
@ -411,6 +411,8 @@ namespace MWGui
//delete mCursorManager; //delete mCursorManager;
cleanupGarbage(); cleanupGarbage();
delete mGuiPlatform;
} }
void WindowManager::cleanupGarbage() void WindowManager::cleanupGarbage()

View file

@ -107,6 +107,8 @@ namespace MWGui
class DebugWindow; class DebugWindow;
class JailScreen; class JailScreen;
class Platform;
class WindowManager : public MWBase::WindowManager class WindowManager : public MWBase::WindowManager
{ {
public: public:
@ -365,6 +367,8 @@ namespace MWGui
virtual void cycleWeapon(bool next); virtual void cycleWeapon(bool next);
private: private:
Platform* mGuiPlatform;
bool mConsoleOnlyScripts; bool mConsoleOnlyScripts;
std::map<MyGUI::Window*, std::string> mTrackedWindows; std::map<MyGUI::Window*, std::string> mTrackedWindows;