graphics.h 2.8 KB

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