From 9012a25276ae20940d5d0bb21d3ca9f6d68f3e9b Mon Sep 17 00:00:00 2001 From: krs Date: Tue, 4 Apr 2023 22:34:56 +0300 Subject: [PATCH] Stub For Max Movement Range highlight When a creature is hovered., besides movement, for max possible movement, a hex in center of map is now highlighted. --- Mods/vcmi/Data/CCNSSh2.png | Bin 1370 -> 0 bytes Mods/vcmi/Data/CCNSShd.png | Bin 858 -> 0 bytes Mods/vcmi/Data/UnitMaxMovementHighlight.png | Bin 0 -> 422 bytes Mods/vcmi/Data/UnitMovementHighlight.png | Bin 0 -> 272 bytes client/battle/BattleFieldController.cpp | 69 +++++++++++++------- client/battle/BattleFieldController.h | 5 +- 6 files changed, 48 insertions(+), 26 deletions(-) delete mode 100644 Mods/vcmi/Data/CCNSSh2.png delete mode 100644 Mods/vcmi/Data/CCNSShd.png create mode 100644 Mods/vcmi/Data/UnitMaxMovementHighlight.png create mode 100644 Mods/vcmi/Data/UnitMovementHighlight.png diff --git a/Mods/vcmi/Data/CCNSSh2.png b/Mods/vcmi/Data/CCNSSh2.png deleted file mode 100644 index 2685b035135a0a20325776698e248c234abbe78e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1370 zcmV-g1*Q6lP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!2kdb!2!6DYwZ941n)^iK~!i%?U`G1 z6-5+<6K;lUq69%fB`8W2Jn+twZ~kSUeY46c#S1DFpb`}&2nGTellXm;=~I0=J#*%A z!k8*n)vBJ;HJMqfd+(m^o!PCet(m=yePz36@yfu^m}(Bp&dwI?$@%jOwkwbCKC<1- zJe!JvNceu5!|*1YgKxw22aoRjOS>!R6+#M+#2=th=qfw|orN{HzPPaT3GJ?+^9)47 z57H=Jv6FC-u)5{Nw8E;jfn>xD8ROh=X#!`+*?CS_JuP~AqHzc%;o`*|_#EcMAA-lX zFUO$i2k;hQbtF79JhuxP%|ImF5wA!3hxkB_sZ+Ws5GGXGE`2$yRcZ>6F3`=@;^`$ zxkUaQp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hq?`5kRUG`>4VR z#g1~Apx{q?#upi;@4G6T(DxAiK2e!UY5@BrO@{(2Dd7F{ITu;R?ifMZ9(uE>H>Ps$ z5a$J1<}tn%<1bZ~fcdjy^1X^Vk#LgaHOXL)(EdT%j07*qoM6N<$g7pi9SpWb4 diff --git a/Mods/vcmi/Data/UnitMaxMovementHighlight.png b/Mods/vcmi/Data/UnitMaxMovementHighlight.png new file mode 100644 index 0000000000000000000000000000000000000000..1ed74dda43db741f6cda3fd1644694809812b9ea GIT binary patch literal 422 zcmV;X0a^ZuP)cN80004PNkl$}R5CIX@rI^0qg;DL#O#i{g zKm4AN?9PWE@6An&adZ({XrZqW?d#t1;W)x?2{$753e-@)|uK zmL~=tf!`1|9i9-5$*~WY-*c*I{{w%vEbaLz!u$Ef=;$fN<^lMVWnu4|{DP03YIGI0 z0DrJNUhrvA(7uKmYytjgp`)W`jd*gfO-J(sC{wAq)VEM+lT*4erucse)$- z!x|2LodI~*>mNX3{O+Hl-W|YdsLsE>82?3)uHvdK|85|j4J2iN~(n^DVPTx`6#L@??_y$g5j{mY-%O>KDB zf7kX}%KP5*q~6x$2{(VNzR{lkRbs-{ZwnVjzj?E3# T%9joRdXd4?)z4*}Q$iB}fUk4L literal 0 HcmV?d00001 diff --git a/client/battle/BattleFieldController.cpp b/client/battle/BattleFieldController.cpp index 2de20d000..7eff5ed2b 100644 --- a/client/battle/BattleFieldController.cpp +++ b/client/battle/BattleFieldController.cpp @@ -43,8 +43,9 @@ BattleFieldController::BattleFieldController(BattleInterface & owner): //preparing cells and hexes cellBorder = IImage::createFromFile("CCELLGRD.BMP", EImageBlitMode::COLORKEY); - cellUnitMovementHighlight = IImage::createFromFile("CCNSSHD.BMP", EImageBlitMode::COLORKEY); cellShade = IImage::createFromFile("CCELLSHD.BMP"); + cellUnitMovementHighlight = IImage::createFromFile("UnitMovementHighlight.PNG", EImageBlitMode::COLORKEY); + cellUnitMaxMovementHighlight = IImage::createFromFile("UnitMaxMovementHighlight.PNG", EImageBlitMode::COLORKEY); if(!owner.siegeController) { @@ -181,7 +182,7 @@ void BattleFieldController::redrawBackgroundWithHexes() if(owner.siegeController) owner.siegeController->showAbsoluteObstacles(*backgroundWithHexes); - // show shaded hexes for active's stack valid movement and the hexes that it can attack + // show shaded hexes for active's stackMovement valid movement and the hexes that it can attack if(settings["battle"]["stackRange"].Bool()) { std::vector hexesToShade = occupyableHexes; @@ -207,20 +208,11 @@ void BattleFieldController::redrawBackgroundWithHexes() } } -void BattleFieldController::showShadedHex(Canvas & canvas, BattleHex hex, bool darkBorder) +void BattleFieldController::showHighlightedHex(Canvas & canvas, std::shared_ptr highlight, BattleHex hex, bool darkBorder) { Point hexPos = hexPositionLocal(hex).topLeft(); - canvas.draw(cellShade, hexPos); - if(!darkBorder && settings["battle"]["cellBorders"].Bool()) - canvas.draw(cellBorder, hexPos); -} - -void BattleFieldController::showHighlightedHexForMovement(Canvas & canvas, BattleHex hex, bool darkBorder) -{ - Point hexPos = hexPositionLocal(hex).topLeft(); - - canvas.draw(cellUnitMovementHighlight, hexPos); + canvas.draw(highlight, hexPos); if(!darkBorder && settings["battle"]["cellBorders"].Bool()) canvas.draw(cellBorder, hexPos); } @@ -267,6 +259,31 @@ std::set BattleFieldController::getMovementRangeForHoveredStack() return result; } +std::set BattleFieldController::STUB_getMaxMovementRangeForHoveredStack() +{ + std::set result; + + if (!owner.stacksController->getActiveStack()) + return result; + + if (!settings["battle"]["stackRange"].Bool()) + return result; + + auto hoveredHex = getHoveredHex(); + + // add max movement hexes for stack under mouse + const CStack * const hoveredStack = owner.curInt->cb->battleGetStackByPos(hoveredHex, true); + if(hoveredStack) + { + auto hex = BattleHex(10, 5); + + result.insert(hex); + } + + return result; + +} + std::set BattleFieldController::getHighlightedHexesForSpellRange() { std::set result; @@ -343,7 +360,8 @@ std::set BattleFieldController::getHighlightedHexesMovementTarget() void BattleFieldController::showHighlightedHexes(Canvas & canvas) { - std::set hoveredStackHexes = getMovementRangeForHoveredStack(); + std::set hoveredStackMovementRangeHexes = getMovementRangeForHoveredStack(); + std::set hoveredStackMaxMovementHexes = STUB_getMaxMovementRangeForHoveredStack(); std::set hoveredSpellHexes = getHighlightedHexesForSpellRange(); std::set hoveredMoveHexes = getHighlightedHexesMovementTarget(); @@ -352,24 +370,27 @@ void BattleFieldController::showHighlightedHexes(Canvas & canvas) auto const & hoveredMouseHexes = owner.actionsController->currentActionSpellcasting(getHoveredHex()) ? hoveredSpellHexes : hoveredMoveHexes; - for(int b=0; b background; std::shared_ptr cellBorder; std::shared_ptr cellUnitMovementHighlight; + std::shared_ptr cellUnitMaxMovementHighlight; std::shared_ptr cellShade; /// Canvas that contains background, hex grid (if enabled), absolute obstacles and movement range of active stack @@ -47,11 +48,11 @@ class BattleFieldController : public CIntObject /// hexes that when in front of a unit cause it's amount box to move back std::array stackCountOutsideHexes; - void showHighlightedHexForMovement(Canvas& canvas, BattleHex hex, bool darkBorder); - void showShadedHex(Canvas & to, BattleHex hex, bool darkBorder); + void showHighlightedHex(Canvas & to, std::shared_ptr highlight, BattleHex hex, bool darkBorder); std::set getHighlightedHexesForActiveStack(); std::set getMovementRangeForHoveredStack(); + std::set STUB_getMaxMovementRangeForHoveredStack(); std::set getHighlightedHexesForSpellRange(); std::set getHighlightedHexesMovementTarget();