When quitting/restarting client clear screen and render message

When quitting or restarting the client, clear the screen and render a message "Quitting. Please wait…" or "Restarting. Please wait…" respectively.

Previously the last frame would keep getting shown while the client is busy with cleanup tasks. Rendering a final message before the client window stops being updated provides a cleaner user experience.
This commit is contained in:
Robert Müller 2023-08-03 17:13:00 +02:00
parent 26cd03bca1
commit 43739ea9aa
2 changed files with 23 additions and 0 deletions

View file

@ -915,6 +915,8 @@ void CGameClient::OnStateChange(int NewState, int OldState)
void CGameClient::OnShutdown()
{
RenderShutdownMessage();
for(auto &pComponent : m_vpAll)
pComponent->OnShutdown();
}
@ -972,6 +974,25 @@ void CGameClient::OnLanguageChange()
UI()->OnLanguageChange();
}
void CGameClient::RenderShutdownMessage()
{
const char *pMessage = nullptr;
if(Client()->State() == IClient::STATE_QUITTING)
pMessage = Localize("Quitting. Please wait…");
else if(Client()->State() == IClient::STATE_RESTARTING)
pMessage = Localize("Restarting. Please wait…");
else
dbg_assert(false, "Invalid client state for quitting message");
// This function only gets called after the render loop has already terminated, so we have to call Swap manually.
Graphics()->Clear(0.0f, 0.0f, 0.0f);
UI()->MapScreen();
TextRender()->TextColor(TextRender()->DefaultTextColor());
UI()->DoLabel(UI()->Screen(), pMessage, 16.0f, TEXTALIGN_MC);
Graphics()->Swap();
Graphics()->Clear(0.0f, 0.0f, 0.0f);
}
void CGameClient::OnRconType(bool UsernameReq)
{
m_GameConsole.RequireUsername(UsernameReq);

View file

@ -489,6 +489,8 @@ public:
void OnLanguageChange();
void RenderShutdownMessage();
const char *GetItemName(int Type) const override;
const char *Version() const override;
const char *NetVersion() const override;