Merge branch 'loadingscreen'

This commit is contained in:
Marc Zinnschlag 2012-09-11 20:35:10 +02:00
commit d030fe7e79
17 changed files with 408 additions and 50 deletions

View File

@ -29,7 +29,7 @@ add_openmw_dir (mwgui
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
formatting inventorywindow container hud countdialog tradewindow settingswindow formatting inventorywindow container hud countdialog tradewindow settingswindow
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
itemselection spellbuyingwindow itemselection spellbuyingwindow loadingscreen
) )
add_openmw_dir (mwdialogue add_openmw_dir (mwdialogue

View File

@ -67,7 +67,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
mEnvironment.setFrameDuration (evt.timeSinceLastFrame); mEnvironment.setFrameDuration (evt.timeSinceLastFrame);
// update input // update input
MWBase::Environment::get().getInputManager()->update(evt.timeSinceLastFrame); MWBase::Environment::get().getInputManager()->update(evt.timeSinceLastFrame, false);
// sound // sound
if (mUseSound) if (mUseSound)
@ -351,6 +351,11 @@ void OMW::Engine::go()
mEnvironment.setJournal (new MWDialogue::Journal); mEnvironment.setJournal (new MWDialogue::Journal);
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions)); mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions));
// Sets up the input system
mEnvironment.setInputManager (new MWInput::InputManager (*mOgre,
MWBase::Environment::get().getWorld()->getPlayer(),
*MWBase::Environment::get().getWindowManager(), mDebug, *this, keybinderUser, keybinderUserExists));
// load cell // load cell
ESM::Position pos; ESM::Position pos;
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
@ -370,12 +375,6 @@ void OMW::Engine::go()
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos); MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos);
} }
// Sets up the input system
mEnvironment.setInputManager (new MWInput::InputManager (*mOgre,
MWBase::Environment::get().getWorld()->getPlayer(),
*MWBase::Environment::get().getWindowManager(), mDebug, *this, keybinderUser, keybinderUserExists));
std::cout << "\nPress Q/ESC or close window to exit.\n"; std::cout << "\nPress Q/ESC or close window to exit.\n";
mOgre->getRoot()->addFrameListener (this); mOgre->getRoot()->addFrameListener (this);

View File

@ -22,7 +22,7 @@ namespace MWBase
virtual ~InputManager() {} virtual ~InputManager() {}
virtual void update(float dt) = 0; virtual void update(float dt, bool loading) = 0;
virtual void changeInputMode(bool guiMode) = 0; virtual void changeInputMode(bool guiMode) = 0;

View File

@ -216,6 +216,8 @@ namespace MWBase
virtual void processChangedSettings(const Settings::CategorySettingVector& changed) = 0; virtual void processChangedSettings(const Settings::CategorySettingVector& changed) = 0;
virtual void executeInConsole (const std::string& path) = 0; virtual void executeInConsole (const std::string& path) = 0;
virtual void setLoadingProgress (const std::string& stage, int depth, int current, int total) = 0;
}; };
} }

View File

