From 1079bb26778afcf454b7aa0f01e0edee6574e53b Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 21 May 2012 05:14:07 +0200 Subject: [PATCH] finished tooltips for everything in the stats window, some gui refactoring --- apps/openmw/mwgui/hud.cpp | 18 ++--- apps/openmw/mwgui/hud.hpp | 1 - apps/openmw/mwgui/stats_window.cpp | 52 +++++++++++++ apps/openmw/mwgui/tooltips.cpp | 12 ++- files/mygui/openmw_hud_layout.xml | 30 ++++++-- files/mygui/openmw_stats_window_layout.xml | 88 ++++++++++++++++++---- files/mygui/openmw_tooltips.xml | 79 ++++++++++++++++++- 7 files changed, 242 insertions(+), 38 deletions(-) diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 4a65458df..892bd6c7a 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -129,16 +129,6 @@ void HUD::setBatchCount(size_t count) batchcounter->setCaption(boost::lexical_cast(count)); } -void HUD::setStats(int h, int hmax, int m, int mmax, int s, int smax) -{ - health->setProgressRange(hmax); - health->setProgressPosition(h); - magicka->setProgressRange(mmax); - magicka->setProgressPosition(m); - stamina->setProgressRange(smax); - stamina->setProgressPosition(s); -} - void HUD::setWeapIcon(const char *str) { weapImage->setImageTexture(str); @@ -176,19 +166,27 @@ void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat& v for (int i=0; ids[i]; ++i) if (ids[i]==id) { + MyGUI::Widget* w; + std::string valStr = boost::lexical_cast(value.getCurrent()) + "/" + boost::lexical_cast(value.getModified()); switch (i) { case 0: health->setProgressRange (value.getModified()); health->setProgressPosition (value.getCurrent()); + getWidget(w, "HealthFrame"); + w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); break; case 1: magicka->setProgressRange (value.getModified()); magicka->setProgressPosition (value.getCurrent()); + getWidget(w, "MagickaFrame"); + w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr); break; case 2: stamina->setProgressRange (value.getModified()); stamina->setProgressPosition (value.getCurrent()); + getWidget(w, "FatigueFrame"); + w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr); break; } } diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index d588113dd..81f64ee50 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -12,7 +12,6 @@ namespace MWGui { public: HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop); - void setStats(int h, int hmax, int m, int mmax, int s, int smax); void setWeapIcon(const char *str); void setSpellIcon(const char *str); void setWeapStatus(int s, int smax); diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index de12559ca..eba51c26f 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -172,11 +172,32 @@ void StatsWindow::setValue (const std::string& id, const MWMechanics::DynamicSta }; for (int i=0; ids[i]; ++i) + { if (ids[i]==id) { std::string id (ids[i]); setBar (id, id + "T", value.getCurrent(), value.getModified()); + + // health, magicka, fatigue tooltip + MyGUI::Widget* w; + std::string valStr = boost::lexical_cast(value.getCurrent()) + "/" + boost::lexical_cast(value.getModified()); + if (i==0) + { + getWidget(w, "Health"); + w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); + } + else if (i==1) + { + getWidget(w, "Magicka"); + w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr); + } + else if (i==2) + { + getWidget(w, "Fatigue"); + w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr); + } } + } } void StatsWindow::setValue (const std::string& id, const std::string& value) @@ -417,6 +438,37 @@ void StatsWindow::updateSkillArea() const ESMS::ESMStore &store = mWindowManager.getStore(); + // race tooltip + const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace()); + MyGUI::Widget* raceWidget; + getWidget(raceWidget, "RaceText"); + raceWidget->setUserString("Caption_CenteredCaption", playerRace->name); + raceWidget->setUserString("Caption_CenteredCaptionText", playerRace->description); + getWidget(raceWidget, "Race_str"); + raceWidget->setUserString("Caption_CenteredCaption", playerRace->name); + raceWidget->setUserString("Caption_CenteredCaptionText", playerRace->description); + + // class tooltip + MyGUI::Widget* classWidget; + const ESM::Class& playerClass = MWBase::Environment::get().getWorld()->getPlayer().getClass(); + int spec = playerClass.data.specialization; + std::string specStr; + if (spec == 0) + specStr = "#{sSpecializationCombat}"; + else if (spec == 1) + specStr = "#{sSpecializationMagic}"; + else if (spec == 2) + specStr = "#{sSpecializationStealth}"; + + getWidget(classWidget, "ClassText"); + classWidget->setUserString("Caption_ClassName", playerClass.name); + classWidget->setUserString("Caption_ClassDescription", playerClass.description); + classWidget->setUserString("Caption_ClassSpecialisation", "#{sSpecialization}: " + specStr); + getWidget(classWidget, "Class_str"); + classWidget->setUserString("Caption_ClassName", playerClass.name); + classWidget->setUserString("Caption_ClassDescription", playerClass.description); + classWidget->setUserString("Caption_ClassSpecialisation", "#{sSpecialization}: " + specStr); + if (!mFactions.empty()) { // Add a line separator if there are items above diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 52ba391a6..3ade598ba 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -85,9 +85,14 @@ void ToolTips::onFrame(float frameDuration) getWidget(tooltip, focus->getUserString("ToolTipLayout")); tooltip->setVisible(true); - tooltip->setCoord(0, 0, 300, 300); + if (!tooltip->isUserString("DontResize")) + { + tooltip->setCoord(0, 0, 450, 300); // this is the maximum width of the tooltip before it starts word-wrapping - tooltipSize = MyGUI::IntSize(0, tooltip->getSize().height); + tooltipSize = MyGUI::IntSize(0, tooltip->getSize().height); + } + else + tooltipSize = tooltip->getSize(); std::map userStrings = focus->getUserStrings(); for (std::map::iterator it = userStrings.begin(); @@ -116,7 +121,7 @@ void ToolTips::onFrame(float frameDuration) MyGUI::TextBox* text = w->castType(); tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + text->getTextSize().width + 8); } - else + else if (!tooltip->isUserString("DontResize")) tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + w->getWidth() + 8); if (w->isUserString("AutoResizeVertical")) @@ -133,7 +138,6 @@ void ToolTips::onFrame(float frameDuration) } } } - tooltip->setCoord(0, 0, tooltipSize.width, tooltipSize.height); } else diff --git a/files/mygui/openmw_hud_layout.xml b/files/mygui/openmw_hud_layout.xml index 0c5ffba6a..0aabc3e3e 100644 --- a/files/mygui/openmw_hud_layout.xml +++ b/files/mygui/openmw_hud_layout.xml @@ -3,12 +3,30 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_stats_window_layout.xml b/files/mygui/openmw_stats_window_layout.xml index 8b6080227..4729e3bca 100644 --- a/files/mygui/openmw_stats_window_layout.xml +++ b/files/mygui/openmw_stats_window_layout.xml @@ -7,37 +7,95 @@ - - + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + - - - diff --git a/files/mygui/openmw_tooltips.xml b/files/mygui/openmw_tooltips.xml index af4d26775..a1673d346 100644 --- a/files/mygui/openmw_tooltips.xml +++ b/files/mygui/openmw_tooltips.xml @@ -21,6 +21,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -78,6 +134,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -88,8 +165,6 @@ - -