mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
dead area for zoom
This commit is contained in:
@@ -90,13 +90,13 @@ void MapViewController::modifyTileSize(int stepsChange)
|
|||||||
// we want to zoom in/out in fixed 10% steps, to allow player to return back to exactly 100% zoom just by scrolling
|
// 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
|
// so, zooming in for 5 steps will put game at 1.1^5 = 1.61 scale
|
||||||
// try to determine current zooming level and change it by requested number of steps
|
// try to determine current zooming level and change it by requested number of steps
|
||||||
double currentZoomFactor = model->getSingleTileSize().x / 32.0;
|
double currentZoomFactor = targetTileSize.x / static_cast<double>(defaultTileSize);
|
||||||
double currentZoomSteps = std::round(std::log(currentZoomFactor) / std::log(1.01));
|
double currentZoomSteps = std::round(std::log(currentZoomFactor) / std::log(1.01));
|
||||||
double newZoomSteps = stepsChange != 0 ? currentZoomSteps + stepsChange : stepsChange;
|
double newZoomSteps = stepsChange != 0 ? currentZoomSteps + stepsChange : stepsChange;
|
||||||
double newZoomFactor = std::pow(1.01, newZoomSteps);
|
double newZoomFactor = std::pow(1.01, newZoomSteps);
|
||||||
|
|
||||||
Point currentZoom = model->getSingleTileSize();
|
Point currentZoom = targetTileSize;
|
||||||
Point desiredZoom = Point(32,32) * newZoomFactor;
|
Point desiredZoom = Point(defaultTileSize,defaultTileSize) * newZoomFactor;
|
||||||
|
|
||||||
if (desiredZoom == currentZoom && stepsChange < 0)
|
if (desiredZoom == currentZoom && stepsChange < 0)
|
||||||
desiredZoom -= Point(1,1);
|
desiredZoom -= Point(1,1);
|
||||||
@@ -112,7 +112,14 @@ void MapViewController::modifyTileSize(int stepsChange)
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (actualZoom != currentZoom)
|
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;
|
||||||
setTileSize(actualZoom);
|
setTileSize(actualZoom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MapViewController::MapViewController(std::shared_ptr<MapViewModel> model, std::shared_ptr<MapViewCache> view)
|
MapViewController::MapViewController(std::shared_ptr<MapViewModel> model, std::shared_ptr<MapViewCache> view)
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "IMapRendererObserver.h"
|
#include "IMapRendererObserver.h"
|
||||||
|
#include "../../lib/Point.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
class Point;
|
|
||||||
struct ObjectPosInfo;
|
struct ObjectPosInfo;
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
|
||||||
@@ -50,6 +50,10 @@ class MapViewController : public IMapObjectObserver
|
|||||||
std::shared_ptr<MapRendererPuzzleMapContext> puzzleMapContext;
|
std::shared_ptr<MapRendererPuzzleMapContext> puzzleMapContext;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const int defaultTileSize = 32;
|
||||||
|
const int zoomTileDeadArea = 4;
|
||||||
|
Point targetTileSize = Point(32, 32);
|
||||||
|
|
||||||
bool isEventInstant(const CGObjectInstance * obj);
|
bool isEventInstant(const CGObjectInstance * obj);
|
||||||
bool isEventVisible(const CGObjectInstance * obj);
|
bool isEventVisible(const CGObjectInstance * obj);
|
||||||
bool isEventVisible(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
|
bool isEventVisible(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
|
||||||
|
|||||||
Reference in New Issue
Block a user