|
|
|
@ -4,10 +4,12 @@
|
|
|
|
|
|
|
|
|
|
#include <OgreVector2.h>
|
|
|
|
|
#include <OgreTextureManager.h>
|
|
|
|
|
#include <OgreSceneNode.h>
|
|
|
|
|
|
|
|
|
|
#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<MyGUI::Button>("ButtonImage",
|
|
|
|
|
widgetCoord, MyGUI::Align::Default, "Marker" + boost::lexical_cast<std::string>(_counter));
|
|
|
|
|
markerWidget->setImageResource("DoorMarker");
|
|
|
|
|
markerWidget->setUserString("ToolTipType", "Layout");
|
|
|
|
|
markerWidget->setUserString("ToolTipLayout", "TextToolTip");
|
|
|
|
|
markerWidget->setUserString("Caption_Text", name);
|
|
|
|
|
++_counter;
|
|
|
|
|
|
|
|
|
|
markerWidget = mEventBoxGlobal->createWidget<MyGUI::Button>("",
|
|
|
|
|
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; i<mGlobalMapImage->getChildCount (); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (mGlobalMapImage->getChildAt (i)->getName().substr(0,6) == "Marker")
|
|
|
|
|
mGlobalMapImage->getChildAt (i)->castType<MyGUI::Button>()->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<MyGUI::RotatingSkin>();
|
|
|
|
|
rotatingSubskin->setCenter(MyGUI::IntPoint(16,16));
|
|
|
|
|
float angle = std::atan2(dir.x, dir.y);
|
|
|
|
|
rotatingSubskin->setAngle(angle);
|
|
|
|
|
|
|
|
|
|
mPlayerArrowGlobal->setImageTexture ("textures\\compass.dds");
|
|
|
|
|
}
|
|
|
|
|