Graphics.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 "IFont.h"
  12. #include "../lib/GameConstants.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. struct SDL_Color;
  26. class CAnimation;
  27. enum EFonts : int
  28. {
  29. FONT_BIG, FONT_CALLI, FONT_CREDITS, FONT_HIGH_SCORE, FONT_MEDIUM, FONT_SMALL, FONT_TIMES, FONT_TINY, FONT_VERD
  30. };
  31. /// Handles fonts, hero images, town images, various graphics
  32. class Graphics
  33. {
  34. void addImageListEntry(size_t index, size_t group, const std::string & listName, const std::string & imageName);
  35. void addImageListEntries(const EntityService * service);
  36. void initializeBattleGraphics();
  37. void loadPaletteAndColors();
  38. void loadErmuToPicture();
  39. void loadFonts();
  40. void initializeImageLists();
  41. std::map<std::string, std::shared_ptr<CAnimation>> cachedAnimations;
  42. public:
  43. std::shared_ptr<CAnimation> getAnimation(const std::string & path);
  44. //Fonts
  45. static const int FONTS_NUMBER = 9;
  46. std::array< std::shared_ptr<IFont>, FONTS_NUMBER> fonts;
  47. //various graphics
  48. SDL_Color * playerColors; //array [8]
  49. SDL_Color * neutralColor;
  50. SDL_Color * playerColorPalette; //palette to make interface colors good - array of size [256]
  51. SDL_Color * neutralColorPalette;
  52. std::map<std::string, JsonNode> imageLists;
  53. //towns
  54. std::map<int, std::string> ERMUtoPicture[GameConstants::F_NUMBER]; //maps building ID to it's picture's name for each town type
  55. //for battles
  56. std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names
  57. //functions
  58. Graphics();
  59. ~Graphics();
  60. void blueToPlayersAdv(SDL_Surface * sur, PlayerColor player); //replaces blue interface colour with a color of player
  61. };
  62. extern Graphics * graphics;