Graphics.h 2.0 KB

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