2
0

Graphics.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. struct SDL_Surface;
  15. class CGHeroInstance;
  16. class CGTownInstance;
  17. class CHeroClass;
  18. struct SDL_Color;
  19. struct InfoAboutHero;
  20. struct InfoAboutTown;
  21. class CGObjectInstance;
  22. class ObjectTemplate;
  23. class CAnimation;
  24. class EntityService;
  25. enum EFonts
  26. {
  27. FONT_BIG, FONT_CALLI, FONT_CREDITS, FONT_HIGH_SCORE, FONT_MEDIUM, FONT_SMALL, FONT_TIMES, FONT_TINY, FONT_VERD
  28. };
  29. /// Handles fonts, hero images, town images, various graphics
  30. class Graphics
  31. {
  32. void addImageListEntry(size_t index, const std::string & listName, const std::string & imageName);
  33. void addImageListEntries(const EntityService * service);
  34. void initializeBattleGraphics();
  35. void loadPaletteAndColors();
  36. void loadHeroAnimations();
  37. //loads animation and adds required rotated frames
  38. std::shared_ptr<CAnimation> loadHeroAnimation(const std::string &name);
  39. void loadHeroFlagAnimations();
  40. //loads animation and adds required rotated frames
  41. std::shared_ptr<CAnimation> loadHeroFlagAnimation(const std::string &name);
  42. void loadErmuToPicture();
  43. void loadFogOfWar();
  44. void loadFonts();
  45. void initializeImageLists();
  46. public:
  47. //Fonts
  48. static const int FONTS_NUMBER = 9;
  49. std::array< std::shared_ptr<IFont>, FONTS_NUMBER> fonts;
  50. //various graphics
  51. SDL_Color * playerColors; //array [8]
  52. SDL_Color * neutralColor;
  53. SDL_Color * playerColorPalette; //palette to make interface colors good - array of size [256]
  54. SDL_Color * neutralColorPalette;
  55. std::shared_ptr<CAnimation> heroMoveArrows;
  56. // [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
  57. std::map< std::string, std::shared_ptr<CAnimation> > heroAnimations;
  58. std::vector< std::shared_ptr<CAnimation> > heroFlagAnimations;
  59. // [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
  60. std::array< std::shared_ptr<CAnimation>, 3> boatAnimations;
  61. std::array< std::vector<std::shared_ptr<CAnimation> >, 3> boatFlagAnimations;
  62. //all other objects (not hero or boat)
  63. std::map< std::string, std::shared_ptr<CAnimation> > mapObjectAnimations;
  64. std::shared_ptr<CAnimation> fogOfWarFullHide;
  65. std::shared_ptr<CAnimation> fogOfWarPartialHide;
  66. std::map<std::string, JsonNode> imageLists;
  67. //towns
  68. std::map<int, std::string> ERMUtoPicture[GameConstants::F_NUMBER]; //maps building ID to it's picture's name for each town type
  69. //for battles
  70. std::vector< std::vector< std::string > > battleBacks; //battleBacks[terType] - vector of possible names for certain terrain type
  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(const ObjectTemplate & info);
  79. };
  80. extern Graphics * graphics;