CMessage.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef CMESSAGE_H
  2. #define CMESSAGE_H
  3. #include "global.h"
  4. #include "SDL_TTF.h"
  5. #include "SDL.h"
  6. enum EWindowType {infoOnly, infoOK, yesOrNO};
  7. class CPreGame;
  8. class MapSel;
  9. class CSimpleWindow;
  10. class CInfoWindow;
  11. class CDefHandler;
  12. class SComponent;
  13. class CSelWindow;
  14. class CSelectableComponent;
  15. namespace NMessage
  16. {
  17. extern CDefHandler * ok, *cancel;
  18. extern std::vector<std::vector<SDL_Surface*> > piecesOfBox; //in colors of all players
  19. extern SDL_Surface * background ;
  20. }
  21. class CMessage
  22. {
  23. public:
  24. static std::pair<int,int> getMaxSizes(std::vector<std::vector<SDL_Surface*> > * txtg);
  25. static std::pair<int, int> getMaxSizes(std::vector< std::vector<CSelectableComponent*> > * komp);
  26. static std::vector<std::vector<SDL_Surface*> > * drawText(std::vector<std::string> * brtext);
  27. static SDL_Surface * blitTextOnSur(std::vector<std::vector<SDL_Surface*> > * txtg, int & curh, SDL_Surface * ret);
  28. static SDL_Surface * blitCompsOnSur(std::vector<SComponent*> & comps, int maxw, int inter, int & curh, SDL_Surface * ret);
  29. static SDL_Surface* blitCompsOnSur(SDL_Surface * or, std::vector< std::vector<CSelectableComponent*> > * komp, int inter, int &curh, SDL_Surface *ret);
  30. static CInfoWindow * genIWindow(std::string text, int player, int charperline, std::vector<SComponent*> & comps);
  31. static std::vector< std::vector<CSelectableComponent*> > * breakComps(std::vector<CSelectableComponent*> & comps,int maxw, SDL_Surface* or=NULL);
  32. static CSelWindow * genSelWindow(std::string text, int player, int charperline, std::vector<CSelectableComponent*> & comps, int owner);
  33. static CSimpleWindow * genWindow(std::string text, int player, int Lmar=35, int Rmar=35, int Tmar=35, int Bmar=35);//supports h3 text formatting; player sets color of window, Lmar/Rmar/Tmar/Bmar are Left/Right/Top/Bottom margins
  34. static SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly,
  35. std::vector<CDefHandler*> *addPics=NULL, void * cb=NULL);
  36. static SDL_Surface * drawBox1(int w, int h, int playerColor=1);
  37. static std::vector<std::string> * breakText(std::string text, int line=30, bool userBreak=true, bool ifor=true); //line - chars per line
  38. CMessage();
  39. static void init();
  40. static void dispose();
  41. };
  42. //
  43. #endif //CMESSAGE_H