mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-18 17:36:45 +00:00
Make the local map cell distance configurable
This commit is contained in:
parent
bd655c20fd
commit
7d647088ab
6 changed files with 46 additions and 32 deletions
|
@ -159,7 +159,7 @@ namespace MWGui
|
||||||
|
|
||||||
getWidget(mCrosshair, "Crosshair");
|
getWidget(mCrosshair, "Crosshair");
|
||||||
|
|
||||||
LocalMapBase::init(mMinimap, mCompass, Settings::Manager::getInt("local map hud widget size", "Map"));
|
LocalMapBase::init(mMinimap, mCompass, Settings::Manager::getInt("local map hud widget size", "Map"), Settings::Manager::getInt("local map cell distance", "Map"));
|
||||||
|
|
||||||
mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked);
|
mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked);
|
||||||
mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver);
|
mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver);
|
||||||
|
|
|
@ -181,20 +181,22 @@ namespace MWGui
|
||||||
mCustomMarkers.eventMarkersChanged -= MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers);
|
mCustomMarkers.eventMarkersChanged -= MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalMapBase::init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass, int mapWidgetSize)
|
void LocalMapBase::init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass, int mapWidgetSize, int cellDistance)
|
||||||
{
|
{
|
||||||
mLocalMap = widget;
|
mLocalMap = widget;
|
||||||
mCompass = compass;
|
mCompass = compass;
|
||||||
mMapWidgetSize = mapWidgetSize;
|
mMapWidgetSize = mapWidgetSize;
|
||||||
|
mCellDistance = cellDistance;
|
||||||
|
mNumCells = cellDistance * 2 + 1;
|
||||||
|
|
||||||
mLocalMap->setCanvasSize(mMapWidgetSize*3, mMapWidgetSize*3);
|
mLocalMap->setCanvasSize(mMapWidgetSize*mNumCells, mMapWidgetSize*mNumCells);
|
||||||
|
|
||||||
mCompass->setDepth(Local_CompassLayer);
|
mCompass->setDepth(Local_CompassLayer);
|
||||||
mCompass->setNeedMouseFocus(false);
|
mCompass->setNeedMouseFocus(false);
|
||||||
|
|
||||||
for (int mx=0; mx<3; ++mx)
|
for (int mx=0; mx<mNumCells; ++mx)
|
||||||
{
|
{
|
||||||
for (int my=0; my<3; ++my)
|
for (int my=0; my<mNumCells; ++my)
|
||||||
{
|
{
|
||||||
MyGUI::ImageBox* map = mLocalMap->createWidget<MyGUI::ImageBox>("ImageBox",
|
MyGUI::ImageBox* map = mLocalMap->createWidget<MyGUI::ImageBox>("ImageBox",
|
||||||
MyGUI::IntCoord(mx*mMapWidgetSize, my*mMapWidgetSize, mMapWidgetSize, mMapWidgetSize),
|
MyGUI::IntCoord(mx*mMapWidgetSize, my*mMapWidgetSize, mMapWidgetSize, mMapWidgetSize),
|
||||||
|
@ -231,13 +233,13 @@ namespace MWGui
|
||||||
void LocalMapBase::applyFogOfWar()
|
void LocalMapBase::applyFogOfWar()
|
||||||
{
|
{
|
||||||
TextureVector fogTextures;
|
TextureVector fogTextures;
|
||||||
for (int mx=0; mx<3; ++mx)
|
for (int mx=0; mx<mNumCells; ++mx)
|
||||||
{
|
{
|
||||||
for (int my=0; my<3; ++my)
|
for (int my=0; my<mNumCells; ++my)
|
||||||
{
|
{
|
||||||
int x = mCurX + (mx-1);
|
int x = mCurX + (mx - mCellDistance);
|
||||||
int y = mCurY + (-1*(my-1));
|
int y = mCurY + (-1*(my - mCellDistance));
|
||||||
MyGUI::ImageBox* fog = mFogWidgets[my + 3*mx];
|
MyGUI::ImageBox* fog = mFogWidgets[my + mNumCells*mx];
|
||||||
|
|
||||||
if (!mFogOfWarToggled || !mFogOfWarEnabled)
|
if (!mFogOfWarToggled || !mFogOfWarEnabled)
|
||||||
{
|
{
|
||||||
|
@ -284,8 +286,8 @@ namespace MWGui
|
||||||
markerPos.cellX = cellX;
|
markerPos.cellX = cellX;
|
||||||
markerPos.cellY = cellY;
|
markerPos.cellY = cellY;
|
||||||
|
|
||||||
widgetPos = MyGUI::IntPoint(static_cast<int>(nX * mMapWidgetSize + (1 + cellDx) * mMapWidgetSize),
|
widgetPos = MyGUI::IntPoint(static_cast<int>(nX * mMapWidgetSize + (mCellDistance + cellDx) * mMapWidgetSize),
|
||||||
static_cast<int>(nY * mMapWidgetSize - (cellDy-1) * mMapWidgetSize));
|
static_cast<int>(nY * mMapWidgetSize + (mCellDistance - cellDy) * mMapWidgetSize));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -297,8 +299,8 @@ namespace MWGui
|
||||||
markerPos.cellY = cellY;
|
markerPos.cellY = cellY;
|
||||||
|
|
||||||
// Image space is -Y up, cells are Y up
|
// Image space is -Y up, cells are Y up
|
||||||
widgetPos = MyGUI::IntPoint(static_cast<int>(nX * mMapWidgetSize + (1 + (cellX - mCurX)) * mMapWidgetSize),
|
widgetPos = MyGUI::IntPoint(static_cast<int>(nX * mMapWidgetSize + (mCellDistance + (cellX - mCurX)) * mMapWidgetSize),
|
||||||
static_cast<int>(nY * mMapWidgetSize + (1-(cellY-mCurY)) * mMapWidgetSize));
|
static_cast<int>(nY * mMapWidgetSize + (mCellDistance - (cellY - mCurY)) * mMapWidgetSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
markerPos.nX = nX;
|
markerPos.nX = nX;
|
||||||
|
@ -312,9 +314,9 @@ namespace MWGui
|
||||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||||
mCustomMarkerWidgets.clear();
|
mCustomMarkerWidgets.clear();
|
||||||
|
|
||||||
for (int dX = -1; dX <= 1; ++dX)
|
for (int dX = -mCellDistance; dX <= mCellDistance; ++dX)
|
||||||
{
|
{
|
||||||
for (int dY =-1; dY <= 1; ++dY)
|
for (int dY =-mCellDistance; dY <= mCellDistance; ++dY)
|
||||||
{
|
{
|
||||||
ESM::CellId cellId;
|
ESM::CellId cellId;
|
||||||
cellId.mPaged = !mInterior;
|
cellId.mPaged = !mInterior;
|
||||||
|
@ -372,14 +374,14 @@ namespace MWGui
|
||||||
|
|
||||||
// Update the map textures
|
// Update the map textures
|
||||||
TextureVector textures;
|
TextureVector textures;
|
||||||
for (int mx=0; mx<3; ++mx)
|
for (int mx=0; mx<mNumCells; ++mx)
|
||||||
{
|
{
|
||||||
for (int my=0; my<3; ++my)
|
for (int my=0; my<mNumCells; ++my)
|
||||||
{
|
{
|
||||||
int mapX = x + (mx-1);
|
int mapX = x + (mx - mCellDistance);
|
||||||
int mapY = y + (-1*(my-1));
|
int mapY = y + (-1*(my - mCellDistance));
|
||||||
|
|
||||||
MyGUI::ImageBox* box = mMapWidgets[my + 3*mx];
|
MyGUI::ImageBox* box = mMapWidgets[my + mNumCells*mx];
|
||||||
|
|
||||||
osg::ref_ptr<osg::Texture2D> texture = mLocalMapRender->getMapTexture(mapX, mapY);
|
osg::ref_ptr<osg::Texture2D> texture = mLocalMapRender->getMapTexture(mapX, mapY);
|
||||||
if (texture)
|
if (texture)
|
||||||
|
@ -406,9 +408,9 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int dX=-1; dX<2; ++dX)
|
for (int dX=-mCellDistance; dX<=mCellDistance; ++dX)
|
||||||
{
|
{
|
||||||
for (int dY=-1; dY<2; ++dY)
|
for (int dY=-mCellDistance; dY<=mCellDistance; ++dY)
|
||||||
{
|
{
|
||||||
MWWorld::CellStore* cell = world->getExterior (mCurX+dX, mCurY+dY);
|
MWWorld::CellStore* cell = world->getExterior (mCurX+dX, mCurY+dY);
|
||||||
world->getDoorMarkers(cell, doors);
|
world->getDoorMarkers(cell, doors);
|
||||||
|
@ -461,9 +463,9 @@ namespace MWGui
|
||||||
cells.insert(cell);
|
cells.insert(cell);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int dX=-1; dX<2; ++dX)
|
for (int dX=-mCellDistance; dX<=mCellDistance; ++dX)
|
||||||
{
|
{
|
||||||
for (int dY=-1; dY<2; ++dY)
|
for (int dY=-mCellDistance; dY<=mCellDistance; ++dY)
|
||||||
{
|
{
|
||||||
const MWWorld::CellStore* gridCell = MWBase::Environment::get().getWorld()->getExterior (cell->getCell()->getGridX()+dX, cell->getCell()->getGridY()+dY);
|
const MWWorld::CellStore* gridCell = MWBase::Environment::get().getWorld()->getExterior (cell->getCell()->getGridX()+dX, cell->getCell()->getGridY()+dY);
|
||||||
cells.insert(gridCell);
|
cells.insert(gridCell);
|
||||||
|
@ -482,7 +484,7 @@ namespace MWGui
|
||||||
|
|
||||||
void LocalMapBase::setPlayerPos(int cellX, int cellY, const float nx, const float ny)
|
void LocalMapBase::setPlayerPos(int cellX, int cellY, const float nx, const float ny)
|
||||||
{
|
{
|
||||||
MyGUI::IntPoint pos(static_cast<int>(mMapWidgetSize + nx*mMapWidgetSize - 16), static_cast<int>(mMapWidgetSize + ny*mMapWidgetSize - 16));
|
MyGUI::IntPoint pos(static_cast<int>(mMapWidgetSize * mCellDistance + nx*mMapWidgetSize - 16), static_cast<int>(mMapWidgetSize * mCellDistance + ny*mMapWidgetSize - 16));
|
||||||
pos.left += (cellX - mCurX) * mMapWidgetSize;
|
pos.left += (cellX - mCurX) * mMapWidgetSize;
|
||||||
pos.top -= (cellY - mCurY) * mMapWidgetSize;
|
pos.top -= (cellY - mCurY) * mMapWidgetSize;
|
||||||
|
|
||||||
|
@ -663,7 +665,8 @@ namespace MWGui
|
||||||
mEventBoxLocal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
|
mEventBoxLocal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
|
||||||
mEventBoxLocal->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onMapDoubleClicked);
|
mEventBoxLocal->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onMapDoubleClicked);
|
||||||
|
|
||||||
LocalMapBase::init(mLocalMap, mPlayerArrowLocal, Settings::Manager::getInt("local map widget size", "Map")); }
|
LocalMapBase::init(mLocalMap, mPlayerArrowLocal, Settings::Manager::getInt("local map widget size", "Map"), Settings::Manager::getInt("local map cell distance", "Map"));
|
||||||
|
}
|
||||||
|
|
||||||
void MapWindow::onNoteEditOk()
|
void MapWindow::onNoteEditOk()
|
||||||
{
|
{
|
||||||
|
@ -707,8 +710,8 @@ namespace MWGui
|
||||||
MyGUI::IntPoint clickedPos = MyGUI::InputManager::getInstance().getMousePosition();
|
MyGUI::IntPoint clickedPos = MyGUI::InputManager::getInstance().getMousePosition();
|
||||||
|
|
||||||
MyGUI::IntPoint widgetPos = clickedPos - mEventBoxLocal->getAbsolutePosition();
|
MyGUI::IntPoint widgetPos = clickedPos - mEventBoxLocal->getAbsolutePosition();
|
||||||
int x = int(widgetPos.left/float(mMapWidgetSize))-1;
|
int x = int(widgetPos.left/float(mMapWidgetSize))-mCellDistance;
|
||||||
int y = (int(widgetPos.top/float(mMapWidgetSize))-1)*-1;
|
int y = (int(widgetPos.top/float(mMapWidgetSize))-mCellDistance)*-1;
|
||||||
float nX = widgetPos.left/float(mMapWidgetSize) - int(widgetPos.left/float(mMapWidgetSize));
|
float nX = widgetPos.left/float(mMapWidgetSize) - int(widgetPos.left/float(mMapWidgetSize));
|
||||||
float nY = widgetPos.top/float(mMapWidgetSize) - int(widgetPos.top/float(mMapWidgetSize));
|
float nY = widgetPos.top/float(mMapWidgetSize) - int(widgetPos.top/float(mMapWidgetSize));
|
||||||
x += mCurX;
|
x += mCurX;
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace MWGui
|
||||||
public:
|
public:
|
||||||
LocalMapBase(CustomMarkerCollection& markers, MWRender::LocalMap* localMapRender, bool fogOfWarEnabled = true);
|
LocalMapBase(CustomMarkerCollection& markers, MWRender::LocalMap* localMapRender, bool fogOfWarEnabled = true);
|
||||||
virtual ~LocalMapBase();
|
virtual ~LocalMapBase();
|
||||||
void init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass, int mapWidgetSize);
|
void init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass, int mapWidgetSize, int cellDistance);
|
||||||
|
|
||||||
void setCellPrefix(const std::string& prefix);
|
void setCellPrefix(const std::string& prefix);
|
||||||
void setActiveCell(const int x, const int y, bool interior=false);
|
void setActiveCell(const int x, const int y, bool interior=false);
|
||||||
|
@ -116,6 +116,9 @@ namespace MWGui
|
||||||
|
|
||||||
int mMapWidgetSize;
|
int mMapWidgetSize;
|
||||||
|
|
||||||
|
int mNumCells; // for convenience, mCellDistance * 2 + 1
|
||||||
|
int mCellDistance;
|
||||||
|
|
||||||
// Stores markers that were placed by a player. May be shared between multiple map views.
|
// Stores markers that were placed by a player. May be shared between multiple map views.
|
||||||
CustomMarkerCollection& mCustomMarkers;
|
CustomMarkerCollection& mCustomMarkers;
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ LocalMap::LocalMap(osgViewer::Viewer* viewer)
|
||||||
: mViewer(viewer)
|
: mViewer(viewer)
|
||||||
, mMapResolution(Settings::Manager::getInt("local map resolution", "Map"))
|
, mMapResolution(Settings::Manager::getInt("local map resolution", "Map"))
|
||||||
, mMapWorldSize(8192.f)
|
, mMapWorldSize(8192.f)
|
||||||
|
, mCellDistance(Settings::Manager::getInt("local map cell distance", "Map"))
|
||||||
, mAngle(0.f)
|
, mAngle(0.f)
|
||||||
, mInterior(false)
|
, mInterior(false)
|
||||||
{
|
{
|
||||||
|
@ -533,9 +534,9 @@ void LocalMap::updatePlayer (const osg::Vec3f& position, const osg::Quat& orient
|
||||||
const float exploreRadiusUV = exploreRadius / sFogOfWarResolution; // explore radius from 0 to 1 (UV space)
|
const float exploreRadiusUV = exploreRadius / sFogOfWarResolution; // explore radius from 0 to 1 (UV space)
|
||||||
|
|
||||||
// change the affected fog of war textures (in a 3x3 grid around the player)
|
// change the affected fog of war textures (in a 3x3 grid around the player)
|
||||||
for (int mx = -1; mx<2; ++mx)
|
for (int mx = -mCellDistance; mx<=mCellDistance; ++mx)
|
||||||
{
|
{
|
||||||
for (int my = -1; my<2; ++my)
|
for (int my = -mCellDistance; my<=mCellDistance; ++my)
|
||||||
{
|
{
|
||||||
// is this texture affected at all?
|
// is this texture affected at all?
|
||||||
bool affected = false;
|
bool affected = false;
|
||||||
|
|
|
@ -143,6 +143,8 @@ namespace MWRender
|
||||||
// size of a map segment (for exteriors, 1 cell)
|
// size of a map segment (for exteriors, 1 cell)
|
||||||
float mMapWorldSize;
|
float mMapWorldSize;
|
||||||
|
|
||||||
|
int mCellDistance;
|
||||||
|
|
||||||
float mAngle;
|
float mAngle;
|
||||||
const osg::Vec2f rotatePoint(const osg::Vec2f& point, const osg::Vec2f& center, const float angle);
|
const osg::Vec2f rotatePoint(const osg::Vec2f& point, const osg::Vec2f& center, const float angle);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,11 @@ local map resolution = 256
|
||||||
# Size of local map in GUI window in pixels. (e.g. 256 to 1024).
|
# Size of local map in GUI window in pixels. (e.g. 256 to 1024).
|
||||||
local map widget size = 512
|
local map widget size = 512
|
||||||
|
|
||||||
|
# Similar to "[Cells] exterior cell load distance", controls
|
||||||
|
# how many cells are rendered on the local map. Values higher than the default
|
||||||
|
# may result in longer loading times.
|
||||||
|
local map cell distance = 1
|
||||||
|
|
||||||
[GUI]
|
[GUI]
|
||||||
|
|
||||||
# Scales GUI window and widget size. (<1.0 is smaller, >1.0 is larger).
|
# Scales GUI window and widget size. (<1.0 is smaller, >1.0 is larger).
|
||||||
|
|
Loading…
Reference in a new issue