|
|
@@ -82,39 +82,30 @@ namespace HexMasks
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-std::map<int, int> hexEdgeMaskToFrameIndex;
|
|
|
-
|
|
|
-// Maps HexEdgesMask to "Frame" indexes for range highlight images
|
|
|
-void initializeHexEdgeMaskToFrameIndex()
|
|
|
-{
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::empty] = 0;
|
|
|
-
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::topLeft] = 1;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::topRight] = 2;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::right] = 3;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::bottomRight] = 4;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::bottomLeft] = 5;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::left] = 6;
|
|
|
-
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::top] = 7;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::bottom] = 8;
|
|
|
-
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::topRightHalfCorner] = 9;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::bottomRightHalfCorner] = 10;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::bottomLeftHalfCorner] = 11;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::topLeftHalfCorner] = 12;
|
|
|
-
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::rightTopAndBottom] = 13;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::leftTopAndBottom] = 14;
|
|
|
-
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::rightHalf] = 13;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::leftHalf] = 14;
|
|
|
-
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::topRightCorner] = 15;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::bottomRightCorner] = 16;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::bottomLeftCorner] = 17;
|
|
|
- hexEdgeMaskToFrameIndex[HexMasks::topLeftCorner] = 18;
|
|
|
-}
|
|
|
+static const std::map<int, int> hexEdgeMaskToFrameIndex =
|
|
|
+{
|
|
|
+ { HexMasks::empty, 0 },
|
|
|
+ { HexMasks::topLeft, 1 },
|
|
|
+ { HexMasks::topRight, 2 },
|
|
|
+ { HexMasks::right, 3 },
|
|
|
+ { HexMasks::bottomRight, 4 },
|
|
|
+ { HexMasks::bottomLeft, 5 },
|
|
|
+ { HexMasks::left, 6 },
|
|
|
+ { HexMasks::top, 7 },
|
|
|
+ { HexMasks::bottom, 8 },
|
|
|
+ { HexMasks::topRightHalfCorner, 9 },
|
|
|
+ { HexMasks::bottomRightHalfCorner, 10 },
|
|
|
+ { HexMasks::bottomLeftHalfCorner, 11 },
|
|
|
+ { HexMasks::topLeftHalfCorner, 12 },
|
|
|
+ { HexMasks::rightTopAndBottom, 13 },
|
|
|
+ { HexMasks::leftTopAndBottom, 14 },
|
|
|
+ { HexMasks::rightHalf, 13 },
|
|
|
+ { HexMasks::leftHalf, 14 },
|
|
|
+ { HexMasks::topRightCorner, 15 },
|
|
|
+ { HexMasks::bottomRightCorner, 16 },
|
|
|
+ { HexMasks::bottomLeftCorner, 17 },
|
|
|
+ { HexMasks::topLeftCorner, 18 }
|
|
|
+};
|
|
|
|
|
|
BattleFieldController::BattleFieldController(BattleInterface & owner):
|
|
|
owner(owner)
|
|
|
@@ -130,14 +121,9 @@ BattleFieldController::BattleFieldController(BattleInterface & owner):
|
|
|
attackCursors = GH.renderHandler().loadAnimation(AnimationPath::builtin("CRCOMBAT"), EImageBlitMode::COLORKEY);
|
|
|
spellCursors = GH.renderHandler().loadAnimation(AnimationPath::builtin("CRSPELL"), EImageBlitMode::COLORKEY);
|
|
|
|
|
|
- initializeHexEdgeMaskToFrameIndex();
|
|
|
-
|
|
|
rangedFullDamageLimitImages = GH.renderHandler().loadAnimation(AnimationPath::builtin("battle/rangeHighlights/rangeHighlightsGreen.json"), EImageBlitMode::COLORKEY);
|
|
|
shootingRangeLimitImages = GH.renderHandler().loadAnimation(AnimationPath::builtin("battle/rangeHighlights/rangeHighlightsRed.json"), EImageBlitMode::COLORKEY);
|
|
|
|
|
|
- flipRangeLimitImagesIntoPositions(rangedFullDamageLimitImages);
|
|
|
- flipRangeLimitImagesIntoPositions(shootingRangeLimitImages);
|
|
|
-
|
|
|
if(!owner.siegeController)
|
|
|
{
|
|
|
auto bfieldType = owner.getBattle()->battleGetBattlefieldType();
|
|
|
@@ -536,7 +522,7 @@ std::vector<std::shared_ptr<IImage>> BattleFieldController::calculateRangeLimitH
|
|
|
mask.set(direction);
|
|
|
|
|
|
uint8_t imageKey = static_cast<uint8_t>(mask.to_ulong());
|
|
|
- output.push_back(limitImages->getImage(hexEdgeMaskToFrameIndex[imageKey]));
|
|
|
+ output.push_back(limitImages->getImage(hexEdgeMaskToFrameIndex.at(imageKey)));
|
|
|
}
|
|
|
|
|
|
return output;
|
|
|
@@ -550,25 +536,6 @@ void BattleFieldController::calculateRangeLimitAndHighlightImages(uint8_t distan
|
|
|
rangeLimitHexesHighlights = calculateRangeLimitHighlightImages(rangeLimitNeighbourDirections, rangeLimitImages);
|
|
|
}
|
|
|
|
|
|
-void BattleFieldController::flipRangeLimitImagesIntoPositions(std::shared_ptr<CAnimation> images)
|
|
|
-{
|
|
|
- images->verticalFlip(hexEdgeMaskToFrameIndex[HexMasks::topRight]);
|
|
|
- images->verticalFlip(hexEdgeMaskToFrameIndex[HexMasks::right]);
|
|
|
- images->verticalFlip(hexEdgeMaskToFrameIndex[HexMasks::bottomRight]);
|
|
|
- images->horizontalFlip(hexEdgeMaskToFrameIndex[HexMasks::bottomRight]);
|
|
|
- images->horizontalFlip(hexEdgeMaskToFrameIndex[HexMasks::bottomLeft]);
|
|
|
- images->horizontalFlip(hexEdgeMaskToFrameIndex[HexMasks::bottom]);
|
|
|
- images->verticalFlip(hexEdgeMaskToFrameIndex[HexMasks::topRightHalfCorner]);
|
|
|
- images->verticalFlip(hexEdgeMaskToFrameIndex[HexMasks::bottomRightHalfCorner]);
|
|
|
- images->horizontalFlip(hexEdgeMaskToFrameIndex[HexMasks::bottomRightHalfCorner]);
|
|
|
- images->horizontalFlip(hexEdgeMaskToFrameIndex[HexMasks::bottomLeftHalfCorner]);
|
|
|
- images->verticalFlip(hexEdgeMaskToFrameIndex[HexMasks::rightHalf]);
|
|
|
- images->verticalFlip(hexEdgeMaskToFrameIndex[HexMasks::topRightCorner]);
|
|
|
- images->verticalFlip(hexEdgeMaskToFrameIndex[HexMasks::bottomRightCorner]);
|
|
|
- images->horizontalFlip(hexEdgeMaskToFrameIndex[HexMasks::bottomRightCorner]);
|
|
|
- images->horizontalFlip(hexEdgeMaskToFrameIndex[HexMasks::bottomLeftCorner]);
|
|
|
-}
|
|
|
-
|
|
|
void BattleFieldController::showHighlightedHexes(Canvas & canvas)
|
|
|
{
|
|
|
std::vector<BattleHex> rangedFullDamageLimitHexes;
|