1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-15 13:33:36 +02:00

Merge pull request #4968 from Laserlicht/fix_window

fix hero window outside of screen
This commit is contained in:
Ivan Savenko 2024-11-25 13:45:45 +02:00 committed by GitHub
commit ebf0437f09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 17 deletions

View File

@ -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)

View File

@ -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);
}
}

View File

@ -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>

View File

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