1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

improvements for non quadratic maps

This commit is contained in:
Laserlicht
2023-10-21 16:49:50 +02:00
committed by GitHub
parent f3acc939b9
commit e03f2a9d3a
6 changed files with 31 additions and 5 deletions

View File

@ -91,10 +91,19 @@ CMinimap::CMinimap(const Rect & position)
level(0)
{
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
pos.w = position.w;
pos.h = position.h;
aiShield = std::make_shared<CPicture>(ImagePath::builtin("AIShield"));
double maxSideLenghtSrc = std::max(LOCPLINT->cb->getMapSize().x, LOCPLINT->cb->getMapSize().y);
double maxSideLenghtDst = std::max(position.w, position.h);
double resize = maxSideLenghtSrc / maxSideLenghtDst;
Point newMinimapSize = Point(LOCPLINT->cb->getMapSize().x/ resize, LOCPLINT->cb->getMapSize().y / resize);
Point offset = Point((std::max(newMinimapSize.x, newMinimapSize.y) - newMinimapSize.x) / 2, (std::max(newMinimapSize.x, newMinimapSize.y) - newMinimapSize.y) / 2);
pos.x += offset.x;
pos.y += offset.y;
pos.w = newMinimapSize.x;
pos.h = newMinimapSize.y;
aiShield = std::make_shared<CPicture>(ImagePath::builtin("AIShield"), -offset);
aiShield->disable();
}
@ -238,4 +247,3 @@ void CMinimap::updateTiles(const std::unordered_set<int3> & positions)
}
redraw();
}