@ -0,0 +1,182 @@
#include "loadingscreen.hpp"
#include <OgreRenderWindow.h>
#include <OgreRoot.h>
#include <OgreCompositorManager.h>
#include <OgreCompositorChain.h>
#include <OgreMaterial.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp"
namespace MWGui
{
LoadingScreen::LoadingScreen(Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* rw, MWBase::WindowManager& parWindowManager)
: mSceneMgr(sceneMgr)
, mWindow(rw)
, WindowBase("openmw_loading_screen.layout", parWindowManager)
, mLoadingOn(false)
, mLastRenderTime(0.f)
{
getWidget(mLoadingText, "LoadingText");
getWidget(mProgressBar, "ProgressBar");
getWidget(mBackgroundImage, "BackgroundImage");
mBackgroundMaterial = Ogre::MaterialManager::getSingleton().create("BackgroundMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mBackgroundMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false);
mBackgroundMaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
mBackgroundMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("");
mRectangle = new Ogre::Rectangle2D(true);
mRectangle->setCorners(-1.0, 1.0, 1.0, -1.0);
mRectangle->setMaterial("BackgroundMaterial");
// Render the background before everything else
mRectangle->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY-1);
// Use infinite AAB to always stay visible
Ogre::AxisAlignedBox aabInf;
aabInf.setInfinite();
mRectangle->setBoundingBox(aabInf);
// Attach background to the scene
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(mRectangle);
mRectangle->setVisible(false);
}
LoadingScreen::~LoadingScreen()
{
delete mRectangle;
}
void LoadingScreen::onResChange(int w, int h)
{
setCoord(0,0,w,h);
}
void LoadingScreen::setLoadingProgress (const std::string& stage, int depth, int current, int total)
{
if (!mLoadingOn)
loadingOn();
const int numRefLists = 20;
if (depth == 0)
{
mCurrentCellLoading = current;
mTotalCellsLoading = total;
mCurrentRefLoading = 0;
mCurrentRefList = 0;
}
else if (depth == 1)
{
mCurrentRefLoading = current;
mTotalRefsLoading = total;
}
if (mTotalCellsLoading == 0)
{
loadingOff();
return;
}
float refProgress;
if (mTotalRefsLoading <= 1)
refProgress = 1;
else
refProgress = float(mCurrentRefLoading) / float(mTotalRefsLoading-1);
refProgress += mCurrentRefList;
refProgress /= numRefLists;
assert(refProgress <= 1 && refProgress >= 0);
if (depth == 1 && mCurrentRefLoading == mTotalRefsLoading-1)
++mCurrentRefList;
float progress = (float(mCurrentCellLoading)+refProgress) / float(mTotalCellsLoading);
assert(progress <= 1 && progress >= 0);
if (progress >= 1)
{
loadingOff();
return;
}
mLoadingText->setCaption(stage + "... ");
mProgressBar->setProgressPosition (static_cast<size_t>(progress * 1000));
static float loadingScreenFps = 30.f;
if (mTimer.getMilliseconds () > mLastRenderTime + (1.f/loadingScreenFps) * 1000.f)
{
mLastRenderTime = mTimer.getMilliseconds ();
// Turn off rendering except the GUI
mSceneMgr->clearSpecialCaseRenderQueues();
// SCRQM_INCLUDE with RENDER_QUEUE_OVERLAY does not work.
for (int i = 0; i < Ogre::RENDER_QUEUE_MAX; ++i)
{
if (i > 0 && i < 96)
mSceneMgr->addSpecialCaseRenderQueue(i);
}
mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);
// always update input before rendering something, otherwise mygui goes crazy when something was entered in the frame before
// (e.g. when using "coc" console command, it would enter an infinite loop and crash due to overflow)
MWBase::Environment::get().getInputManager()->update(0, true);
Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain(mWindow->getViewport(0));
bool hasCompositor = chain->getCompositor ("gbufferFinalizer");
if (!hasCompositor)
{
mWindow->getViewport(0)->setClearEveryFrame(false);
}
else
{
mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName());
mRectangle->setVisible(true);
for (unsigned int i = 0; i<chain->getNumCompositors(); ++i)
{
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), false);
}
}
mWindow->update();
if (!hasCompositor)
mWindow->getViewport(0)->setClearEveryFrame(true);
else
{
for (unsigned int i = 0; i<chain->getNumCompositors(); ++i)
{
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), true);
}
mRectangle->setVisible(false);
}
// resume 3d rendering
mSceneMgr->clearSpecialCaseRenderQueues();
mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);
}
}
void LoadingScreen::loadingOn()
{
setVisible(true);
mLoadingOn = true;
}
void LoadingScreen::loadingOff()
{
setVisible(false);
mLoadingOn = false;
}
}

