Graphics.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. 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. VCMI_LIB_NAMESPACE_END
  23. struct SDL_Surface;
  24. struct SDL_Color;
  25. class CAnimation;
  26. enum EFonts : int
  27. {
  28. FONT_BIG, FONT_CALLI, FONT_CREDITS, FONT_HIGH_SCORE, FONT_MEDIUM, FONT_SMALL, FONT_TIMES, FONT_TINY, FONT_VERD
  29. };
  30. /// Handles fonts, hero images, town images, various graphics
  31. class Graphics
  32. {
  33. void addImageListEntry(size_t index, size_t group, const std::string & listName, const std::string & imageName);
  34. void addImageListEntries(const EntityService * service);
  35. void initializeBattleGraphics();
  36. void loadPaletteAndColors();
  37. void loadHeroAnimations();
  38. //loads animation and adds required rotated frames
  39. std::shared_ptr<CAnimation> loadHeroAnimation(const std::string &name);
  40. void loadHeroFlagAnimations();
  41. //loads animation and adds required rotated frames
  42. std::shared_ptr<CAnimation> loadHeroFlagAnimation(const std::string &name);
  43. void loadErmuToPicture();
  44. void loadFogOfWar();
  45. void loadFonts();
  46. void initializeImageLists();
  47. public:
  48. //Fonts
  49. static const int FONTS_NUMBER = 9;
  50. std::array< std::shared_ptr<IFont>, FONTS_NUMBER> fonts;
  51. //various graphics
  52. SDL_Color * playerColors; //array [8]
  53. SDL_Color * neutralColor;
  54. SDL_Color * playerColorPalette; //palette to make interface colors good - array of size [256]
  55. SDL_Color * neutralColorPalette;
  56. std::shared_ptr<CAnimation> heroMoveArrows;
  57. // [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
  58. std::map< std::string, std::shared_ptr<CAnimation> > heroAnimations;
  59. std::vector< std::shared_ptr<CAnimation> > heroFlagAnimations;
  60. // [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
  61. std::array< std::shared_ptr<CAnimation>, 3> boatAnimations;
  62. std::array< std::vector<std::shared_ptr<CAnimation> >, 3> boatFlagAnimations;
  63. //all other objects (not hero or boat)
  64. std::map< std::string, std::shared_ptr<CAnimation> > mapObjectAnimations;
  65. std::shared_ptr<CAnimation> fogOfWarFullHide;
  66. std::shared_ptr<CAnimation> fogOfWarPartialHide;
  67. std::map<std::string, JsonNode> imageLists;
  68. //towns
  69. std::map<int, std::string> ERMUtoPicture[GameConstants::F_NUMBER]; //maps building ID to it's picture's name for each town type
  70. //for battles
  71. std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names
  72. //functions
  73. Graphics();
  74. ~Graphics();
  75. void load();
  76. void blueToPlayersAdv(SDL_Surface * sur, PlayerColor player); //replaces blue interface colour with a color of player
  77. std::shared_ptr<CAnimation> getAnimation(const CGObjectInstance * obj);
  78. std::shared_ptr<CAnimation> getAnimation(std::shared_ptr<const ObjectTemplate> info);
  79. };
  80. extern Graphics * graphics;