mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Fixed timer countdown sound playback
This commit is contained in:
@@ -104,13 +104,14 @@ void TurnTimerWidget::show(Canvas & to)
|
|||||||
|
|
||||||
void TurnTimerWidget::updateNotifications(PlayerColor player, int timeMs)
|
void TurnTimerWidget::updateNotifications(PlayerColor player, int timeMs)
|
||||||
{
|
{
|
||||||
|
if(player != LOCPLINT->playerID)
|
||||||
|
return;
|
||||||
|
|
||||||
int newTimeSeconds = timeMs / 1000;
|
int newTimeSeconds = timeMs / 1000;
|
||||||
if(player == LOCPLINT->playerID
|
|
||||||
&& newTimeSeconds != lastSoundCheckSeconds
|
if (newTimeSeconds != lastSoundCheckSeconds && notificationThresholds.count(newTimeSeconds))
|
||||||
&& notificationThresholds.count(newTimeSeconds))
|
|
||||||
{
|
|
||||||
CCS->soundh->playSound(AudioPath::builtin("WE5"));
|
CCS->soundh->playSound(AudioPath::builtin("WE5"));
|
||||||
}
|
|
||||||
lastSoundCheckSeconds = newTimeSeconds;
|
lastSoundCheckSeconds = newTimeSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@ class TurnTimerWidget : public CIntObject
|
|||||||
int lastSoundCheckSeconds;
|
int lastSoundCheckSeconds;
|
||||||
bool isBattleMode;
|
bool isBattleMode;
|
||||||
|
|
||||||
const std::set<int> notificationThresholds = {0, 1, 2, 3, 4, 5, 10, 20, 30};
|
const std::set<int> notificationThresholds = {1, 2, 3, 4, 5, 10, 20, 30};
|
||||||
|
|
||||||
std::map<PlayerColor, std::shared_ptr<CLabel>> playerLabelsMain;
|
std::map<PlayerColor, std::shared_ptr<CLabel>> playerLabelsMain;
|
||||||
std::map<PlayerColor, std::shared_ptr<CLabel>> playerLabelsBattle;
|
std::map<PlayerColor, std::shared_ptr<CLabel>> playerLabelsBattle;
|
||||||
|
Reference in New Issue
Block a user