CBattleFieldController.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * CBattleFieldController.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../../lib/battle/BattleHex.h"
  12. #include "../gui/CIntObject.h"
  13. struct SDL_Surface;
  14. struct Rect;
  15. struct Point;
  16. class CClickableHex;
  17. class CCanvas;
  18. class CStack;
  19. class IImage;
  20. class CBattleInterface;
  21. class CBattleFieldController : public CIntObject
  22. {
  23. CBattleInterface * owner;
  24. std::shared_ptr<IImage> background;
  25. std::shared_ptr<IImage> cellBorder;
  26. std::shared_ptr<IImage> cellShade;
  27. std::shared_ptr<CCanvas> cellBorders;
  28. /// Canvas that contains background, hex grid (if enabled), absolute obstacles and movement range of active stack
  29. std::shared_ptr<CCanvas> backgroundWithHexes;
  30. //BattleHex previouslyHoveredHex; //number of hex that was hovered by the cursor a while ago
  31. //BattleHex currentlyHoveredHex; //number of hex that is supposed to be hovered (for a while it may be inappropriately set, but will be renewed soon)
  32. BattleHex attackingHex; //hex from which the stack would perform attack with current cursor
  33. std::vector<BattleHex> occupyableHexes; //hexes available for active stack
  34. std::array<bool, GameConstants::BFIELD_SIZE> stackCountOutsideHexes; // hexes that when in front of a unit cause it's amount box to move back
  35. std::vector<std::shared_ptr<CClickableHex>> bfield; //11 lines, 17 hexes on each
  36. void showHighlightedHex(std::shared_ptr<CCanvas> to, BattleHex hex, bool darkBorder);
  37. std::set<BattleHex> getHighlightedHexesStackRange();
  38. std::set<BattleHex> getHighlightedHexesSpellRange();
  39. public:
  40. CBattleFieldController(CBattleInterface * owner);
  41. void showBackgroundImage(SDL_Surface *to);
  42. void showBackgroundImageWithHexes(SDL_Surface *to);
  43. void redrawBackgroundWithHexes();
  44. void showHighlightedHexes(SDL_Surface *to);
  45. Rect hexPositionLocal(BattleHex hex) const;
  46. Rect hexPosition(BattleHex hex) const;
  47. bool isPixelInHex(Point const & position);
  48. BattleHex getHoveredHex();
  49. void setBattleCursor(BattleHex myNumber);
  50. BattleHex fromWhichHexAttack(BattleHex myNumber);
  51. bool isTileAttackable(const BattleHex & number) const;
  52. bool stackCountOutsideHex(const BattleHex & number) const;
  53. };