graphics.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * graphics.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. //code is copied from vcmiclient/Graphics.h with minimal changes
  12. #include "../lib/GameConstants.h"
  13. #include <QImage>
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class CGHeroInstance;
  16. class CGTownInstance;
  17. class CGObjectInstance;
  18. class EntityService;
  19. class JsonNode;
  20. class ObjectTemplate;
  21. VCMI_LIB_NAMESPACE_END
  22. class CHeroClass;
  23. struct InfoAboutHero;
  24. struct InfoAboutTown;
  25. class Animation;
  26. /// Handles fonts, hero images, town images, various graphics
  27. class Graphics
  28. {
  29. void addImageListEntry(size_t index, size_t group, const std::string & listName, const std::string & imageName);
  30. void addImageListEntries(const EntityService * service);
  31. void initializeBattleGraphics();
  32. void loadPaletteAndColors();
  33. void loadHeroAnimations();
  34. //loads animation and adds required rotated frames
  35. std::shared_ptr<Animation> loadHeroAnimation(const std::string &name);
  36. void loadHeroFlagAnimations();
  37. //loads animation and adds required rotated frames
  38. std::shared_ptr<Animation> loadHeroFlagAnimation(const std::string &name);
  39. void loadErmuToPicture();
  40. void loadFogOfWar();
  41. void loadFonts();
  42. void initializeImageLists();
  43. public:
  44. //various graphics
  45. QVector<QRgb> playerColors; //array [8]
  46. QRgb neutralColor;
  47. QVector<QRgb> playerColorPalette; //palette to make interface colors good - array of size [256]
  48. QVector<QRgb> neutralColorPalette;
  49. // [hero class def name] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
  50. std::map< std::string, std::shared_ptr<Animation> > heroAnimations;
  51. std::vector< std::shared_ptr<Animation> > heroFlagAnimations;
  52. // [boat type: 0 .. 2] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
  53. std::array< std::shared_ptr<Animation>, 3> boatAnimations;
  54. std::array< std::vector<std::shared_ptr<Animation> >, 3> boatFlagAnimations;
  55. //all other objects (not hero or boat)
  56. std::map< std::string, std::shared_ptr<Animation> > mapObjectAnimations;
  57. std::map<std::string, JsonNode> imageLists;
  58. //functions
  59. Graphics();
  60. ~Graphics();
  61. void load();
  62. void blueToPlayersAdv(QImage * sur, PlayerColor player); //replaces blue interface colour with a color of player
  63. std::shared_ptr<Animation> getAnimation(const CGObjectInstance * obj);
  64. std::shared_ptr<Animation> getAnimation(const std::shared_ptr<const ObjectTemplate> info);
  65. std::shared_ptr<Animation> getHeroAnimation(const std::shared_ptr<const ObjectTemplate> info);
  66. };
  67. extern Graphics * graphics;