Make local map widget size configurable

This commit is contained in:
scrawl 2014-12-23 02:33:14 +01:00
parent a47de06492
commit 5d7dcafa53
6 changed files with 26 additions and 25 deletions

View file

@ -162,7 +162,7 @@ namespace MWGui
getWidget(mTriangleCounter, "TriangleCounter"); getWidget(mTriangleCounter, "TriangleCounter");
getWidget(mBatchCounter, "BatchCounter"); getWidget(mBatchCounter, "BatchCounter");
LocalMapBase::init(mMinimap, mCompass); LocalMapBase::init(mMinimap, mCompass, Settings::Manager::getInt("local map hud widget size", "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);

View file

@ -22,8 +22,6 @@
namespace namespace
{ {
const int widgetSize = 512;
const int cellSize = 8192; const int cellSize = 8192;
enum LocalMapWidgetDepth enum LocalMapWidgetDepth
@ -164,6 +162,7 @@ namespace MWGui
, mCompass(NULL) , mCompass(NULL)
, mMarkerUpdateTimer(0.0f) , mMarkerUpdateTimer(0.0f)
, mCustomMarkers(markers) , mCustomMarkers(markers)
, mMapWidgetSize(0)
{ {
mCustomMarkers.eventMarkersChanged += MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers); mCustomMarkers.eventMarkersChanged += MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers);
} }
@ -173,26 +172,28 @@ 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) void LocalMapBase::init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass, int mapWidgetSize)
{ {
mLocalMap = widget; mLocalMap = widget;
mCompass = compass; mCompass = compass;
mMapWidgetSize = mapWidgetSize;
mLocalMap->setCanvasSize(mMapWidgetSize*3, mMapWidgetSize*3);
mCompass->setDepth(Local_CompassLayer); mCompass->setDepth(Local_CompassLayer);
mCompass->setNeedMouseFocus(false); mCompass->setNeedMouseFocus(false);
// create 3x3 map widgets, 512x512 each, holding a 1024x1024 texture each
for (int mx=0; mx<3; ++mx) for (int mx=0; mx<3; ++mx)
{ {
for (int my=0; my<3; ++my) for (int my=0; my<3; ++my)
{ {
MyGUI::ImageBox* map = mLocalMap->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::ImageBox* map = mLocalMap->createWidget<MyGUI::ImageBox>("ImageBox",
MyGUI::IntCoord(mx*widgetSize, my*widgetSize, widgetSize, widgetSize), MyGUI::IntCoord(mx*mMapWidgetSize, my*mMapWidgetSize, mMapWidgetSize, mMapWidgetSize),
MyGUI::Align::Top | MyGUI::Align::Left); MyGUI::Align::Top | MyGUI::Align::Left);
map->setDepth(Local_MapLayer); map->setDepth(Local_MapLayer);
MyGUI::ImageBox* fog = mLocalMap->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::ImageBox* fog = mLocalMap->createWidget<MyGUI::ImageBox>("ImageBox",
MyGUI::IntCoord(mx*widgetSize, my*widgetSize, widgetSize, widgetSize), MyGUI::IntCoord(mx*mMapWidgetSize, my*mMapWidgetSize, mMapWidgetSize, mMapWidgetSize),
MyGUI::Align::Top | MyGUI::Align::Left); MyGUI::Align::Top | MyGUI::Align::Left);
fog->setDepth(Local_FogLayer); fog->setDepth(Local_FogLayer);
@ -258,8 +259,8 @@ namespace MWGui
markerPos.cellX = cellX; markerPos.cellX = cellX;
markerPos.cellY = cellY; markerPos.cellY = cellY;
widgetPos = MyGUI::IntPoint(nX * widgetSize + (1+cellDx) * widgetSize, widgetPos = MyGUI::IntPoint(nX * mMapWidgetSize + (1+cellDx) * mMapWidgetSize,
nY * widgetSize - (cellDy-1) * widgetSize); nY * mMapWidgetSize - (cellDy-1) * mMapWidgetSize);
} }
else else
{ {
@ -271,8 +272,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(nX * widgetSize + (1+(cellX-mCurX)) * widgetSize, widgetPos = MyGUI::IntPoint(nX * mMapWidgetSize + (1+(cellX-mCurX)) * mMapWidgetSize,
nY * widgetSize + (1-(cellY-mCurY)) * widgetSize); nY * mMapWidgetSize + (1-(cellY-mCurY)) * mMapWidgetSize);
} }
markerPos.nX = nX; markerPos.nX = nX;
@ -425,9 +426,9 @@ 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(widgetSize+nx*widgetSize-16, widgetSize+ny*widgetSize-16); MyGUI::IntPoint pos(mMapWidgetSize+nx*mMapWidgetSize-16, mMapWidgetSize+ny*mMapWidgetSize-16);
pos.left += (cellX - mCurX) * widgetSize; pos.left += (cellX - mCurX) * mMapWidgetSize;
pos.top -= (cellY - mCurY) * widgetSize; pos.top -= (cellY - mCurY) * mMapWidgetSize;
if (pos != mCompass->getPosition()) if (pos != mCompass->getPosition())
{ {
@ -612,8 +613,7 @@ 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); LocalMapBase::init(mLocalMap, mPlayerArrowLocal, Settings::Manager::getInt("local map widget size", "Map")); }
}
void MapWindow::onNoteEditOk() void MapWindow::onNoteEditOk()
{ {
@ -657,10 +657,10 @@ 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(widgetSize))-1; int x = int(widgetPos.left/float(mMapWidgetSize))-1;
int y = (int(widgetPos.top/float(widgetSize))-1)*-1; int y = (int(widgetPos.top/float(mMapWidgetSize))-1)*-1;
float nX = widgetPos.left/float(widgetSize) - int(widgetPos.left/float(widgetSize)); float nX = widgetPos.left/float(mMapWidgetSize) - int(widgetPos.left/float(mMapWidgetSize));
float nY = widgetPos.top/float(widgetSize) - int(widgetPos.top/float(widgetSize)); float nY = widgetPos.top/float(mMapWidgetSize) - int(widgetPos.top/float(mMapWidgetSize));
x += mCurX; x += mCurX;
y += mCurY; y += mCurY;

View file

@ -70,7 +70,7 @@ namespace MWGui
public: public:
LocalMapBase(CustomMarkerCollection& markers); LocalMapBase(CustomMarkerCollection& markers);
virtual ~LocalMapBase(); virtual ~LocalMapBase();
void init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass); void init(MyGUI::ScrollView* widget, MyGUI::ImageBox* compass, int mapWidgetSize);
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);
@ -99,6 +99,8 @@ namespace MWGui
bool mChanged; bool mChanged;
bool mFogOfWar; bool mFogOfWar;
int mMapWidgetSize;
// 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;

