mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Use new adventure map state to detect opponent human turn
This commit is contained in:
@@ -323,7 +323,7 @@ void AdventureMapInterface::onEnemyTurnStarted(PlayerColor playerID, bool isHuma
|
|||||||
mapAudio->onEnemyTurnStarted();
|
mapAudio->onEnemyTurnStarted();
|
||||||
widget->getMinimap()->setAIRadar(!isHuman);
|
widget->getMinimap()->setAIRadar(!isHuman);
|
||||||
widget->getInfoBar()->startEnemyTurn(LOCPLINT->cb->getCurrentPlayer());
|
widget->getInfoBar()->startEnemyTurn(LOCPLINT->cb->getCurrentPlayer());
|
||||||
setState(EAdventureState::ENEMY_TURN);
|
setState(isHuman ? EAdventureState::OTHER_HUMAN_PLAYER_TURN : EAdventureState::AI_PLAYER_TURN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdventureMapInterface::setState(EAdventureState state)
|
void AdventureMapInterface::setState(EAdventureState state)
|
||||||
|
@@ -36,14 +36,6 @@
|
|||||||
#include "../../lib/mapping/CMap.h"
|
#include "../../lib/mapping/CMap.h"
|
||||||
#include "../../lib/pathfinder/CGPathNode.h"
|
#include "../../lib/pathfinder/CGPathNode.h"
|
||||||
|
|
||||||
bool isCurrentPlayerHuman()
|
|
||||||
{
|
|
||||||
PlayerColor currentPlayer = LOCPLINT->cb->getCurrentPlayer();
|
|
||||||
bool isHuman = LOCPLINT->cb->getStartInfo()->playerInfos.count(currentPlayer)
|
|
||||||
&& LOCPLINT->cb->getStartInfo()->playerInfos.at(currentPlayer).isControlledByHuman();
|
|
||||||
return isHuman;
|
|
||||||
}
|
|
||||||
|
|
||||||
AdventureMapShortcuts::AdventureMapShortcuts(AdventureMapInterface & owner)
|
AdventureMapShortcuts::AdventureMapShortcuts(AdventureMapInterface & owner)
|
||||||
: owner(owner)
|
: owner(owner)
|
||||||
, state(EAdventureState::NOT_INITIALIZED)
|
, state(EAdventureState::NOT_INITIALIZED)
|
||||||
@@ -471,11 +463,11 @@ bool AdventureMapShortcuts::optionSidePanelActive()
|
|||||||
|
|
||||||
bool AdventureMapShortcuts::optionMapScrollingActive()
|
bool AdventureMapShortcuts::optionMapScrollingActive()
|
||||||
{
|
{
|
||||||
return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || (state == EAdventureState::ENEMY_TURN && isCurrentPlayerHuman());
|
return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || (state == EAdventureState::OTHER_HUMAN_PLAYER_TURN);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdventureMapShortcuts::optionMapViewActive()
|
bool AdventureMapShortcuts::optionMapViewActive()
|
||||||
{
|
{
|
||||||
return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || state == EAdventureState::CASTING_SPELL
|
return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || state == EAdventureState::CASTING_SPELL
|
||||||
|| (state == EAdventureState::ENEMY_TURN && isCurrentPlayerHuman());
|
|| (state == EAdventureState::OTHER_HUMAN_PLAYER_TURN);
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,8 @@ enum class EAdventureState
|
|||||||
NOT_INITIALIZED,
|
NOT_INITIALIZED,
|
||||||
HOTSEAT_WAIT,
|
HOTSEAT_WAIT,
|
||||||
MAKING_TURN,
|
MAKING_TURN,
|
||||||
ENEMY_TURN,
|
AI_PLAYER_TURN,
|
||||||
|
OTHER_HUMAN_PLAYER_TURN,
|
||||||
CASTING_SPELL,
|
CASTING_SPELL,
|
||||||
WORLD_VIEW
|
WORLD_VIEW
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user