original 1.0.1 release
[xwelltris.git] / src / include / wellobject.h
blobb80ade0b55ccc55ff367f11332914e96c3f59427
1 #ifndef WELLOBJECT_H
2 #define WELLOBJECT_H
4 #include "geometry.h"
6 enum EvType {
7 eTimeOut,
8 eKeyPress,
9 eMouseMove,
10 eMousePress,
11 eExpose,
12 eDelete,
13 eFocusOut,
15 aEmpty,
16 aGameOver,
17 aIntroExit,
18 aKeyPressed,
19 aSwitchChanged,
20 aInputDone
24 enum ButtonState { But1Press, But2Press, But3Press };
26 struct wEvent
28 EvType type;
29 void *data;
30 wEvent(EvType t,void *idata=0) { type=t;data=idata;};
33 struct MouseEvent
35 int mx,my;
36 ButtonState bstate;
39 //Basic class of all game objects
40 class WellObject
42 protected:
43 bool shown;
44 Geo *geo;
45 char object_name[GEO_NAME+1];
47 public:
48 WellObject() { shown=false; geo=0; object_name[0]=0;};
49 virtual bool process_event(wEvent)=0;
50 virtual void show() { shown=true;};
51 virtual bool show_by_call(wEvent) { show(); return true;};
52 virtual void hide() { shown=false;};
53 virtual bool hide_by_call(wEvent) { hide(); return true;};
54 virtual void redraw() {};
55 virtual bool redraw_by_call(wEvent) { redraw(); return true;};
58 class ObjectCaller
60 WellObject *object;
61 bool (WellObject::*method)(wEvent);
63 public:
64 ObjectCaller() { object=0; method=0;};
65 ObjectCaller(WellObject* o,bool (WellObject::*m)(wEvent)) { object=o; method=m;};
66 bool call(wEvent ev)
68 if(!object)
69 return false;
70 return (object->*method)(ev);
74 #endif