diff --git a/apps/openmw/mwgui/map_window.cpp b/apps/openmw/mwgui/map_window.cpp index b2b8538ba..824e72bd8 100644 --- a/apps/openmw/mwgui/map_window.cpp +++ b/apps/openmw/mwgui/map_window.cpp @@ -4,10 +4,12 @@ #include #include +#include #include "../mwbase/windowmanager.hpp" #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" +#include "../mwworld/player.hpp" using namespace MWGui; @@ -256,7 +258,8 @@ MapWindow::MapWindow(MWBase::WindowManager& parWindowManager) : getWidget(mLocalMap, "LocalMap"); getWidget(mGlobalMap, "GlobalMap"); getWidget(mGlobalMapImage, "GlobalMapImage"); - getWidget(mPlayerArrow, "Compass"); + getWidget(mPlayerArrowLocal, "CompassLocal"); + getWidget(mPlayerArrowGlobal, "CompassGlobal"); mGlobalMap->setVisible (false); @@ -264,12 +267,14 @@ MapWindow::MapWindow(MWBase::WindowManager& parWindowManager) : mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked); mButton->setCaptionWithReplacing("#{sWorld}"); - MyGUI::Button* eventbox; - getWidget(eventbox, "EventBox"); - eventbox->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); - eventbox->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); + getWidget(mEventBoxGlobal, "EventBoxGlobal"); + mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); + mEventBoxGlobal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); + getWidget(mEventBoxLocal, "EventBoxLocal"); + mEventBoxLocal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); + mEventBoxLocal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); - LocalMapBase::init(mLocalMap, mPlayerArrow, this); + LocalMapBase::init(mLocalMap, mPlayerArrowLocal, this); } void MapWindow::setCellName(const std::string& cellName) @@ -277,6 +282,35 @@ void MapWindow::setCellName(const std::string& cellName) setTitle(cellName); } +void MapWindow::addVisitedLocation(const std::string& name, int x, int y) +{ + const int cellSize = 24; + + Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().getByName("GlobalMap.png"); + + MyGUI::IntCoord widgetCoord( + (x+30)*cellSize+6, + (tex->getHeight()-1) - (y+30)*cellSize+6, + 12, 12); + + + static int _counter=0; + MyGUI::Button* markerWidget = mGlobalMapImage->createWidget("ButtonImage", + widgetCoord, MyGUI::Align::Default, "Marker" + boost::lexical_cast(_counter)); + markerWidget->setImageResource("DoorMarker"); + markerWidget->setUserString("ToolTipType", "Layout"); + markerWidget->setUserString("ToolTipLayout", "TextToolTip"); + markerWidget->setUserString("Caption_Text", name); + ++_counter; + + markerWidget = mEventBoxGlobal->createWidget("", + widgetCoord, MyGUI::Align::Default); + markerWidget->setNeedMouseFocus (true); + markerWidget->setUserString("ToolTipType", "Layout"); + markerWidget->setUserString("ToolTipLayout", "TextToolTip"); + markerWidget->setUserString("Caption_Text", name); +} + void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { if (_id!=MyGUI::MouseButton::Left) return; @@ -320,4 +354,27 @@ void MapWindow::open() Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().getByName("GlobalMap.png"); mGlobalMap->setCanvasSize (tex->getWidth(), tex->getHeight()); mGlobalMapImage->setSize(tex->getWidth(), tex->getHeight()); + + for (unsigned int i=0; igetChildCount (); ++i) + { + if (mGlobalMapImage->getChildAt (i)->getName().substr(0,6) == "Marker") + mGlobalMapImage->getChildAt (i)->castType()->setImageResource("DoorMarker"); + } + + 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().z); + + float worldX = ((pos.x / 8192.f-0.5) / 30.f+1)/2.f; + float worldY = ((pos.z / 8192.f+1.5) / 30.f+1)/2.f; + + mPlayerArrowGlobal->setPosition(MyGUI::IntPoint(tex->getWidth() * worldX - 16, tex->getHeight() * worldY - 16)); + + MyGUI::ISubWidget* main = mPlayerArrowGlobal->getSubWidgetMain(); + MyGUI::RotatingSkin* rotatingSubskin = main->castType(); + rotatingSubskin->setCenter(MyGUI::IntPoint(16,16)); + float angle = std::atan2(dir.x, dir.y); + rotatingSubskin->setAngle(angle); + + mPlayerArrowGlobal->setImageTexture ("textures\\compass.dds"); } diff --git a/apps/openmw/mwgui/map_window.hpp b/apps/openmw/mwgui/map_window.hpp index abb6a0653..e9c473a29 100644 --- a/apps/openmw/mwgui/map_window.hpp +++ b/apps/openmw/mwgui/map_window.hpp @@ -62,6 +62,8 @@ namespace MWGui void setCellName(const std::string& cellName); + void addVisitedLocation(const std::string& name, int x, int y); // adds the marker to the global map + virtual void open(); private: @@ -71,11 +73,18 @@ namespace MWGui MyGUI::ScrollView* mGlobalMap; MyGUI::ImageBox* mGlobalMapImage; - MyGUI::ImageBox* mPlayerArrow; + MyGUI::ImageBox* mPlayerArrowLocal; + MyGUI::ImageBox* mPlayerArrowGlobal; MyGUI::Button* mButton; MyGUI::IntPoint mLastDragPos; bool mGlobal; + MyGUI::Button* mEventBoxGlobal; + MyGUI::Button* mEventBoxLocal; + + int mGlobalMapSizeX; + int mGlobalMapSizeY; + protected: virtual void onPinToggled(); }; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 0241cc734..728243d5f 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -555,7 +555,10 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) { std::string name; if (cell->cell->name != "") + { name = cell->cell->name; + mMap->addVisitedLocation (name, cell->cell->getGridX (), cell->cell->getGridY ()); + } else { const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->region); diff --git a/files/mygui/openmw_map_window.layout b/files/mygui/openmw_map_window.layout index 2b9b43906..20cfbbd6e 100644 --- a/files/mygui/openmw_map_window.layout +++ b/files/mygui/openmw_map_window.layout @@ -7,10 +7,11 @@ - + + @@ -19,9 +20,14 @@ + + + + + + -