CBattleFieldController.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 CStack;
  18. class CBattleInterface;
  19. class CBattleFieldController : public CIntObject
  20. {
  21. CBattleInterface * owner;
  22. SDL_Surface *background;
  23. SDL_Surface *backgroundWithHexes;
  24. SDL_Surface *cellBorders;
  25. SDL_Surface *cellBorder;
  26. SDL_Surface *cellShade;
  27. BattleHex previouslyHoveredHex; //number of hex that was hovered by the cursor a while ago
  28. BattleHex currentlyHoveredHex; //number of hex that is supposed to be hovered (for a while it may be inappropriately set, but will be renewed soon)
  29. BattleHex attackingHex; //hex from which the stack would perform attack with current cursor
  30. std::vector<BattleHex> occupyableHexes; //hexes available for active stack
  31. std::vector<BattleHex> attackableHexes; //hexes attackable by active stack
  32. std::array<bool, GameConstants::BFIELD_SIZE> stackCountOutsideHexes; // hexes that when in front of a unit cause it's amount box to move back
  33. std::vector<std::shared_ptr<CClickableHex>> bfield; //11 lines, 17 hexes on each
  34. public:
  35. CBattleFieldController(CBattleInterface * owner);
  36. ~CBattleFieldController();
  37. void showBackgroundImage(SDL_Surface *to);
  38. void showBackgroundImageWithHexes(SDL_Surface *to);
  39. void redrawBackgroundWithHexes();
  40. void showHighlightedHexes(SDL_Surface *to);
  41. void showHighlightedHex(SDL_Surface *to, BattleHex hex, bool darkBorder);
  42. Rect hexPosition(BattleHex hex) const;
  43. bool isPixelInHex(Point const & position);
  44. BattleHex getHoveredHex();
  45. void setBattleCursor(BattleHex myNumber);
  46. BattleHex fromWhichHexAttack(BattleHex myNumber);
  47. bool isTileAttackable(const BattleHex & number) const;
  48. bool stackCountOutsideHex(const BattleHex & number) const;
  49. };