CMessage.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef CMESSAGE_H
  2. #define CMESSAGE_H
  3. #include "SDL_TTF.h"
  4. #include "CSemiDefHandler.h"
  5. enum EWindowType {infoOnly, infoOK, yesOrNO};
  6. class CPreGame;
  7. typedef void(CPreGame::*ttt)();
  8. template <class T=ttt> class CGroup;
  9. template <class T=ttt> class CPoinGroup ;
  10. template <class T=ttt> struct Button
  11. {
  12. int type;
  13. SDL_Rect pos;
  14. T fun;
  15. CSemiDefHandler* imgs;
  16. Button( SDL_Rect Pos, T Fun,CSemiDefHandler* Imgs, bool Sel=false, CGroup<T>* gr=NULL, int id=-1)
  17. :state(0),selectable(Sel),selected(false),imgs(Imgs),pos(Pos),fun(Fun),ourGroup(gr), type(0), ID(id){};
  18. Button(){};
  19. bool selectable, selected;
  20. bool highlightable, highlighted;
  21. int state;
  22. int ID;
  23. virtual void hover(bool on=true);
  24. virtual void press(bool down=true);
  25. virtual void select(bool on=true);
  26. CGroup<T> * ourGroup;
  27. };
  28. //template<class T=void(CPreGame::*)(int)>
  29. template<class T=ttt> struct IntSelBut: public Button<T>
  30. {
  31. public:
  32. CPoinGroup<T> * ourGroup;
  33. int key;
  34. IntSelBut(){};
  35. IntSelBut( SDL_Rect Pos, T Fun,CSemiDefHandler* Imgs, bool Sel=false, CPoinGroup<T>* gr=NULL, int My=-1)
  36. : Button(Pos,Fun,Imgs,Sel,gr),key(My){ourGroup=gr;};
  37. void select(bool on=true) {(*this).Button::select(on);ourGroup->setYour(this);}
  38. };
  39. template <class T=ttt> class CPoinGroup :public CGroup<T>
  40. {
  41. public:
  42. int * gdzie; //where (po polsku, bo by by³o s³owo kluczowe :/)
  43. void setYour(IntSelBut<T> * your){*gdzie=your->key;};
  44. };
  45. template <class T=ttt> class CGroup
  46. {
  47. public:
  48. Button<T> * selected;
  49. int type; // 1=sinsel
  50. CGroup():selected(NULL),type(0){};
  51. };
  52. class CMessage
  53. {
  54. public:
  55. std::vector<std::string> * breakText(std::string text);
  56. CSemiDefHandler * piecesOfBox;
  57. SDL_Surface * background;
  58. SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly,
  59. std::vector<CSemiDefHandler*> *addPics=NULL, void * cb=NULL);
  60. SDL_Surface * drawBox1(int w, int h);
  61. CMessage();
  62. };
  63. //
  64. #endif //CMESSAGE_H