forked from mirror/openmw-tes3mp
attribute tooltips now use a new system that allows complex tooltips to be defined entirely through layout files
This commit is contained in:
parent
876b369ca5
commit
8d52ee27dc
3 changed files with 160 additions and 70 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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<MWWorld::Ptr>();
|
||||
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<std::string, std::string> userStrings = focus->getUserStrings();
|
||||
for (std::map<std::string, std::string>::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; i<tooltip->getChildCount(); ++i)
|
||||
{
|
||||
MyGUI::Widget* w = tooltip->getChildAt(i);
|
||||
|
||||
if (w->isUserString("AutoResizeHorizontal"))
|
||||
{
|
||||
MyGUI::TextBox* text = w->castType<MyGUI::TextBox>();
|
||||
tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + text->getTextSize().width + 8);
|
||||
}
|
||||
|
||||
if (w->isUserString("AutoResizeVertical"))
|
||||
{
|
||||
MyGUI::TextBox* text = w->castType<MyGUI::TextBox>();
|
||||
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;
|
||||
|
|
|
@ -8,6 +8,26 @@
|
|||
<Property key="Visible" value="false"/>
|
||||
</Widget>
|
||||
|
||||
<!-- Attribute tooltip -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 300 300" align="Stretch" name="AttributeToolTip">
|
||||
<Property key="Visible" value="false"/>
|
||||
|
||||
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="AttributeImage"/>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="44 8 252 32" align="Left Top HStretch" name="AttributeName">
|
||||
<Property key="TextAlign" value="Left VCenter"/>
|
||||
<UserString key="AutoResizeHorizontal" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="EditBox" skin="SandText" position="8 44 284 248" align="Left Top Stretch" name="AttributeDescription">
|
||||
<Property key="MultiLine" value="true"/>
|
||||
<Property key="WordWrap" value="true"/>
|
||||
<Property key="TextAlign" value="Left Top"/>
|
||||
<UserString key="AutoResizeHorizontal" value="true"/>
|
||||
<UserString key="AutoResizeVertical" value="true"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
||||
|
||||
|
|
Loading…
Reference in a new issue