Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/CTooltip.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | void CTooltip::SetupText() | ||||
CStrW font; | CStrW font; | ||||
if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty()) | if (GUI<CStrW>::GetSetting(this, "font", font) != PSRETURN_OK || font.empty()) | ||||
font = L"default"; | font = L"default"; | ||||
float buffer_zone = 0.f; | float buffer_zone = 0.f; | ||||
GUI<float>::GetSetting(this, "buffer_zone", buffer_zone); | GUI<float>::GetSetting(this, "buffer_zone", buffer_zone); | ||||
CGUIString* caption = nullptr; | const CGUIString& caption = GUI<CGUIString>::GetSetting(this, "caption"); | ||||
GUI<CGUIString>::GetSettingPointer(this, "caption", caption); | |||||
float max_width = 0.f; | float max_width = 0.f; | ||||
GUI<float>::GetSetting(this, "maxwidth", max_width); | GUI<float>::GetSetting(this, "maxwidth", max_width); | ||||
m_GeneratedTexts[0] = CGUIText(m_pGUI, *caption, font, max_width, buffer_zone, this); | m_GeneratedTexts[0] = CGUIText(m_pGUI, caption, font, max_width, buffer_zone, this); | ||||
// Position the tooltip relative to the mouse: | // Position the tooltip relative to the mouse: | ||||
CPos mousepos, offset; | CPos mousepos, offset; | ||||
EVAlign anchor; | EVAlign anchor; | ||||
bool independent; | bool independent; | ||||
GUI<bool>::GetSetting(this, "independent", independent); | GUI<bool>::GetSetting(this, "independent", independent); | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
IGUITextOwner::HandleMessage(Message); | IGUITextOwner::HandleMessage(Message); | ||||
} | } | ||||
void CTooltip::Draw() | void CTooltip::Draw() | ||||
{ | { | ||||
float z = 900.f; // TODO: Find a nicer way of putting the tooltip on top of everything else | float z = 900.f; // TODO: Find a nicer way of putting the tooltip on top of everything else | ||||
CGUISpriteInstance* sprite; | CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, "sprite"); | ||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite); | |||||
// Normally IGUITextOwner will handle this updating but since SetupText can modify the position | // Normally IGUITextOwner will handle this updating but since SetupText can modify the position | ||||
// we need to call it now *before* we do the rest of the drawing | // we need to call it now *before* we do the rest of the drawing | ||||
if (!m_GeneratedTextsValid) | if (!m_GeneratedTextsValid) | ||||
{ | { | ||||
SetupText(); | SetupText(); | ||||
m_GeneratedTextsValid = true; | m_GeneratedTextsValid = true; | ||||
} | } | ||||
GetGUI()->DrawSprite(*sprite, 0, z, m_CachedActualSize); | m_pGUI->DrawSprite(sprite, 0, z, m_CachedActualSize); | ||||
CGUIColor color; | CGUIColor color; | ||||
GUI<CGUIColor>::GetSetting(this, "textcolor", color); | GUI<CGUIColor>::GetSetting(this, "textcolor", color); | ||||
DrawText(0, color, m_CachedActualSize.TopLeft(), z+0.1f); | DrawText(0, color, m_CachedActualSize.TopLeft(), z+0.1f); | ||||
} | } |
Wildfire Games · Phabricator