From ff1a635e9e9fa72896d236f63b20a8c8435e0c50 Mon Sep 17 00:00:00 2001 From: Dydzio Date: Wed, 26 Jul 2023 21:20:11 +0200 Subject: [PATCH] Unblock basic adventure map actions (scrolling / right-click) in multiplayer --- client/adventureMap/AdventureMapInterface.cpp | 2 +- client/adventureMap/AdventureMapShortcuts.cpp | 16 +++++++++++++++- client/adventureMap/AdventureMapShortcuts.h | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index 5d9c0a276..fba871751 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/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) diff --git a/client/adventureMap/AdventureMapShortcuts.cpp b/client/adventureMap/AdventureMapShortcuts.cpp index 722814d08..1892ef448 100644 --- a/client/adventureMap/AdventureMapShortcuts.cpp +++ b/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()); } diff --git a/client/adventureMap/AdventureMapShortcuts.h b/client/adventureMap/AdventureMapShortcuts.h index 770e40fa2..8e86779a7 100644 --- a/client/adventureMap/AdventureMapShortcuts.h +++ b/client/adventureMap/AdventureMapShortcuts.h @@ -81,6 +81,7 @@ public: bool optionInMapView(); bool optionInWorldView(); bool optionSidePanelActive(); + bool optionMapScrollingActive(); bool optionMapViewActive(); void setState(EAdventureState newState);