From 63213b36bfdf162fe9fd3edaec8a2a9716c7c672 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 26 May 2012 23:06:15 +0200 Subject: [PATCH] Show a label on the HUD with the cell name when it changes (visible for a few seconds) - like Morrowind --- apps/openmw/mwgui/hud.cpp | 23 +++++++++++++++++++++++ apps/openmw/mwgui/hud.hpp | 8 ++++++++ apps/openmw/mwgui/window_manager.cpp | 4 ++++ files/mygui/openmw_hud_layout.xml | 8 ++++++++ 4 files changed, 43 insertions(+) diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index a3036cec4..d3d7696b4 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -41,6 +41,8 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop) , effectBoxBaseRight(0) , minimapBoxBaseRight(0) , mDragAndDrop(dragAndDrop) + , mCellNameTimer(0.0f) + , mCellNameBox(NULL) { setCoord(0,0, width, height); @@ -83,6 +85,8 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop) getWidget(minimap, "MiniMap"); getWidget(compass, "Compass"); + getWidget(mCellNameBox, "CellName"); + getWidget(crosshair, "Crosshair"); setFpsLevel(fpsLevel); @@ -324,3 +328,22 @@ void HUD::onMagicClicked(MyGUI::Widget* _sender) { MWBase::Environment::get().getWindowManager()->toggleVisible(GW_Magic); } + +void HUD::setCellName(const std::string& cellName) +{ + if (mCellName != cellName) + { + mCellNameTimer = 5.0f; + mCellName = cellName; + + mCellNameBox->setCaption(mCellName); + mCellNameBox->setVisible(true); + } +} + +void HUD::onFrame(float dt) +{ + mCellNameTimer -= dt; + if (mCellNameTimer < 0) + mCellNameBox->setVisible(false); +} diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index 924893351..f7131a39c 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -25,6 +25,10 @@ namespace MWGui void setBottomRightVisibility(bool effectBoxVisible, bool minimapVisible); void setFpsLevel(const int level); + void onFrame(float dt); + + void setCellName(const std::string& cellName); + MyGUI::ProgressPtr health, magicka, stamina; MyGUI::Widget *weapBox, *spellBox; MyGUI::ImageBox *weapImage, *spellImage; @@ -34,6 +38,7 @@ namespace MWGui MyGUI::ScrollView* minimap; MyGUI::ImageBox* compass; MyGUI::ImageBox* crosshair; + MyGUI::TextBox* mCellNameBox; MyGUI::WidgetPtr fpsbox; MyGUI::TextBox* fpscounter; @@ -48,6 +53,9 @@ namespace MWGui DragAndDrop* mDragAndDrop; + std::string mCellName; + float mCellNameTimer; + void onWorldClicked(MyGUI::Widget* _sender); void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y); void onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new); diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 088e9c61e..acd0b089f 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -470,6 +470,8 @@ void WindowManager::onFrame (float frameDuration) mInventoryWindow->onFrame(); mStatsWindow->onFrame(); + + hud->onFrame(frameDuration); } const ESMS::ESMStore& WindowManager::getStore() const @@ -494,6 +496,7 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) } map->setCellName( name ); + hud->setCellName( name ); map->setCellPrefix("Cell"); hud->setCellPrefix("Cell"); @@ -503,6 +506,7 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) else { map->setCellName( cell->cell->name ); + hud->setCellName( cell->cell->name ); map->setCellPrefix( cell->cell->name ); hud->setCellPrefix( cell->cell->name ); } diff --git a/files/mygui/openmw_hud_layout.xml b/files/mygui/openmw_hud_layout.xml index 26c31793c..d0026bf25 100644 --- a/files/mygui/openmw_hud_layout.xml +++ b/files/mygui/openmw_hud_layout.xml @@ -59,6 +59,14 @@ name="Effect1"/> + + + + + + + +