mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fix hot seat timer visualization
This commit is contained in:
parent
e4e9bcfb9b
commit
614a285fb8
@ -41,7 +41,7 @@ void TurnTimerWidget::DrawRect::showAll(Canvas & to)
|
||||
|
||||
TurnTimerWidget::TurnTimerWidget():
|
||||
InterfaceObjectConfigurable(TIME),
|
||||
turnTime(0), lastTurnTime(0), cachedTurnTime(0)
|
||||
turnTime(0), lastTurnTime(0), cachedTurnTime(0), lastPlayer(PlayerColor::CANNOT_DETERMINE)
|
||||
{
|
||||
REGISTER_BUILDER("drawRect", &TurnTimerWidget::buildDrawRect);
|
||||
|
||||
@ -73,8 +73,8 @@ void TurnTimerWidget::show(Canvas & to)
|
||||
void TurnTimerWidget::setTime(PlayerColor player, int time)
|
||||
{
|
||||
int newTime = time / 1000;
|
||||
if(player == LOCPLINT->playerID)
|
||||
&& (newTime != turnTime)
|
||||
if(player == LOCPLINT->playerID
|
||||
&& newTime != turnTime
|
||||
&& notifications.count(newTime))
|
||||
{
|
||||
CCS->soundh->playSound(variables["notificationSound"].String());
|
||||
@ -117,6 +117,12 @@ void TurnTimerWidget::tick(uint32_t msPassed)
|
||||
cachedTurnTime -= msPassed;
|
||||
if(cachedTurnTime < 0) cachedTurnTime = 0; //do not go below zero
|
||||
|
||||
if(lastPlayer != player)
|
||||
{
|
||||
lastPlayer = player;
|
||||
lastTurnTime = 0;
|
||||
}
|
||||
|
||||
auto timeCheckAndUpdate = [&](int time)
|
||||
{
|
||||
if(time / 1000 != lastTurnTime / 1000)
|
||||
@ -130,7 +136,7 @@ void TurnTimerWidget::tick(uint32_t msPassed)
|
||||
};
|
||||
|
||||
auto * playerInfo = LOCPLINT->cb->getPlayer(player);
|
||||
if(playerInfo && playerInfo->isHuman())
|
||||
if(player.isValidPlayer() || (playerInfo && playerInfo->isHuman()))
|
||||
{
|
||||
if(LOCPLINT->battleInt)
|
||||
{
|
||||
|
@ -18,6 +18,12 @@
|
||||
class CAnimImage;
|
||||
class CLabel;
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class PlayerColor;
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
class TurnTimerWidget : public InterfaceObjectConfigurable
|
||||
{
|
||||
private:
|
||||
@ -35,6 +41,7 @@ private:
|
||||
int turnTime;
|
||||
int lastTurnTime;
|
||||
int cachedTurnTime;
|
||||
PlayerColor lastPlayer;
|
||||
|
||||
std::set<int> notifications;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user