Skip to content

Commit

Permalink
Add gameclient warnings to queue instead of overriding others
Browse files Browse the repository at this point in the history
Using `CMenus::PopupWarning` will immediately set the popup and override the current warning, which can hide warnings when multiple are shown at the same time. Now all warnings are added to the queue with `IClient::AddWarning`.
  • Loading branch information
Robyt3 committed Nov 1, 2023
1 parent 03400f6 commit ebe2dde
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/engine/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ class IClient : public IInterface

virtual void GetSmoothTick(int *pSmoothTick, float *pSmoothIntraTick, float MixAmount) = 0;

virtual void AddWarning(const SWarning &Warning) = 0;
virtual SWarning *GetCurWarning() = 0;

virtual CChecksumData *ChecksumData() = 0;
virtual bool InfoTaskRunning() = 0;
virtual int UdpConnectivity(int NetType) = 0;
Expand Down
5 changes: 5 additions & 0 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4662,6 +4662,11 @@ void CClient::GetSmoothTick(int *pSmoothTick, float *pSmoothIntraTick, float Mix
*pSmoothIntraTick = (SmoothTime - (*pSmoothTick - 1) * time_freq() / 50) / (float)(time_freq() / 50);
}

void CClient::AddWarning(const SWarning &Warning)
{
m_vWarnings.emplace_back(Warning);
}

SWarning *CClient::GetCurWarning()
{
if(m_vWarnings.empty())
Expand Down
2 changes: 2 additions & 0 deletions src/engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,9 @@ class CClient : public IClient, public CDemoPlayer::IListener

void GetSmoothTick(int *pSmoothTick, float *pSmoothIntraTick, float MixAmount) override;

void AddWarning(const SWarning &Warning) override;
SWarning *GetCurWarning() override;

CChecksumData *ChecksumData() override { return &m_Checksum.m_Data; }
bool InfoTaskRunning() override { return m_pDDNetInfoTask != nullptr; }
int UdpConnectivity(int NetType) override;
Expand Down
6 changes: 1 addition & 5 deletions src/game/client/components/mapimages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
#include <game/localization.h>
#include <game/mapitems.h>

#include <chrono>

using namespace std::chrono_literals;

const char *const gs_apModEntitiesNames[] = {
"ddnet",
"ddrace",
Expand Down Expand Up @@ -146,7 +142,7 @@ void CMapImages::OnMapLoadImpl(class CLayers *pLayers, IMap *pMap)
}
if(ShowWarning)
{
m_pClient->m_Menus.PopupWarning(Localize("Warning"), Localize("Some map images could not be loaded. Check the local console for details."), Localize("Ok"), 10s);
Client()->AddWarning(SWarning(Localize("Some map images could not be loaded. Check the local console for details.")));
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/game/client/components/mapsounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
#include <game/localization.h>
#include <game/mapitems.h>

#include <chrono>

using namespace std::chrono_literals;

CMapSounds::CMapSounds()
{
m_Count = 0;
Expand Down Expand Up @@ -63,7 +59,7 @@ void CMapSounds::OnMapLoad()
}
if(ShowWarning)
{
m_pClient->m_Menus.PopupWarning(Localize("Warning"), Localize("Some map sounds could not be loaded. Check the local console for details."), Localize("Ok"), 10s);
Client()->AddWarning(SWarning(Localize("Some map sounds could not be loaded. Check the local console for details.")));
}

// enqueue sound sources
Expand Down
8 changes: 2 additions & 6 deletions src/game/client/components/menus_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

#include "menus.h"

#include <chrono>

using namespace std::chrono_literals;

void CMenus::RenderStartMenu(CUIRect MainView)
{
// render logo
Expand Down Expand Up @@ -84,7 +80,7 @@ void CMenus::RenderStartMenu(CUIRect MainView)
}
else
{
PopupWarning(Localize("Warning"), Localize("Can't find a Tutorial server"), Localize("Ok"), 10s);
Client()->AddWarning(SWarning(Localize("Can't find a Tutorial server")));
s_JoinTutorialTime = 0.0f;
}
}
Expand Down Expand Up @@ -160,7 +156,7 @@ void CMenus::RenderStartMenu(CUIRect MainView)
}
else
{
PopupWarning(Localize("Warning"), Localize("Server executable not found, can't run server"), Localize("Ok"), 10s);
Client()->AddWarning(SWarning(Localize("Server executable not found, can't run server")));
}
}
}
Expand Down

0 comments on commit ebe2dde

Please sign in to comment.