CMessage.h 1.3 KB

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