diff --git a/client/adventureMap/CList.cpp b/client/adventureMap/CList.cpp index 121853931..d25a612a3 100644 --- a/client/adventureMap/CList.cpp +++ b/client/adventureMap/CList.cpp @@ -450,7 +450,7 @@ void CTownList::CTownItem::open() void CTownList::CTownItem::showTooltip() { - CRClickPopup::createAndPush(town, GH.getCursorPosition()); + CRClickPopup::createAndPush(town, pos.center()); } void CTownList::CTownItem::gesture(bool on, const Point & initialPosition, const Point & finalPosition) diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index eba40eedc..3d917712e 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -456,7 +456,7 @@ void CHeroGSlot::showPopupWindow(const Point & cursorPosition) { if(hero) { - GH.windows().createAndPushWindow(Point(pos.x + 175, pos.y + 100), hero); + GH.windows().createAndPushWindow(pos.center(), hero); } } diff --git a/client/windows/InfoWindows.cpp b/client/windows/InfoWindows.cpp index 2719c08d5..494192e4c 100644 --- a/client/windows/InfoWindows.cpp +++ b/client/windows/InfoWindows.cpp @@ -266,16 +266,6 @@ void CRClickPopupInt::mouseDraggedPopup(const Point & cursorPosition, const Poin close(); } -Point CInfoBoxPopup::toScreen(Point p) -{ - auto bounds = adventureInt->terrainAreaPixels(); - - vstd::abetween(p.x, bounds.top() + 100, bounds.bottom() - 100); - vstd::abetween(p.y, bounds.left() + 100, bounds.right() - 100); - - return p; -} - void CInfoBoxPopup::mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) { if(!settings["adventure"]["rightButtonDrag"].Bool()) @@ -289,7 +279,7 @@ void CInfoBoxPopup::mouseDraggedPopup(const Point & cursorPosition, const Point CInfoBoxPopup::CInfoBoxPopup(Point position, const CGTownInstance * town) - : CWindowObject(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("TOWNQVBK"), toScreen(position)) + : CWindowObject(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("TOWNQVBK"), position) { InfoAboutTown iah; LOCPLINT->cb->getTownInfo(town, iah, LOCPLINT->localState->getCurrentArmy()); //todo: should this be nearest hero? @@ -298,10 +288,12 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGTownInstance * town) tooltip = std::make_shared(Point(9, 10), iah); addUsedEvents(DRAG_POPUP); + + fitToScreen(10); } CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero) - : CWindowObject(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("HEROQVBK"), toScreen(position)) + : CWindowObject(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("HEROQVBK"), position) { InfoAboutHero iah; LOCPLINT->cb->getHeroInfo(hero, iah, LOCPLINT->localState->getCurrentArmy()); //todo: should this be nearest hero? @@ -310,10 +302,12 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero) tooltip = std::make_shared(Point(9, 10), iah); addUsedEvents(DRAG_POPUP); + + fitToScreen(10); } CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr) - : CWindowObject(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("TOWNQVBK"), toScreen(position)) + : CWindowObject(RCLICK_POPUP | PLAYER_COLORED, ImagePath::builtin("TOWNQVBK"), position) { InfoAboutTown iah; LOCPLINT->cb->getTownInfo(garr, iah); @@ -322,15 +316,19 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr) tooltip = std::make_shared(Point(9, 10), iah); addUsedEvents(DRAG_POPUP); + + fitToScreen(10); } CInfoBoxPopup::CInfoBoxPopup(Point position, const CGCreature * creature) - : CWindowObject(RCLICK_POPUP | BORDERED, ImagePath::builtin("DIBOXBCK"), toScreen(position)) + : CWindowObject(RCLICK_POPUP | BORDERED, ImagePath::builtin("DIBOXBCK"), position) { OBJECT_CONSTRUCTION; tooltip = std::make_shared(Point(9, 10), creature); addUsedEvents(DRAG_POPUP); + + fitToScreen(10); } std::shared_ptr diff --git a/client/windows/InfoWindows.h b/client/windows/InfoWindows.h index 81b661339..468088dd2 100644 --- a/client/windows/InfoWindows.h +++ b/client/windows/InfoWindows.h @@ -90,7 +90,6 @@ public: class CInfoBoxPopup : public CWindowObject { std::shared_ptr tooltip; - Point toScreen(Point pos); Point dragDistance;