CMessage.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef CMESSAGE_H
  2. #define CMESSAGE_H
  3. #include "global.h"
  4. #include <SDL_ttf.h>
  5. #include "SDL.h"
  6. #include "CPreGame.h"
  7. enum EWindowType {infoOnly, infoOK, yesOrNO};
  8. class CPreGame;
  9. class MapSel;
  10. class CSimpleWindow;
  11. class CInfoWindow;
  12. class CDefHandler;
  13. class SComponent;
  14. class CSelWindow;
  15. class CSelectableComponent;
  16. namespace NMessage
  17. {
  18. extern CDefHandler * ok, *cancel;
  19. extern std::vector<std::vector<SDL_Surface*> > piecesOfBox; //in colors of all players
  20. extern SDL_Surface * background ;
  21. }
  22. class CMessage
  23. {
  24. public:
  25. static std::pair<int,int> getMaxSizes(std::vector<std::vector<SDL_Surface*> > * txtg);
  26. static std::pair<int, int> getMaxSizes(std::vector< std::vector<SComponent*> > * komp);
  27. static std::vector<std::vector<SDL_Surface*> > * drawText(std::vector<std::string> * brtext);
  28. static SDL_Surface * blitTextOnSur(std::vector<std::vector<SDL_Surface*> > * txtg, int & curh, SDL_Surface * ret);
  29. static SDL_Surface * blitCompsOnSur(std::vector<SComponent*> & comps, int maxw, int inter, int & curh, SDL_Surface * ret);
  30. static SDL_Surface * blitCompsOnSur(SDL_Surface *_or, std::vector< std::vector<SComponent*> > *komp, int inter, int &curh, SDL_Surface *ret);
  31. static void drawIWindow(CInfoWindow * ret, std::string text, int player, int charperline);
  32. static std::vector< std::vector<SComponent*> > * breakComps(std::vector<SComponent*> &comps, int maxw, SDL_Surface* _or=NULL);
  33. static CSelWindow * genSelWindow(std::string text, int player, int charperline, std::vector<CSelectableComponent*> & comps, int owner);
  34. 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
  35. static SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly,
  36. std::vector<CDefHandler*> *addPics=NULL, void * cb=NULL);
  37. static SDL_Surface * drawBox1(int w, int h, int playerColor=1);
  38. static void drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int x=0, int y=0);
  39. static SDL_Surface * drawBoxTextBitmapSub(int player, std::string text, SDL_Surface* bitmap, std::string sub, int charperline=30, int imgToBmp=55);
  40. static std::vector<std::string> * breakText(std::string text, int line=30, bool userBreak=true, bool ifor=true); //line - chars per line
  41. CMessage();
  42. static void init();
  43. static void dispose();
  44. };
  45. //
  46. #endif //CMESSAGE_H