View File

@ -0,0 +1,51 @@
#ifndef MWGUI_LOADINGSCREEN_H
#define MWGUI_LOADINGSCREEN_H
#include <OgreSceneManager.h>
#include <OgreResourceGroupManager.h>
#include "window_base.hpp"
namespace MWGui
{
class LoadingScreen : public WindowBase
{
public:
LoadingScreen(Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* rw, MWBase::WindowManager& parWindowManager);
virtual ~LoadingScreen();
void setLoadingProgress (const std::string& stage, int depth, int current, int total);
void onResChange(int w, int h);
private:
Ogre::SceneManager* mSceneMgr;
Ogre::RenderWindow* mWindow;
unsigned long mLastRenderTime;
Ogre::Timer mTimer;
MyGUI::TextBox* mLoadingText;
MyGUI::ProgressBar* mProgressBar;
MyGUI::ImageBox* mBackgroundImage;
int mCurrentCellLoading;
int mTotalCellsLoading;
int mCurrentRefLoading;
int mTotalRefsLoading;
int mCurrentRefList;
Ogre::Rectangle2D* mRectangle;
Ogre::MaterialPtr mBackgroundMaterial;
bool mLoadingOn;
void loadingOn();
void loadingOff();
};
}
#endif

View File

@ -43,6 +43,7 @@
#include "alchemywindow.hpp" #include "alchemywindow.hpp"
#include "spellwindow.hpp" #include "spellwindow.hpp"
#include "quickkeysmenu.hpp" #include "quickkeysmenu.hpp"
#include "loadingscreen.hpp"
using namespace MWGui; using namespace MWGui;
@ -67,6 +68,7 @@ WindowManager::WindowManager(
, mConfirmationDialog(NULL) , mConfirmationDialog(NULL)
, mAlchemyWindow(NULL) , mAlchemyWindow(NULL)
, mSpellWindow(NULL) , mSpellWindow(NULL)
, mLoadingScreen(NULL)
, mCharGen(NULL) , mCharGen(NULL)
, mPlayerClass() , mPlayerClass()
, mPlayerName() , mPlayerName()
@ -146,6 +148,9 @@ WindowManager::WindowManager(
mSpellWindow = new SpellWindow(*this); mSpellWindow = new SpellWindow(*this);
mQuickKeysMenu = new QuickKeysMenu(*this); mQuickKeysMenu = new QuickKeysMenu(*this);
mLoadingScreen = new LoadingScreen(mOgre->getScene (), mOgre->getWindow (), *this);
mLoadingScreen->onResChange (w,h);
mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Default,"Windows",""); mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Default,"Windows","");
// The HUD is always on // The HUD is always on
@ -194,6 +199,7 @@ WindowManager::~WindowManager()
delete mConfirmationDialog; delete mConfirmationDialog;
delete mAlchemyWindow; delete mAlchemyWindow;
delete mSpellWindow; delete mSpellWindow;
delete mLoadingScreen;
cleanupGarbage(); cleanupGarbage();
@ -679,6 +685,7 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
mBookWindow->center(); mBookWindow->center();
mQuickKeysMenu->center(); mQuickKeysMenu->center();
mSpellBuyingWindow->center(); mSpellBuyingWindow->center();
mLoadingScreen->onResChange (x,y);
mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y)); mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y));
mInputBlocker->setSize(MyGUI::IntSize(x,y)); mInputBlocker->setSize(MyGUI::IntSize(x,y));
} }
@ -897,3 +904,8 @@ void WindowManager::toggleHud ()
mHudEnabled = !mHudEnabled; mHudEnabled = !mHudEnabled;
mHud->setVisible (mHudEnabled); mHud->setVisible (mHudEnabled);
} }
void WindowManager::setLoadingProgress (const std::string& stage, int depth, int current, int total)
{
mLoadingScreen->setLoadingProgress (stage, depth, current, total);
}

