diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index 6c66bb51fd..e55feceb24 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -84,6 +84,15 @@ namespace MWGui eventbox->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); } + void setVisible(bool b) + { + mMainWidget->setVisible(b); + if (b) + mVisible = true; + else + mVisible = false; + } + void setCellName(const std::string& cellName) { static_cast(mMainWidget)->setCaption(cellName); @@ -110,8 +119,13 @@ namespace MWGui if (MyGUI::RenderManager::getInstance().getTexture(image) != 0) setImage(name, image); + else + setImage(name, "black.png"); + if (MyGUI::RenderManager::getInstance().getTexture(image+"_fog") != 0) setImage(name+"_fog", image+"_fog"); + else + setImage(name+"_fog", "black.png"); } } mInterior = interior; @@ -119,6 +133,17 @@ namespace MWGui mCurY = y; } + void setPlayerPos(const float x, const float y) + { + if (mVisible) return; + MyGUI::IntSize size = mMap->getCanvasSize(); + MyGUI::IntPoint middle = MyGUI::IntPoint(x*size.width,y*size.height); + MyGUI::IntCoord viewsize = mMap->getCoord(); + MyGUI::IntPoint pos(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top); + std::cout << pos.left << " top " << pos.top << std::endl; + mMap->setViewOffset(pos); + } + void onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { if (_id!=MyGUI::MouseButton::Left) return; @@ -146,6 +171,7 @@ namespace MWGui MyGUI::IntPoint mLastDragPos; int mCurX, mCurY; bool mInterior; + bool mVisible; }; class MainMenu : public OEngine::GUI::Layout diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index bb04543a03..c7ee1438ed 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -424,3 +424,8 @@ void WindowManager::setInteriorMapTexture(const int x, const int y) { map->setActiveCell(x,y, true); } + +void WindowManager::setPlayerPos(const float x, const float y) +{ + map->setPlayerPos(x,y); +} diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 2b141acf5f..922009e4d4 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -154,6 +154,7 @@ namespace MWGui void updateSkillArea(); ///< update display of skills, factions, birth sign, reputation and bounty void changeCell(MWWorld::Ptr::CellStore* cell); ///< change the active cell + void setPlayerPos(const float x, const float y); ///< set player position in map space void setInteriorMapTexture(const int x, const int y); ///< set the index of the map texture that should be used (for interiors) diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index e08559d261..b7deb6f7fc 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -263,6 +263,7 @@ void LocalMap::setPlayerPosition (const Ogre::Vector3& position) u = std::abs((pos.x - (sSize*x))/sSize); v = 1-std::abs((pos.y + (sSize*y))/sSize); texName = "Cell_"+coordStr(x,y); + } else { @@ -274,6 +275,7 @@ void LocalMap::setPlayerPosition (const Ogre::Vector3& position) texName = mInteriorName + "_" + coordStr(x,y); } + mEnvironment->mWindowManager->setPlayerPos(1/3.f + u/3.f, 1/3.f + v/3.f); // explore radius (squared) const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution;