Hi,
Really we should move this thread to the Help forum.
How are you triggering the pop-ups based off a delay? In other words, how are you counting time passing with nothing happening in the system?
Well, I am using an OGRE framelistener to give me the time since the last frame. So every frame, I just send the time to a method in my ToolTip class. If the tooltip should be showing, I increment some local variables until the delay is over, then I show the tooltip. If the tooltip has been showing long enough, I fade it out by slowly decrementing the tips alpha value, using the time value. Heres the method with the meat:
Code: Select all
void PEToolTip::updateToolTipTime(float time)
{
if (showingTip && tipsEnabled)
{
incTipTime = incTipTime + (0.1f * time);
// Wait for delay until showing tooltip
if ( (incTipTime > tipTimeDelay) && (incTipTime < tipTimeCutoff))
{
tipAlpha = 1.0f;
updateToolTip();
}
// Wait for cut off time until fading out tooltip
else if (incTipTime > tipTimeCutoff)
{
tipAlpha = tipAlpha - (0.5f * time);
if (tipAlpha < 0.0f)
{
hideToolTip();
}
else
{
updateToolTip();
}
}
}
}
Here's the updateToolTip() method, which really just sets the position and the alpha:
Code: Select all
void PEToolTip::updateToolTip()
{
Window* sheet = System::getSingleton().getGUISheet();
Point toolPos = MouseCursor::getSingleton().getDisplayIndependantPosition();
// Get tooltip sizes with a bit of buffering
float toolWidth = ToolTip->getWidth() + 0.002f;
float toolHeight = ToolTip->getHeight() + 0.002f;
// Shimmy height above cursor
toolPos.d_y = toolPos.d_y - toolHeight;
float testLength = toolPos.d_x + toolWidth;
if (testLength > sheet->getRelativeWidth())
{
toolPos.d_x = sheet->getRelativeWidth() - toolWidth;
}
if (toolPos.d_y < 0)
{
toolPos.d_y = 0;
}
ToolTip->setPosition( Point(toolPos.d_x, toolPos.d_y) );
ToolTip->setAlpha(tipAlpha);
}