View File

@ -61,6 +61,7 @@ namespace MWGui
class SettingsWindow; class SettingsWindow;
class AlchemyWindow; class AlchemyWindow;
class QuickKeysMenu; class QuickKeysMenu;
class LoadingScreen;
class WindowManager : public MWBase::WindowManager class WindowManager : public MWBase::WindowManager
{ {
@ -195,6 +196,8 @@ namespace MWGui
virtual void executeInConsole (const std::string& path); virtual void executeInConsole (const std::string& path);
virtual void setLoadingProgress (const std::string& stage, int depth, int current, int total);
private: private:
OEngine::GUI::MyGUIManager *mGuiManager; OEngine::GUI::MyGUIManager *mGuiManager;
HUD *mHud; HUD *mHud;
@ -219,6 +222,7 @@ namespace MWGui
AlchemyWindow* mAlchemyWindow; AlchemyWindow* mAlchemyWindow;
SpellWindow* mSpellWindow; SpellWindow* mSpellWindow;
QuickKeysMenu* mQuickKeysMenu; QuickKeysMenu* mQuickKeysMenu;
LoadingScreen* mLoadingScreen;
CharacterCreation* mCharGen; CharacterCreation* mCharGen;

View File

@ -233,14 +233,15 @@ namespace MWInput
} }
} }
void InputManager::update(float dt) void InputManager::update(float dt, bool loading)
{ {
// Tell OIS to handle all input events // Tell OIS to handle all input events
mKeyboard->capture(); mKeyboard->capture();
mMouse->capture(); mMouse->capture();
// update values of channels (as a result of pressed keys) // update values of channels (as a result of pressed keys)
mInputCtrl->update(dt); if (!loading)
mInputCtrl->update(dt);
// Update windows/gui as a result of input events // Update windows/gui as a result of input events
// For instance this could mean opening a new window/dialog, // For instance this could mean opening a new window/dialog,

View File

@ -66,7 +66,7 @@ namespace MWInput
virtual ~InputManager(); virtual ~InputManager();
virtual void update(float dt); virtual void update(float dt, bool loading);
virtual void changeInputMode(bool guiMode); virtual void changeInputMode(bool guiMode);

View File

@ -734,6 +734,7 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec
sh::Factory::getInstance ().setGlobalSetting ("mrt_output", useMRT() ? "true" : "false"); sh::Factory::getInstance ().setGlobalSetting ("mrt_output", useMRT() ? "true" : "false");
sh::Factory::getInstance ().setGlobalSetting ("simple_water", Settings::Manager::getBool("shader", "Water") ? "false" : "true"); sh::Factory::getInstance ().setGlobalSetting ("simple_water", Settings::Manager::getBool("shader", "Water") ? "false" : "true");
mObjects.rebuildStaticGeometry (); mObjects.rebuildStaticGeometry ();
mRendering.getViewport ()->setClearEveryFrame (true);
} }
else if (it->second == "underwater effect" && it->first == "Water") else if (it->second == "underwater effect" && it->first == "Water")
{ {

View File

@ -25,9 +25,14 @@ namespace
const MWWorld::Class& class_ = const MWWorld::Class& class_ =
MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell)); MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell));
int numRefs = cellRefList.list.size();
int current = 0;
for (typename T::List::iterator it = cellRefList.list.begin(); for (typename T::List::iterator it = cellRefList.list.begin();
it != cellRefList.list.end(); it++) it != cellRefList.list.end(); it++)
{ {
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 1, current, numRefs);
++current;
if (it->mData.getCount() || it->mData.isEnabled()) if (it->mData.getCount() || it->mData.isEnabled())
{ {
MWWorld::Ptr ptr (&*it, &cell); MWWorld::Ptr ptr (&*it, &cell);
@ -45,6 +50,10 @@ namespace
} }
} }
} }
else
{
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 1, 0, 1);
}
} }
} }
@ -175,6 +184,26 @@ namespace MWWorld
CellStoreCollection::iterator active = mActiveCells.begin(); CellStoreCollection::iterator active = mActiveCells.begin();
// get the number of cells to unload
int numUnload = 0;
while (active!=mActiveCells.end())
{
if (!((*active)->cell->data.flags & ESM::Cell::Interior))
{
if (std::abs (X-(*active)->cell->data.gridX)<=1 &&
std::abs (Y-(*active)->cell->data.gridY)<=1)
{
// keep cells within the new 3x3 grid
++active;
continue;
}
}
++active;
++numUnload;
}
int current = 0;
active = mActiveCells.begin();
while (active!=mActiveCells.end()) while (active!=mActiveCells.end())
{ {
if (!((*active)->cell->data.flags & ESM::Cell::Interior)) if (!((*active)->cell->data.flags & ESM::Cell::Interior))
@ -188,10 +217,35 @@ namespace MWWorld
} }
} }
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload);
unloadCell (active++); unloadCell (active++);
++current;
} }
int numLoad = 0;
// get the number of cells to load
for (int x=X-1; x<=X+1; ++x)
for (int y=Y-1; y<=Y+1; ++y)
{
CellStoreCollection::iterator iter = mActiveCells.begin();
while (iter!=mActiveCells.end())
{
assert (!((*iter)->cell->data.flags & ESM::Cell::Interior));
if (x==(*iter)->cell->data.gridX &&
y==(*iter)->cell->data.gridY)
break;
++iter;
}
if (iter==mActiveCells.end())
++numLoad;
}
// Load cells // Load cells
current = 0;
for (int x=X-1; x<=X+1; ++x) for (int x=X-1; x<=X+1; ++x)
for (int y=Y-1; y<=Y+1; ++y) for (int y=Y-1; y<=Y+1; ++y)
{ {
@ -212,7 +266,9 @@ namespace MWWorld
{ {
CellStore *cell = MWBase::Environment::get().getWorld()->getExterior(x, y); CellStore *cell = MWBase::Environment::get().getWorld()->getExterior(x, y);
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, current, numLoad);
loadCell (cell); loadCell (cell);
++current;
} }
} }
@ -275,14 +331,30 @@ namespace MWWorld
// remove active // remove active
CellStoreCollection::iterator active = mActiveCells.begin(); CellStoreCollection::iterator active = mActiveCells.begin();
// count number of cells to unload
int numUnload = 0;
while (active!=mActiveCells.end()) while (active!=mActiveCells.end())
{ {
++active;
++numUnload;
}
// unload
int current = 0;
active = mActiveCells.begin();
while (active!=mActiveCells.end())
{
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload);
unloadCell (active++); unloadCell (active++);
++current;
} }
// Load cell. // Load cell.
std::cout << "cellName:" << cellName << std::endl; std::cout << "cellName:" << cellName << std::endl;
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1);
loadCell (cell); loadCell (cell);
// adjust player // adjust player

