graphics.h 2.7 KB

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