diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 06576b42b..480b85265 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -459,91 +459,109 @@ void StatsWindow::setupToolTips() const ESMS::ESMStore &store = mWindowManager.getStore(); MyGUI::Widget* widget; + /// \todo move this into the .layout file! + getWidget(widget, "Attrib1"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeStrength")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sStrDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_strength.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeStrength")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sStrDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_strength.dds"); getWidget(widget, "AttribVal1"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeStrength")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sStrDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_strength.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeStrength")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sStrDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_strength.dds"); getWidget(widget, "Attrib2"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeIntelligence")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sIntDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_int.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeIntelligence")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sIntDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_int.dds"); getWidget(widget, "AttribVal2"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeIntelligence")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sIntDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_int.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeIntelligence")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sIntDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_int.dds"); getWidget(widget, "Attrib3"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeWillpower")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sWilDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_wilpower.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeWillpower")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sWilDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_wilpower.dds"); getWidget(widget, "AttribVal3"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeWillpower")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sWilDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_wilpower.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeWillpower")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sWilDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_wilpower.dds"); getWidget(widget, "Attrib4"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeAgility")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sAgiDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_agility.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeAgility")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sAgiDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_agility.dds"); getWidget(widget, "AttribVal4"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeAgility")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sAgiDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_agility.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeAgility")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sAgiDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_agility.dds"); getWidget(widget, "Attrib5"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeSpeed")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sSpdDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_speed.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeSpeed")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sSpdDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_speed.dds"); getWidget(widget, "AttribVal5"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeSpeed")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sSpdDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_speed.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeSpeed")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sSpdDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_speed.dds"); getWidget(widget, "Attrib6"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeEndurance")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sEndDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_endurance.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeEndurance")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sEndDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_endurance.dds"); getWidget(widget, "AttribVal6"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeEndurance")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sEndDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_endurance.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeEndurance")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sEndDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_endurance.dds"); getWidget(widget, "Attrib7"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributePersonality")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sPerDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_personality.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributePersonality")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sPerDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_personality.dds"); getWidget(widget, "AttribVal7"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributePersonality")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sPerDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_personality.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributePersonality")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sPerDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_personality.dds"); getWidget(widget, "Attrib8"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeLuck")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sLucDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_luck.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeLuck")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sLucDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_luck.dds"); getWidget(widget, "AttribVal8"); - widget->setUserString("ToolTipType", "ImageCaptionText"); - widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeLuck")->str); - widget->setUserString("ToolTipText", store.gameSettings.find ("sLucDesc")->str); - widget->setUserString("ToolTipImage", "k\\attribute_luck.dds"); + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "AttributeToolTip"); + widget->setUserString("Caption_AttributeName", store.gameSettings.find ("sAttributeLuck")->str); + widget->setUserString("Caption_AttributeDescription", store.gameSettings.find ("sLucDesc")->str); + widget->setUserString("ImageTexture_AttributeImage", "icons\\k\\attribute_luck.dds"); } diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index e986b59be..edb93320d 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -42,11 +42,16 @@ void ToolTips::onFrame(float frameDuration) IntCoord(0, 0, mMainWidget->getCoord().width, mMainWidget->getCoord().height), Align::Stretch, "DynamicToolTipBox"); + // start by hiding everything + for (unsigned int i=0; i < mMainWidget->getChildCount(); ++i) + { + mMainWidget->getChildAt(i)->setVisible(false); + } + const IntSize &viewSize = RenderManager::getInstance().getViewSize(); if (!mEnabled) { - mDynamicToolTipBox->setVisible(false); return; } @@ -55,7 +60,6 @@ void ToolTips::onFrame(float frameDuration) Widget* focus = InputManager::getInstance().getMouseFocusWidget(); if (focus == 0) { - mDynamicToolTipBox->setVisible(false); return; } @@ -67,7 +71,6 @@ void ToolTips::onFrame(float frameDuration) ToolTipInfo info; if (type == "") { - mDynamicToolTipBox->setVisible(false); return; } else if (type == "Text") @@ -98,6 +101,54 @@ void ToolTips::onFrame(float frameDuration) mFocusObject = *focus->getUserData(); tooltipSize = getToolTipViaPtr(false); } + else if (type == "Layout") + { + // tooltip defined in the layout + MyGUI::Widget* tooltip; + getWidget(tooltip, focus->getUserString("ToolTipLayout")); + + tooltip->setVisible(true); + tooltip->setCoord(0, 0, 300, 300); + + tooltipSize = MyGUI::IntSize(0,0); + + std::map userStrings = focus->getUserStrings(); + for (std::map::iterator it = userStrings.begin(); + it != userStrings.end(); ++it) + { + if (it->first == "ToolTipType" + || it->first == "ToolTipLayout") + continue; + + + size_t underscorePos = it->first.find("_"); + std::string propertyKey = it->first.substr(0, underscorePos); + std::string widgetName = it->first.substr(underscorePos+1, it->first.size()-(underscorePos+1)); + + MyGUI::Widget* w; + getWidget(w, widgetName); + w->setProperty(propertyKey, it->second); + } + + for (unsigned int i=0; igetChildCount(); ++i) + { + MyGUI::Widget* w = tooltip->getChildAt(i); + + if (w->isUserString("AutoResizeHorizontal")) + { + MyGUI::TextBox* text = w->castType(); + tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + text->getTextSize().width + 8); + } + + if (w->isUserString("AutoResizeVertical")) + { + MyGUI::TextBox* text = w->castType(); + tooltipSize.height = std::max(tooltipSize.height, w->getTop() + text->getTextSize().height + 8); + } + } + + tooltip->setCoord(0, 0, tooltipSize.width, tooltipSize.height); + } IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); @@ -112,7 +163,6 @@ void ToolTips::onFrame(float frameDuration) } setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height); - mDynamicToolTipBox->setVisible(true); } else { @@ -124,9 +174,9 @@ void ToolTips::onFrame(float frameDuration) std::max(0, int(mFocusToolTipY*viewSize.height - tooltipSize.height)), tooltipSize.width, tooltipSize.height); + + mDynamicToolTipBox->setVisible(true); } - else - mDynamicToolTipBox->setVisible(false); } } @@ -186,6 +236,8 @@ void ToolTips::findImageExtension(std::string& image) IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info) { + mDynamicToolTipBox->setVisible(true); + std::string caption = info.caption; std::string image = info.icon; int imageSize = (image != "") ? 32 : 0; diff --git a/files/mygui/openmw_tooltips.xml b/files/mygui/openmw_tooltips.xml index 2d5a5da9f..3c6c98ea9 100644 --- a/files/mygui/openmw_tooltips.xml +++ b/files/mygui/openmw_tooltips.xml @@ -8,6 +8,26 @@ + + + + + + + + + + + + + + + + + + + +