From 4ecac31752cb59082817921cd6e74812d435f7b8 Mon Sep 17 00:00:00 2001 From: Ragora Date: Fri, 12 Sep 2014 05:16:33 -0400 Subject: [PATCH 1/3] Map keeps focus on wherever it was last moved when resizing map window --- apps/openmw/mwgui/mapwindow.cpp | 21 +++++++++++++++++++++ apps/openmw/mwgui/mapwindow.hpp | 1 + 2 files changed, 22 insertions(+) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 1968181ceb..17e0847672 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -14,6 +14,9 @@ #include "../mwrender/globalmap.hpp" +#include "../mwgui/container.hpp" +#include "../mwgui/itemview.hpp" + #include "../components/esm/globalmap.hpp" #include "widgets.hpp" @@ -537,6 +540,9 @@ namespace MWGui getWidget(mPlayerArrowLocal, "CompassLocal"); getWidget(mPlayerArrowGlobal, "CompassGlobal"); + // Seems to be called when the map window is resized at all regardless of local or world map view + mLocalMap->eventChangeCoord += MyGUI::newDelegate(this, &MapWindow::onChangeCoord); + mGlobalMap->setVisible (false); getWidget(mButton, "WorldButton"); @@ -632,6 +638,21 @@ namespace MWGui mEditNoteDialog.setText(""); } + void MapWindow::onChangeCoord(MyGUI::Widget* sender) + { + static MyGUI::IntCoord lastCoordinates = sender->getCoord(); + MyGUI::IntCoord currentCoordinates = sender->getCoord(); + + MyGUI::IntPoint currentViewPortCenter = MyGUI::IntPoint(currentCoordinates.width / 2, currentCoordinates.height / 2); + MyGUI::IntPoint lastViewPortCenter = MyGUI::IntPoint(lastCoordinates.width / 2, lastCoordinates.height / 2); + MyGUI::IntPoint viewPortCenterDiff = currentViewPortCenter - lastViewPortCenter; + + mLocalMap->setViewOffset(mLocalMap->getViewOffset() + viewPortCenterDiff); + mGlobalMap->setViewOffset(mGlobalMap->getViewOffset() + viewPortCenterDiff); + + lastCoordinates = currentCoordinates; + } + void MapWindow::renderGlobalMap(Loading::Listener* loadingListener) { mGlobalMapRender = new MWRender::GlobalMap(""); diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index a9edbe0b1e..d1e9f95c6f 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -200,6 +200,7 @@ namespace MWGui void onNoteEditDelete(); void onNoteEditDeleteConfirm(); void onNoteDoubleClicked(MyGUI::Widget* sender); + void onChangeCoord(MyGUI::Widget* sender); void globalMapUpdatePlayer(); MyGUI::ScrollView* mGlobalMap; From 58d70c2895931c2841779ddd2f43b2e50a972dbc Mon Sep 17 00:00:00 2001 From: Ragora Date: Fri, 12 Sep 2014 05:20:03 -0400 Subject: [PATCH 2/3] Removed Unused includes from experimentation --- apps/openmw/mwgui/mapwindow.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 17e0847672..3f8b3c7aa0 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -14,9 +14,6 @@ #include "../mwrender/globalmap.hpp" -#include "../mwgui/container.hpp" -#include "../mwgui/itemview.hpp" - #include "../components/esm/globalmap.hpp" #include "widgets.hpp" From 25f99c5d5a979ee835e1499f2c185a5895895405 Mon Sep 17 00:00:00 2001 From: Ragora Date: Fri, 12 Sep 2014 15:06:37 -0400 Subject: [PATCH 3/3] Discarded use of a static variable and renamed event function to be less ambiguous --- apps/openmw/mwgui/mapwindow.cpp | 11 +++++------ apps/openmw/mwgui/mapwindow.hpp | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 3f8b3c7aa0..b071cc5461 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -537,8 +537,8 @@ namespace MWGui getWidget(mPlayerArrowLocal, "CompassLocal"); getWidget(mPlayerArrowGlobal, "CompassGlobal"); - // Seems to be called when the map window is resized at all regardless of local or world map view - mLocalMap->eventChangeCoord += MyGUI::newDelegate(this, &MapWindow::onChangeCoord); + mLastScrollWindowCoordinates = mLocalMap->getCoord(); + mLocalMap->eventChangeCoord += MyGUI::newDelegate(this, &MapWindow::onChangeScrollWindowCoord); mGlobalMap->setVisible (false); @@ -635,19 +635,18 @@ namespace MWGui mEditNoteDialog.setText(""); } - void MapWindow::onChangeCoord(MyGUI::Widget* sender) + void MapWindow::onChangeScrollWindowCoord(MyGUI::Widget* sender) { - static MyGUI::IntCoord lastCoordinates = sender->getCoord(); MyGUI::IntCoord currentCoordinates = sender->getCoord(); MyGUI::IntPoint currentViewPortCenter = MyGUI::IntPoint(currentCoordinates.width / 2, currentCoordinates.height / 2); - MyGUI::IntPoint lastViewPortCenter = MyGUI::IntPoint(lastCoordinates.width / 2, lastCoordinates.height / 2); + MyGUI::IntPoint lastViewPortCenter = MyGUI::IntPoint(mLastScrollWindowCoordinates.width / 2, mLastScrollWindowCoordinates.height / 2); MyGUI::IntPoint viewPortCenterDiff = currentViewPortCenter - lastViewPortCenter; mLocalMap->setViewOffset(mLocalMap->getViewOffset() + viewPortCenterDiff); mGlobalMap->setViewOffset(mGlobalMap->getViewOffset() + viewPortCenterDiff); - lastCoordinates = currentCoordinates; + mLastScrollWindowCoordinates = currentCoordinates; } void MapWindow::renderGlobalMap(Loading::Listener* loadingListener) diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index d1e9f95c6f..02f69d47fe 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -200,7 +200,7 @@ namespace MWGui void onNoteEditDelete(); void onNoteEditDeleteConfirm(); void onNoteDoubleClicked(MyGUI::Widget* sender); - void onChangeCoord(MyGUI::Widget* sender); + void onChangeScrollWindowCoord(MyGUI::Widget* sender); void globalMapUpdatePlayer(); MyGUI::ScrollView* mGlobalMap; @@ -212,6 +212,8 @@ namespace MWGui MyGUI::IntPoint mLastDragPos; bool mGlobal; + MyGUI::IntCoord mLastScrollWindowCoordinates; + // Markers on global map typedef std::pair CellId; std::vector mMarkers;