annotate window/event.h @ 66:d112357a0ec1

Fix a bug with savegames introduced with changeset c7bcc0ec2267. Warning: savegames created since c7bcc0ec2267 are probably corrupted, you may have to start the game over. If you chose not to do so, you should replace all occurrences of 'TextWindow' by 'TextImplWindow', and 'Text Window' by 'TextImpl Window' in your save files.
author Thibaut Girka <thib@sitedethib.com>
date Sat, 11 Dec 2010 18:36:20 +0100
parents 4416cfac86ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
1 /*
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
3 * All rights reserved.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
4 *
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
5 * Redistribution and use in source and binary forms, with or without
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
6 * modification, are permitted provided that the following conditions
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
7 * are met:
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
8 * 1. Redistributions of source code must retain the above copyright
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
9 * notice, this list of conditions and the following disclaimer.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
12 * documentation and/or other materials provided with the distribution.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
13 * 3. The name of the author may not be used to endorse or promote products
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
14 * derived from this software without specific prior written permission.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
15 *
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
26 */
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
27
0
223b71206888 Initial import
thib
parents:
diff changeset
28 #ifndef __EVENT__
223b71206888 Initial import
thib
parents:
diff changeset
29 #define __EVENT__
223b71206888 Initial import
thib
parents:
diff changeset
30
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
31 #include "rect.h"
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
32 #include "SDL.h"
0
223b71206888 Initial import
thib
parents:
diff changeset
33
223b71206888 Initial import
thib
parents:
diff changeset
34 namespace Event {
223b71206888 Initial import
thib
parents:
diff changeset
35
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
36 class Video;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
37 class Time;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
38 class Container;
0
223b71206888 Initial import
thib
parents:
diff changeset
39
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
40 /*
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
41 ** マウスの press, ドラッグ、in/out を検出できる
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
42 ** focus がある時の left/right/space(==press) のキーを判別できる
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
43 */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
44 struct Video {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
45 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
46 virtual void Press(void) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
47 virtual void Release(void) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
48 virtual void Drag(int x_from, int y_from, int x_to, int y_to) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
49 virtual void Motion(int x, int y) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
50 virtual void In(void) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
51 virtual void Out(void) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
52 virtual void KeyLeft(void) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
53 virtual void KeyRight(void) {}
0
223b71206888 Initial import
thib
parents:
diff changeset
54
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
55 int point_in(int x, int y); /* z or -1 を返す。大きいほど高いところにある */
0
223b71206888 Initial import
thib
parents:
diff changeset
56
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
57 Video(Container& container);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
58 Video(Container& container, const Rect& init_rect);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
59 Video(Container& container, const Rect& init_rect, int z);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
60 void SetRegion(const Rect& new_rect);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
61 void SetZ(int new_z);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
62 void activate(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
63 void deactivate(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
64 virtual ~Video();
0
223b71206888 Initial import
thib
parents:
diff changeset
65
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
66 Rect Region(void) const { return region;}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
67 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
68 Rect region;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
69 int z;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
70 Container& parent;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
71 bool activated;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
72 friend bool operator <(const Video& position1, const Video& position2);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
73 };
0
223b71206888 Initial import
thib
parents:
diff changeset
74
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
75 struct Time {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
76 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
77 enum { NEVER_WAKE = 0xffffffffUL, FRAME_UPDATE = 0xfffffffeUL};
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
78 virtual void Elapsed(unsigned int current_time) {wakeup_time = NEVER_WAKE; }; /* next: never elapsed */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
79 void SetWakeup(unsigned int new_wakeup_time) { wakeup_time = new_wakeup_time; }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
80 unsigned Wakeup(void) const { return wakeup_time; }
0
223b71206888 Initial import
thib
parents:
diff changeset
81
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
82 Time(Container& container);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
83 ~Time();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
84 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
85 unsigned int wakeup_time;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
86 Container& parent;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
87 };
0
223b71206888 Initial import
thib
parents:
diff changeset
88
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
89 struct Container {
0
223b71206888 Initial import
thib
parents:
diff changeset
90 #define MOUSE_LEFT 0
223b71206888 Initial import
thib
parents:
diff changeset
91 #define MOUSE_MIDDLE 1
223b71206888 Initial import
thib
parents:
diff changeset
92 #define MOUSE_RIGHT 2
223b71206888 Initial import
thib
parents:
diff changeset
93 #define MOUSE_UP 3
223b71206888 Initial import
thib
parents:
diff changeset
94 #define MOUSE_DOWN 4
223b71206888 Initial import
thib
parents:
diff changeset
95 #define KEY_SHIFT 10
223b71206888 Initial import
thib
parents:
diff changeset
96 #define BUTTON_MAX 32
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
97 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
98 int button_pressed;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
99 int button_presscount[BUTTON_MAX];
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
100 int current_time;
0
223b71206888 Initial import
thib
parents:
diff changeset
101
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
102 void MousePos(int& x, int& y);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
103 bool Exec(unsigned int current_time);
0
223b71206888 Initial import
thib
parents:
diff changeset
104
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
105 void Add(Video* item);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
106 void Delete(Video* item);
0
223b71206888 Initial import
thib
parents:
diff changeset
107
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
108 void Add(Time* item);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
109 void Delete(Time* item);
0
223b71206888 Initial import
thib
parents:
diff changeset
110
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
111 typedef bool (*motionfunc)(int x, int y, void* pointer);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
112 void RegisterGlobalMotionFunc(motionfunc, void* pointer); // マウスの移動のたびに呼び出される関数を登録する
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
113 void DeleteGlobalMotionFunc(motionfunc, void* pointer);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
114 void RegisterGlobalPressFunc(motionfunc, void* pointer); // マウスのクリックのたびに呼び出される関数を登録する
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
115 void DeleteGlobalPressFunc(motionfunc, void* pointer);
0
223b71206888 Initial import
thib
parents:
diff changeset
116
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
117 Container(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
118 ~Container(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
119 bool pressed(int mask);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
120 bool presscount(int mask);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
121 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
122 class ContainerImplVideo* pimpl_video;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
123 class ContainerImplTime* pimpl_time;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
124 };
0
223b71206888 Initial import
thib
parents:
diff changeset
125
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 31
diff changeset
126 } /* end of namespace Event */
0
223b71206888 Initial import
thib
parents:
diff changeset
127
223b71206888 Initial import
thib
parents:
diff changeset
128
223b71206888 Initial import
thib
parents:
diff changeset
129 #endif