diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index 69ab62ba9..981b3da7c 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/client/adventureMap/AdventureMapInterface.cpp @@ -886,9 +886,9 @@ void AdventureMapInterface::hotkeySwitchMapLevel() widget->getMapView()->onMapLevelSwitched(); } -void AdventureMapInterface::hotkeyZoom(int delta) +void AdventureMapInterface::hotkeyZoom(int delta, bool useDeadZone) { - widget->getMapView()->onMapZoomLevelChanged(delta); + widget->getMapView()->onMapZoomLevelChanged(delta, useDeadZone); } void AdventureMapInterface::onScreenResize() diff --git a/client/adventureMap/AdventureMapInterface.h b/client/adventureMap/AdventureMapInterface.h index cd63e5b24..b0509a77c 100644 --- a/client/adventureMap/AdventureMapInterface.h +++ b/client/adventureMap/AdventureMapInterface.h @@ -120,7 +120,7 @@ public: void hotkeyEndingTurn(); void hotkeyNextTown(); void hotkeySwitchMapLevel(); - void hotkeyZoom(int delta); + void hotkeyZoom(int delta, bool useDeadZone); /// Called by PlayerInterface when specified player is ready to start his turn void onHotseatWaitStarted(PlayerColor playerID); diff --git a/client/adventureMap/AdventureMapShortcuts.cpp b/client/adventureMap/AdventureMapShortcuts.cpp index e84da1544..5cc33fc28 100644 --- a/client/adventureMap/AdventureMapShortcuts.cpp +++ b/client/adventureMap/AdventureMapShortcuts.cpp @@ -94,8 +94,8 @@ std::vector AdventureMapShortcuts::getShortcuts() { EShortcut::ADVENTURE_VISIT_OBJECT, optionCanVisitObject(), [this]() { this->visitObject(); } }, { EShortcut::ADVENTURE_VIEW_SELECTED, optionInMapView(), [this]() { this->openObject(); } }, { EShortcut::ADVENTURE_MARKETPLACE, optionInMapView(), [this]() { this->showMarketplace(); } }, - { EShortcut::ADVENTURE_ZOOM_IN, optionSidePanelActive(),[this]() { this->zoom(+1); } }, - { EShortcut::ADVENTURE_ZOOM_OUT, optionSidePanelActive(),[this]() { this->zoom(-1); } }, + { EShortcut::ADVENTURE_ZOOM_IN, optionSidePanelActive(),[this]() { this->zoom(+10); } }, + { EShortcut::ADVENTURE_ZOOM_OUT, optionSidePanelActive(),[this]() { this->zoom(-10); } }, { EShortcut::ADVENTURE_ZOOM_RESET, optionSidePanelActive(),[this]() { this->zoom( 0); } }, { EShortcut::ADVENTURE_FIRST_TOWN, optionInMapView(), [this]() { this->firstTown(); } }, { EShortcut::ADVENTURE_NEXT_TOWN, optionInMapView(), [this]() { this->nextTown(); } }, @@ -442,7 +442,7 @@ void AdventureMapShortcuts::nextTown() void AdventureMapShortcuts::zoom( int distance) { - owner.hotkeyZoom(distance); + owner.hotkeyZoom(distance, false); } void AdventureMapShortcuts::nextObject() diff --git a/client/mapView/MapView.cpp b/client/mapView/MapView.cpp index 23ef811b1..8d6405fd5 100644 --- a/client/mapView/MapView.cpp +++ b/client/mapView/MapView.cpp @@ -239,9 +239,9 @@ void MapView::onViewWorldActivated(uint32_t tileSize) controller->setTileSize(Point(tileSize, tileSize)); } -void MapView::onMapZoomLevelChanged(int stepsChange) +void MapView::onMapZoomLevelChanged(int stepsChange, bool useDeadZone) { - controller->modifyTileSize(stepsChange); + controller->modifyTileSize(stepsChange, useDeadZone); } void MapView::onViewMapActivated() diff --git a/client/mapView/MapView.h b/client/mapView/MapView.h index f83b9d319..cd4faa0ec 100644 --- a/client/mapView/MapView.h +++ b/client/mapView/MapView.h @@ -87,7 +87,7 @@ public: void onViewWorldActivated(uint32_t tileSize); /// Changes zoom level / tile size of current view by specified factor - void onMapZoomLevelChanged(int stepsChange); + void onMapZoomLevelChanged(int stepsChange, bool useDeadZone); /// Switches view from View World mode back to standard view void onViewMapActivated(); diff --git a/client/mapView/MapViewActions.cpp b/client/mapView/MapViewActions.cpp index 68cb692fd..6c87edba4 100644 --- a/client/mapView/MapViewActions.cpp +++ b/client/mapView/MapViewActions.cpp @@ -87,7 +87,7 @@ void MapViewActions::mouseMoved(const Point & cursorPosition, const Point & last void MapViewActions::wheelScrolled(int distance) { - adventureInt->hotkeyZoom(distance * 4); + adventureInt->hotkeyZoom(distance * 4, true); } void MapViewActions::mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) @@ -114,7 +114,7 @@ void MapViewActions::gesturePinch(const Point & centerPosition, double lastUpdat int oldZoomSteps = std::round(std::log(pinchZoomFactor) / std::log(1.01)); if (newZoomSteps != oldZoomSteps) - adventureInt->hotkeyZoom(newZoomSteps - oldZoomSteps); + adventureInt->hotkeyZoom(newZoomSteps - oldZoomSteps, true); pinchZoomFactor = newZoom; } diff --git a/client/mapView/MapViewController.cpp b/client/mapView/MapViewController.cpp index 7b20d1c71..bfab5e889 100644 --- a/client/mapView/MapViewController.cpp +++ b/client/mapView/MapViewController.cpp @@ -88,7 +88,7 @@ void MapViewController::setTileSize(const Point & tileSize) setViewCenter(newViewCenter, model->getLevel()); } -void MapViewController::modifyTileSize(int stepsChange) +void MapViewController::modifyTileSize(int stepsChange, bool useDeadZone) { // we want to zoom in/out in fixed 10% steps, to allow player to return back to exactly 100% zoom just by scrolling // so, zooming in for 5 steps will put game at 1.1^5 = 1.61 scale @@ -117,10 +117,13 @@ void MapViewController::modifyTileSize(int stepsChange) if (actualZoom != currentZoom) { targetTileSize = actualZoom; - if(actualZoom.x >= defaultTileSize - zoomTileDeadArea && actualZoom.x <= defaultTileSize + zoomTileDeadArea) - actualZoom.x = defaultTileSize; - if(actualZoom.y >= defaultTileSize - zoomTileDeadArea && actualZoom.y <= defaultTileSize + zoomTileDeadArea) - actualZoom.y = defaultTileSize; + if (useDeadZone) + { + if(actualZoom.x >= defaultTileSize - zoomTileDeadArea && actualZoom.x <= defaultTileSize + zoomTileDeadArea) + actualZoom.x = defaultTileSize; + if(actualZoom.y >= defaultTileSize - zoomTileDeadArea && actualZoom.y <= defaultTileSize + zoomTileDeadArea) + actualZoom.y = defaultTileSize; + } bool isInDeadZone = targetTileSize != actualZoom || actualZoom == Point(defaultTileSize, defaultTileSize); diff --git a/client/mapView/MapViewController.h b/client/mapView/MapViewController.h index 151ef6a93..d723886f2 100644 --- a/client/mapView/MapViewController.h +++ b/client/mapView/MapViewController.h @@ -52,7 +52,7 @@ class MapViewController : public IMapObjectObserver private: const int defaultTileSize = 32; - const int zoomTileDeadArea = 5; + const int zoomTileDeadArea = 4; Point targetTileSize = Point(32, 32); bool wasInDeadZone = true; @@ -91,7 +91,7 @@ public: void setViewCenter(const int3 & position); void setViewCenter(const Point & position, int level); void setTileSize(const Point & tileSize); - void modifyTileSize(int stepsChange); + void modifyTileSize(int stepsChange, bool useDeadZone); void tick(uint32_t timePassed); void afterRender();