View File

@ -71,6 +71,7 @@ set(MYGUI_FILES
openmw_itemselection_dialog.layout openmw_itemselection_dialog.layout
openmw_magicselection_dialog.layout openmw_magicselection_dialog.layout
openmw_spell_buying_window.layout openmw_spell_buying_window.layout
openmw_loading_screen.layout
smallbars.png smallbars.png
VeraMono.ttf VeraMono.ttf
markers.png markers.png

View File

@ -8,5 +8,6 @@
<Layer name="Notification" overlapped="false" peek="false"/> <Layer name="Notification" overlapped="false" peek="false"/>
<Layer name="Popup" overlapped="true" peek="true"/> <Layer name="Popup" overlapped="true" peek="true"/>
<Layer name="DragAndDrop" overlapped="false" peek="true"/> <Layer name="DragAndDrop" overlapped="false" peek="true"/>
<Layer name="LoadingScreen" overlapped="false" peek="true"/>
<Layer name="Pointer" overlapped="false" peek="false"/> <Layer name="Pointer" overlapped="false" peek="false"/>
</MyGUI> </MyGUI>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<!-- The entire screen -->
<Widget type="Widget" layer="LoadingScreen" position="0 0 300 300" name="_Main">
<Widget type="ImageBox" skin="ImageBox" position="0 0 300 300" align="Stretch" name="BackgroundImage">
<Widget type="Widget" skin="HUD_Box" position="0 200 300 70" align="Bottom HCenter">
<Widget type="AutoSizedTextBox" skin="SandText" position="20 12 260 24" name="LoadingText">
</Widget>
<Widget type="ProgressBar" skin="MW_Progress_Blue" position="20 38 260 24" name="ProgressBar">
<Property key="Range" value="1000"/>
</Widget>
</Widget>
</Widget>
</Widget>
</MyGUI>

View File

@ -8,41 +8,43 @@ using namespace OEngine::GUI;
void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging, const std::string& logDir) void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging, const std::string& logDir)
{ {
assert(wnd); assert(wnd);
assert(mgr); assert(mgr);
using namespace MyGUI; mSceneMgr = mgr;
// Enable/disable MyGUI logging to stdout. (Logging to MyGUI.log is using namespace MyGUI;
// 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); // Enable/disable MyGUI logging to stdout. (Logging to MyGUI.log is
if(!logDir.empty()) // still enabled.) In order to do this we have to initialize the log
theLogFile.insert(0, logDir); // 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.
// Set up OGRE platform. We might make this more generic later. std::string theLogFile = std::string(MYGUI_PLATFORM_LOG_FILENAME);
mPlatform = new OgrePlatform(); if(!logDir.empty())
LogManager::getInstance().setSTDOutputEnabled(logging); theLogFile.insert(0, logDir);
mPlatform->initialise(wnd, mgr, "General", theLogFile);
// Set up OGRE platform. We might make this more generic later.
mPlatform = new OgrePlatform();
LogManager::getInstance().setSTDOutputEnabled(logging);
mPlatform->initialise(wnd, mgr, "General", theLogFile);
// Create GUI // Create GUI
mGui = new Gui(); mGui = new Gui();
mGui->initialise("core.xml"); mGui->initialise("core.xml");
} }
void MyGUIManager::shutdown() void MyGUIManager::shutdown()
{ {
mGui->shutdown (); mGui->shutdown ();
delete mGui; delete mGui;
if(mPlatform) if(mPlatform)
{ {
mPlatform->shutdown(); mPlatform->shutdown();
delete mPlatform; delete mPlatform;
} }
mGui = NULL; mGui = NULL;
mPlatform = NULL; mPlatform = NULL;
} }

View File

@ -16,21 +16,28 @@ namespace Ogre
namespace OEngine { namespace OEngine {
namespace GUI namespace GUI
{ {
class MyGUIManager class MyGUIManager
{ {
MyGUI::OgrePlatform *mPlatform; MyGUI::OgrePlatform *mPlatform;
MyGUI::Gui *mGui; MyGUI::Gui *mGui;
Ogre::SceneManager* mSceneMgr;
public: public:
MyGUIManager() : mPlatform(NULL), mGui(NULL) {} MyGUIManager() : mPlatform(NULL), mGui(NULL) {}
MyGUIManager(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string("")) MyGUIManager(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string(""))
{ setup(wnd,mgr,logging, logDir); } {
~MyGUIManager() { shutdown(); } setup(wnd,mgr,logging, logDir);
}
~MyGUIManager()
{
shutdown();
}
void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string("")); void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string(""));
void shutdown(); void shutdown();
MyGUI::Gui *getGui() { return mGui; } MyGUI::Gui *getGui() { return mGui; }
}; };
}} }
}
#endif #endif