CMessage.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #include "FontBase.h"
  3. #include "UIFramework/Geometries.h"
  4. /*
  5. * CMessage.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. struct SDL_Surface;
  14. enum EWindowType {infoOnly, infoOK, yesOrNO};
  15. class CInfoWindow;
  16. class CDefHandler;
  17. class CComponent;
  18. class CSelWindow;
  19. class ComponentResolved;
  20. /// Class which draws formatted text messages and generates chat windows
  21. class CMessage
  22. {
  23. public:
  24. //Function usd only in CMessage.cpp
  25. static std::pair<int,int> getMaxSizes(std::vector<std::vector<SDL_Surface*> > * txtg, int fontHeight);
  26. static std::vector<std::vector<SDL_Surface*> > * drawText(std::vector<std::string> * brtext, int &fontHeigh, EFonts font = FONT_MEDIUM);
  27. static SDL_Surface * blitTextOnSur(std::vector<std::vector<SDL_Surface*> > * txtg, int fontHeight, int & curh, SDL_Surface * ret, int xCenterPos=-1); //xPos==-1 works as if ret->w/2
  28. /// Draw border on exiting surface
  29. static void drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int x=0, int y=0);
  30. /// Draw simple dialog box (borders and background only)
  31. static SDL_Surface * drawDialogBox(int w, int h, int playerColor=1);
  32. /// Draw simple dialog box and blit bitmap with text on it
  33. static SDL_Surface * drawBoxTextBitmapSub(int player, std::string text, SDL_Surface* bitmap, std::string sub, int charPerline=30, int imgToBmp=55);
  34. static void drawIWindow(CInfoWindow * ret, std::string text, int player);
  35. /// split text in lines
  36. static std::vector<std::string> breakText(std::string text, size_t maxLineSize=30, const boost::function<int(char)> &charMetric = boost::function<int(char)>(), bool allowLeadingWhitespace = false);
  37. static std::vector<std::string> breakText(std::string text, size_t maxLineWidth, EFonts font);
  38. /// constructor
  39. static void init();
  40. /// destructor
  41. static void dispose();
  42. };