diff --git a/source/gui/CTooltip.cpp b/source/gui/CTooltip.cpp index 18c67a7123..1f4da670ba 100644 --- a/source/gui/CTooltip.cpp +++ b/source/gui/CTooltip.cpp @@ -16,7 +16,7 @@ CTooltip::CTooltip() AddSetting(GUIST_CGUISpriteInstance, "sprite"); AddSetting(GUIST_int, "delay"); AddSetting(GUIST_CColor, "textcolor"); - AddSetting(GUIST_int, "maxwidth"); + AddSetting(GUIST_float, "maxwidth"); AddSetting(GUIST_CPos, "offset"); AddSetting(GUIST_EVAlign, "anchor"); @@ -57,10 +57,10 @@ void CTooltip::SetupText() CGUIString caption; GUI::GetSetting(this, "caption", caption); - int max_width = 0; - GUI::GetSetting(this, "maxwidth", max_width); + float max_width = 0.f; + GUI::GetSetting(this, "maxwidth", max_width); - *m_GeneratedTexts[0] = GetGUI()->GenerateText(caption, font, (float)max_width, buffer_zone, this); + *m_GeneratedTexts[0] = GetGUI()->GenerateText(caption, font, max_width, buffer_zone, this); // Position the tooltip relative to the mouse: diff --git a/source/gui/GUITooltip.cpp b/source/gui/GUITooltip.cpp index b6e5f7e13c..e59d5f9edb 100644 --- a/source/gui/GUITooltip.cpp +++ b/source/gui/GUITooltip.cpp @@ -222,8 +222,13 @@ void GUITooltip::Update(IGUIObject* Nearest, CPos MousePos, CGUI* GUI) { // Check for movement onto a zero-delayed tooltip if (GetTooltip(Nearest, style) && GetTooltipDelay(style, GUI)==0) + { + // Reset any previous tooltips completely + //m_Time = now + (double)GetTooltipDelay(style, GUI) / 1000.; + HideTooltip(m_PreviousTooltipName, GUI); nextstate = ST_SHOWING; + } } break; @@ -253,9 +258,31 @@ void GUITooltip::Update(IGUIObject* Nearest, CPos MousePos, CGUI* GUI) if (Nearest != m_PreviousObject) { if (GetTooltip(Nearest, style)) - nextstate = ST_SHOWING; + { + CStr style_old; + + // If we're displaying a tooltip with no delay, then we want to + // reset so that other object that should have delay can't + // "ride this tail", it have to wait. + // Notice that this doesn't apply to when you go from one delay=0 + // to another delay=0 + if (GetTooltip(m_PreviousObject, style_old) && GetTooltipDelay(style_old, GUI)==0 && + GetTooltipDelay(style, GUI)!=0) + { + HideTooltip(m_PreviousTooltipName, GUI); + nextstate = ST_IN_MOTION; + } + else + { + // Hide old scrollbar + HideTooltip(m_PreviousTooltipName, GUI); + nextstate = ST_SHOWING; + } + } else + { nextstate = ST_COOLING; + } } break;