Browse Source

fix window

Laserlicht 11 months ago
parent
commit
6366175a3c

+ 1 - 1
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)

+ 1 - 1
client/windows/CCastleInterface.cpp

@@ -456,7 +456,7 @@ void CHeroGSlot::showPopupWindow(const Point & cursorPosition)
 {
 	if(hero)
 	{
-		GH.windows().createAndPushWindow<CInfoBoxPopup>(Point(pos.x + 175, pos.y + 100), hero);
+		GH.windows().createAndPushWindow<CInfoBoxPopup>(pos.center(), hero);
 	}
 }
 

+ 12 - 14
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<CTownTooltip>(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<CHeroTooltip>(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<CArmyTooltip>(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<CreatureTooltip>(Point(9, 10), creature);
 	
 	addUsedEvents(DRAG_POPUP);
+
+	fitToScreen(10);
 }
 
 std::shared_ptr<WindowBase>

+ 0 - 1
client/windows/InfoWindows.h

@@ -90,7 +90,6 @@ public:
 class CInfoBoxPopup : public CWindowObject
 {
 	std::shared_ptr<CIntObject> tooltip;
-	Point toScreen(Point pos);
 
 	Point dragDistance;