mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Changes for BattleInterface classes according to code review:
- added documentation comments for classes, members and methods - added const specifier to methods where applicable - renamed some methods with more clear name - removed some commented-out or unused code
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CBattleFieldController.h, part of VCMI engine
|
||||
* BattleFieldController.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
@@ -27,6 +27,7 @@ class Canvas;
|
||||
class IImage;
|
||||
class BattleInterface;
|
||||
|
||||
/// Handles battlefield grid as well as rendering of background layer of battle interface
|
||||
class BattleFieldController : public CIntObject
|
||||
{
|
||||
BattleInterface * owner;
|
||||
@@ -35,19 +36,22 @@ class BattleFieldController : public CIntObject
|
||||
std::shared_ptr<IImage> cellBorder;
|
||||
std::shared_ptr<IImage> cellShade;
|
||||
|
||||
std::unique_ptr<Canvas> cellBorders;
|
||||
|
||||
/// Canvas that contains background, hex grid (if enabled), absolute obstacles and movement range of active stack
|
||||
std::unique_ptr<Canvas> backgroundWithHexes;
|
||||
|
||||
//BattleHex previouslyHoveredHex; //number of hex that was hovered by the cursor a while ago
|
||||
//BattleHex currentlyHoveredHex; //number of hex that is supposed to be hovered (for a while it may be inappropriately set, but will be renewed soon)
|
||||
BattleHex attackingHex; //hex from which the stack would perform attack with current cursor
|
||||
/// Canvas that contains cell borders of all tiles in the battlefield
|
||||
std::unique_ptr<Canvas> cellBorders;
|
||||
|
||||
std::vector<BattleHex> occupyableHexes; //hexes available for active stack
|
||||
std::array<bool, GameConstants::BFIELD_SIZE> stackCountOutsideHexes; // hexes that when in front of a unit cause it's amount box to move back
|
||||
/// hex from which the stack would perform attack with current cursor
|
||||
BattleHex attackingHex;
|
||||
|
||||
std::vector<std::shared_ptr<ClickableHex>> bfield; //11 lines, 17 hexes on each
|
||||
/// hexes to which currently active stack can move
|
||||
std::vector<BattleHex> occupyableHexes;
|
||||
|
||||
/// hexes that when in front of a unit cause it's amount box to move back
|
||||
std::array<bool, GameConstants::BFIELD_SIZE> stackCountOutsideHexes;
|
||||
|
||||
std::vector<std::shared_ptr<ClickableHex>> bfield;
|
||||
|
||||
void showHighlightedHex(Canvas & to, BattleHex hex, bool darkBorder);
|
||||
|
||||
@@ -65,14 +69,24 @@ public:
|
||||
void redrawBackgroundWithHexes();
|
||||
void renderBattlefield(Canvas & canvas);
|
||||
|
||||
/// Returns position of hex relative to owner (BattleInterface)
|
||||
Rect hexPositionLocal(BattleHex hex) const;
|
||||
Rect hexPosition(BattleHex hex) const;
|
||||
|
||||
/// Returns position of hex relative to game window
|
||||
Rect hexPositionAbsolute(BattleHex hex) const;
|
||||
|
||||
/// Checks whether selected pixel is transparent, uses local coordinates of a hex
|
||||
bool isPixelInHex(Point const & position);
|
||||
|
||||
/// Returns ID of currently hovered hex or BattleHex::INVALID if none
|
||||
BattleHex getHoveredHex();
|
||||
|
||||
/// returns true if selected tile can be attacked in melee by current stack
|
||||
bool isTileAttackable(const BattleHex & number) const;
|
||||
|
||||
/// returns true if stack should render its stack count image in default position - outside own hex
|
||||
bool stackCountOutsideHex(const BattleHex & number) const;
|
||||
|
||||
void setBattleCursor(BattleHex myNumber);
|
||||
BattleHex fromWhichHexAttack(BattleHex myNumber);
|
||||
bool isTileAttackable(const BattleHex & number) const;
|
||||
bool stackCountOutsideHex(const BattleHex & number) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user