use loading screen to freeze the screen

pull/456/head
Miloslav Číž 7 years ago
parent 2b5f147545
commit 3ae5310567

@ -153,7 +153,7 @@ namespace MWGui
virtual osg::BoundingSphere computeBound(const osg::Node&) const { return osg::BoundingSphere(); }
};
void LoadingScreen::loadingOn()
void LoadingScreen::loadingOn(bool visible)
{
mLoadingOnTime = mTimer.time_m();
// 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()
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);
setVisible(true);
@ -181,10 +184,15 @@ namespace MWGui
}
MWBase::Environment::get().getWindowManager()->pushGuiMode(mShowWallpaper ? GM_LoadingWallpaper : GM_Loading);
if (!mVisible)
draw();
}
void LoadingScreen::loadingOff()
{
mLoadingBox->setVisible(true); // restore
if (mLastRenderTime < mLoadingOnTime)
{
// the loading was so fast that we didn't show loading screen at all
@ -307,7 +315,7 @@ namespace MWGui
void LoadingScreen::draw()
{
if (!needToDrawLoadingScreen())
if (mVisible && !needToDrawLoadingScreen())
return;
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
virtual void setLabel (const std::string& label, bool important);
virtual void loadingOn();
virtual void loadingOn(bool visible=true);
virtual void loadingOff();
virtual void setProgressRange (size_t range);
virtual void setProgress (size_t value);
@ -63,6 +63,8 @@ namespace MWGui
bool mImportantLabel;
bool mVisible;
size_t mProgress;
bool mShowWallpaper;

@ -47,6 +47,9 @@
#include <boost/algorithm/string.hpp>
#include "../mwworld/cellstore.hpp"
#include "../mwgui/loadingscreen.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "sky.hpp"
#include "effectmanager.hpp"
@ -809,26 +812,14 @@ namespace MWRender
osg::ref_ptr<NotifyDrawCompletedCallback> callback (new NotifyDrawCompletedCallback);
camera->setFinalDrawCallback(callback);
GLbitfield maskBackup = mViewer->getCamera()->getClearMask();
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
MWBase::Environment::get().getWindowManager()->getLoadingScreen()->loadingOn(false);
mViewer->eventTraversal();
mViewer->updateTraversal();
mViewer->renderingTraversals();
callback->waitTillDone();
mSceneSwitch->setAllChildrenOn();
mViewer->getCamera()->setClearMask(maskBackup);
mViewer->getCamera()->setClearDepth(clearDepthBackup);
MWBase::Environment::get().getWindowManager()->getLoadingScreen()->loadingOff();
// 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());

@ -20,7 +20,7 @@ namespace Loading
/// @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,
/// so that the loading is exception safe.
virtual void loadingOn() {}
virtual void loadingOn(bool visible=true) {}
virtual void loadingOff() {}
/// Set the total range of progress (e.g. the number of objects to load).

Loading…
Cancel
Save