Change tooltip positioning to resemble vanilla

actorid
scrawl 12 years ago
parent dbdfa624e1
commit bbb5d2b98a

@ -102,17 +102,8 @@ namespace MWGui
else
tooltipSize = getToolTipViaPtr(true);
MyGUI::IntPoint tooltipPosition = MyGUI::InputManager::getInstance().getMousePosition() + MyGUI::IntPoint(0, 24);
// make the tooltip stay completely in the viewport
if ((tooltipPosition.left + tooltipSize.width) > viewSize.width)
{
tooltipPosition.left = viewSize.width - tooltipSize.width;
}
if ((tooltipPosition.top + tooltipSize.height) > viewSize.height)
{
tooltipPosition.top = viewSize.height - tooltipSize.height;
}
MyGUI::IntPoint tooltipPosition = MyGUI::InputManager::getInstance().getMousePosition();
position(tooltipPosition, tooltipSize, viewSize);
setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height);
}
@ -267,17 +258,9 @@ namespace MWGui
else
throw std::runtime_error ("unknown tooltip type");
MyGUI::IntPoint tooltipPosition = MyGUI::InputManager::getInstance().getMousePosition() + MyGUI::IntPoint(0, 24);
MyGUI::IntPoint tooltipPosition = MyGUI::InputManager::getInstance().getMousePosition();
// make the tooltip stay completely in the viewport
if ((tooltipPosition.left + tooltipSize.width) > viewSize.width)
{
tooltipPosition.left = viewSize.width - tooltipSize.width;
}
if ((tooltipPosition.top + tooltipSize.height) > viewSize.height)
{
tooltipPosition.top = viewSize.height - tooltipSize.height;
}
position(tooltipPosition, tooltipSize, viewSize);
setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height);
}
@ -298,6 +281,21 @@ namespace MWGui
}
}
void ToolTips::position(MyGUI::IntPoint& position, MyGUI::IntSize size, MyGUI::IntSize viewportSize)
{
position += MyGUI::IntPoint(0, 32)
- MyGUI::IntPoint((MyGUI::InputManager::getInstance().getMousePosition().left / float(viewportSize.width) * size.width), 0);
if ((position.left + size.width) > viewportSize.width)
{
position.left = viewportSize.width - size.width;
}
if ((position.top + size.height) > viewportSize.height)
{
position.top = MyGUI::InputManager::getInstance().getMousePosition().top - size.height - 8;
}
}
void ToolTips::setFocusObject(const MWWorld::Ptr& focus)
{
mFocusObject = focus;
@ -413,12 +411,6 @@ namespace MWGui
MyGUI::IntCoord coord(0, 6, totalSize.width, 24);
/**
* \todo
* the various potion effects should appear in the tooltip depending if the player
* has enough skill in alchemy to know about the effects of this potion.
*/
Widgets::MWEffectListPtr effectsWidget = effectArea->createWidget<Widgets::MWEffectList>
("MW_StatName", coord, MyGUI::Align::Default, "ToolTipEffectsWidget");
effectsWidget->setEffectList(info.effects);

@ -92,6 +92,9 @@ namespace MWGui
float mFocusToolTipX;
float mFocusToolTipY;
/// Adjust position for a tooltip so that it doesn't leave the screen and does not obscure the mouse cursor
void position(MyGUI::IntPoint& position, MyGUI::IntSize size, MyGUI::IntSize viewportSize);
int mHorizontalScrollIndex;

Loading…
Cancel
Save