mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
Make local map widget size configurable
This commit is contained in:
parent
a47de06492
commit
5d7dcafa53
6 changed files with 26 additions and 25 deletions
|
@ -162,7 +162,7 @@ namespace MWGui
|
|||
getWidget(mTriangleCounter, "TriangleCounter");
|
||||
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->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver);
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
namespace
|
||||
{
|
||||
|
||||
const int widgetSize = 512;
|
||||
|
||||
const int cellSize = 8192;
|
||||
|
||||
enum LocalMapWidgetDepth
|
||||
|
@ -164,6 +162,7 @@ namespace MWGui
|
|||
, mCompass(NULL)
|
||||
, mMarkerUpdateTimer(0.0f)
|
||||
, mCustomMarkers(markers)
|
||||
, mMapWidgetSize(0)
|
||||
{
|
||||
mCustomMarkers.eventMarkersChanged += MyGUI::newDelegate(this, &LocalMapBase::updateCustomMarkers);
|
||||
}
|
||||
|
@ -173,26 +172,28 @@ namespace MWGui
|
|||
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;
|
||||
mCompass = compass;
|
||||
mMapWidgetSize = mapWidgetSize;
|
||||
|
||||
mLocalMap->setCanvasSize(mMapWidgetSize*3, mMapWidgetSize*3);
|
||||
|
||||
mCompass->setDepth(Local_CompassLayer);
|
||||
mCompass->setNeedMouseFocus(false);
|
||||
|
||||
// create 3x3 map widgets, 512x512 each, holding a 1024x1024 texture each
|
||||
for (int mx=0; mx<3; ++mx)
|
||||
{
|
||||
for (int my=0; my<3; ++my)
|
||||
{
|
||||
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);
|
||||
map->setDepth(Local_MapLayer);
|
||||
|
||||
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);
|
||||
fog->setDepth(Local_FogLayer);
|
||||
|
||||
|
@ -258,8 +259,8 @@ namespace MWGui
|
|||
markerPos.cellX = cellX;
|
||||
markerPos.cellY = cellY;
|
||||
|
||||
widgetPos = MyGUI::IntPoint(nX * widgetSize + (1+cellDx) * widgetSize,
|
||||
nY * widgetSize - (cellDy-1) * widgetSize);
|
||||
widgetPos = MyGUI::IntPoint(nX * mMapWidgetSize + (1+cellDx) * mMapWidgetSize,
|
||||
nY * mMapWidgetSize - (cellDy-1) * mMapWidgetSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -271,8 +272,8 @@ namespace MWGui
|
|||
markerPos.cellY = cellY;
|
||||
|
||||
// Image space is -Y up, cells are Y up
|
||||
widgetPos = MyGUI::IntPoint(nX * widgetSize + (1+(cellX-mCurX)) * widgetSize,
|
||||
nY * widgetSize + (1-(cellY-mCurY)) * widgetSize);
|
||||
widgetPos = MyGUI::IntPoint(nX * mMapWidgetSize + (1+(cellX-mCurX)) * mMapWidgetSize,
|
||||
nY * mMapWidgetSize + (1-(cellY-mCurY)) * mMapWidgetSize);
|
||||
}
|
||||
|
||||
markerPos.nX = nX;
|
||||
|
@ -425,9 +426,9 @@ namespace MWGui
|
|||
|
||||
void LocalMapBase::setPlayerPos(int cellX, int cellY, const float nx, const float ny)
|
||||
{
|
||||
MyGUI::IntPoint pos(widgetSize+nx*widgetSize-16, widgetSize+ny*widgetSize-16);
|
||||
pos.left += (cellX - mCurX) * widgetSize;
|
||||
pos.top -= (cellY - mCurY) * widgetSize;
|
||||
MyGUI::IntPoint pos(mMapWidgetSize+nx*mMapWidgetSize-16, mMapWidgetSize+ny*mMapWidgetSize-16);
|
||||
pos.left += (cellX - mCurX) * mMapWidgetSize;
|
||||
pos.top -= (cellY - mCurY) * mMapWidgetSize;
|
||||
|
||||
if (pos != mCompass->getPosition())
|
||||
{
|
||||
|
@ -612,8 +613,7 @@ namespace MWGui
|
|||
mEventBoxLocal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
|
||||
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()
|
||||
{
|
||||
|
@ -657,10 +657,10 @@ namespace MWGui
|
|||
MyGUI::IntPoint clickedPos = MyGUI::InputManager::getInstance().getMousePosition();
|
||||
|
||||
MyGUI::IntPoint widgetPos = clickedPos - mEventBoxLocal->getAbsolutePosition();
|
||||
int x = int(widgetPos.left/float(widgetSize))-1;
|
||||
int y = (int(widgetPos.top/float(widgetSize))-1)*-1;
|
||||
float nX = widgetPos.left/float(widgetSize) - int(widgetPos.left/float(widgetSize));
|
||||
float nY = widgetPos.top/float(widgetSize) - int(widgetPos.top/float(widgetSize));
|
||||
int x = int(widgetPos.left/float(mMapWidgetSize))-1;
|
||||
int y = (int(widgetPos.top/float(mMapWidgetSize))-1)*-1;
|
||||
float nX = widgetPos.left/float(mMapWidgetSize) - int(widgetPos.left/float(mMapWidgetSize));
|
||||
float nY = widgetPos.top/float(mMapWidgetSize) - int(widgetPos.top/float(mMapWidgetSize));
|
||||
x += mCurX;
|
||||
y += mCurY;
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace MWGui
|
|||
public:
|
||||
LocalMapBase(CustomMarkerCollection& markers);
|
||||
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 setActiveCell(const int x, const int y, bool interior=false);
|
||||
|
@ -99,6 +99,8 @@ namespace MWGui
|
|||
bool mChanged;
|
||||
bool mFogOfWar;
|
||||
|
||||
int mMapWidgetSize;
|
||||
|
||||
// Stores markers that were placed by a player. May be shared between multiple map views.
|
||||
CustomMarkerCollection& mCustomMarkers;
|
||||
|
||||
|
|
|
@ -108,8 +108,6 @@
|
|||
<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">
|
||||
<Property key="CanvasSize" value="1536 1536"/>
|
||||
|
||||
<Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="Bottom Left" name="Compass">
|
||||
<Property key="ImageTexture" value="textures\compass.dds"/>
|
||||
</Widget>
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
<!-- Local map -->
|
||||
<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">
|
||||
<Property key="ImageTexture" value="textures\compass.dds"/>
|
||||
</Widget>
|
||||
|
|
|
@ -117,6 +117,9 @@ global map cell size = 18
|
|||
|
||||
local map resolution = 256
|
||||
|
||||
local map widget size = 512
|
||||
local map hud widget size = 512
|
||||
|
||||
[Viewing distance]
|
||||
# Limit the rendering distance of small objects
|
||||
limit small object distance = false
|
||||
|
|
Loading…
Reference in a new issue