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