Use generic client warning for failed sound init

Simplify code by using generic warning system instead of hard-coding the warning.
This commit is contained in:
Robert Müller 2023-12-19 21:25:18 +01:00
parent 1e012af2fd
commit e4ea04950a
4 changed files with 8 additions and 14 deletions

View file

@ -242,8 +242,6 @@ public:
virtual const char *LatestVersion() const = 0;
virtual bool ConnectionProblems() const = 0;
virtual bool SoundInitFailed() const = 0;
virtual IGraphics::CTextureHandle GetDebugFont() const = 0; // TODO: remove this function
//DDRace

View file

@ -2727,7 +2727,7 @@ void CClient::Run()
Graphics()->Swap();
// init sound, allowed to fail
m_SoundInitFailed = Sound()->Init() != 0;
const bool SoundInitFailed = Sound()->Init() != 0;
#if defined(CONF_VIDEORECORDER)
// init video recorder aka ffmpeg
@ -2805,6 +2805,13 @@ void CClient::Run()
else
RequestDDNetInfo();
if(SoundInitFailed)
{
SWarning Warning(Localize("Sound error"), Localize("The audio device couldn't be initialised."));
Warning.m_AutoHide = false;
m_vWarnings.emplace_back(Warning);
}
bool LastD = false;
bool LastE = false;
bool LastG = false;

View file

@ -109,7 +109,6 @@ class CClient : public IClient, public CDemoPlayer::IListener
bool m_AutoStatScreenshotRecycle = false;
bool m_AutoCSVRecycle = false;
bool m_EditorActive = false;
bool m_SoundInitFailed = false;
int m_aAckGameTick[NUM_DUMMIES] = {-1, -1};
int m_aCurrentRecvTick[NUM_DUMMIES] = {0, 0};
@ -287,8 +286,6 @@ public:
bool ConnectionProblems() const override;
bool SoundInitFailed() const override { return m_SoundInitFailed; }
IGraphics::CTextureHandle GetDebugFont() const override { return m_DebugFont; }
void DirectInput(int *pInput, int Size);

View file

@ -1045,14 +1045,6 @@ void CMenus::Render()
ms_ColorTabbarHover = ms_ColorTabbarHoverOutgame;
}
static bool s_SoundCheck = false;
if(!s_SoundCheck && m_Popup == POPUP_NONE)
{
if(Client()->SoundInitFailed())
PopupMessage(Localize("Sound error"), Localize("The audio device couldn't be initialised."), Localize("Ok"));
s_SoundCheck = true;
}
if(m_Popup == POPUP_NONE)
{
if(m_JoinTutorial && ServerBrowser()->DDNetInfoAvailable() && !ServerBrowser()->IsGettingServerlist())