mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
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:
parent
26cd03bca1
commit
43739ea9aa
|
@ -915,6 +915,8 @@ void CGameClient::OnStateChange(int NewState, int OldState)
|
||||||
|
|
||||||
void CGameClient::OnShutdown()
|
void CGameClient::OnShutdown()
|
||||||
{
|
{
|
||||||
|
RenderShutdownMessage();
|
||||||
|
|
||||||
for(auto &pComponent : m_vpAll)
|
for(auto &pComponent : m_vpAll)
|
||||||
pComponent->OnShutdown();
|
pComponent->OnShutdown();
|
||||||
}
|
}
|
||||||
|
@ -972,6 +974,25 @@ void CGameClient::OnLanguageChange()
|
||||||
UI()->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)
|
void CGameClient::OnRconType(bool UsernameReq)
|
||||||
{
|
{
|
||||||
m_GameConsole.RequireUsername(UsernameReq);
|
m_GameConsole.RequireUsername(UsernameReq);
|
||||||
|
|
|
@ -489,6 +489,8 @@ public:
|
||||||
|
|
||||||
void OnLanguageChange();
|
void OnLanguageChange();
|
||||||
|
|
||||||
|
void RenderShutdownMessage();
|
||||||
|
|
||||||
const char *GetItemName(int Type) const override;
|
const char *GetItemName(int Type) const override;
|
||||||
const char *Version() const override;
|
const char *Version() const override;
|
||||||
const char *NetVersion() const override;
|
const char *NetVersion() const override;
|
||||||
|
|
Loading…
Reference in a new issue