CardItem.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * CardItem.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 <QWidget>
  12. #include <QGraphicsSvgItem>
  13. #include "../../StdInc.h"
  14. #include "../../../lib/constants/EntityIdentifiers.h"
  15. #include "../../../lib/rmg/CRmgTemplate.h"
  16. class CardItem : public QGraphicsSvgItem
  17. {
  18. private:
  19. QDomElement getElementById(const QDomDocument& doc, const QString& id);
  20. QDomDocument doc;
  21. bool useBlackText;
  22. int id = -1;
  23. bool mousePressed;
  24. std::function<void(bool)> selectCallback;
  25. std::function<void(QPointF)> posChangeCallback;
  26. public:
  27. CardItem();
  28. static constexpr double GRID_SIZE = 10.;
  29. void setSelectCallback(std::function<void(bool)> func);
  30. void setPosChangeCallback(std::function<void(QPointF)> func);
  31. void updateContent();
  32. void setFillColor(QColor color);
  33. void setMultiFillColor(QColor color1, QColor color2);
  34. void setPlayerColor(PlayerColor color);
  35. void setJunction(bool val);
  36. void setId(int val);
  37. int getId();
  38. void setResAmount(GameResID res, int val);
  39. void setChestValue(int val);
  40. void setMonsterStrength(EMonsterStrength::EMonsterStrength val);
  41. protected:
  42. void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
  43. void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
  44. QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
  45. };