Sfoglia il codice sorgente

Unblock basic adventure map actions (scrolling / right-click) in multiplayer

Dydzio 2 anni fa
parent
commit
ff1a635e9e

+ 1 - 1
client/adventureMap/AdventureMapInterface.cpp

@@ -192,7 +192,7 @@ void AdventureMapInterface::handleMapScrollingUpdate(uint32_t timePassed)
 	Point scrollDelta = scrollDirection * scrollDistance;
 
 	bool cursorInScrollArea = scrollDelta != Point(0,0);
-	bool scrollingActive = cursorInScrollArea && isActive() && shortcuts->optionSidePanelActive() && !scrollingWasBlocked;
+	bool scrollingActive = cursorInScrollArea && shortcuts->optionMapScrollingActive() && !scrollingWasBlocked;
 	bool scrollingBlocked = GH.isKeyboardCtrlDown() || !settings["adventure"]["borderScroll"].Bool();
 
 	if (!scrollingWasActive && scrollingBlocked)

+ 15 - 1
client/adventureMap/AdventureMapShortcuts.cpp

@@ -36,6 +36,14 @@
 #include "../../lib/mapping/CMap.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)
 	: owner(owner)
 	, state(EAdventureState::NOT_INITIALIZED)
@@ -461,7 +469,13 @@ bool AdventureMapShortcuts::optionSidePanelActive()
 	return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW;
 }
 
+bool AdventureMapShortcuts::optionMapScrollingActive()
+{
+	return state == EAdventureState::MAKING_TURN || state == EAdventureState::WORLD_VIEW || (state == EAdventureState::ENEMY_TURN && isCurrentPlayerHuman());
+}
+
 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());
 }

+ 1 - 0
client/adventureMap/AdventureMapShortcuts.h

@@ -81,6 +81,7 @@ public:
 	bool optionInMapView();
 	bool optionInWorldView();
 	bool optionSidePanelActive();
+	bool optionMapScrollingActive();
 	bool optionMapViewActive();
 
 	void setState(EAdventureState newState);