Graphics.h 3.3 KB

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