Graphics.h 3.3 KB

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