mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-29 21:56:54 +02:00
improvements for non quadratic maps
This commit is contained in:
parent
f3acc939b9
commit
e03f2a9d3a
@ -91,10 +91,19 @@ CMinimap::CMinimap(const Rect & position)
|
|||||||
level(0)
|
level(0)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
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();
|
aiShield->disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,4 +247,3 @@ void CMinimap::updateTiles(const std::unordered_set<int3> & positions)
|
|||||||
}
|
}
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ InfoCard::InfoCard()
|
|||||||
pos.y += 6;
|
pos.y += 6;
|
||||||
|
|
||||||
labelSaveDate = std::make_shared<CLabel>(310, 38, FONT_SMALL, ETextAlignment::BOTTOMRIGHT, Colors::WHITE);
|
labelSaveDate = std::make_shared<CLabel>(310, 38, FONT_SMALL, ETextAlignment::BOTTOMRIGHT, Colors::WHITE);
|
||||||
|
labelMapSize = std::make_shared<CLabel>(332, 56, FONT_TINY, ETextAlignment::CENTER, Colors::WHITE);
|
||||||
mapName = std::make_shared<CLabel>(26, 39, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW);
|
mapName = std::make_shared<CLabel>(26, 39, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW);
|
||||||
Rect descriptionRect(26, 149, 320, 115);
|
Rect descriptionRect(26, 149, 320, 115);
|
||||||
mapDescription = std::make_shared<CTextBox>("", descriptionRect, 1);
|
mapDescription = std::make_shared<CTextBox>("", descriptionRect, 1);
|
||||||
@ -185,6 +186,7 @@ InfoCard::InfoCard()
|
|||||||
void InfoCard::disableLabelRedraws()
|
void InfoCard::disableLabelRedraws()
|
||||||
{
|
{
|
||||||
labelSaveDate->setAutoRedraw(false);
|
labelSaveDate->setAutoRedraw(false);
|
||||||
|
labelMapSize->setAutoRedraw(false);
|
||||||
mapName->setAutoRedraw(false);
|
mapName->setAutoRedraw(false);
|
||||||
mapDescription->label->setAutoRedraw(false);
|
mapDescription->label->setAutoRedraw(false);
|
||||||
labelVictoryConditionText->setAutoRedraw(false);
|
labelVictoryConditionText->setAutoRedraw(false);
|
||||||
@ -200,6 +202,7 @@ void InfoCard::changeSelection()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
labelSaveDate->setText(mapInfo->date);
|
labelSaveDate->setText(mapInfo->date);
|
||||||
|
labelMapSize->setText(std::to_string(mapInfo->mapHeader->width) + "x" + std::to_string(mapInfo->mapHeader->height));
|
||||||
mapName->setText(mapInfo->getNameTranslated());
|
mapName->setText(mapInfo->getNameTranslated());
|
||||||
mapDescription->setText(mapInfo->getDescriptionTranslated());
|
mapDescription->setText(mapInfo->getDescriptionTranslated());
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ class InfoCard : public CIntObject
|
|||||||
std::shared_ptr<CAnimImage> iconsMapSizes;
|
std::shared_ptr<CAnimImage> iconsMapSizes;
|
||||||
|
|
||||||
std::shared_ptr<CLabel> labelSaveDate;
|
std::shared_ptr<CLabel> labelSaveDate;
|
||||||
|
std::shared_ptr<CLabel> labelMapSize;
|
||||||
std::shared_ptr<CLabel> labelScenarioName;
|
std::shared_ptr<CLabel> labelScenarioName;
|
||||||
std::shared_ptr<CLabel> labelScenarioDescription;
|
std::shared_ptr<CLabel> labelScenarioDescription;
|
||||||
std::shared_ptr<CLabel> labelVictoryCondition;
|
std::shared_ptr<CLabel> labelVictoryCondition;
|
||||||
|
@ -186,3 +186,8 @@ SDL_Surface * Canvas::getInternalSurface()
|
|||||||
{
|
{
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect Canvas::getRenderArea() const
|
||||||
|
{
|
||||||
|
return renderArea;
|
||||||
|
}
|
||||||
|
@ -101,4 +101,7 @@ public:
|
|||||||
|
|
||||||
/// Compatibility method. AVOID USAGE. To be removed once SDL abstraction layer is finished.
|
/// Compatibility method. AVOID USAGE. To be removed once SDL abstraction layer is finished.
|
||||||
SDL_Surface * getInternalSurface();
|
SDL_Surface * getInternalSurface();
|
||||||
|
|
||||||
|
/// get the render area
|
||||||
|
Rect getRenderArea() const;
|
||||||
};
|
};
|
||||||
|
@ -135,8 +135,14 @@ std::shared_ptr<CPicture> CMapOverviewWidget::buildDrawMinimap(const JsonNode &
|
|||||||
if(id >= minimaps.size())
|
if(id >= minimaps.size())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
Rect minimapRect = minimaps[id].getRenderArea();
|
||||||
|
double maxSideLenghtSrc = std::max(minimapRect.w, minimapRect.h);
|
||||||
|
double maxSideLenghtDst = std::max(rect.w, rect.h);
|
||||||
|
double resize = maxSideLenghtSrc / maxSideLenghtDst;
|
||||||
|
Point newMinimapSize = Point(minimapRect.w / resize, minimapRect.h / resize);
|
||||||
|
|
||||||
Canvas canvasScaled = Canvas(Point(rect.w, rect.h));
|
Canvas canvasScaled = Canvas(Point(rect.w, rect.h));
|
||||||
canvasScaled.drawScaled(minimaps[id], Point(0, 0), Point(rect.w, rect.h));
|
canvasScaled.drawScaled(minimaps[id], Point((rect.w - newMinimapSize.x) / 2, (rect.h - newMinimapSize.y) / 2), newMinimapSize);
|
||||||
std::shared_ptr<IImage> img = GH.renderHandler().createImage(canvasScaled.getInternalSurface());
|
std::shared_ptr<IImage> img = GH.renderHandler().createImage(canvasScaled.getInternalSurface());
|
||||||
|
|
||||||
return std::make_shared<CPicture>(img, Point(rect.x, rect.y));
|
return std::make_shared<CPicture>(img, Point(rect.x, rect.y));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user