Graphics.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 "gui/Fonts.h"
  12. #include "../lib/GameConstants.h"
  13. #include "gui/Geometries.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. 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 loadHeroAnimations();
  39. //loads animation and adds required rotated frames
  40. std::shared_ptr<CAnimation> loadHeroAnimation(const std::string &name);
  41. void loadHeroFlagAnimations();
  42. //loads animation and adds required rotated frames
  43. std::shared_ptr<CAnimation> loadHeroFlagAnimation(const std::string &name);
  44. void loadErmuToPicture();
  45. void loadFogOfWar();
  46. void loadFonts();
  47. void initializeImageLists();
  48. public:
  49. //Fonts
  50. static const int FONTS_NUMBER = 9;
  51. std::array< std::shared_ptr<IFont>, FONTS_NUMBER> fonts;
  52. //various graphics
  53. SDL_Color * playerColors; //array [8]
  54. SDL_Color * neutralColor;
  55. SDL_Color * playerColorPalette; //palette to make interface colors good - array of size [256]
  56. SDL_Color * neutralColorPalette;
  57. std::shared_ptr<CAnimation> heroMoveArrows;
  58. // [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
  59. std::map< std::string, std::shared_ptr<CAnimation> > heroAnimations;
  60. std::vector< std::shared_ptr<CAnimation> > heroFlagAnimations;
  61. // [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
  62. std::array< std::shared_ptr<CAnimation>, 3> boatAnimations;
  63. std::array< std::vector<std::shared_ptr<CAnimation> >, 3> boatFlagAnimations;
  64. //all other objects (not hero or boat)
  65. std::map< std::string, std::shared_ptr<CAnimation> > mapObjectAnimations;
  66. std::shared_ptr<CAnimation> fogOfWarFullHide;
  67. std::shared_ptr<CAnimation> fogOfWarPartialHide;
  68. std::map<std::string, JsonNode> imageLists;
  69. //towns
  70. std::map<int, std::string> ERMUtoPicture[GameConstants::F_NUMBER]; //maps building ID to it's picture's name for each town type
  71. //for battles
  72. std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names
  73. //functions
  74. Graphics();
  75. ~Graphics();
  76. void load();
  77. void blueToPlayersAdv(SDL_Surface * sur, PlayerColor player); //replaces blue interface colour with a color of player
  78. std::shared_ptr<CAnimation> getAnimation(const CGObjectInstance * obj);
  79. std::shared_ptr<CAnimation> getAnimation(std::shared_ptr<const ObjectTemplate> info);
  80. };
  81. extern Graphics * graphics;