mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Fixed scrolling blocking with Ctrl
This commit is contained in:
@@ -43,7 +43,8 @@ std::shared_ptr<CAdventureMapInterface> adventureInt;
|
|||||||
CAdventureMapInterface::CAdventureMapInterface():
|
CAdventureMapInterface::CAdventureMapInterface():
|
||||||
mapAudio(new MapAudioPlayer()),
|
mapAudio(new MapAudioPlayer()),
|
||||||
spellBeingCasted(nullptr),
|
spellBeingCasted(nullptr),
|
||||||
scrollingCursorSet(false)
|
scrollingWasActive(false),
|
||||||
|
scrollingWasBlocked(false)
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||||
pos.x = pos.y = 0;
|
pos.x = pos.y = 0;
|
||||||
@@ -150,8 +151,6 @@ void CAdventureMapInterface::handleMapScrollingUpdate()
|
|||||||
uint32_t scrollSpeedPixels = settings["adventure"]["scrollSpeedPixels"].Float();
|
uint32_t scrollSpeedPixels = settings["adventure"]["scrollSpeedPixels"].Float();
|
||||||
uint32_t scrollDistance = scrollSpeedPixels * timePassed / 1000;
|
uint32_t scrollDistance = scrollSpeedPixels * timePassed / 1000;
|
||||||
|
|
||||||
bool scrollingActive = !GH.isKeyboardCtrlDown() && active && shortcuts->optionInMapView();
|
|
||||||
|
|
||||||
Point cursorPosition = GH.getCursorPosition();
|
Point cursorPosition = GH.getCursorPosition();
|
||||||
Point scrollDirection;
|
Point scrollDirection;
|
||||||
|
|
||||||
@@ -169,10 +168,26 @@ void CAdventureMapInterface::handleMapScrollingUpdate()
|
|||||||
|
|
||||||
Point scrollDelta = scrollDirection * scrollDistance;
|
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);
|
widget->getMapView()->onMapScrolled(scrollDelta);
|
||||||
|
|
||||||
if (scrollDelta == Point(0,0) && !scrollingCursorSet)
|
if (!scrollingActive && !scrollingWasActive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(scrollDelta.x > 0)
|
if(scrollDelta.x > 0)
|
||||||
@@ -204,7 +219,7 @@ void CAdventureMapInterface::handleMapScrollingUpdate()
|
|||||||
CCS->curh->set(Cursor::Map::POINTER);
|
CCS->curh->set(Cursor::Map::POINTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollingCursorSet = scrollDelta != Point(0,0);
|
scrollingWasActive = scrollingActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAdventureMapInterface::centerOnTile(int3 on)
|
void CAdventureMapInterface::centerOnTile(int3 on)
|
||||||
|
@@ -52,8 +52,11 @@ private:
|
|||||||
/// currently acting player
|
/// currently acting player
|
||||||
PlayerColor currentPlayerID;
|
PlayerColor currentPlayerID;
|
||||||
|
|
||||||
/// uses EDirections enum
|
/// if true, cursor was changed to scrolling and must be reset back once scroll is over
|
||||||
bool scrollingCursorSet;
|
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
|
const CSpell *spellBeingCasted; //nullptr if none
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user