CMessage.h 1.9 KB

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