mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Global compass arrow rotates regardless of indoor or outdoor presence
This commit is contained in:
parent
70ee899691
commit
35571bb108
@ -754,12 +754,14 @@ namespace MWGui
|
||||
|
||||
void MapWindow::globalMapUpdatePlayer ()
|
||||
{
|
||||
Ogre::Quaternion orient = MWBase::Environment::get().getWorld ()->getPlayerPtr().getRefData ().getBaseNode ()->_getDerivedOrientation ();
|
||||
Ogre::Vector2 dir (orient.yAxis ().x, orient.yAxis().y);
|
||||
float globalPlayerArrowAngle = std::atan2(dir.x, dir.y);
|
||||
|
||||
// For interiors, position is set by WindowManager via setGlobalMapPlayerPosition
|
||||
if (MWBase::Environment::get().getWorld ()->isCellExterior ())
|
||||
{
|
||||
Ogre::Vector3 pos = MWBase::Environment::get().getWorld ()->getPlayerPtr().getRefData ().getBaseNode ()->_getDerivedPosition ();
|
||||
Ogre::Quaternion orient = MWBase::Environment::get().getWorld ()->getPlayerPtr().getRefData ().getBaseNode ()->_getDerivedOrientation ();
|
||||
Ogre::Vector2 dir (orient.yAxis ().x, orient.yAxis().y);
|
||||
|
||||
float worldX, worldY;
|
||||
mGlobalMapRender->worldPosToImageSpace (pos.x, pos.y, worldX, worldY);
|
||||
@ -768,17 +770,19 @@ namespace MWGui
|
||||
|
||||
mPlayerArrowGlobal->setPosition(MyGUI::IntPoint(worldX - 16, worldY - 16));
|
||||
|
||||
MyGUI::ISubWidget* main = mPlayerArrowGlobal->getSubWidgetMain();
|
||||
MyGUI::RotatingSkin* rotatingSubskin = main->castType<MyGUI::RotatingSkin>();
|
||||
rotatingSubskin->setCenter(MyGUI::IntPoint(16,16));
|
||||
float angle = std::atan2(dir.x, dir.y);
|
||||
rotatingSubskin->setAngle(angle);
|
||||
|
||||
// set the view offset so that player is in the center
|
||||
MyGUI::IntSize viewsize = mGlobalMap->getSize();
|
||||
MyGUI::IntPoint viewoffs(0.5*viewsize.width - worldX, 0.5*viewsize.height - worldY);
|
||||
mGlobalMap->setViewOffset(viewoffs);
|
||||
}
|
||||
else
|
||||
globalPlayerArrowAngle -= M_PI/2; // If we're indoors, apparently the angle is +90 degrees off.
|
||||
|
||||
// Always rotate the global map compass
|
||||
MyGUI::ISubWidget* main = mPlayerArrowGlobal->getSubWidgetMain();
|
||||
MyGUI::RotatingSkin* rotatingSubskin = main->castType<MyGUI::RotatingSkin>();
|
||||
rotatingSubskin->setCenter(MyGUI::IntPoint(16,16));
|
||||
rotatingSubskin->setAngle(globalPlayerArrowAngle);
|
||||
}
|
||||
|
||||
void MapWindow::notifyPlayerUpdate ()
|
||||
|
Loading…
x
Reference in New Issue
Block a user