forked from mirror/openmw-tes3mp
Closes #566: In interior cells, update global map position marker using the first exterior teleport door
This commit is contained in:
parent
be1938ee90
commit
3604b9d171
6 changed files with 58 additions and 13 deletions
|
@ -430,6 +430,8 @@ namespace MWBase
|
|||
|
||||
// Are we in an exterior or pseudo-exterior cell and it's night?
|
||||
virtual bool isDark() const = 0;
|
||||
|
||||
virtual bool findInteriorPositionInWorldSpace(MWWorld::CellStore* cell, Ogre::Vector3& result) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -396,20 +396,18 @@ namespace MWGui
|
|||
|
||||
void MapWindow::globalMapUpdatePlayer ()
|
||||
{
|
||||
Ogre::Vector3 pos = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer().getRefData ().getBaseNode ()->_getDerivedPosition ();
|
||||
Ogre::Quaternion orient = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer().getRefData ().getBaseNode ()->_getDerivedOrientation ();
|
||||
Ogre::Vector2 dir (orient.yAxis ().x, orient.yAxis().y);
|
||||
|
||||
float worldX, worldY;
|
||||
mGlobalMapRender->worldPosToImageSpace (pos.x, pos.y, worldX, worldY);
|
||||
worldX *= mGlobalMapRender->getWidth();
|
||||
worldY *= mGlobalMapRender->getHeight();
|
||||
|
||||
|
||||
// for interiors, we have no choice other than using the last position & direction.
|
||||
/// \todo save this last position in the savegame?
|
||||
// For interiors, position is set by WindowManager via setGlobalMapPlayerPosition
|
||||
if (MWBase::Environment::get().getWorld ()->isCellExterior ())
|
||||
{
|
||||
Ogre::Vector3 pos = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer().getRefData ().getBaseNode ()->_getDerivedPosition ();
|
||||
Ogre::Quaternion orient = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer().getRefData ().getBaseNode ()->_getDerivedOrientation ();
|
||||
Ogre::Vector2 dir (orient.yAxis ().x, orient.yAxis().y);
|
||||
|
||||
float worldX, worldY;
|
||||
mGlobalMapRender->worldPosToImageSpace (pos.x, pos.y, worldX, worldY);
|
||||
worldX *= mGlobalMapRender->getWidth();
|
||||
worldY *= mGlobalMapRender->getHeight();
|
||||
|
||||
mPlayerArrowGlobal->setPosition(MyGUI::IntPoint(worldX - 16, worldY - 16));
|
||||
|
||||
MyGUI::ISubWidget* main = mPlayerArrowGlobal->getSubWidgetMain();
|
||||
|
@ -444,4 +442,19 @@ namespace MWGui
|
|||
"#{sWorld}");
|
||||
}
|
||||
|
||||
void MapWindow::setGlobalMapPlayerPosition(float worldX, float worldY)
|
||||
{
|
||||
float x, y;
|
||||
mGlobalMapRender->worldPosToImageSpace (worldX, worldY, x, y);
|
||||
x *= mGlobalMapRender->getWidth();
|
||||
y *= mGlobalMapRender->getHeight();
|
||||
|
||||
mPlayerArrowGlobal->setPosition(MyGUI::IntPoint(x - 16, y - 16));
|
||||
|
||||
// set the view offset so that player is in the center
|
||||
MyGUI::IntSize viewsize = mGlobalMap->getSize();
|
||||
MyGUI::IntPoint viewoffs(0.5*viewsize.width - x, 0.5*viewsize.height - y);
|
||||
mGlobalMap->setViewOffset(viewoffs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,6 +81,8 @@ namespace MWGui
|
|||
void addVisitedLocation(const std::string& name, int x, int y); // adds the marker to the global map
|
||||
void cellExplored(int x, int y);
|
||||
|
||||
void setGlobalMapPlayerPosition (float worldX, float worldY);
|
||||
|
||||
virtual void open();
|
||||
|
||||
private:
|
||||
|
|
|
@ -774,6 +774,11 @@ namespace MWGui
|
|||
mHud->setCellName( cell->mCell->mName );
|
||||
mMap->setCellPrefix( cell->mCell->mName );
|
||||
mHud->setCellPrefix( cell->mCell->mName );
|
||||
|
||||
Ogre::Vector3 worldPos;
|
||||
if (MWBase::Environment::get().getWorld()->findInteriorPositionInWorldSpace(cell, worldPos))
|
||||
mMap->setGlobalMapPlayerPosition(worldPos.x, worldPos.y);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2288,6 +2288,27 @@ namespace MWWorld
|
|||
|
||||
bool World::isDark() const
|
||||
{
|
||||
return mWeatherManager->isDark();
|
||||
return mWeatherManager->isDark();
|
||||
}
|
||||
|
||||
bool World::findInteriorPositionInWorldSpace(MWWorld::CellStore* cell, Ogre::Vector3& result)
|
||||
{
|
||||
MWWorld::CellRefList<ESM::Door>& doors = cell->mDoors;
|
||||
CellRefList<ESM::Door>::List& refList = doors.mList;
|
||||
|
||||
// Check if any door in the cell leads to an exterior directly
|
||||
for (CellRefList<ESM::Door>::List::iterator it = refList.begin(); it != refList.end(); ++it)
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Door>& ref = *it;
|
||||
if (ref.mRef.mTeleport && ref.mRef.mDestCell.empty())
|
||||
{
|
||||
ESM::Position pos = ref.mRef.mDoorDest;
|
||||
result = Ogre::Vector3(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// No luck :(
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -518,6 +518,8 @@ namespace MWWorld
|
|||
virtual void breakInvisibility (const MWWorld::Ptr& actor);
|
||||
// Are we in an exterior or pseudo-exterior cell and it's night?
|
||||
virtual bool isDark() const;
|
||||
|
||||
virtual bool findInteriorPositionInWorldSpace(MWWorld::CellStore* cell, Ogre::Vector3& result);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue