LoadingScreen: add support for important labels

Used in saveGame so the player can be sure whether or not the game was saved.

Fixes #3074
openmw-38
scrawl 9 years ago
parent 67883feaae
commit d5a2586f38

@ -36,6 +36,7 @@ namespace MWGui
, mLastWallpaperChangeTime(0.0)
, mLastRenderTime(0.0)
, mLoadingOnTime(0.0)
, mImportantLabel(false)
, mProgress(0)
{
mMainWidget->setSize(MyGUI::RenderManager::getInstance().getViewSize());
@ -82,8 +83,10 @@ namespace MWGui
std::cerr << "No splash screens found!" << std::endl;
}
void LoadingScreen::setLabel(const std::string &label)
void LoadingScreen::setLabel(const std::string &label, bool important)
{
mImportantLabel = important;
mLoadingText->setCaptionWithReplacing(label);
int padding = mLoadingBox->getWidth() - mLoadingText->getWidth();
MyGUI::IntSize size(mLoadingText->getTextSize().width+padding, mLoadingBox->getHeight());
@ -176,6 +179,19 @@ namespace MWGui
void LoadingScreen::loadingOff()
{
if (mLastRenderTime < mLoadingOnTime)
{
// the loading was so fast that we didn't show loading screen at all
// we may still want to show the label if the caller requested it
if (mImportantLabel)
{
MWBase::Environment::get().getWindowManager()->messageBox(mLoadingText->getCaption());
mImportantLabel = false;
}
}
else
mImportantLabel = false; // label was already shown on loading screen
//std::cout << "loading took " << mTimer.time_m() - mLoadingOnTime << std::endl;
setVisible(false);

@ -34,7 +34,7 @@ namespace MWGui
virtual ~LoadingScreen();
/// Overridden from Loading::Listener, see the Loading::Listener documentation for usage details
virtual void setLabel (const std::string& label);
virtual void setLabel (const std::string& label, bool important);
virtual void loadingOn();
virtual void loadingOff();
virtual void setProgressRange (size_t range);
@ -57,6 +57,8 @@ namespace MWGui
osg::Timer mTimer;
double mLoadingOnTime;
bool mImportantLabel;
size_t mProgress;
MyGUI::Widget* mLoadingBox;

@ -242,7 +242,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
Loading::Listener& listener = *MWBase::Environment::get().getWindowManager()->getLoadingScreen();
// Using only Cells for progress information, since they typically have the largest records by far
listener.setProgressRange(MWBase::Environment::get().getWorld()->countSavedGameCells());
listener.setLabel("#{sNotifyMessage4}");
listener.setLabel("#{sNotifyMessage4}", true);
Loading::ScopedLoad load(&listener);

@ -9,7 +9,12 @@ namespace Loading
{
public:
/// Set a text label to show on the loading screen.
virtual void setLabel (const std::string& label) {}
/// @param label The label
/// @param important Is the label considered important to show?
/// @note "non-important" labels may not show on screen if the loading process went so fast
/// that the implementation decided not to show a loading screen at all. "important" labels
/// will show in a separate message-box if the loading screen was not shown.
virtual void setLabel (const std::string& label, bool important=false) {}
/// Start a loading sequence. Must call loadingOff() when done.
/// @note To get the loading screen to actually update, you must call setProgress / increaseProgress periodically.

Loading…
Cancel
Save