From 18f5853279ddf8c0dfae0b58321fc703d6abb0b7 Mon Sep 17 00:00:00 2001 From: CedricMocquillon Date: Sun, 29 Nov 2020 22:03:16 +0100 Subject: [PATCH] [Global <-> Local] Auto switch between local and global map when zoom in/out --- apps/openmw/mwgui/mapwindow.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 9cc47e8c16..d4f63c0a26 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -886,16 +886,18 @@ namespace MWGui void MapWindow::onMapZoomed(MyGUI::Widget* sender, int rel) { const static int localWidgetSize = Settings::Manager::getInt("local map widget size", "Map"); + const static int globalCellSize = Settings::Manager::getInt("global map cell size", "Map"); const bool zoomOut = rel < 0; const bool zoomIn = !zoomOut; const double speedDiff = zoomOut ? 1.0 / speed : speed; const float localMapSizeInUnits = localWidgetSize * mNumCells; - const float currentMinLocalMapZoom = std::max( + const float currentMinLocalMapZoom = std::max({ + (float(globalCellSize) * 4.f) / float(localWidgetSize), float(mLocalMap->getWidth()) / localMapSizeInUnits, float(mLocalMap->getHeight()) / localMapSizeInUnits - ); + }); if (mGlobal) { @@ -910,6 +912,9 @@ namespace MWGui if (zoomIn && mGlobalMapZoom > 4.f) { mGlobalMapZoom = currentGlobalZoom; + mLocalMapZoom = currentMinLocalMapZoom; + onWorldButtonClicked(nullptr); + updateLocalMap(); return; //the zoom in is too big } @@ -933,7 +938,13 @@ namespace MWGui if (zoomOut && mLocalMapZoom < currentMinLocalMapZoom) { mLocalMapZoom = currentLocalZoom; - return; //the zoom out is too big + + float zoomRatio = 4.f/ mGlobalMapZoom; + mGlobalMapZoom = 4.f; + onWorldButtonClicked(nullptr); + + zoomOnCursor(zoomRatio); + return; //the zoom out is too big, we switch to the global map } } zoomOnCursor(speedDiff);