mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
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.
This commit is contained in:
parent
51ad49532b
commit
9012a25276
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 858 B |
BIN
Mods/vcmi/Data/UnitMaxMovementHighlight.png
Normal file
BIN
Mods/vcmi/Data/UnitMaxMovementHighlight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 422 B |
BIN
Mods/vcmi/Data/UnitMovementHighlight.png
Normal file
BIN
Mods/vcmi/Data/UnitMovementHighlight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 272 B |
@ -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<BattleHex> 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<IImage> 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<BattleHex> BattleFieldController::getMovementRangeForHoveredStack()
|
||||
return result;
|
||||
}
|
||||
|
||||
std::set<BattleHex> BattleFieldController::STUB_getMaxMovementRangeForHoveredStack()
|
||||
{
|
||||
std::set<BattleHex> 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<BattleHex> BattleFieldController::getHighlightedHexesForSpellRange()
|
||||
{
|
||||
std::set<BattleHex> result;
|
||||
@ -343,7 +360,8 @@ std::set<BattleHex> BattleFieldController::getHighlightedHexesMovementTarget()
|
||||
|
||||
void BattleFieldController::showHighlightedHexes(Canvas & canvas)
|
||||
{
|
||||
std::set<BattleHex> hoveredStackHexes = getMovementRangeForHoveredStack();
|
||||
std::set<BattleHex> hoveredStackMovementRangeHexes = getMovementRangeForHoveredStack();
|
||||
std::set<BattleHex> hoveredStackMaxMovementHexes = STUB_getMaxMovementRangeForHoveredStack();
|
||||
std::set<BattleHex> hoveredSpellHexes = getHighlightedHexesForSpellRange();
|
||||
std::set<BattleHex> 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<GameConstants::BFIELD_SIZE; ++b)
|
||||
for(int hex = 0; hex < GameConstants::BFIELD_SIZE; ++hex)
|
||||
{
|
||||
bool stack = hoveredStackHexes.count(b);
|
||||
bool mouse = hoveredMouseHexes.count(b);
|
||||
bool stackMovement = hoveredStackMovementRangeHexes.count(hex);
|
||||
bool stackMaxMovement = hoveredStackMaxMovementHexes.count(hex);
|
||||
bool mouse = hoveredMouseHexes.count(hex);
|
||||
|
||||
if(stack && mouse) // area where hovered stack can move shown with highlight. Because also affected by mouse cursor, shade as well
|
||||
if(stackMovement && mouse) // area where hovered stackMovement can move shown with highlight. Because also affected by mouse cursor, shade as well
|
||||
{
|
||||
showHighlightedHexForMovement(canvas, b, false);
|
||||
showShadedHex(canvas, b, true);
|
||||
showHighlightedHex(canvas, cellUnitMovementHighlight, hex, false);
|
||||
showHighlightedHex(canvas, cellShade, hex, true);
|
||||
}
|
||||
if(!stack && mouse) // hexes affected only at mouse cursor shown as shaded
|
||||
if(!stackMovement && mouse) // hexes affected only at mouse cursor shown as shaded
|
||||
{
|
||||
showShadedHex(canvas, b, true);
|
||||
showHighlightedHex(canvas, cellShade, hex, true);
|
||||
}
|
||||
if(stack && !mouse) // hexes where hovered stack can move shown with highlight
|
||||
if(stackMovement && !mouse) // hexes where hovered stackMovement can move shown with highlight
|
||||
{
|
||||
showHighlightedHexForMovement(canvas, b, false);
|
||||
showHighlightedHex(canvas, cellUnitMovementHighlight, hex, false);
|
||||
}
|
||||
if(stackMaxMovement)
|
||||
showHighlightedHex(canvas, cellUnitMaxMovementHighlight, hex, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ class BattleFieldController : public CIntObject
|
||||
std::shared_ptr<IImage> background;
|
||||
std::shared_ptr<IImage> cellBorder;
|
||||
std::shared_ptr<IImage> cellUnitMovementHighlight;
|
||||
std::shared_ptr<IImage> cellUnitMaxMovementHighlight;
|
||||
std::shared_ptr<IImage> 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<bool, GameConstants::BFIELD_SIZE> stackCountOutsideHexes;
|
||||
|
||||
void showHighlightedHexForMovement(Canvas& canvas, BattleHex hex, bool darkBorder);
|
||||
void showShadedHex(Canvas & to, BattleHex hex, bool darkBorder);
|
||||
void showHighlightedHex(Canvas & to, std::shared_ptr<IImage> highlight, BattleHex hex, bool darkBorder);
|
||||
|
||||
std::set<BattleHex> getHighlightedHexesForActiveStack();
|
||||
std::set<BattleHex> getMovementRangeForHoveredStack();
|
||||
std::set<BattleHex> STUB_getMaxMovementRangeForHoveredStack();
|
||||
std::set<BattleHex> getHighlightedHexesForSpellRange();
|
||||
std::set<BattleHex> getHighlightedHexesMovementTarget();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user