From bdb480858800c208afb636b84d0ce5f0191eba1f Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 27 Jul 2023 22:52:00 +0200 Subject: [PATCH 1/2] Remove unused local map hud widget size setting Unused since d1a3cc98ffdcb5e40b5cc56a1d5db37ffac2a602 --- components/settings/categories/map.hpp | 1 - .../source/reference/modding/settings/map.rst | 20 ------------------- files/settings-default.cfg | 4 ---- 3 files changed, 25 deletions(-) diff --git a/components/settings/categories/map.hpp b/components/settings/categories/map.hpp index bd5bd33d53..af3857b206 100644 --- a/components/settings/categories/map.hpp +++ b/components/settings/categories/map.hpp @@ -19,7 +19,6 @@ namespace Settings using WithIndex::WithIndex; SettingValue mGlobalMapCellSize{ mIndex, "Map", "global map cell size", makeClampSanitizerInt(1, 50) }; - SettingValue mLocalMapHudWidgetSize{ mIndex, "Map", "local map hud widget size", makeMaxSanitizerInt(1) }; SettingValue mLocalMapHudFogOfWar{ mIndex, "Map", "local map hud fog of war" }; SettingValue mLocalMapResolution{ mIndex, "Map", "local map resolution", makeMaxSanitizerInt(1) }; SettingValue mLocalMapWidgetSize{ mIndex, "Map", "local map widget size", makeMaxSanitizerInt(1) }; diff --git a/docs/source/reference/modding/settings/map.rst b/docs/source/reference/modding/settings/map.rst index e20a993a29..7468b2b836 100644 --- a/docs/source/reference/modding/settings/map.rst +++ b/docs/source/reference/modding/settings/map.rst @@ -36,26 +36,6 @@ Values from 12 to 36 are recommended. For reference, Vvardenfell is approximatel This setting can not be configured except by editing the settings configuration file. -local map hud widget size -------------------------- - -:Type: integer -:Range: >= 1 -:Default: 256 - -This setting controls the zoom level for the HUD map widget (the map in the lower right corner of the window). -A value of 64 results in the HUD map widget displaying one entire exterior cell. -Since the GUI mode map displays 3x3 cells, a value of approximately 21 displays the same area as the GUI mode map. -Larger values increase the level of zoom, -while smaller values are wasteful since there's no map data to display beyond the 3x3 cell grid. - -Note that the actual size of the widget is always the same on the screen -unless the scaling factor setting in the "GUI" section is changed. -Increasing both the scaling factor of the GUI and this setting does result in a higher resolution HUD map, -unfortunately with a scaled direction pointer on top of it. - -This setting can not be configured except by editing the settings configuration file. - local map hud fog of war ------------------------ diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 40c1ae7ff4..5c473bea81 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -160,10 +160,6 @@ sky rtt resolution = 512 256 # Warning: affects explored areas in save files, see documentation. global map cell size = 18 -# Zoom level in pixels for HUD map widget. 64 is one cell, 128 is 1/4 -# cell, 256 is 1/8 cell. See documentation for details. (e.g. 64 to 256). -local map hud widget size = 256 - # Enables Fog of War rendering on the HUD map. Default is Off since with default settings # the map is so small that the fog would not obscure anything, just darken the edges slightly. local map hud fog of war = false From 9acb93ab2995ef362b43d034234a2b15af1e4e2b Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 27 Jul 2023 22:52:51 +0200 Subject: [PATCH 2/2] Use settings values for Map settings --- apps/openmw/mwgui/hud.cpp | 2 +- apps/openmw/mwgui/mapwindow.cpp | 73 +++++++++++++------------- apps/openmw/mwgui/mapwindow.hpp | 7 +-- apps/openmw/mwrender/globalmap.cpp | 22 ++++---- apps/openmw/mwrender/globalmap.hpp | 2 - apps/openmw/mwrender/localmap.cpp | 9 ++-- components/settings/categories/map.hpp | 3 +- 7 files changed, 56 insertions(+), 62 deletions(-) diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 022840ea5e..5cf2fcf10b 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -88,7 +88,7 @@ namespace MWGui HUD::HUD(CustomMarkerCollection& customMarkers, DragAndDrop* dragAndDrop, MWRender::LocalMap* localMapRender) : WindowBase("openmw_hud.layout") - , LocalMapBase(customMarkers, localMapRender, Settings::Manager::getBool("local map hud fog of war", "Map")) + , LocalMapBase(customMarkers, localMapRender) , mHealth(nullptr) , mMagicka(nullptr) , mStamina(nullptr) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 47478d1efc..536e2b5a9f 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -87,14 +87,13 @@ namespace int getLocalViewingDistance() { - if (!Settings::Manager::getBool("allow zooming", "Map")) + if (!Settings::map().mAllowZooming) return Constants::CellGridRadius; if (!Settings::Manager::getBool("distant terrain", "Terrain")) return Constants::CellGridRadius; - const int maxLocalViewingDistance - = std::max(Settings::Manager::getInt("max local viewing distance", "Map"), Constants::CellGridRadius); const int viewingDistanceInCells = Settings::camera().mViewingDistance / Constants::CellSizeInUnits; - return std::clamp(viewingDistanceInCells, Constants::CellGridRadius, maxLocalViewingDistance); + return std::clamp( + viewingDistanceInCells, Constants::CellGridRadius, Settings::map().mMaxLocalViewingDistance.get()); } } @@ -168,8 +167,7 @@ namespace MWGui // ------------------------------------------------------ - LocalMapBase::LocalMapBase( - CustomMarkerCollection& markers, MWRender::LocalMap* localMapRender, bool fogOfWarEnabled) + LocalMapBase::LocalMapBase(CustomMarkerCollection& markers, MWRender::LocalMap* localMapRender) : mLocalMapRender(localMapRender) , mCurX(0) , mCurY(0) @@ -178,8 +176,6 @@ namespace MWGui , mCompass(nullptr) , mChanged(true) , mFogOfWarToggled(true) - , mFogOfWarEnabled(fogOfWarEnabled) - , mMapWidgetSize(0) , mNumCells(1) , mCellDistance(0) , mCustomMarkers(markers) @@ -200,11 +196,12 @@ namespace MWGui { mLocalMap = widget; mCompass = compass; - mMapWidgetSize = std::max(1, Settings::Manager::getInt("local map widget size", "Map")); mCellDistance = cellDistance; mNumCells = mCellDistance * 2 + 1; - mLocalMap->setCanvasSize(mMapWidgetSize * mNumCells, mMapWidgetSize * mNumCells); + const int mapWidgetSize = Settings::map().mLocalMapWidgetSize; + + mLocalMap->setCanvasSize(mapWidgetSize * mNumCells, mapWidgetSize * mNumCells); mCompass->setDepth(Local_CompassLayer); mCompass->setNeedMouseFocus(false); @@ -214,12 +211,12 @@ namespace MWGui for (int my = 0; my < mNumCells; ++my) { MyGUI::ImageBox* map = mLocalMap->createWidget("ImageBox", - MyGUI::IntCoord(mx * mMapWidgetSize, my * mMapWidgetSize, mMapWidgetSize, mMapWidgetSize), + MyGUI::IntCoord(mx * mapWidgetSize, my * mapWidgetSize, mapWidgetSize, mapWidgetSize), MyGUI::Align::Top | MyGUI::Align::Left); map->setDepth(Local_MapLayer); MyGUI::ImageBox* fog = mLocalMap->createWidget("ImageBox", - MyGUI::IntCoord(mx * mMapWidgetSize, my * mMapWidgetSize, mMapWidgetSize, mMapWidgetSize), + MyGUI::IntCoord(mx * mapWidgetSize, my * mapWidgetSize, mapWidgetSize, mapWidgetSize), MyGUI::Align::Top | MyGUI::Align::Left); fog->setDepth(Local_FogLayer); fog->setColour(MyGUI::Colour(0, 0, 0)); @@ -247,7 +244,7 @@ namespace MWGui void LocalMapBase::applyFogOfWar() { - if (!mFogOfWarToggled || !mFogOfWarEnabled) + if (!mFogOfWarToggled || !Settings::map().mLocalMapHudFogOfWar) { for (auto& entry : mMaps) { @@ -464,7 +461,7 @@ namespace MWGui float LocalMapBase::getWidgetSize() const { - return mLocalMapZoom * mMapWidgetSize; + return mLocalMapZoom * Settings::map().mLocalMapWidgetSize; } void LocalMapBase::setPlayerPos(int cellX, int cellY, const float nx, const float ny) @@ -598,7 +595,7 @@ namespace MWGui else entry.mMapTexture = std::make_unique(std::string(), nullptr); } - if (!entry.mFogTexture && mFogOfWarToggled && mFogOfWarEnabled) + if (!entry.mFogTexture && mFogOfWarToggled && Settings::map().mLocalMapHudFogOfWar) { osg::ref_ptr tex = mLocalMapRender->getFogOfWarTexture(entry.mCellX, entry.mCellY); if (tex) @@ -760,12 +757,10 @@ namespace MWGui , mGlobalMap(nullptr) , mGlobalMapImage(nullptr) , mGlobalMapOverlay(nullptr) - , mGlobal(Settings::Manager::getBool("global", "Map")) , mEventBoxGlobal(nullptr) , mEventBoxLocal(nullptr) , mGlobalMapRender(std::make_unique(localMapRender->getRoot(), workQueue)) , mEditNoteDialog() - , mAllowZooming(Settings::Manager::getBool("allow zooming", "Map")) { static bool registered = false; if (!registered) @@ -799,12 +794,18 @@ namespace MWGui getWidget(mButton, "WorldButton"); mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked); - mButton->setCaptionWithReplacing(mGlobal ? "#{sLocal}" : "#{sWorld}"); + + const bool global = Settings::map().mGlobal; + + mButton->setCaptionWithReplacing(global ? "#{sLocal}" : "#{sWorld}"); getWidget(mEventBoxGlobal, "EventBoxGlobal"); mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxGlobal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); - if (mAllowZooming) + + const bool allowZooming = Settings::map().mAllowZooming; + + if (allowZooming) mEventBoxGlobal->eventMouseWheel += MyGUI::newDelegate(this, &MapWindow::onMapZoomed); mEventBoxGlobal->setDepth(Global_ExploreOverlayLayer); @@ -812,13 +813,13 @@ namespace MWGui mEventBoxLocal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxLocal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); mEventBoxLocal->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onMapDoubleClicked); - if (mAllowZooming) + if (allowZooming) mEventBoxLocal->eventMouseWheel += MyGUI::newDelegate(this, &MapWindow::onMapZoomed); LocalMapBase::init(mLocalMap, mPlayerArrowLocal, getLocalViewingDistance()); - mGlobalMap->setVisible(mGlobal); - mLocalMap->setVisible(!mGlobal); + mGlobalMap->setVisible(global); + mLocalMap->setVisible(!global); } void MapWindow::onNoteEditOk() @@ -895,8 +896,7 @@ namespace MWGui void MapWindow::onMapZoomed(MyGUI::Widget* sender, int rel) { - const static int localWidgetSize = Settings::Manager::getInt("local map widget size", "Map"); - + const int localWidgetSize = Settings::map().mLocalMapWidgetSize; const bool zoomOut = rel < 0; const bool zoomIn = !zoomOut; const double speedDiff = zoomOut ? 1.0 / speed : speed; @@ -906,7 +906,7 @@ namespace MWGui / float(localWidgetSize), float(mLocalMap->getWidth()) / localMapSizeInUnits, float(mLocalMap->getHeight()) / localMapSizeInUnits }); - if (mGlobal) + if (Settings::map().mGlobal) { const float currentGlobalZoom = mGlobalMapZoom; const float currentMinGlobalMapZoom @@ -961,11 +961,11 @@ namespace MWGui void MapWindow::zoomOnCursor(float speedDiff) { - auto map = mGlobal ? mGlobalMap : mLocalMap; + auto map = Settings::map().mGlobal ? mGlobalMap : mLocalMap; auto cursor = MyGUI::InputManager::getInstance().getMousePosition() - map->getAbsolutePosition(); auto centerView = map->getViewOffset() - cursor; - mGlobal ? updateGlobalMap() : updateLocalMap(); + Settings::map().mGlobal ? updateGlobalMap() : updateLocalMap(); map->setViewOffset(MyGUI::IntPoint(std::round(centerView.left * speedDiff) + cursor.left, std::round(centerView.top * speedDiff) + cursor.top)); @@ -1053,7 +1053,7 @@ namespace MWGui MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); markerWidget->setDepth(Global_MarkerLayer); markerWidget->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); - if (mAllowZooming) + if (Settings::map().mAllowZooming) markerWidget->eventMouseWheel += MyGUI::newDelegate(this, &MapWindow::onMapZoomed); markerWidget->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); @@ -1177,7 +1177,7 @@ namespace MWGui MyGUI::IntPoint diff = MyGUI::IntPoint(_left, _top) - mLastDragPos; - if (!mGlobal) + if (!Settings::map().mGlobal) { mNeedDoorMarkersUpdate = true; mLocalMap->setViewOffset(mLocalMap->getViewOffset() + diff); @@ -1190,13 +1190,14 @@ namespace MWGui void MapWindow::onWorldButtonClicked(MyGUI::Widget* _sender) { - mGlobal = !mGlobal; - mGlobalMap->setVisible(mGlobal); - mLocalMap->setVisible(!mGlobal); + const bool global = !Settings::map().mGlobal; - Settings::Manager::setBool("global", "Map", mGlobal); + Settings::map().mGlobal.set(global); - mButton->setCaptionWithReplacing(mGlobal ? "#{sLocal}" : "#{sWorld}"); + mGlobalMap->setVisible(global); + mLocalMap->setVisible(!global); + + mButton->setCaptionWithReplacing(global ? "#{sLocal}" : "#{sWorld}"); } void MapWindow::onPinToggled() @@ -1340,7 +1341,7 @@ namespace MWGui marker->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); marker->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); marker->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onCustomMarkerDoubleClicked); - if (mAllowZooming) + if (Settings::map().mAllowZooming) marker->eventMouseWheel += MyGUI::newDelegate(this, &MapWindow::onMapZoomed); } @@ -1348,7 +1349,7 @@ namespace MWGui { marker->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); marker->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); - if (mAllowZooming) + if (Settings::map().mAllowZooming) marker->eventMouseWheel += MyGUI::newDelegate(this, &MapWindow::onMapZoomed); } diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index 937b215375..ea3165ac4b 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -73,7 +73,7 @@ namespace MWGui class LocalMapBase { public: - LocalMapBase(CustomMarkerCollection& markers, MWRender::LocalMap* localMapRender, bool fogOfWarEnabled = true); + LocalMapBase(CustomMarkerCollection& markers, MWRender::LocalMap* localMapRender); virtual ~LocalMapBase(); void init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass, int cellDistance = Constants::CellGridRadius); @@ -125,9 +125,6 @@ namespace MWGui std::string mPrefix; bool mChanged; bool mFogOfWarToggled; - bool mFogOfWarEnabled; - - int mMapWidgetSize; int mNumCells; // for convenience, mCellDistance * 2 + 1 int mCellDistance; @@ -301,7 +298,6 @@ namespace MWGui MyGUI::ImageBox* mPlayerArrowGlobal; MyGUI::Button* mButton; MyGUI::IntPoint mLastDragPos; - bool mGlobal; MyGUI::IntCoord mLastScrollWindowCoordinates; @@ -328,7 +324,6 @@ namespace MWGui EditNoteDialog mEditNoteDialog; ESM::CustomMarker mEditingMarker; - bool mAllowZooming; void onPinToggled() override; void onTitleDoubleClicked() override; diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 8e61c0c4e1..cfd7084965 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -263,8 +263,7 @@ namespace MWRender }; GlobalMap::GlobalMap(osg::Group* root, SceneUtil::WorkQueue* workQueue) - : mCellSize(Settings::map().mGlobalMapCellSize) - , mRoot(root) + : mRoot(root) , mWorkQueue(workQueue) , mWidth(0) , mHeight(0) @@ -304,11 +303,13 @@ namespace MWRender mMaxY = it->getGridY(); } - mWidth = mCellSize * (mMaxX - mMinX + 1); - mHeight = mCellSize * (mMaxY - mMinY + 1); + const int cellSize = Settings::map().mGlobalMapCellSize; + + mWidth = cellSize * (mMaxX - mMinX + 1); + mHeight = cellSize * (mMaxY - mMinY + 1); mWorkItem - = new CreateMapWorkItem(mWidth, mHeight, mMinX, mMinY, mMaxX, mMaxY, mCellSize, esmStore.get()); + = new CreateMapWorkItem(mWidth, mHeight, mMinX, mMinY, mMaxX, mMaxY, cellSize, esmStore.get()); mWorkQueue->addWorkItem(mWorkItem); } @@ -412,14 +413,15 @@ namespace MWRender if (!localMapTexture) return; - int originX = (cellX - mMinX) * mCellSize; - int originY = (cellY - mMinY + 1) - * mCellSize; // +1 because we want the top left corner of the cell, not the bottom left + const int cellSize = Settings::map().mGlobalMapCellSize; + const int originX = (cellX - mMinX) * cellSize; + // +1 because we want the top left corner of the cell, not the bottom left + const int originY = (cellY - mMinY + 1) * cellSize; if (cellX > mMaxX || cellX < mMinX || cellY > mMaxY || cellY < mMinY) return; - requestOverlayTextureUpdate(originX, mHeight - originY, mCellSize, mCellSize, localMapTexture, false, true); + requestOverlayTextureUpdate(originX, mHeight - originY, cellSize, cellSize, localMapTexture, false, true); } void GlobalMap::clear() @@ -520,7 +522,7 @@ namespace MWRender // If cell bounds of the currently loaded content and the loaded savegame do not match, // we need to resize source/dest boxes to accommodate // This means nonexisting cells will be dropped silently - int cellImageSizeDst = mCellSize; + const int cellImageSizeDst = Settings::map().mGlobalMapCellSize; // Completely off-screen? -> no need to blit anything if (bounds.mMaxX < mMinX || bounds.mMaxY < mMinY || bounds.mMinX > mMaxX || bounds.mMinY > mMaxY) diff --git a/apps/openmw/mwrender/globalmap.hpp b/apps/openmw/mwrender/globalmap.hpp index ad5bd38ab1..e0582b20fa 100644 --- a/apps/openmw/mwrender/globalmap.hpp +++ b/apps/openmw/mwrender/globalmap.hpp @@ -86,8 +86,6 @@ namespace MWRender bool clear, bool cpuCopy, float srcLeft = 0.f, float srcTop = 0.f, float srcRight = 1.f, float srcBottom = 1.f); - int mCellSize; - osg::ref_ptr mRoot; typedef std::vector> CameraVector; diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 5f85182f87..a07fa10b09 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include "../mwbase/environment.hpp" @@ -75,16 +75,13 @@ namespace MWRender LocalMap::LocalMap(osg::Group* root) : mRoot(root) - , mMapResolution(Settings::Manager::getInt("local map resolution", "Map")) + , mMapResolution( + Settings::map().mLocalMapResolution * MWBase::Environment::get().getWindowManager()->getScalingFactor()) , mMapWorldSize(Constants::CellSizeInUnits) , mCellDistance(Constants::CellGridRadius) , mAngle(0.f) , mInterior(false) { - // Increase map resolution, if use UI scaling - float uiScale = MWBase::Environment::get().getWindowManager()->getScalingFactor(); - mMapResolution *= uiScale; - SceneUtil::FindByNameVisitor find("Scene Root"); mRoot->accept(find); mSceneRoot = find.mFoundNode; diff --git a/components/settings/categories/map.hpp b/components/settings/categories/map.hpp index af3857b206..bdccd6f205 100644 --- a/components/settings/categories/map.hpp +++ b/components/settings/categories/map.hpp @@ -1,6 +1,7 @@ #ifndef OPENMW_COMPONENTS_SETTINGS_CATEGORIES_MAP_H #define OPENMW_COMPONENTS_SETTINGS_CATEGORIES_MAP_H +#include "components/misc/constants.hpp" #include "components/settings/sanitizerimpl.hpp" #include "components/settings/settingvalue.hpp" @@ -25,7 +26,7 @@ namespace Settings SettingValue mGlobal{ mIndex, "Map", "global" }; SettingValue mAllowZooming{ mIndex, "Map", "allow zooming" }; SettingValue mMaxLocalViewingDistance{ mIndex, "Map", "max local viewing distance", - makeMaxSanitizerInt(1) }; + makeMaxSanitizerInt(Constants::CellGridRadius) }; }; }