CGameInterface.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef CGAMEINTERFACE_H
  2. #define CGAMEINTERFACE_H
  3. #include "SDL.h"
  4. #include "CDefHandler.h"
  5. #include "SDL_Extensions.h"
  6. class CGameInterface
  7. {
  8. };
  9. class CAdvMapInt : public CGameInterface //adventure map interface
  10. {
  11. SDL_Surface * bg;
  12. };
  13. class CAICallback : public CGameInterface // callback for AI
  14. {
  15. };
  16. class CIntObject //interface object
  17. {
  18. public:
  19. SDL_Rect pos;
  20. int ID;
  21. };
  22. class CButtonBase : public CIntObject
  23. {
  24. public:
  25. int type;
  26. bool abs;
  27. struct Offset
  28. {
  29. int x, y;
  30. } *offset;
  31. CIntObject * ourObj;
  32. int state;
  33. std::vector<SDL_Surface*> imgs;
  34. virtual void show() ;
  35. CButtonBase(){abs=true;ourObj=NULL;}
  36. };
  37. class ClickableL : public virtual CButtonBase //for left-clicks
  38. {
  39. bool pressed;
  40. virtual void press (bool down)=0;
  41. };
  42. class ClickableR : public virtual CButtonBase //for right-clicks
  43. {
  44. bool pressed;
  45. virtual void click (bool down)=0;
  46. };
  47. class Hoverable : public virtual CButtonBase
  48. {
  49. bool hovered;
  50. virtual void hover (bool on)=0;
  51. };
  52. class KeyInterested : public virtual CButtonBase
  53. {
  54. virtual void keyPressed (SDL_KeyboardEvent & key)=0;
  55. };
  56. class CPlayerInterface
  57. {
  58. static CGameInterface * gamein;
  59. std::vector<ClickableL*> lclickable;
  60. std::vector<ClickableR*> rclickable;
  61. std::vector<Hoverable*> hoverable;
  62. std::vector<KeyInterested*> keyinterested;
  63. void handleEvent(SDL_Event * sEvent);
  64. };
  65. #endif //CGAMEINTERFACE_H