fix window

This commit is contained in:
Laserlicht
2024-11-23 19:19:07 +01:00
parent a4417f3fc5
commit 6366175a3c
4 changed files with 14 additions and 17 deletions
+1 -1
View File
@@ -450,7 +450,7 @@ void CTownList::CTownItem::open()
void CTownList::CTownItem::showTooltip() 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) void CTownList::CTownItem::gesture(bool on, const Point & initialPosition, const Point & finalPosition)
+1 -1
View File
@@ -456,7 +456,7 @@ void CHeroGSlot::showPopupWindow(const Point & cursorPosition)
{ {
if(hero) if(hero)
{ {
GH.windows().createAndPushWindow<CInfoBoxPopup>(Point(pos.x + 175, pos.y + 100), hero); GH.windows().createAndPushWindow<CInfoBoxPopup>(pos.center(), hero);
} }
} }
+12 -14
View File
@@ -266,16 +266,6 @@ void CRClickPopupInt::mouseDraggedPopup(const Point & cursorPosition, const Poin
close(); 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) void CInfoBoxPopup::mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance)
{ {
if(!settings["adventure"]["rightButtonDrag"].Bool()) if(!settings["adventure"]["rightButtonDrag"].Bool())
@@ -289,7 +279,7 @@ void CInfoBoxPopup::mouseDraggedPopup(const Point & cursorPosition, const Point
CInfoBoxPopup::CInfoBoxPopup(Point position, const CGTownInstance * town) 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; InfoAboutTown iah;
LOCPLINT->cb->getTownInfo(town, iah, LOCPLINT->localState->getCurrentArmy()); //todo: should this be nearest hero? 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); tooltip = std::make_shared<CTownTooltip>(Point(9, 10), iah);
addUsedEvents(DRAG_POPUP); addUsedEvents(DRAG_POPUP);
fitToScreen(10);
} }
CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero) 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; InfoAboutHero iah;
LOCPLINT->cb->getHeroInfo(hero, iah, LOCPLINT->localState->getCurrentArmy()); //todo: should this be nearest hero? 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); tooltip = std::make_shared<CHeroTooltip>(Point(9, 10), iah);
addUsedEvents(DRAG_POPUP); addUsedEvents(DRAG_POPUP);
fitToScreen(10);
} }
CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr) 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; InfoAboutTown iah;
LOCPLINT->cb->getTownInfo(garr, 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); tooltip = std::make_shared<CArmyTooltip>(Point(9, 10), iah);
addUsedEvents(DRAG_POPUP); addUsedEvents(DRAG_POPUP);
fitToScreen(10);
} }
CInfoBoxPopup::CInfoBoxPopup(Point position, const CGCreature * creature) 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; OBJECT_CONSTRUCTION;
tooltip = std::make_shared<CreatureTooltip>(Point(9, 10), creature); tooltip = std::make_shared<CreatureTooltip>(Point(9, 10), creature);
addUsedEvents(DRAG_POPUP); addUsedEvents(DRAG_POPUP);
fitToScreen(10);
} }
std::shared_ptr<WindowBase> std::shared_ptr<WindowBase>
-1
View File
@@ -90,7 +90,6 @@ public:
class CInfoBoxPopup : public CWindowObject class CInfoBoxPopup : public CWindowObject
{ {
std::shared_ptr<CIntObject> tooltip; std::shared_ptr<CIntObject> tooltip;
Point toScreen(Point pos);
Point dragDistance; Point dragDistance;