forked from mirror/openmw-tes3mp
use loading screen to freeze the screen
This commit is contained in:
parent
2b5f147545
commit
3ae5310567
4 changed files with 20 additions and 19 deletions
|
@ -153,7 +153,7 @@ namespace MWGui
|
||||||
virtual osg::BoundingSphere computeBound(const osg::Node&) const { return osg::BoundingSphere(); }
|
virtual osg::BoundingSphere computeBound(const osg::Node&) const { return osg::BoundingSphere(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
void LoadingScreen::loadingOn()
|
void LoadingScreen::loadingOn(bool visible)
|
||||||
{
|
{
|
||||||
mLoadingOnTime = mTimer.time_m();
|
mLoadingOnTime = mTimer.time_m();
|
||||||
// Early-out if already on
|
// Early-out if already on
|
||||||
|
@ -170,7 +170,10 @@ namespace MWGui
|
||||||
// We are already using node masks to avoid the scene from being updated/rendered, but node masks don't work for computeBound()
|
// We are already using node masks to avoid the scene from being updated/rendered, but node masks don't work for computeBound()
|
||||||
mViewer->getSceneData()->setComputeBoundingSphereCallback(new DontComputeBoundCallback);
|
mViewer->getSceneData()->setComputeBoundingSphereCallback(new DontComputeBoundCallback);
|
||||||
|
|
||||||
mShowWallpaper = (MWBase::Environment::get().getStateManager()->getState()
|
mVisible = visible;
|
||||||
|
mLoadingBox->setVisible(mVisible);
|
||||||
|
|
||||||
|
mShowWallpaper = mVisible && (MWBase::Environment::get().getStateManager()->getState()
|
||||||
== MWBase::StateManager::State_NoGame);
|
== MWBase::StateManager::State_NoGame);
|
||||||
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
@ -181,10 +184,15 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(mShowWallpaper ? GM_LoadingWallpaper : GM_Loading);
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(mShowWallpaper ? GM_LoadingWallpaper : GM_Loading);
|
||||||
|
|
||||||
|
if (!mVisible)
|
||||||
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadingScreen::loadingOff()
|
void LoadingScreen::loadingOff()
|
||||||
{
|
{
|
||||||
|
mLoadingBox->setVisible(true); // restore
|
||||||
|
|
||||||
if (mLastRenderTime < mLoadingOnTime)
|
if (mLastRenderTime < mLoadingOnTime)
|
||||||
{
|
{
|
||||||
// the loading was so fast that we didn't show loading screen at all
|
// the loading was so fast that we didn't show loading screen at all
|
||||||
|
@ -307,7 +315,7 @@ namespace MWGui
|
||||||
|
|
||||||
void LoadingScreen::draw()
|
void LoadingScreen::draw()
|
||||||
{
|
{
|
||||||
if (!needToDrawLoadingScreen())
|
if (mVisible && !needToDrawLoadingScreen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mShowWallpaper && mTimer.time_m() > mLastWallpaperChangeTime + 5000*1)
|
if (mShowWallpaper && mTimer.time_m() > mLastWallpaperChangeTime + 5000*1)
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace MWGui
|
||||||
|
|
||||||
/// Overridden from Loading::Listener, see the Loading::Listener documentation for usage details
|
/// Overridden from Loading::Listener, see the Loading::Listener documentation for usage details
|
||||||
virtual void setLabel (const std::string& label, bool important);
|
virtual void setLabel (const std::string& label, bool important);
|
||||||
virtual void loadingOn();
|
virtual void loadingOn(bool visible=true);
|
||||||
virtual void loadingOff();
|
virtual void loadingOff();
|
||||||
virtual void setProgressRange (size_t range);
|
virtual void setProgressRange (size_t range);
|
||||||
virtual void setProgress (size_t value);
|
virtual void setProgress (size_t value);
|
||||||
|
@ -63,6 +63,8 @@ namespace MWGui
|
||||||
|
|
||||||
bool mImportantLabel;
|
bool mImportantLabel;
|
||||||
|
|
||||||
|
bool mVisible;
|
||||||
|
|
||||||
size_t mProgress;
|
size_t mProgress;
|
||||||
|
|
||||||
bool mShowWallpaper;
|
bool mShowWallpaper;
|
||||||
|
|
|
@ -47,6 +47,9 @@
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include "../mwworld/cellstore.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwgui/loadingscreen.hpp"
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "sky.hpp"
|
#include "sky.hpp"
|
||||||
#include "effectmanager.hpp"
|
#include "effectmanager.hpp"
|
||||||
|
@ -809,26 +812,14 @@ namespace MWRender
|
||||||
osg::ref_ptr<NotifyDrawCompletedCallback> callback (new NotifyDrawCompletedCallback);
|
osg::ref_ptr<NotifyDrawCompletedCallback> callback (new NotifyDrawCompletedCallback);
|
||||||
camera->setFinalDrawCallback(callback);
|
camera->setFinalDrawCallback(callback);
|
||||||
|
|
||||||
GLbitfield maskBackup = mViewer->getCamera()->getClearMask();
|
MWBase::Environment::get().getWindowManager()->getLoadingScreen()->loadingOn(false);
|
||||||
double clearDepthBackup = mViewer->getCamera()->getClearDepth();
|
|
||||||
mViewer->getCamera()->setClearMask(GL_DEPTH_BUFFER_BIT); // don't render the main camera
|
|
||||||
mViewer->getCamera()->setClearDepth(0);
|
|
||||||
|
|
||||||
// at the time this function is called we are in the middle of a frame,
|
|
||||||
// so out of order calls are necessary to get a correct frameNumber for the next frame.
|
|
||||||
// refer to the advance() and frame() order in Engine::go()
|
|
||||||
|
|
||||||
mSceneSwitch->setAllChildrenOff(); // don't render the scene for main camera
|
|
||||||
|
|
||||||
mViewer->eventTraversal();
|
mViewer->eventTraversal();
|
||||||
mViewer->updateTraversal();
|
mViewer->updateTraversal();
|
||||||
mViewer->renderingTraversals();
|
mViewer->renderingTraversals();
|
||||||
callback->waitTillDone();
|
callback->waitTillDone();
|
||||||
|
|
||||||
mSceneSwitch->setAllChildrenOn();
|
MWBase::Environment::get().getWindowManager()->getLoadingScreen()->loadingOff();
|
||||||
|
|
||||||
mViewer->getCamera()->setClearMask(maskBackup);
|
|
||||||
mViewer->getCamera()->setClearDepth(clearDepthBackup);
|
|
||||||
|
|
||||||
// now that we've "used up" the current frame, get a fresh framenumber for the next frame() following after the screenshot is completed
|
// now that we've "used up" the current frame, get a fresh framenumber for the next frame() following after the screenshot is completed
|
||||||
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Loading
|
||||||
/// @note To get the loading screen to actually update, you must call setProgress / increaseProgress periodically.
|
/// @note To get the loading screen to actually update, you must call setProgress / increaseProgress periodically.
|
||||||
/// @note It is best to use the ScopedLoad object instead of using loadingOn()/loadingOff() directly,
|
/// @note It is best to use the ScopedLoad object instead of using loadingOn()/loadingOff() directly,
|
||||||
/// so that the loading is exception safe.
|
/// so that the loading is exception safe.
|
||||||
virtual void loadingOn() {}
|
virtual void loadingOn(bool visible=true) {}
|
||||||
virtual void loadingOff() {}
|
virtual void loadingOff() {}
|
||||||
|
|
||||||
/// Set the total range of progress (e.g. the number of objects to load).
|
/// Set the total range of progress (e.g. the number of objects to load).
|
||||||
|
|
Loading…
Reference in a new issue