Fix missing news text in main menu if loading is too fast

This commit is contained in:
Benau 2022-10-31 10:39:54 +08:00
parent 61bd2a6e70
commit 54973d0174
2 changed files with 12 additions and 6 deletions

View File

@ -158,9 +158,9 @@ void MainMenuScreen::init()
w->setBadge(LOADING_BADGE);
}
m_news_text = L"";
LabelWidget* w = getWidget<LabelWidget>("info_addons");
const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
w->setText(news_text, true);
w->setText(m_news_text, true);
w->update(0.01f);
#endif
@ -217,11 +217,15 @@ void MainMenuScreen::onUpdate(float delta)
}
LabelWidget* w = getWidget<LabelWidget>("info_addons");
w->update(delta);
if(w->scrolledOff())
if (m_news_text.empty())
m_news_text = NewsManager::get()->getNextNewsMessage();
if (!m_news_text.empty())
{
const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
w->setText(news_text, true);
if (w->getText().empty())
w->setText(m_news_text, true);
w->update(delta);
if (w->scrolledOff())
w->setText(m_news_text, true);
}
PlayerProfile *player = PlayerManager::getCurrentPlayer();

View File

@ -35,6 +35,8 @@ private:
/** Keep the widget to to the user name. */
GUIEngine::ButtonWidget *m_user_id;
core::stringw m_news_text;
MainMenuScreen();
void startTutorial();