1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fixed scrolling blocking with Ctrl

This commit is contained in:
Ivan Savenko 2023-05-07 19:44:34 +03:00
parent a6fda031ed
commit 8b27780c11
2 changed files with 26 additions and 8 deletions

View File

@ -43,7 +43,8 @@ std::shared_ptr<CAdventureMapInterface> adventureInt;
CAdventureMapInterface::CAdventureMapInterface():
mapAudio(new MapAudioPlayer()),
spellBeingCasted(nullptr),
scrollingCursorSet(false)
scrollingWasActive(false),
scrollingWasBlocked(false)
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
pos.x = pos.y = 0;
@ -150,8 +151,6 @@ void CAdventureMapInterface::handleMapScrollingUpdate()
uint32_t scrollSpeedPixels = settings["adventure"]["scrollSpeedPixels"].Float();
uint32_t scrollDistance = scrollSpeedPixels * timePassed / 1000;
bool scrollingActive = !GH.isKeyboardCtrlDown() && active && shortcuts->optionInMapView();
Point cursorPosition = GH.getCursorPosition();
Point scrollDirection;
@ -169,10 +168,26 @@ void CAdventureMapInterface::handleMapScrollingUpdate()
Point scrollDelta = scrollDirection * scrollDistance;
if (scrollingActive && scrollDelta != Point(0,0))
bool cursorInScrollArea = scrollDelta != Point(0,0);
bool scrollingActive = cursorInScrollArea && active && shortcuts->optionSidePanelActive() && !scrollingWasBlocked;
bool scrollingBlocked = GH.isKeyboardCtrlDown();
if (!scrollingWasActive && scrollingBlocked)
{
scrollingWasBlocked = true;
return;
}
if (!cursorInScrollArea && scrollingWasBlocked)
{
scrollingWasBlocked = false;
return;
}
if (scrollingActive)
widget->getMapView()->onMapScrolled(scrollDelta);
if (scrollDelta == Point(0,0) && !scrollingCursorSet)
if (!scrollingActive && !scrollingWasActive)
return;
if(scrollDelta.x > 0)
@ -204,7 +219,7 @@ void CAdventureMapInterface::handleMapScrollingUpdate()
CCS->curh->set(Cursor::Map::POINTER);
}
scrollingCursorSet = scrollDelta != Point(0,0);
scrollingWasActive = scrollingActive;
}
void CAdventureMapInterface::centerOnTile(int3 on)

View File

@ -52,8 +52,11 @@ private:
/// currently acting player
PlayerColor currentPlayerID;
/// uses EDirections enum
bool scrollingCursorSet;
/// if true, cursor was changed to scrolling and must be reset back once scroll is over
bool scrollingWasActive;
/// if true, then scrolling was blocked via ctrl and should not restart until player move cursor outside scrolling area
bool scrollingWasBlocked;
const CSpell *spellBeingCasted; //nullptr if none