mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-09 21:44:54 +00:00
player arrow & markers
This commit is contained in:
parent
e8bba2b833
commit
e5e3d829d0
@ -4,10 +4,12 @@
|
|||||||
|
|
||||||
#include <OgreVector2.h>
|
#include <OgreVector2.h>
|
||||||
#include <OgreTextureManager.h>
|
#include <OgreTextureManager.h>
|
||||||
|
#include <OgreSceneNode.h>
|
||||||
|
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
@ -256,7 +258,8 @@ MapWindow::MapWindow(MWBase::WindowManager& parWindowManager) :
|
|||||||
getWidget(mLocalMap, "LocalMap");
|
getWidget(mLocalMap, "LocalMap");
|
||||||
getWidget(mGlobalMap, "GlobalMap");
|
getWidget(mGlobalMap, "GlobalMap");
|
||||||
getWidget(mGlobalMapImage, "GlobalMapImage");
|
getWidget(mGlobalMapImage, "GlobalMapImage");
|
||||||
getWidget(mPlayerArrow, "Compass");
|
getWidget(mPlayerArrowLocal, "CompassLocal");
|
||||||
|
getWidget(mPlayerArrowGlobal, "CompassGlobal");
|
||||||
|
|
||||||
mGlobalMap->setVisible (false);
|
mGlobalMap->setVisible (false);
|
||||||
|
|
||||||
@ -264,12 +267,14 @@ MapWindow::MapWindow(MWBase::WindowManager& parWindowManager) :
|
|||||||
mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked);
|
mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked);
|
||||||
mButton->setCaptionWithReplacing("#{sWorld}");
|
mButton->setCaptionWithReplacing("#{sWorld}");
|
||||||
|
|
||||||
MyGUI::Button* eventbox;
|
getWidget(mEventBoxGlobal, "EventBoxGlobal");
|
||||||
getWidget(eventbox, "EventBox");
|
mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag);
|
||||||
eventbox->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag);
|
mEventBoxGlobal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
|
||||||
eventbox->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)
|
void MapWindow::setCellName(const std::string& cellName)
|
||||||
@ -277,6 +282,35 @@ void MapWindow::setCellName(const std::string& cellName)
|
|||||||
setTitle(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)
|
void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||||
{
|
{
|
||||||
if (_id!=MyGUI::MouseButton::Left) return;
|
if (_id!=MyGUI::MouseButton::Left) return;
|
||||||
@ -320,4 +354,27 @@ void MapWindow::open()
|
|||||||
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().getByName("GlobalMap.png");
|
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().getByName("GlobalMap.png");
|
||||||
mGlobalMap->setCanvasSize (tex->getWidth(), tex->getHeight());
|
mGlobalMap->setCanvasSize (tex->getWidth(), tex->getHeight());
|
||||||
mGlobalMapImage->setSize(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");
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,8 @@ namespace MWGui
|
|||||||
|
|
||||||
void setCellName(const std::string& cellName);
|
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();
|
virtual void open();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -71,11 +73,18 @@ namespace MWGui
|
|||||||
|
|
||||||
MyGUI::ScrollView* mGlobalMap;
|
MyGUI::ScrollView* mGlobalMap;
|
||||||
MyGUI::ImageBox* mGlobalMapImage;
|
MyGUI::ImageBox* mGlobalMapImage;
|
||||||
MyGUI::ImageBox* mPlayerArrow;
|
MyGUI::ImageBox* mPlayerArrowLocal;
|
||||||
|
MyGUI::ImageBox* mPlayerArrowGlobal;
|
||||||
MyGUI::Button* mButton;
|
MyGUI::Button* mButton;
|
||||||
MyGUI::IntPoint mLastDragPos;
|
MyGUI::IntPoint mLastDragPos;
|
||||||
bool mGlobal;
|
bool mGlobal;
|
||||||
|
|
||||||
|
MyGUI::Button* mEventBoxGlobal;
|
||||||
|
MyGUI::Button* mEventBoxLocal;
|
||||||
|
|
||||||
|
int mGlobalMapSizeX;
|
||||||
|
int mGlobalMapSizeY;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onPinToggled();
|
virtual void onPinToggled();
|
||||||
};
|
};
|
||||||
|
@ -555,7 +555,10 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
|
|||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
if (cell->cell->name != "")
|
if (cell->cell->name != "")
|
||||||
|
{
|
||||||
name = cell->cell->name;
|
name = cell->cell->name;
|
||||||
|
mMap->addVisitedLocation (name, cell->cell->getGridX (), cell->cell->getGridY ());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->region);
|
const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->region);
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
<Widget type="ScrollView" skin="MW_MapView" position="0 0 284 264" align="ALIGN_STRETCH" name="LocalMap">
|
<Widget type="ScrollView" skin="MW_MapView" position="0 0 284 264" align="ALIGN_STRETCH" name="LocalMap">
|
||||||
<Property key="CanvasSize" value="1536 1536"/>
|
<Property key="CanvasSize" value="1536 1536"/>
|
||||||
|
|
||||||
<Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="ALIGN_TOP ALIGN_LEFT" name="Compass">
|
<Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="ALIGN_TOP ALIGN_LEFT" name="CompassLocal">
|
||||||
<Property key="ImageTexture" value="textures\compass.dds"/>
|
<Property key="ImageTexture" value="textures\compass.dds"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
|
<Widget type="Button" skin="" position_real="0 0 1 1" name="EventBoxLocal" align="ALIGN_STRETCH"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<!-- Global map -->
|
<!-- Global map -->
|
||||||
@ -19,9 +20,14 @@
|
|||||||
|
|
||||||
<Widget type="ImageBox" skin="ImageBox" position_real="0 0 1 1" align="Stretch" name="GlobalMapImage">
|
<Widget type="ImageBox" skin="ImageBox" position_real="0 0 1 1" align="Stretch" name="GlobalMapImage">
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
|
<Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="ALIGN_TOP ALIGN_LEFT" name="CompassGlobal">
|
||||||
|
<Property key="ImageTexture" value="textures\compass.dds"/>
|
||||||
|
</Widget>
|
||||||
|
|
||||||
|
<Widget type="Button" skin="" position_real="0 0 1 1" name="EventBoxGlobal" align="ALIGN_STRETCH"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="Button" skin="" position="0 0 300 300" name="EventBox" align="ALIGN_STRETCH"/>
|
|
||||||
|
|
||||||
<!-- World button -->
|
<!-- World button -->
|
||||||
<Widget type="AutoSizedButton" skin="MW_Button" position="213 233 61 22" align="ALIGN_BOTTOM ALIGN_RIGHT" name="WorldButton">
|
<Widget type="AutoSizedButton" skin="MW_Button" position="213 233 61 22" align="ALIGN_BOTTOM ALIGN_RIGHT" name="WorldButton">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user