From 97df7c9b22ed635e66aec8c3296c89d170f1d102 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 13:40:10 +0200 Subject: [PATCH] Get rid of markers.png and use original MW texture, cleanup --- apps/openmw/mwgui/mapwindow.cpp | 111 +++++++++++++++++++++++-------- files/mygui/CMakeLists.txt | 1 - files/mygui/markers.png | Bin 245 -> 0 bytes files/mygui/openmw_resources.xml | 34 ++-------- 4 files changed, 87 insertions(+), 59 deletions(-) delete mode 100644 files/mygui/markers.png diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 43ea6f7f9..2fba92372 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -26,15 +26,55 @@ namespace const int cellSize = 8192; - enum WidgetDepth + enum LocalMapWidgetDepth { - CompassLayer = 0, - MarkerAboveFogLayer = 1, - FogLayer = 2, - MarkerLayer = 3, - MapLayer = 4 + Local_CompassLayer = 0, + Local_MarkerAboveFogLayer = 1, + Local_FogLayer = 2, + Local_MarkerLayer = 3, + Local_MapLayer = 4 }; + enum GlobalMapWidgetDepth + { + Global_CompassLayer = 0, + Global_MarkerLayer = 1, + Global_ExploreOverlayLayer = 2, + Global_MapLayer = 3 + }; + + + /// @brief A widget that changes its color when hovered. + class MarkerWidget: public MyGUI::Widget + { + MYGUI_RTTI_DERIVED(MarkerWidget) + + public: + void setNormalColour(const MyGUI::Colour& colour) + { + mNormalColour = colour; + setColour(colour); + } + + void setHoverColour(const MyGUI::Colour& colour) + { + mHoverColour = colour; + } + + private: + MyGUI::Colour mNormalColour; + MyGUI::Colour mHoverColour; + + void onMouseLostFocus(MyGUI::Widget* _new) + { + setColour(mNormalColour); + } + + void onMouseSetFocus(MyGUI::Widget* _old) + { + setColour(mHoverColour); + } + }; } namespace MWGui @@ -140,7 +180,7 @@ namespace MWGui mLocalMap = widget; mCompass = compass; - mCompass->setDepth(CompassLayer); + mCompass->setDepth(Local_CompassLayer); mCompass->setNeedMouseFocus(false); // create 3x3 map widgets, 512x512 each, holding a 1024x1024 texture each @@ -151,12 +191,12 @@ namespace MWGui MyGUI::ImageBox* map = mLocalMap->createWidget("ImageBox", MyGUI::IntCoord(mx*widgetSize, my*widgetSize, widgetSize, widgetSize), MyGUI::Align::Top | MyGUI::Align::Left); - map->setDepth(MapLayer); + map->setDepth(Local_MapLayer); MyGUI::ImageBox* fog = mLocalMap->createWidget("ImageBox", MyGUI::IntCoord(mx*widgetSize, my*widgetSize, widgetSize, widgetSize), MyGUI::Align::Top | MyGUI::Align::Left); - fog->setDepth(FogLayer); + fog->setDepth(Local_FogLayer); map->setNeedMouseFocus(false); fog->setNeedMouseFocus(false); @@ -273,15 +313,17 @@ namespace MWGui MyGUI::IntCoord widgetCoord(widgetPos.left - 4, widgetPos.top - 4, 8, 8); - MyGUI::Button* markerWidget = mLocalMap->createWidget("ButtonImage", + MarkerWidget* markerWidget = mLocalMap->createWidget("MarkerButton", widgetCoord, MyGUI::Align::Default); - markerWidget->setDepth(MarkerAboveFogLayer); - markerWidget->setImageResource("DoorMarker"); + markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", MyGUI::TextIterator::toTagsString(marker.mNote)); markerWidget->setColour(MyGUI::Colour(1.0,0.3,0.3)); + markerWidget->setNormalColour(MyGUI::Colour(1.0,0.3,0.3)); + markerWidget->setHoverColour(MyGUI::Colour(1.0,0.5,0.5)); markerWidget->setUserData(marker); + markerWidget->setNeedMouseFocus(true); markerWidget->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &LocalMapBase::onCustomMarkerDoubleClicked); mCustomMarkerWidgets.push_back(markerWidget); } @@ -357,10 +399,12 @@ namespace MWGui widgetPos.top - 4, 8, 8); ++counter; - MyGUI::Button* markerWidget = mLocalMap->createWidget("ButtonImage", + MarkerWidget* markerWidget = mLocalMap->createWidget("MarkerButton", widgetCoord, MyGUI::Align::Default); - markerWidget->setDepth(MarkerLayer); - markerWidget->setImageResource("DoorMarker"); + markerWidget->setNormalColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); + markerWidget->setHoverColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal_over}"))); + markerWidget->setDepth(Local_MarkerLayer); + markerWidget->setNeedMouseFocus(true); markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", marker.name); @@ -458,7 +502,7 @@ namespace MWGui ++counter; MyGUI::ImageBox* markerWidget = mLocalMap->createWidget("ImageBox", widgetCoord, MyGUI::Align::Default); - markerWidget->setDepth(MarkerAboveFogLayer); + markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setImageTexture(markerTexture); markerWidget->setUserString("IsMarker", "true"); markerWidget->setUserData(markerPos); @@ -503,7 +547,7 @@ namespace MWGui 8, 8); MyGUI::ImageBox* markerWidget = mLocalMap->createWidget("ImageBox", widgetCoord, MyGUI::Align::Default); - markerWidget->setDepth(MarkerAboveFogLayer); + markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setImageTexture("textures\\menu_map_smark.dds"); markerWidget->setUserString("IsMarker", "true"); markerWidget->setUserData(markerPos); @@ -523,7 +567,18 @@ namespace MWGui , mGlobalMap(0) , mGlobalMapRender(0) , mEditNoteDialog() + , mEventBoxGlobal(NULL) + , mEventBoxLocal(NULL) + , mGlobalMapImage(NULL) + , mGlobalMapOverlay(NULL) { + static bool registered = false; + if (!registered) + { + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + registered = true; + } + mEditNoteDialog.setVisible(false); mEditNoteDialog.eventOkClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditOk); mEditNoteDialog.eventDeleteClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditDelete); @@ -537,6 +592,11 @@ namespace MWGui getWidget(mPlayerArrowLocal, "CompassLocal"); getWidget(mPlayerArrowGlobal, "CompassGlobal"); + mPlayerArrowGlobal->setDepth(Global_CompassLayer); + mPlayerArrowGlobal->setNeedMouseFocus(false); + mGlobalMapImage->setDepth(Global_MapLayer); + mGlobalMapOverlay->setDepth(Global_ExploreOverlayLayer); + mLastScrollWindowCoordinates = mLocalMap->getCoord(); mLocalMap->eventChangeCoord += MyGUI::newDelegate(this, &MapWindow::onChangeScrollWindowCoord); @@ -549,6 +609,8 @@ namespace MWGui getWidget(mEventBoxGlobal, "EventBoxGlobal"); mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxGlobal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); + mEventBoxGlobal->setDepth(Global_ExploreOverlayLayer); + getWidget(mEventBoxLocal, "EventBoxLocal"); mEventBoxLocal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxLocal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); @@ -683,21 +745,16 @@ namespace MWGui markerSize, markerSize); static int _counter=0; - MyGUI::Button* markerWidget = mGlobalMapOverlay->createWidget("ButtonImage", + MyGUI::Widget* markerWidget = mGlobalMap->createWidget("MarkerButton", widgetCoord, MyGUI::Align::Default); - markerWidget->setImageResource("DoorMarker"); + markerWidget->setNeedMouseFocus(true); + markerWidget->setColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", name); + markerWidget->setDepth(Global_MarkerLayer); ++_counter; - markerWidget = mEventBoxGlobal->createWidget("", - widgetCoord, MyGUI::Align::Default); - markerWidget->setNeedMouseFocus (true); - markerWidget->setUserString("ToolTipType", "Layout"); - markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); - markerWidget->setUserString("Caption_TextOneLine", name); - CellId cell; cell.first = x; cell.second = y; @@ -829,8 +886,6 @@ namespace MWGui while (mEventBoxGlobal->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(mEventBoxGlobal->getChildAt(0)); - while (mGlobalMapOverlay->getChildCount()) - MyGUI::Gui::getInstance().destroyWidget(mGlobalMapOverlay->getChildAt(0)); } void MapWindow::write(ESM::ESMWriter &writer, Loading::Listener& progress) diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 323371eb7..87e750cc9 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -84,7 +84,6 @@ set(MYGUI_FILES openmw_screen_fader.layout openmw_edit_note.layout DejaVuLGCSansMono.ttf - markers.png ../launcher/images/openmw.png OpenMWResourcePlugin.xml ) diff --git a/files/mygui/markers.png b/files/mygui/markers.png deleted file mode 100644 index 76b6b9913b01cd9f805d1a9d7ff7693cf49c99fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~c!3HEhl+{lMQfx`y?k)`fL2$v|<&%LToCO|{ z#S9GG!XV7ZFl&wkP>{XE)7O>#4u_0@5~t(+j%PrjCQlc~5RLQ6JiQ!qPd2bbNJdQD z$+KUw&iKLP^u&aOgov#*p;F9Z0BR06 zaSc8`saxaIQNyTA9w6{J(G|8nV(z}2qnk?DWEf`K2s5`fu+9{g60{PwoxpMOFz*4; i2?h - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + +