mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
fix window open while sound playing
This commit is contained in:
parent
6ae09d8458
commit
a2174dc83f
@ -22,6 +22,7 @@
|
||||
#include "../gui/TextAlignment.h"
|
||||
#include "../render/Colors.h"
|
||||
#include "../render/Canvas.h"
|
||||
#include "../render/IScreenHandler.h"
|
||||
#include "../adventureMap/AdventureMapInterface.h"
|
||||
#include "../windows/CMessage.h"
|
||||
|
||||
@ -111,7 +112,7 @@ void CInGameConsole::print(const std::string & txt)
|
||||
CCS->soundh->setVolume(settings["general"]["sound"].Integer());
|
||||
int handle = CCS->soundh->playSound(AudioPath::builtin("CHAT"));
|
||||
if(volume == 0)
|
||||
CCS->soundh->setCallback(handle, [&]() { CCS->soundh->setVolume(0); });
|
||||
CCS->soundh->setCallback(handle, [&]() { if(!GH.screenHandler().hasFocus()) CCS->soundh->setVolume(0); });
|
||||
}
|
||||
|
||||
bool CInGameConsole::captureThisKey(EShortcut key)
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "../PlayerLocalState.h"
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../gui/WindowHandler.h"
|
||||
#include "../render/IScreenHandler.h"
|
||||
|
||||
#include "../../CCallback.h"
|
||||
#include "../../lib/CConfigHandler.h"
|
||||
@ -243,7 +244,7 @@ void CInfoBar::playNewDaySound()
|
||||
handle = CCS->soundh->playSound(soundBase::newDay);
|
||||
|
||||
if(volume == 0)
|
||||
CCS->soundh->setCallback(handle, [&]() { CCS->soundh->setVolume(0); });
|
||||
CCS->soundh->setCallback(handle, [&]() { if(!GH.screenHandler().hasFocus()) CCS->soundh->setVolume(0); });
|
||||
}
|
||||
|
||||
void CInfoBar::reset()
|
||||
|
@ -40,4 +40,7 @@ public:
|
||||
|
||||
/// Dimensions of render output
|
||||
virtual Point getRenderResolution() const = 0;
|
||||
|
||||
/// Window has focus
|
||||
virtual bool hasFocus() = 0;
|
||||
};
|
||||
|
@ -565,3 +565,9 @@ std::vector<Point> ScreenHandler::getSupportedResolutions( int displayIndex) con
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ScreenHandler::hasFocus()
|
||||
{
|
||||
ui32 flags = SDL_GetWindowFlags(mainWindow);
|
||||
return flags & SDL_WINDOW_INPUT_FOCUS;
|
||||
}
|
@ -86,6 +86,9 @@ public:
|
||||
/// Dimensions of render output, usually same as window size except for high-DPI screens on macOS / iOS
|
||||
Point getRenderResolution() const final;
|
||||
|
||||
/// Window has focus
|
||||
bool hasFocus() final;
|
||||
|
||||
std::vector<Point> getSupportedResolutions() const final;
|
||||
std::vector<Point> getSupportedResolutions(int displayIndex) const;
|
||||
std::tuple<int, int> getSupportedScalingRange() const final;
|
||||
|
Loading…
Reference in New Issue
Block a user