mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 20:09:40 +00:00
Stick focused object tooltip to slightly above its top (#4710)
This commit is contained in:
parent
69c4a68187
commit
efdea0fb42
9 changed files with 31 additions and 42 deletions
|
@ -11,6 +11,7 @@
|
||||||
Bug #4508: Can't stack enchantment buffs from different instances of the same self-cast generic magic apparel
|
Bug #4508: Can't stack enchantment buffs from different instances of the same self-cast generic magic apparel
|
||||||
Bug #4610: Casting a Bound Weapon spell cancels the casting animation by equipping the weapon prematurely
|
Bug #4610: Casting a Bound Weapon spell cancels the casting animation by equipping the weapon prematurely
|
||||||
Bug #4683: Disposition decrease when player commits crime is not implemented properly
|
Bug #4683: Disposition decrease when player commits crime is not implemented properly
|
||||||
|
Bug #4710: Object tooltips don't always stick to the top of the object
|
||||||
Bug #4742: Actors with wander never stop walking after Loopgroup Walkforward
|
Bug #4742: Actors with wander never stop walking after Loopgroup Walkforward
|
||||||
Bug #4743: PlayGroup doesn't play non-looping animations correctly
|
Bug #4743: PlayGroup doesn't play non-looping animations correctly
|
||||||
Bug #4754: Stack of ammunition cannot be equipped partially
|
Bug #4754: Stack of ammunition cannot be equipped partially
|
||||||
|
|
|
@ -184,7 +184,7 @@ namespace MWBase
|
||||||
///< change the active cell
|
///< change the active cell
|
||||||
|
|
||||||
virtual void setFocusObject(const MWWorld::Ptr& focus) = 0;
|
virtual void setFocusObject(const MWWorld::Ptr& focus) = 0;
|
||||||
virtual void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y) = 0;
|
virtual void setFocusObjectScreenCoords(float x, float y) = 0;
|
||||||
|
|
||||||
virtual void setCursorVisible(bool visible) = 0;
|
virtual void setCursorVisible(bool visible) = 0;
|
||||||
virtual void setCursorActive(bool active) = 0;
|
virtual void setCursorActive(bool active) = 0;
|
||||||
|
|
|
@ -308,9 +308,9 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
MyGUI::IntSize tooltipSize = getToolTipViaPtr(mFocusObject.getCellRef().getCount(), true, checkOwned());
|
MyGUI::IntSize tooltipSize = getToolTipViaPtr(mFocusObject.getCellRef().getCount(), true, checkOwned());
|
||||||
|
|
||||||
setCoord(viewSize.width / 2 - tooltipSize.width / 2,
|
const int left = viewSize.width / 2 - tooltipSize.width / 2;
|
||||||
std::max(0, int(mFocusToolTipY * viewSize.height - tooltipSize.height)), tooltipSize.width,
|
const int top = std::max(0, int(mFocusToolTipY * viewSize.height - tooltipSize.height - 20));
|
||||||
tooltipSize.height);
|
setCoord(left, top, tooltipSize.width, tooltipSize.height);
|
||||||
|
|
||||||
mDynamicToolTipBox->setVisible(true);
|
mDynamicToolTipBox->setVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -818,10 +818,10 @@ namespace MWGui
|
||||||
return mFullHelp;
|
return mFullHelp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTips::setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y)
|
void ToolTips::setFocusObjectScreenCoords(float x, float y)
|
||||||
{
|
{
|
||||||
mFocusToolTipX = (min_x + max_x) / 2;
|
mFocusToolTipX = x;
|
||||||
mFocusToolTipY = min_y;
|
mFocusToolTipY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTips::createSkillToolTip(MyGUI::Widget* widget, ESM::RefId skillId)
|
void ToolTips::createSkillToolTip(MyGUI::Widget* widget, ESM::RefId skillId)
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace MWGui
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void setFocusObject(const MWWorld::Ptr& focus);
|
void setFocusObject(const MWWorld::Ptr& focus);
|
||||||
void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
|
void setFocusObjectScreenCoords(float x, float y);
|
||||||
///< set the screen-space position of the tooltip for focused object
|
///< set the screen-space position of the tooltip for focused object
|
||||||
|
|
||||||
static std::string getWeightString(const float weight, const std::string& prefix);
|
static std::string getWeightString(const float weight, const std::string& prefix);
|
||||||
|
|
|
@ -1038,9 +1038,9 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y)
|
void WindowManager::setFocusObjectScreenCoords(float x, float y)
|
||||||
{
|
{
|
||||||
mToolTips->setFocusObjectScreenCoords(min_x, min_y, max_x, max_y);
|
mToolTips->setFocusObjectScreenCoords(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowManager::toggleFullHelp()
|
bool WindowManager::toggleFullHelp()
|
||||||
|
|
|
@ -204,7 +204,7 @@ namespace MWGui
|
||||||
void changeCell(const MWWorld::CellStore* cell) override; ///< change the active cell
|
void changeCell(const MWWorld::CellStore* cell) override; ///< change the active cell
|
||||||
|
|
||||||
void setFocusObject(const MWWorld::Ptr& focus) override;
|
void setFocusObject(const MWWorld::Ptr& focus) override;
|
||||||
void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y) override;
|
void setFocusObjectScreenCoords(float x, float y) override;
|
||||||
|
|
||||||
void getMousePosition(int& x, int& y) override;
|
void getMousePosition(int& x, int& y) override;
|
||||||
void getMousePosition(float& x, float& y) override;
|
void getMousePosition(float& x, float& y) override;
|
||||||
|
|
|
@ -1013,34 +1013,24 @@ namespace MWRender
|
||||||
mScreenshotManager->screenshot(image, w, h);
|
mScreenshotManager->screenshot(image, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec4f RenderingManager::getScreenBounds(const osg::BoundingBox& worldbb)
|
osg::Vec2f RenderingManager::getScreenCoords(const osg::BoundingBox& bb)
|
||||||
{
|
{
|
||||||
if (!worldbb.valid())
|
if (bb.valid())
|
||||||
return osg::Vec4f();
|
|
||||||
osg::Matrix viewProj = mViewer->getCamera()->getViewMatrix() * mViewer->getCamera()->getProjectionMatrix();
|
|
||||||
float min_x = 1.0f, max_x = 0.0f, min_y = 1.0f, max_y = 0.0f;
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
{
|
{
|
||||||
osg::Vec3f corner = worldbb.corner(i);
|
const osg::Matrix viewProj
|
||||||
corner = corner * viewProj;
|
= mViewer->getCamera()->getViewMatrix() * mViewer->getCamera()->getProjectionMatrix();
|
||||||
|
const osg::Vec3f worldPoint((bb.xMin() + bb.xMax()) * 0.5f, (bb.yMin() + bb.yMax()) * 0.5f, bb.zMax());
|
||||||
float x = (corner.x() + 1.f) * 0.5f;
|
const osg::Vec4f clipPoint = osg::Vec4f(worldPoint, 1.0f) * viewProj;
|
||||||
float y = (corner.y() - 1.f) * (-0.5f);
|
if (clipPoint.w() > 0.f)
|
||||||
|
{
|
||||||
if (x < min_x)
|
const float screenPointX = (clipPoint.x() / clipPoint.w() + 1.f) * 0.5f;
|
||||||
min_x = x;
|
const float screenPointY = (clipPoint.y() / clipPoint.w() - 1.f) * (-0.5f);
|
||||||
|
if (screenPointX >= 0.f && screenPointX <= 1.f && screenPointY >= 0.f && screenPointY <= 1.f)
|
||||||
if (x > max_x)
|
return osg::Vec2f(screenPointX, screenPointY);
|
||||||
max_x = x;
|
}
|
||||||
|
|
||||||
if (y < min_y)
|
|
||||||
min_y = y;
|
|
||||||
|
|
||||||
if (y > max_y)
|
|
||||||
max_y = y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return osg::Vec4f(min_x, min_y, max_x, max_y);
|
return osg::Vec2f(0.5f, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderingManager::RayResult getIntersectionResult(osgUtil::LineSegmentIntersector* intersector,
|
RenderingManager::RayResult getIntersectionResult(osgUtil::LineSegmentIntersector* intersector,
|
||||||
|
|
|
@ -185,9 +185,8 @@ namespace MWRender
|
||||||
RayResult castCameraToViewportRay(
|
RayResult castCameraToViewportRay(
|
||||||
const float nX, const float nY, float maxDistance, bool ignorePlayer, bool ignoreActors = false);
|
const float nX, const float nY, float maxDistance, bool ignorePlayer, bool ignoreActors = false);
|
||||||
|
|
||||||
/// Get the bounding box of the given object in screen coordinates as (minX, minY, maxX, maxY), with (0,0) being
|
/// Get normalized screen coordinates of the bounding box's summit, where (0,0) is the top left corner
|
||||||
/// the top left corner.
|
osg::Vec2f getScreenCoords(const osg::BoundingBox& bb);
|
||||||
osg::Vec4f getScreenBounds(const osg::BoundingBox& worldbb);
|
|
||||||
|
|
||||||
void setSkyEnabled(bool enabled);
|
void setSkyEnabled(bool enabled);
|
||||||
|
|
||||||
|
|
|
@ -1784,7 +1784,7 @@ namespace MWWorld
|
||||||
// inform the GUI about focused object
|
// inform the GUI about focused object
|
||||||
MWWorld::Ptr object = getFacedObject();
|
MWWorld::Ptr object = getFacedObject();
|
||||||
|
|
||||||
// retrieve object dimensions so we know where to place the floating label
|
// retrieve the object's top point's screen position so we know where to place the floating label
|
||||||
if (!object.isEmpty())
|
if (!object.isEmpty())
|
||||||
{
|
{
|
||||||
osg::BoundingBox bb = mPhysics->getBoundingBox(object);
|
osg::BoundingBox bb = mPhysics->getBoundingBox(object);
|
||||||
|
@ -1795,9 +1795,8 @@ namespace MWWorld
|
||||||
object.getRefData().getBaseNode()->accept(computeBoundsVisitor);
|
object.getRefData().getBaseNode()->accept(computeBoundsVisitor);
|
||||||
bb = computeBoundsVisitor.getBoundingBox();
|
bb = computeBoundsVisitor.getBoundingBox();
|
||||||
}
|
}
|
||||||
osg::Vec4f screenBounds = mRendering->getScreenBounds(bb);
|
const osg::Vec2f pos = mRendering->getScreenCoords(bb);
|
||||||
MWBase::Environment::get().getWindowManager()->setFocusObjectScreenCoords(
|
MWBase::Environment::get().getWindowManager()->setFocusObjectScreenCoords(pos.x(), pos.y());
|
||||||
screenBounds.x(), screenBounds.y(), screenBounds.z(), screenBounds.w());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->setFocusObject(object);
|
MWBase::Environment::get().getWindowManager()->setFocusObject(object);
|
||||||
|
|
Loading…
Reference in a new issue