1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

calculateRangeLimitAndHighlightImages() is now separate function

This commit is contained in:
krs 2023-06-18 12:03:12 +03:00
parent 756dd398c2
commit 1ba9a2a42a
2 changed files with 13 additions and 8 deletions

View File

@ -533,6 +533,14 @@ std::vector<std::shared_ptr<IImage>> BattleFieldController::calculateRangeHighli
return output;
}
void BattleFieldController::calculateRangeLimitAndHighlightImages(uint8_t distance, std::shared_ptr<CAnimation> rangeLimitImages, std::vector<BattleHex> & rangeLimitHexes, std::vector<std::shared_ptr<IImage>> & rangeLimitHexesHighligts)
{
std::vector<BattleHex> rangeHexes = getRangeHexes(hoveredHex, distance);
rangeLimitHexes = getRangeLimitHexes(hoveredHex, rangeHexes, distance);
std::vector<std::vector<BattleHex::EDir>> rangeLimitNeighbourDirections = getOutsideNeighbourDirectionsForLimitHexes(rangeHexes, rangeLimitHexes);
rangeLimitHexesHighligts = calculateRangeHighlightImages(rangeLimitNeighbourDirections, rangeLimitImages);
}
void BattleFieldController::flipRangedFullDamageLimitImagesIntoPositions(std::shared_ptr<CAnimation> images)
{
images->getImage(hexEdgeMaskToFrameIndex[HexMasks::topRight])->verticalFlip();
@ -576,17 +584,11 @@ void BattleFieldController::showHighlightedHexes(Canvas & canvas)
{
// calculate array with highlight images for ranged full damage limit
auto rangedFullDamageDistance = hoveredStack->getRangedFullDamageDistance();
std::vector<BattleHex> rangedFullDamageHexes = getRangeHexes(hoveredHex, rangedFullDamageDistance);
rangedFullDamageLimitHexes = getRangeLimitHexes(hoveredHex, rangedFullDamageHexes, rangedFullDamageDistance);
std::vector<std::vector<BattleHex::EDir>> rangedFullDamageLimitHexesNeighbourDirections = getOutsideNeighbourDirectionsForLimitHexes(rangedFullDamageHexes, rangedFullDamageLimitHexes);
rangedFullDamageLimitHexesHighligts = calculateRangeHighlightImages(rangedFullDamageLimitHexesNeighbourDirections, rangedFullDamageLimitImages);
calculateRangeLimitAndHighlightImages(rangedFullDamageDistance, rangedFullDamageLimitImages, rangedFullDamageLimitHexes, rangedFullDamageLimitHexesHighligts);
// calculate array with highlight images for shooting range limit
auto shootingRangeDistance = hoveredStack->getSootingRangeDistance();
std::vector<BattleHex> shootingRangeHexes = getRangeHexes(hoveredHex, shootingRangeDistance);
shootingRangeLimitHexes = getRangeLimitHexes(hoveredHex, shootingRangeHexes, shootingRangeDistance);
std::vector<std::vector<BattleHex::EDir>> shootingRangeLimitHexesNeighbourDirections = getOutsideNeighbourDirectionsForLimitHexes(shootingRangeHexes, shootingRangeLimitHexes);
shootingRangeLimitHexesHighligts = calculateRangeHighlightImages(shootingRangeLimitHexesNeighbourDirections, shootingRangeLimitImages);
calculateRangeLimitAndHighlightImages(shootingRangeDistance, shootingRangeLimitImages, shootingRangeLimitHexes, shootingRangeLimitHexesHighligts);
}
auto const & hoveredMouseHexes = owner.actionsController->currentActionSpellcasting(getHoveredHex()) ? hoveredSpellHexes : hoveredMoveHexes;

View File

@ -74,6 +74,9 @@ class BattleFieldController : public CIntObject
/// based on this mask the corresponding image is selected
std::vector<std::shared_ptr<IImage>> calculateRangeHighlightImages(std::vector<std::vector<BattleHex::EDir>> hexesNeighbourDirections, std::shared_ptr<CAnimation> limitImages);
/// calculates all hexes for a range limit and what images to be shown as highlight for each of the hexes
void calculateRangeLimitAndHighlightImages(uint8_t distance, std::shared_ptr<CAnimation> rangedFullDamageLimitImages, std::vector<BattleHex> & rangedFullDamageLimitHexes, std::vector<std::shared_ptr<IImage>> & rangedFullDamageLimitHexesHighligts);
/// to reduce the number of source images used, some images will be used as flipped versions of preloaded ones
void flipRangedFullDamageLimitImagesIntoPositions(std::shared_ptr<CAnimation> images);