1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-03 09:39:40 +00:00

Merge branch 'settings_values_map' into 'master'

Use settings values for Map settings (#6876)

See merge request OpenMW/openmw!3284
This commit is contained in:
psi29a 2023-08-06 16:14:09 +00:00
commit fadfffe22c
9 changed files with 56 additions and 87 deletions

View file

@ -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)

View file

@ -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<MyGUI::ImageBox>("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<MyGUI::ImageBox>("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<osgMyGUI::OSGTexture>(std::string(), nullptr);
}
if (!entry.mFogTexture && mFogOfWarToggled && mFogOfWarEnabled)
if (!entry.mFogTexture && mFogOfWarToggled && Settings::map().mLocalMapHudFogOfWar)
{
osg::ref_ptr<osg::Texture2D> 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<MWRender::GlobalMap>(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);
}

View file

@ -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;

View file

@ -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<ESM::Land>());
= new CreateMapWorkItem(mWidth, mHeight, mMinX, mMinY, mMaxX, mMaxY, cellSize, esmStore.get<ESM::Land>());
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)

View file

@ -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<osg::Group> mRoot;
typedef std::vector<osg::ref_ptr<osg::Camera>> CameraVector;

View file

@ -22,7 +22,7 @@
#include <components/sceneutil/rtt.hpp>
#include <components/sceneutil/shadow.hpp>
#include <components/sceneutil/visitor.hpp>
#include <components/settings/settings.hpp>
#include <components/settings/values.hpp>
#include <components/stereo/multiview.hpp>
#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;

View file

@ -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"
@ -19,14 +20,13 @@ namespace Settings
using WithIndex::WithIndex;
SettingValue<int> mGlobalMapCellSize{ mIndex, "Map", "global map cell size", makeClampSanitizerInt(1, 50) };
SettingValue<int> mLocalMapHudWidgetSize{ mIndex, "Map", "local map hud widget size", makeMaxSanitizerInt(1) };
SettingValue<bool> mLocalMapHudFogOfWar{ mIndex, "Map", "local map hud fog of war" };
SettingValue<int> mLocalMapResolution{ mIndex, "Map", "local map resolution", makeMaxSanitizerInt(1) };
SettingValue<int> mLocalMapWidgetSize{ mIndex, "Map", "local map widget size", makeMaxSanitizerInt(1) };
SettingValue<bool> mGlobal{ mIndex, "Map", "global" };
SettingValue<bool> mAllowZooming{ mIndex, "Map", "allow zooming" };
SettingValue<int> mMaxLocalViewingDistance{ mIndex, "Map", "max local viewing distance",
makeMaxSanitizerInt(1) };
makeMaxSanitizerInt(Constants::CellGridRadius) };
};
}

View file

@ -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
------------------------

View file

@ -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