Graphics.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #pragma once
  2. #include "gui/Fonts.h"
  3. #include "../lib/GameConstants.h"
  4. #include "gui/Geometries.h"
  5. /*
  6. * Graphics.h, part of VCMI engine
  7. *
  8. * Authors: listed in file AUTHORS in main folder
  9. *
  10. * License: GNU General Public License v2.0 or later
  11. * Full text of license available in license.txt file, in main folder
  12. *
  13. */
  14. struct SDL_Surface;
  15. class CGHeroInstance;
  16. class CGTownInstance;
  17. class CDefHandler;
  18. class CHeroClass;
  19. struct SDL_Color;
  20. struct InfoAboutHero;
  21. struct InfoAboutTown;
  22. class CGObjectInstance;
  23. class ObjectTemplate;
  24. class CAnimation;
  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, std::string listName, std::string imageName);
  33. void initializeBattleGraphics();
  34. void loadPaletteAndColors();
  35. void loadHeroAnimations();
  36. //loads animation and adds required rotated frames
  37. std::shared_ptr<CAnimation> loadHeroAnimation(const std::string &name);
  38. void loadHeroFlagAnimations();
  39. //loads animation and adds required rotated frames
  40. std::shared_ptr<CAnimation> loadHeroFlagAnimation(const std::string &name);
  41. void loadErmuToPicture();
  42. void loadFogOfWar();
  43. void loadFonts();
  44. void initializeImageLists();
  45. public:
  46. //Fonts
  47. static const int FONTS_NUMBER = 9;
  48. IFont * fonts[FONTS_NUMBER];
  49. //various graphics
  50. SDL_Color * playerColors; //array [8]
  51. SDL_Color * neutralColor;
  52. SDL_Color * playerColorPalette; //palette to make interface colors good - array of size [256]
  53. SDL_Color * neutralColorPalette;
  54. std::shared_ptr<CAnimation> heroMoveArrows;
  55. // [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
  56. std::map< std::string, std::shared_ptr<CAnimation> > heroAnimations;
  57. std::vector< std::shared_ptr<CAnimation> > heroFlagAnimations;
  58. // [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
  59. std::array< std::shared_ptr<CAnimation>, 3> boatAnimations;
  60. std::array< std::vector<std::shared_ptr<CAnimation> >, 3> boatFlagAnimations;
  61. //all other objects (not hero or boat)
  62. std::map< std::string, std::shared_ptr<CAnimation> > mapObjectAnimations;
  63. std::shared_ptr<CAnimation> fogOfWarFullHide;
  64. std::shared_ptr<CAnimation> fogOfWarPartialHide;
  65. std::map<std::string, JsonNode> imageLists;
  66. //towns
  67. std::map<int, std::string> ERMUtoPicture[GameConstants::F_NUMBER]; //maps building ID to it's picture's name for each town type
  68. //for battles
  69. std::vector< std::vector< std::string > > battleBacks; //battleBacks[terType] - vector of possible names for certain terrain type
  70. std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names
  71. //functions
  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;