CMessage.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * CMessage.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 "../render/Graphics.h"
  12. #include "../../lib/GameConstants.h"
  13. struct SDL_Surface;
  14. class CInfoWindow;
  15. class CComponent;
  16. /// Class which draws formatted text messages and generates chat windows
  17. class CMessage
  18. {
  19. /// Draw simple dialog box (borders and background only)
  20. static SDL_Surface * drawDialogBox(int w, int h, PlayerColor playerColor = PlayerColor(1));
  21. public:
  22. /// Draw border on exiting surface
  23. static void drawBorder(PlayerColor playerColor, SDL_Surface * ret, int w, int h, int x=0, int y=0);
  24. static void drawIWindow(CInfoWindow * ret, std::string text, PlayerColor player);
  25. /// split text in lines
  26. static std::vector<std::string> breakText(std::string text, size_t maxLineWidth, EFonts font);
  27. /// Try to guess a header of a message
  28. static std::string guessHeader(const std::string & msg);
  29. /// For convenience
  30. static int guessHeight(const std::string & string, int width, EFonts fnt);
  31. static int getEstimatedComponentHeight(int numComps);
  32. /// constructor
  33. static void init();
  34. /// destructor
  35. static void dispose();
  36. };