mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
Moved range highlight transforms to config file
This commit is contained in:
@ -2,33 +2,33 @@
|
|||||||
"basepath" : "battle/rangeHighlights/green/",
|
"basepath" : "battle/rangeHighlights/green/",
|
||||||
"images" :
|
"images" :
|
||||||
[
|
[
|
||||||
{ "frame" : 0, "file" : "empty.png"}, // 000001 -> 00 empty frame
|
{ "frame" : 0, "file" : "empty.png"}, // 000001 -> 00 empty frame
|
||||||
|
|
||||||
// load single edges
|
// load single edges
|
||||||
{ "frame" : 1, "file" : "topLeft.png"}, //000001 -> 01 topLeft
|
{ "frame" : 1, "file" : "topLeft.png"}, //000001 -> 01 topLeft
|
||||||
{ "frame" : 2, "file" : "topLeft.png"}, //000010 -> 02 topRight
|
{ "frame" : 2, "file" : "topLeft.png", "verticalFlip" : true }, //000010 -> 02 topRight
|
||||||
{ "frame" : 3, "file" : "left.png"}, //000100 -> 04 right
|
{ "frame" : 3, "file" : "left.png", "verticalFlip" : true }, //000100 -> 04 right
|
||||||
{ "frame" : 4, "file" : "topLeft.png"}, //001000 -> 08 bottomRight
|
{ "frame" : 4, "file" : "topLeft.png", "verticalFlip" : true, "horizontalFlip" : true }, //001000 -> 08 bottomRight
|
||||||
{ "frame" : 5, "file" : "topLeft.png"}, //010000 -> 16 bottomLeft
|
{ "frame" : 5, "file" : "topLeft.png", "horizontalFlip" : true }, //010000 -> 16 bottomLeft
|
||||||
{ "frame" : 6, "file" : "left.png"}, //100000 -> 32 left
|
{ "frame" : 6, "file" : "left.png"}, //100000 -> 32 left
|
||||||
|
|
||||||
// load double edges
|
// load double edges
|
||||||
{ "frame" : 7, "file" : "top.png"}, //000011 -> 03 top
|
{ "frame" : 7, "file" : "top.png"}, //000011 -> 03 top
|
||||||
{ "frame" : 8, "file" : "top.png"}, //011000 -> 24 bottom
|
{ "frame" : 8, "file" : "top.png", "horizontalFlip" : true }, //011000 -> 24 bottom
|
||||||
{ "frame" : 9, "file" : "topLeftHalfCorner.png"}, //000110 -> 06 topRightHalfCorner
|
{ "frame" : 9, "file" : "topLeftHalfCorner.png", "verticalFlip" : true }, //000110 -> 06 topRightHalfCorner
|
||||||
{ "frame" : 10, "file" : "topLeftHalfCorner.png"}, //001100 -> 12 bottomRightHalfCorner
|
{ "frame" : 10, "file" : "topLeftHalfCorner.png", "verticalFlip" : true, "horizontalFlip" : true }, //001100 -> 12 bottomRightHalfCorner
|
||||||
{ "frame" : 11, "file" : "topLeftHalfCorner.png"}, //110000 -> 48 bottomLeftHalfCorner
|
{ "frame" : 11, "file" : "topLeftHalfCorner.png", "horizontalFlip" : true }, //110000 -> 48 bottomLeftHalfCorner
|
||||||
{ "frame" : 12, "file" : "topLeftHalfCorner.png"}, //100001 -> 33 topLeftHalfCorner
|
{ "frame" : 12, "file" : "topLeftHalfCorner.png"}, //100001 -> 33 topLeftHalfCorner
|
||||||
|
|
||||||
// load halves
|
// load halves
|
||||||
{ "frame" : 13, "file" : "leftHalf.png"}, //001110 -> 14 rightHalf
|
{ "frame" : 13, "file" : "leftHalf.png", "verticalFlip" : true}, //001110 -> 14 rightHalf
|
||||||
{ "frame" : 14, "file" : "leftHalf.png"}, //110001 -> 49 leftHalf
|
{ "frame" : 14, "file" : "leftHalf.png"}, //110001 -> 49 leftHalf
|
||||||
|
|
||||||
// load corners
|
// load corners
|
||||||
{ "frame" : 15, "file" : "topLeftCorner.png"}, //000111 -> 07 topRightCorner
|
{ "frame" : 15, "file" : "topLeftCorner.png", "verticalFlip" : true }, //000111 -> 07 topRightCorner
|
||||||
{ "frame" : 16, "file" : "topLeftCorner.png"}, //011100 -> 28 bottomRightCorner
|
{ "frame" : 16, "file" : "topLeftCorner.png", "verticalFlip" : true, "horizontalFlip" : true }, //011100 -> 28 bottomRightCorner
|
||||||
{ "frame" : 17, "file" : "topLeftCorner.png"}, //111000 -> 56 bottomLeftCorner
|
{ "frame" : 17, "file" : "topLeftCorner.png", "horizontalFlip" : true }, //111000 -> 56 bottomLeftCorner
|
||||||
{ "frame" : 18, "file" : "topLeftCorner.png"} //100011 -> 35 topLeftCorner
|
{ "frame" : 18, "file" : "topLeftCorner.png"} //100011 -> 35 topLeftCorner
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,33 +2,33 @@
|
|||||||
"basepath" : "battle/rangeHighlights/red/",
|
"basepath" : "battle/rangeHighlights/red/",
|
||||||
"images" :
|
"images" :
|
||||||
[
|
[
|
||||||
{ "frame" : 0, "file" : "empty.png"}, // 000001 -> 00 empty frame
|
{ "frame" : 0, "file" : "empty.png"}, // 000001 -> 00 empty frame
|
||||||
|
|
||||||
// load single edges
|
// load single edges
|
||||||
{ "frame" : 1, "file" : "topLeft.png"}, //000001 -> 01 topLeft
|
{ "frame" : 1, "file" : "topLeft.png"}, //000001 -> 01 topLeft
|
||||||
{ "frame" : 2, "file" : "topLeft.png"}, //000010 -> 02 topRight
|
{ "frame" : 2, "file" : "topLeft.png", "verticalFlip" : true }, //000010 -> 02 topRight
|
||||||
{ "frame" : 3, "file" : "left.png"}, //000100 -> 04 right
|
{ "frame" : 3, "file" : "left.png", "verticalFlip" : true }, //000100 -> 04 right
|
||||||
{ "frame" : 4, "file" : "topLeft.png"}, //001000 -> 08 bottomRight
|
{ "frame" : 4, "file" : "topLeft.png", "verticalFlip" : true, "horizontalFlip" : true }, //001000 -> 08 bottomRight
|
||||||
{ "frame" : 5, "file" : "topLeft.png"}, //010000 -> 16 bottomLeft
|
{ "frame" : 5, "file" : "topLeft.png", "horizontalFlip" : true }, //010000 -> 16 bottomLeft
|
||||||
{ "frame" : 6, "file" : "left.png"}, //100000 -> 32 left
|
{ "frame" : 6, "file" : "left.png"}, //100000 -> 32 left
|
||||||
|
|
||||||
// load double edges
|
// load double edges
|
||||||
{ "frame" : 7, "file" : "top.png"}, //000011 -> 03 top
|
{ "frame" : 7, "file" : "top.png"}, //000011 -> 03 top
|
||||||
{ "frame" : 8, "file" : "top.png"}, //011000 -> 24 bottom
|
{ "frame" : 8, "file" : "top.png", "horizontalFlip" : true }, //011000 -> 24 bottom
|
||||||
{ "frame" : 9, "file" : "topLeftHalfCorner.png"}, //000110 -> 06 topRightHalfCorner
|
{ "frame" : 9, "file" : "topLeftHalfCorner.png", "verticalFlip" : true }, //000110 -> 06 topRightHalfCorner
|
||||||
{ "frame" : 10, "file" : "topLeftHalfCorner.png"}, //001100 -> 12 bottomRightHalfCorner
|
{ "frame" : 10, "file" : "topLeftHalfCorner.png", "verticalFlip" : true, "horizontalFlip" : true }, //001100 -> 12 bottomRightHalfCorner
|
||||||
{ "frame" : 11, "file" : "topLeftHalfCorner.png"}, //110000 -> 48 bottomLeftHalfCorner
|
{ "frame" : 11, "file" : "topLeftHalfCorner.png", "horizontalFlip" : true }, //110000 -> 48 bottomLeftHalfCorner
|
||||||
{ "frame" : 12, "file" : "topLeftHalfCorner.png"}, //100001 -> 33 topLeftHalfCorner
|
{ "frame" : 12, "file" : "topLeftHalfCorner.png"}, //100001 -> 33 topLeftHalfCorner
|
||||||
|
|
||||||
// load halves
|
// load halves
|
||||||
{ "frame" : 13, "file" : "leftHalf.png"}, //001110 -> 14 rightHalf
|
{ "frame" : 13, "file" : "leftHalf.png", "verticalFlip" : true}, //001110 -> 14 rightHalf
|
||||||
{ "frame" : 14, "file" : "leftHalf.png"}, //110001 -> 49 leftHalf
|
{ "frame" : 14, "file" : "leftHalf.png"}, //110001 -> 49 leftHalf
|
||||||
|
|
||||||
// load corners
|
// load corners
|
||||||
{ "frame" : 15, "file" : "topLeftCorner.png"}, //000111 -> 07 topRightCorner
|
{ "frame" : 15, "file" : "topLeftCorner.png", "verticalFlip" : true }, //000111 -> 07 topRightCorner
|
||||||
{ "frame" : 16, "file" : "topLeftCorner.png"}, //011100 -> 28 bottomRightCorner
|
{ "frame" : 16, "file" : "topLeftCorner.png", "verticalFlip" : true, "horizontalFlip" : true }, //011100 -> 28 bottomRightCorner
|
||||||
{ "frame" : 17, "file" : "topLeftCorner.png"}, //111000 -> 56 bottomLeftCorner
|
{ "frame" : 17, "file" : "topLeftCorner.png", "horizontalFlip" : true }, //111000 -> 56 bottomLeftCorner
|
||||||
{ "frame" : 18, "file" : "topLeftCorner.png"} //100011 -> 35 topLeftCorner
|
{ "frame" : 18, "file" : "topLeftCorner.png"} //100011 -> 35 topLeftCorner
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,39 +82,30 @@ namespace HexMasks
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<int, int> hexEdgeMaskToFrameIndex;
|
static const std::map<int, int> hexEdgeMaskToFrameIndex =
|
||||||
|
|
||||||
// Maps HexEdgesMask to "Frame" indexes for range highlight images
|
|
||||||
void initializeHexEdgeMaskToFrameIndex()
|
|
||||||
{
|
{
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::empty] = 0;
|
{ HexMasks::empty, 0 },
|
||||||
|
{ HexMasks::topLeft, 1 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::topLeft] = 1;
|
{ HexMasks::topRight, 2 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::topRight] = 2;
|
{ HexMasks::right, 3 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::right] = 3;
|
{ HexMasks::bottomRight, 4 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::bottomRight] = 4;
|
{ HexMasks::bottomLeft, 5 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::bottomLeft] = 5;
|
{ HexMasks::left, 6 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::left] = 6;
|
{ HexMasks::top, 7 },
|
||||||
|
{ HexMasks::bottom, 8 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::top] = 7;
|
{ HexMasks::topRightHalfCorner, 9 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::bottom] = 8;
|
{ HexMasks::bottomRightHalfCorner, 10 },
|
||||||
|
{ HexMasks::bottomLeftHalfCorner, 11 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::topRightHalfCorner] = 9;
|
{ HexMasks::topLeftHalfCorner, 12 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::bottomRightHalfCorner] = 10;
|
{ HexMasks::rightTopAndBottom, 13 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::bottomLeftHalfCorner] = 11;
|
{ HexMasks::leftTopAndBottom, 14 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::topLeftHalfCorner] = 12;
|
{ HexMasks::rightHalf, 13 },
|
||||||
|
{ HexMasks::leftHalf, 14 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::rightTopAndBottom] = 13;
|
{ HexMasks::topRightCorner, 15 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::leftTopAndBottom] = 14;
|
{ HexMasks::bottomRightCorner, 16 },
|
||||||
|
{ HexMasks::bottomLeftCorner, 17 },
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::rightHalf] = 13;
|
{ HexMasks::topLeftCorner, 18 }
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::leftHalf] = 14;
|
};
|
||||||
|
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::topRightCorner] = 15;
|
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::bottomRightCorner] = 16;
|
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::bottomLeftCorner] = 17;
|
|
||||||
hexEdgeMaskToFrameIndex[HexMasks::topLeftCorner] = 18;
|
|
||||||
}
|
|
||||||
|
|
||||||
BattleFieldController::BattleFieldController(BattleInterface & owner):
|
BattleFieldController::BattleFieldController(BattleInterface & owner):
|
||||||
owner(owner)
|
owner(owner)
|
||||||
@ -130,14 +121,9 @@ BattleFieldController::BattleFieldController(BattleInterface & owner):
|
|||||||
attackCursors = GH.renderHandler().loadAnimation(AnimationPath::builtin("CRCOMBAT"), EImageBlitMode::COLORKEY);
|
attackCursors = GH.renderHandler().loadAnimation(AnimationPath::builtin("CRCOMBAT"), EImageBlitMode::COLORKEY);
|
||||||
spellCursors = GH.renderHandler().loadAnimation(AnimationPath::builtin("CRSPELL"), EImageBlitMode::COLORKEY);
|
spellCursors = GH.renderHandler().loadAnimation(AnimationPath::builtin("CRSPELL"), EImageBlitMode::COLORKEY);
|
||||||
|
|
||||||
initializeHexEdgeMaskToFrameIndex();
|
|
||||||
|
|
||||||
rangedFullDamageLimitImages = GH.renderHandler().loadAnimation(AnimationPath::builtin("battle/rangeHighlights/rangeHighlightsGreen.json"), EImageBlitMode::COLORKEY);
|
rangedFullDamageLimitImages = GH.renderHandler().loadAnimation(AnimationPath::builtin("battle/rangeHighlights/rangeHighlightsGreen.json"), EImageBlitMode::COLORKEY);
|
||||||
shootingRangeLimitImages = GH.renderHandler().loadAnimation(AnimationPath::builtin("battle/rangeHighlights/rangeHighlightsRed.json"), EImageBlitMode::COLORKEY);
|
shootingRangeLimitImages = GH.renderHandler().loadAnimation(AnimationPath::builtin("battle/rangeHighlights/rangeHighlightsRed.json"), EImageBlitMode::COLORKEY);
|
||||||
|
|
||||||
flipRangeLimitImagesIntoPositions(rangedFullDamageLimitImages);
|
|
||||||
flipRangeLimitImagesIntoPositions(shootingRangeLimitImages);
|
|
||||||
|
|
||||||
if(!owner.siegeController)
|
if(!owner.siegeController)
|
||||||
{
|
{
|
||||||
auto bfieldType = owner.getBattle()->battleGetBattlefieldType();
|
auto bfieldType = owner.getBattle()->battleGetBattlefieldType();
|
||||||
@ -536,7 +522,7 @@ std::vector<std::shared_ptr<IImage>> BattleFieldController::calculateRangeLimitH
|
|||||||
mask.set(direction);
|
mask.set(direction);
|
||||||
|
|
||||||
uint8_t imageKey = static_cast<uint8_t>(mask.to_ulong());
|
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;
|
return output;
|
||||||
@ -550,25 +536,6 @@ void BattleFieldController::calculateRangeLimitAndHighlightImages(uint8_t distan
|
|||||||
rangeLimitHexesHighlights = calculateRangeLimitHighlightImages(rangeLimitNeighbourDirections, rangeLimitImages);
|
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)
|
void BattleFieldController::showHighlightedHexes(Canvas & canvas)
|
||||||
{
|
{
|
||||||
std::vector<BattleHex> rangedFullDamageLimitHexes;
|
std::vector<BattleHex> rangedFullDamageLimitHexes;
|
||||||
|
@ -84,9 +84,6 @@ class BattleFieldController : public CIntObject
|
|||||||
/// calculates all hexes for a range limit and what images to be shown as highlight for each of the hexes
|
/// 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> rangeLimitImages, std::vector<BattleHex> & rangeLimitHexes, std::vector<std::shared_ptr<IImage>> & rangeLimitHexesHighlights);
|
void calculateRangeLimitAndHighlightImages(uint8_t distance, std::shared_ptr<CAnimation> rangeLimitImages, std::vector<BattleHex> & rangeLimitHexes, std::vector<std::shared_ptr<IImage>> & rangeLimitHexesHighlights);
|
||||||
|
|
||||||
/// to reduce the number of source images used, some images will be used as flipped versions of preloaded ones
|
|
||||||
void flipRangeLimitImagesIntoPositions(std::shared_ptr<CAnimation> images);
|
|
||||||
|
|
||||||
void showBackground(Canvas & canvas);
|
void showBackground(Canvas & canvas);
|
||||||
void showBackgroundImage(Canvas & canvas);
|
void showBackgroundImage(Canvas & canvas);
|
||||||
void showBackgroundImageWithHexes(Canvas & canvas);
|
void showBackgroundImageWithHexes(Canvas & canvas);
|
||||||
|
@ -65,10 +65,10 @@ void RenderHandler::initFromJson(AnimationLayoutMap & source, const JsonNode & c
|
|||||||
|
|
||||||
for(const JsonNode & frame : group["frames"].Vector())
|
for(const JsonNode & frame : group["frames"].Vector())
|
||||||
{
|
{
|
||||||
JsonNode toAdd;
|
JsonNode toAdd = frame;
|
||||||
JsonUtils::inherit(toAdd, base);
|
JsonUtils::inherit(toAdd, base);
|
||||||
toAdd["file"].String() = basepath + frame.String();
|
toAdd["file"].String() = basepath + frame.String();
|
||||||
source[groupID].push_back(ImageLocator(toAdd));
|
source[groupID].emplace_back(toAdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ void RenderHandler::initFromJson(AnimationLayoutMap & source, const JsonNode & c
|
|||||||
if (source[group].size() <= frame)
|
if (source[group].size() <= frame)
|
||||||
source[group].resize(frame+1);
|
source[group].resize(frame+1);
|
||||||
|
|
||||||
JsonNode toAdd;
|
JsonNode toAdd = node;
|
||||||
JsonUtils::inherit(toAdd, base);
|
JsonUtils::inherit(toAdd, base);
|
||||||
toAdd["file"].String() = basepath + node["file"].String();
|
toAdd["file"].String() = basepath + node["file"].String();
|
||||||
source[group][frame] = ImageLocator(toAdd);
|
source[group][frame] = ImageLocator(toAdd);
|
||||||
|
Reference in New Issue
Block a user