From 9c3e1f48f06df360c00d6e15d1626a7044eeb336 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 23 Mar 2012 09:00:00 +0100 Subject: [PATCH] player arrow --- apps/openmw/mwgui/layouts.hpp | 10 +++++++++- apps/openmw/mwrender/localmap.cpp | 2 +- files/mygui/core.skin | 3 +++ files/mygui/openmw_map_window_layout.xml | 12 ++++++------ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index 20ee1a80c7..1f0bdd0fa4 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -73,6 +73,7 @@ namespace MWGui setCellName("No Cell Loaded"); getWidget(mMap, "Map"); + getWidget(mPlayerArrow, "Compass"); MyGUI::Button* button; getWidget(button, "WorldButton"); @@ -137,10 +138,16 @@ namespace MWGui { if (mVisible) return; MyGUI::IntSize size = mMap->getCanvasSize(); - MyGUI::IntPoint middle = MyGUI::IntPoint(x*size.width,y*size.height); + MyGUI::IntPoint middle = MyGUI::IntPoint((1/3.f + x/3.f)*size.width,(1/3.f + y/3.f)*size.height); MyGUI::IntCoord viewsize = mMap->getCoord(); MyGUI::IntPoint pos(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top); mMap->setViewOffset(pos); + + mPlayerArrow->setPosition(MyGUI::IntPoint(x*512-16, y*512-16)); + + MyGUI::ISubWidget* main = mPlayerArrow->getSubWidgetMain(); + MyGUI::RotatingSkin* rotatingSubskin = main->castType<MyGUI::RotatingSkin>(); + rotatingSubskin->setAngle(3.141 * 0.5); } void onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) @@ -167,6 +174,7 @@ namespace MWGui private: std::string mPrefix; MyGUI::ScrollView* mMap; + MyGUI::ImageBox* mPlayerArrow; MyGUI::IntPoint mLastDragPos; int mCurX, mCurY; bool mInterior; diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index b7deb6f7fc..e7a7c9f052 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -275,7 +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); + mEnvironment->mWindowManager->setPlayerPos(u, v); // explore radius (squared) const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution; diff --git a/files/mygui/core.skin b/files/mygui/core.skin index 83dcd4b9f8..28838c2340 100644 --- a/files/mygui/core.skin +++ b/files/mygui/core.skin @@ -14,4 +14,7 @@ <BasisSkin type="MainSkin" offset = "0 0 16 16"/> </Skin> + <Skin name = "RotatingSkin" size = "16 16"> + <BasisSkin type="RotatingSkin" offset="0 0 16 16" align="Stretch"/> + </Skin> </MyGUI> diff --git a/files/mygui/openmw_map_window_layout.xml b/files/mygui/openmw_map_window_layout.xml index 90ad70edb6..0ec99f4503 100644 --- a/files/mygui/openmw_map_window_layout.xml +++ b/files/mygui/openmw_map_window_layout.xml @@ -4,7 +4,7 @@ <Widget type="Window" skin="MW_Window" layer="Windows" position="0 0 300 300" name="_Main"> <Widget type="ScrollView" skin="MW_MapView" position="0 0 284 264" align="ALIGN_STRETCH" name="Map"> <Property key="CanvasSize" value="1536 1536"/> - + <!-- 3x3 maps, 1024x1024 each, but we will downsample to 512 to antialias them --> <Widget type="ImageBox" skin="ImageBox" position="0 0 512 512" align="ALIGN_TOP ALIGN_LEFT" name="Map_0_0"> <Widget type="ImageBox" skin="ImageBox" position="0 0 512 512" align="ALIGN_TOP ALIGN_LEFT" name="Map_0_0_fog"/> @@ -23,7 +23,10 @@ </Widget> <Widget type="ImageBox" skin="ImageBox" position="512 512 512 512" align="ALIGN_TOP ALIGN_LEFT" name="Map_1_1"> - <Widget type="ImageBox" skin="ImageBox" position="0 0 512 512" align="ALIGN_TOP ALIGN_LEFT" name="Map_1_1_fog"/> + <Widget type="ImageBox" skin="ImageBox" position="0 0 512 512" align="ALIGN_TOP ALIGN_LEFT" name="Map_1_1_fog"> + <!-- Player arrow --> + <Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="ALIGN_TOP ALIGN_LEFT" name="Compass"/> + </Widget> </Widget> <Widget type="ImageBox" skin="ImageBox" position="1024 512 512 512" align="ALIGN_TOP ALIGN_LEFT" name="Map_2_1"> @@ -42,11 +45,8 @@ <Widget type="ImageBox" skin="ImageBox" position="0 0 512 512" align="ALIGN_TOP ALIGN_LEFT" name="Map_2_2_fog"/> </Widget> - <!-- positioned and rotated in code --> - <Widget type="ImageBox" skin="ImageBox" position="0 0 32 32" align="ALIGN_TOP ALIGN_LEFT" name="Compass"/> - <Widget type="Button" skin="" position="0 0 1536 1536" name="EventBox" align="ALIGN_STRETCH"/> - </Widget> + </Widget> <Widget type="Button" skin="MW_Button" position="213 233 61 22" align="ALIGN_BOTTOM ALIGN_RIGHT" name="WorldButton"/> </Widget> </MyGUI>