mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-10 15:39:02 +00:00
3c91f7793b
Created a override of MyGUI::DataManager::isDataExist to fix a performance issue with MyGUI startup. This required moving the functionality of MyGUI::OgrePlatform into OEngine::GUI::MyGUIManager so that a new version of the MyGUI::DataManager could be created.
82 lines
2.1 KiB
C++
82 lines
2.1 KiB
C++
#include <MyGUI.h>
|
|
#include <MyGUI_OgrePlatform.h>
|
|
#include <cassert>
|
|
|
|
#include "manager.hpp"
|
|
|
|
using namespace OEngine::GUI;
|
|
|
|
/*
|
|
* As of MyGUI 3.2.0, MyGUI::OgreDataManager::isDataExist is unnecessarily complex
|
|
* this override fixes the resulting performance issue.
|
|
*/
|
|
class FixedOgreDataManager : public MyGUI::OgreDataManager
|
|
{
|
|
public:
|
|
bool isDataExist(const std::string& _name)
|
|
{
|
|
return Ogre::ResourceGroupManager::getSingleton().resourceExistsInAnyGroup (_name);
|
|
}
|
|
};
|
|
|
|
void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging, const std::string& logDir)
|
|
{
|
|
assert(wnd);
|
|
assert(mgr);
|
|
|
|
mSceneMgr = mgr;
|
|
|
|
using namespace MyGUI;
|
|
|
|
// Enable/disable MyGUI logging to stdout. (Logging to MyGUI.log is
|
|
// still enabled.) In order to do this we have to initialize the log
|
|
// manager before the main gui system itself, otherwise the main
|
|
// object will get the chance to spit out a few messages before we
|
|
// can able to disable it.
|
|
|
|
std::string theLogFile = std::string(MYGUI_PLATFORM_LOG_FILENAME);
|
|
if(!logDir.empty())
|
|
theLogFile.insert(0, logDir);
|
|
|
|
// Set up OGRE platform (bypassing OgrePlatform). We might make this more generic later.
|
|
mLogManager = new LogManager();
|
|
mRenderManager = new OgreRenderManager();
|
|
mDataManager = new FixedOgreDataManager();
|
|
|
|
LogManager::getInstance().setSTDOutputEnabled(logging);
|
|
|
|
if (!theLogFile.empty())
|
|
LogManager::getInstance().createDefaultSource(theLogFile);
|
|
|
|
mRenderManager->initialise(wnd, mgr);
|
|
mDataManager->initialise("General");
|
|
|
|
// Create GUI
|
|
mGui = new Gui();
|
|
mGui->initialise("core.xml");
|
|
}
|
|
|
|
void MyGUIManager::shutdown()
|
|
{
|
|
mGui->shutdown ();
|
|
delete mGui;
|
|
if(mRenderManager)
|
|
{
|
|
mRenderManager->shutdown();
|
|
delete mRenderManager;
|
|
mRenderManager = NULL;
|
|
}
|
|
if(mDataManager)
|
|
{
|
|
mDataManager->shutdown();
|
|
delete mDataManager;
|
|
mDataManager = NULL;
|
|
}
|
|
if (mLogManager)
|
|
{
|
|
delete mLogManager;
|
|
mLogManager = NULL;
|
|
}
|
|
mGui = NULL;
|
|
}
|