Graphics.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #include "../lib/GameConstants.h"
  12. #include "../lib/Color.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class CGHeroInstance;
  15. class CGTownInstance;
  16. class CHeroClass;
  17. struct InfoAboutHero;
  18. struct InfoAboutTown;
  19. class CGObjectInstance;
  20. class ObjectTemplate;
  21. class EntityService;
  22. class JsonNode;
  23. VCMI_LIB_NAMESPACE_END
  24. struct SDL_Surface;
  25. class CAnimation;
  26. class IFont;
  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 loadErmuToPicture();
  35. void loadFonts();
  36. void initializeImageLists();
  37. std::map<std::string, std::shared_ptr<CAnimation>> cachedAnimations;
  38. public:
  39. std::shared_ptr<CAnimation> getAnimation(const std::string & path);
  40. //Fonts
  41. static const int FONTS_NUMBER = 9;
  42. std::array< std::shared_ptr<IFont>, FONTS_NUMBER> fonts;
  43. using PlayerPalette = std::array<ColorRGBA, 32>;
  44. //various graphics
  45. std::array<ColorRGBA, 8> playerColors;
  46. std::array<PlayerPalette, 8> playerColorPalette; //palette to make interface colors good - array of size [256]
  47. PlayerPalette neutralColorPalette;
  48. ColorRGBA neutralColor;
  49. std::map<std::string, JsonNode> imageLists;
  50. //towns
  51. std::map<int, std::string> ERMUtoPicture[GameConstants::F_NUMBER]; //maps building ID to it's picture's name for each town type
  52. //for battles
  53. std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names
  54. //functions
  55. Graphics();
  56. void blueToPlayersAdv(SDL_Surface * sur, PlayerColor player); //replaces blue interface colour with a color of player
  57. };
  58. extern Graphics * graphics;