Change global map cell size from 24 to 18 and make it configurable

deque
scrawl 10 years ago
parent 764c6287e1
commit 4f0fc79ea4

@ -675,10 +675,12 @@ namespace MWGui
float worldX, worldY; float worldX, worldY;
mGlobalMapRender->cellTopLeftCornerToImageSpace (x, y, worldX, worldY); mGlobalMapRender->cellTopLeftCornerToImageSpace (x, y, worldX, worldY);
int markerSize = 12;
int offset = mGlobalMapRender->getCellSize()/2 - markerSize/2;
MyGUI::IntCoord widgetCoord( MyGUI::IntCoord widgetCoord(
worldX * mGlobalMapRender->getWidth()+6, worldX * mGlobalMapRender->getWidth()+offset,
worldY * mGlobalMapRender->getHeight()+6, worldY * mGlobalMapRender->getHeight()+offset,
12, 12); markerSize, markerSize);
static int _counter=0; static int _counter=0;
MyGUI::Button* markerWidget = mGlobalMapOverlay->createWidget<MyGUI::Button>("ButtonImage", MyGUI::Button* markerWidget = mGlobalMapOverlay->createWidget<MyGUI::Button>("ButtonImage",

@ -29,6 +29,7 @@ namespace MWRender
, mWidth(0) , mWidth(0)
, mHeight(0) , mHeight(0)
{ {
mCellSize = Settings::Manager::getInt("global map cell size", "Map");
} }
GlobalMap::~GlobalMap() GlobalMap::~GlobalMap()
@ -57,9 +58,8 @@ namespace MWRender
mMaxY = it->getGridY(); mMaxY = it->getGridY();
} }
int cellSize = 24; mWidth = mCellSize*(mMaxX-mMinX+1);
mWidth = cellSize*(mMaxX-mMinX+1); mHeight = mCellSize*(mMaxY-mMinY+1);
mHeight = cellSize*(mMaxY-mMinY+1);
loadingListener->loadingOn(); loadingListener->loadingOn();
loadingListener->setLabel("Creating map"); loadingListener->setLabel("Creating map");
@ -90,16 +90,16 @@ namespace MWRender
land->loadData(mask); land->loadData(mask);
} }
for (int cellY=0; cellY<cellSize; ++cellY) for (int cellY=0; cellY<mCellSize; ++cellY)
{ {
for (int cellX=0; cellX<cellSize; ++cellX) for (int cellX=0; cellX<mCellSize; ++cellX)
{ {
int vertexX = float(cellX)/float(cellSize) * ESM::Land::LAND_SIZE; int vertexX = float(cellX)/float(mCellSize) * ESM::Land::LAND_SIZE;
int vertexY = float(cellY)/float(cellSize) * ESM::Land::LAND_SIZE; int vertexY = float(cellY)/float(mCellSize) * ESM::Land::LAND_SIZE;
int texelX = (x-mMinX) * cellSize + cellX; int texelX = (x-mMinX) * mCellSize + cellX;
int texelY = (mHeight-1) - ((y-mMinY) * cellSize + cellY); int texelY = (mHeight-1) - ((y-mMinY) * mCellSize + cellY);
unsigned char r,g,b; unsigned char r,g,b;
@ -197,11 +197,9 @@ namespace MWRender
void GlobalMap::exploreCell(int cellX, int cellY) void GlobalMap::exploreCell(int cellX, int cellY)
{ {
const int size = 24; float originX = (cellX - mMinX) * mCellSize;
float originX = (cellX - mMinX) * size;
// NB y + 1, because we want the top left corner, not bottom left where the origin of the cell is // NB y + 1, because we want the top left corner, not bottom left where the origin of the cell is
float originY = mHeight - (cellY+1 - mMinY) * size; float originY = mHeight - (cellY+1 - mMinY) * mCellSize;
if (cellX > mMaxX || cellX < mMinX || cellY > mMaxY || cellY < mMinY) if (cellX > mMaxX || cellX < mMinX || cellY > mMaxY || cellY < mMinY)
return; return;
@ -213,17 +211,17 @@ namespace MWRender
{ {
mOverlayTexture->load(); mOverlayTexture->load();
mOverlayTexture->getBuffer()->blit(localMapTexture->getBuffer(), Ogre::Image::Box(0,0,512,512), mOverlayTexture->getBuffer()->blit(localMapTexture->getBuffer(), Ogre::Image::Box(0,0,512,512),
Ogre::Image::Box(originX,originY,originX+size,originY+size)); Ogre::Image::Box(originX,originY,originX+mCellSize,originY+mCellSize));
Ogre::Image backup; Ogre::Image backup;
std::vector<Ogre::uchar> data; std::vector<Ogre::uchar> data;
data.resize(size*size*4, 0); data.resize(mCellSize*mCellSize*4, 0);
backup.loadDynamicImage(&data[0], size, size, Ogre::PF_A8B8G8R8); backup.loadDynamicImage(&data[0], mCellSize, mCellSize, Ogre::PF_A8B8G8R8);
localMapTexture->getBuffer()->blitToMemory(Ogre::Image::Box(0,0,512,512), backup.getPixelBox()); localMapTexture->getBuffer()->blitToMemory(Ogre::Image::Box(0,0,512,512), backup.getPixelBox());
for (int x=0; x<size; ++x) for (int x=0; x<mCellSize; ++x)
for (int y=0; y<size; ++y) for (int y=0; y<mCellSize; ++y)
{ {
assert (originX+x < mOverlayImage.getWidth()); assert (originX+x < mOverlayImage.getWidth());
assert (originY+y < mOverlayImage.getHeight()); assert (originY+y < mOverlayImage.getHeight());
@ -292,7 +290,7 @@ namespace MWRender
// If cell bounds of the currently loaded content and the loaded savegame do not match, // If cell bounds of the currently loaded content and the loaded savegame do not match,
// we need to resize source/dest boxes to accommodate // we need to resize source/dest boxes to accommodate
// This means nonexisting cells will be dropped silently // This means nonexisting cells will be dropped silently
int cellImageSizeDst = 24; int cellImageSizeDst = mCellSize;
// Completely off-screen? -> no need to blit anything // Completely off-screen? -> no need to blit anything
if (bounds.mMaxX < mMinX if (bounds.mMaxX < mMinX

@ -26,8 +26,10 @@ namespace MWRender
void render(Loading::Listener* loadingListener); void render(Loading::Listener* loadingListener);
int getWidth() { return mWidth; } int getWidth() const { return mWidth; }
int getHeight() { return mHeight; } int getHeight() const { return mHeight; }
int getCellSize() const { return mCellSize; }
void worldPosToImageSpace(float x, float z, float& imageX, float& imageY); void worldPosToImageSpace(float x, float z, float& imageX, float& imageY);
@ -46,6 +48,8 @@ namespace MWRender
private: private:
std::string mCacheDir; std::string mCacheDir;
int mCellSize;
std::vector< std::pair<int,int> > mExploredCells; std::vector< std::pair<int,int> > mExploredCells;
Ogre::TexturePtr mOverlayTexture; Ogre::TexturePtr mOverlayTexture;

@ -108,6 +108,10 @@ num lights = 8
# Use static geometry for static objects. Improves rendering speed. # Use static geometry for static objects. Improves rendering speed.
use static geometry = true use static geometry = true
[Map]
# Adjusts the scale of the global map
global map cell size = 18
[Viewing distance] [Viewing distance]
# Limit the rendering distance of small objects # Limit the rendering distance of small objects
limit small object distance = false limit small object distance = false

Loading…
Cancel
Save