From 770b0f2106e36caa74f1e4bc52bf8c714ca0b548 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 23 Mar 2012 10:25:55 +0100 Subject: [PATCH] gui changes --- apps/openmw/mwgui/layouts.hpp | 45 +++++++++++++++--------- files/mygui/openmw_list.skin.xml | 4 +-- files/mygui/openmw_map_window_layout.xml | 13 +++++-- files/mygui/openmw_map_window_skin.xml | 6 ++-- 4 files changed, 45 insertions(+), 23 deletions(-) diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index 1f0bdd0fa..49b956f0a 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -63,7 +63,7 @@ namespace MWGui { public: MapWindow() - : Layout("openmw_map_window_layout.xml") + : Layout("openmw_map_window_layout.xml"), mGlobal(false) { setCoord(500,0,320,300); setText("WorldButton", "World"); @@ -72,12 +72,12 @@ namespace MWGui // Obviously you should override this later on setCellName("No Cell Loaded"); - getWidget(mMap, "Map"); + getWidget(mLocalMap, "LocalMap"); + getWidget(mGlobalMap, "GlobalMap"); getWidget(mPlayerArrow, "Compass"); - MyGUI::Button* button; - getWidget(button, "WorldButton"); - button->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked); + getWidget(mButton, "WorldButton"); + mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked); MyGUI::Button* eventbox; getWidget(eventbox, "EventBox"); @@ -136,49 +136,62 @@ namespace MWGui void setPlayerPos(const float x, const float y) { - if (mVisible) return; - MyGUI::IntSize size = mMap->getCanvasSize(); + if (mGlobal || mVisible) return; + MyGUI::IntSize size = mLocalMap->getCanvasSize(); 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::IntCoord viewsize = mLocalMap->getCoord(); MyGUI::IntPoint pos(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top); - mMap->setViewOffset(pos); + mLocalMap->setViewOffset(pos); mPlayerArrow->setPosition(MyGUI::IntPoint(x*512-16, y*512-16)); MyGUI::ISubWidget* main = mPlayerArrow->getSubWidgetMain(); MyGUI::RotatingSkin* rotatingSubskin = main->castType(); - rotatingSubskin->setAngle(3.141 * 0.5); + rotatingSubskin->setCenter(MyGUI::IntPoint(16,16)); + rotatingSubskin->setAngle(3.141); } void onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { if (_id!=MyGUI::MouseButton::Left) return; - mLastDragPos = MyGUI::IntPoint(_left, _top); + if (!mGlobal) + mLastDragPos = MyGUI::IntPoint(_left, _top); } void onMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { if (_id!=MyGUI::MouseButton::Left) return; - MyGUI::IntPoint diff = MyGUI::IntPoint(_left, _top) - mLastDragPos; - mMap->setViewOffset( mMap->getViewOffset() + diff ); + if (!mGlobal) + { + MyGUI::IntPoint diff = MyGUI::IntPoint(_left, _top) - mLastDragPos; + mLocalMap->setViewOffset( mLocalMap->getViewOffset() + diff ); - mLastDragPos = MyGUI::IntPoint(_left, _top); + mLastDragPos = MyGUI::IntPoint(_left, _top); + } } void onWorldButtonClicked(MyGUI::Widget* _sender) { - /// \todo + mGlobal = !mGlobal; + mGlobalMap->setVisible(mGlobal); + mLocalMap->setVisible(!mGlobal); + + mButton->setCaption( mGlobal ? "Local" : "World" ); } private: std::string mPrefix; - MyGUI::ScrollView* mMap; + MyGUI::ScrollView* mLocalMap; + MyGUI::ScrollView* mGlobalMap; MyGUI::ImageBox* mPlayerArrow; + MyGUI::Button* mButton; MyGUI::IntPoint mLastDragPos; int mCurX, mCurY; bool mInterior; bool mVisible; + + bool mGlobal; }; class MainMenu : public OEngine::GUI::Layout diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index c3b97c752..98390367c 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -197,7 +197,7 @@ - + @@ -233,7 +233,7 @@ - + diff --git a/files/mygui/openmw_map_window_layout.xml b/files/mygui/openmw_map_window_layout.xml index 0ec99f450..f5c2c9991 100644 --- a/files/mygui/openmw_map_window_layout.xml +++ b/files/mygui/openmw_map_window_layout.xml @@ -2,7 +2,13 @@ - + + + + + + + @@ -46,7 +52,10 @@ - + + + + diff --git a/files/mygui/openmw_map_window_skin.xml b/files/mygui/openmw_map_window_skin.xml index 452177464..fbb7af7ae 100644 --- a/files/mygui/openmw_map_window_skin.xml +++ b/files/mygui/openmw_map_window_skin.xml @@ -2,10 +2,10 @@ - + - - + +