mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
make queue interactable
This commit is contained in:
parent
9cf5c6a6c1
commit
f4bff876d5
@ -11,6 +11,7 @@
|
||||
#include "BattleFieldController.h"
|
||||
|
||||
#include "BattleInterface.h"
|
||||
#include "BattleWindow.h"
|
||||
#include "BattleActionsController.h"
|
||||
#include "BattleInterfaceClasses.h"
|
||||
#include "BattleEffectsController.h"
|
||||
@ -360,10 +361,7 @@ std::set<BattleHex> BattleFieldController::getMovementRangeForHoveredStack()
|
||||
if (!settings["battle"]["movementHighlightOnHover"].Bool() && !GH.isKeyboardShiftDown())
|
||||
return result;
|
||||
|
||||
auto hoveredHex = getHoveredHex();
|
||||
|
||||
// add possible movement hexes for stack under mouse
|
||||
const CStack * const hoveredStack = owner.getBattle()->battleGetStackByPos(hoveredHex, true);
|
||||
auto hoveredStack = getHoveredStack();
|
||||
if(hoveredStack)
|
||||
{
|
||||
std::vector<BattleHex> v = owner.getBattle()->battleGetAvailableHexes(hoveredStack, true, true, nullptr);
|
||||
@ -590,11 +588,9 @@ void BattleFieldController::showHighlightedHexes(Canvas & canvas)
|
||||
std::set<BattleHex> hoveredSpellHexes = getHighlightedHexesForSpellRange();
|
||||
std::set<BattleHex> hoveredMoveHexes = getHighlightedHexesForMovementTarget();
|
||||
|
||||
BattleHex hoveredHex = getHoveredHex();
|
||||
if(hoveredHex == BattleHex::INVALID)
|
||||
return;
|
||||
|
||||
const CStack * hoveredStack = getHoveredStack();
|
||||
if(!hoveredStack)
|
||||
return;
|
||||
|
||||
// skip range limit calculations if unit hovered is not a shooter
|
||||
if(hoveredStack && hoveredStack->isShooter())
|
||||
@ -608,7 +604,7 @@ void BattleFieldController::showHighlightedHexes(Canvas & canvas)
|
||||
calculateRangeLimitAndHighlightImages(shootingRangeDistance, shootingRangeLimitImages, shootingRangeLimitHexes, shootingRangeLimitHexesHighligts);
|
||||
}
|
||||
|
||||
auto const & hoveredMouseHexes = owner.actionsController->currentActionSpellcasting(getHoveredHex()) ? hoveredSpellHexes : hoveredMoveHexes;
|
||||
auto const & hoveredMouseHexes = getHoveredHex() != BattleHex::INVALID && owner.actionsController->currentActionSpellcasting(getHoveredHex()) ? hoveredSpellHexes : hoveredMoveHexes;
|
||||
|
||||
for(int hex = 0; hex < GameConstants::BFIELD_SIZE; ++hex)
|
||||
{
|
||||
@ -676,6 +672,14 @@ const CStack* BattleFieldController::getHoveredStack()
|
||||
auto hoveredHex = getHoveredHex();
|
||||
const CStack* hoveredStack = owner.getBattle()->battleGetStackByPos(hoveredHex, true);
|
||||
|
||||
if(owner.windowObject->getQueueHoveredUnitId().has_value())
|
||||
{
|
||||
auto stacks = owner.getBattle()->battleGetAllStacks();
|
||||
for(const CStack * stack : stacks)
|
||||
if(stack->unitId() == *owner.windowObject->getQueueHoveredUnitId())
|
||||
hoveredStack = stack;
|
||||
}
|
||||
|
||||
return hoveredStack;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "../widgets/TextControls.h"
|
||||
#include "../widgets/MiscWidgets.h"
|
||||
#include "../windows/CMessage.h"
|
||||
#include "../windows/CCreatureWindow.h"
|
||||
#include "../windows/CSpellWindow.h"
|
||||
#include "../render/CAnimation.h"
|
||||
#include "../render/IRenderHandler.h"
|
||||
@ -1053,3 +1054,11 @@ void StackQueue::StackBox::show(Canvas & to)
|
||||
if(isBoundUnitHighlighted())
|
||||
to.drawBorder(background->pos, Colors::CYAN, 2);
|
||||
}
|
||||
|
||||
void StackQueue::StackBox::showPopupWindow(const Point & cursorPosition)
|
||||
{
|
||||
auto stacks = owner->owner.getBattle()->battleGetAllStacks();
|
||||
for(const CStack * stack : stacks)
|
||||
if(boundUnitID.has_value() && stack->unitId() == *boundUnitID)
|
||||
GH.windows().createAndPushWindow<CStackWindow>(stack, true);
|
||||
}
|
||||
|
@ -230,6 +230,7 @@ class StackQueue : public CIntObject
|
||||
|
||||
void show(Canvas & to) override;
|
||||
void showAll(Canvas & to) override;
|
||||
void showPopupWindow(const Point & cursorPosition) override;
|
||||
|
||||
bool isBoundUnitHighlighted() const;
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user