Always center loading screen progress bar by height when there is active message box

To fix all possible situations when active message box overlaps with loading
screen progress.

The only used condition to center loading screen progress by height is
number of message boxes > 0. No need to pass it through interface.
LoadingScreen can check it inside setLabel function.
pull/593/head
elsid 4 years ago
parent 4c4218f70d
commit 3915e5d2cc
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -100,7 +100,7 @@ namespace MWGui
Log(Debug::Warning) << "Warning: no splash screens found!";
}
void LoadingScreen::setLabel(const std::string &label, bool important, bool center)
void LoadingScreen::setLabel(const std::string &label, bool important)
{
mImportantLabel = important;
@ -110,7 +110,7 @@ namespace MWGui
size.width = std::max(300, size.width);
mLoadingBox->setSize(size);
if (center)
if (MWBase::Environment::get().getWindowManager()->getMessagesCount() > 0)
mLoadingBox->setPosition(mMainWidget->getWidth()/2 - mLoadingBox->getWidth()/2, mMainWidget->getHeight()/2 - mLoadingBox->getHeight()/2);
else
mLoadingBox->setPosition(mMainWidget->getWidth()/2 - mLoadingBox->getWidth()/2, mMainWidget->getHeight() - mLoadingBox->getHeight() - 8);

@ -37,7 +37,7 @@ namespace MWGui
virtual ~LoadingScreen();
/// Overridden from Loading::Listener, see the Loading::Listener documentation for usage details
void setLabel (const std::string& label, bool important, bool center) override;
void setLabel (const std::string& label, bool important) override;
void loadingOn(bool visible=true) override;
void loadingOff() override;
void setProgressRange (size_t range) override;

@ -260,10 +260,9 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
writer.save (stream);
Loading::Listener& listener = *MWBase::Environment::get().getWindowManager()->getLoadingScreen();
int messagesCount = MWBase::Environment::get().getWindowManager()->getMessagesCount();
// 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}", true, messagesCount > 0);
listener.setLabel("#{sNotifyMessage4}", true);
Loading::ScopedLoad load(&listener);
@ -385,10 +384,9 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
std::map<int, int> contentFileMap = buildContentFileIndexMap (reader);
Loading::Listener& listener = *MWBase::Environment::get().getWindowManager()->getLoadingScreen();
int messagesCount = MWBase::Environment::get().getWindowManager()->getMessagesCount();
listener.setProgressRange(100);
listener.setLabel("#{sLoadingMessage14}", false, messagesCount > 0);
listener.setLabel("#{sLoadingMessage14}");
Loading::ScopedLoad load(&listener);

@ -566,9 +566,8 @@ namespace MWWorld
Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen();
Loading::ScopedLoad load(loadingListener);
int messagesCount = MWBase::Environment::get().getWindowManager()->getMessagesCount();
std::string loadingExteriorText = "#{sLoadingMessage3}";
loadingListener->setLabel(loadingExteriorText, false, messagesCount > 0);
loadingListener->setLabel(loadingExteriorText);
loadingListener->setProgressRange(refsToLoad);
const auto getDistanceToPlayerCell = [&] (const std::pair<int, int>& cellPosition)
@ -798,9 +797,8 @@ namespace MWWorld
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0.5);
Loading::Listener* loadingListener = MWBase::Environment::get().getWindowManager()->getLoadingScreen();
int messagesCount = MWBase::Environment::get().getWindowManager()->getMessagesCount();
std::string loadingInteriorText = "#{sLoadingMessage2}";
loadingListener->setLabel(loadingInteriorText, false, messagesCount > 0);
loadingListener->setLabel(loadingInteriorText);
Loading::ScopedLoad load(loadingListener);
if(mCurrentCell != nullptr && *mCurrentCell == *cell)

@ -14,7 +14,7 @@ namespace Loading
/// @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, bool center=false) {}
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