View file

@ -108,8 +108,6 @@
<Widget type="Widget" skin="HUD_Box" position="0 0 65 65" align="Center"> <Widget type="Widget" skin="HUD_Box" position="0 0 65 65" align="Center">
<Widget type="ScrollView" skin="MW_MapView" position="2 2 61 61" align="Left Bottom" name="MiniMap"> <Widget type="ScrollView" skin="MW_MapView" position="2 2 61 61" align="Left Bottom" name="MiniMap">
<Property key="CanvasSize" value="1536 1536"/>
<Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="Bottom Left" name="Compass"> <Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="Bottom Left" name="Compass">
<Property key="ImageTexture" value="textures\compass.dds"/> <Property key="ImageTexture" value="textures\compass.dds"/>
</Widget> </Widget>

View file

@ -6,8 +6,6 @@
<!-- Local map --> <!-- Local map -->
<Widget type="ScrollView" skin="MW_MapView" position="0 0 284 264" align="Stretch" name="LocalMap"> <Widget type="ScrollView" skin="MW_MapView" position="0 0 284 264" align="Stretch" name="LocalMap">
<Property key="CanvasSize" value="1536 1536"/>
<Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="Top Left" name="CompassLocal"> <Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="Top Left" name="CompassLocal">
<Property key="ImageTexture" value="textures\compass.dds"/> <Property key="ImageTexture" value="textures\compass.dds"/>
</Widget> </Widget>

View file

@ -117,6 +117,9 @@ global map cell size = 18
local map resolution = 256 local map resolution = 256
local map widget size = 512
local map hud widget size = 512
[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