1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
// Event management module header file
#ifndef SAGA_EVENT_H
#define SAGA_EVENT_H
#include "saga/list.h"
namespace Saga {
enum EventTypes {
kEvTOneshot, // Event takes no time
kEvTContinuous, // Event takes time; next event starts immediately
kEvTInterval, // Not yet implemented
kEvTImmediate // Event takes time; next event starts when event is done
};
enum EventFlags {
kEvFSignaled = 0x8000,
kEvFNoDestory = 0x4000
};
enum EventCodes {
kBgEvent = 1,
kAnimEvent,
kMusicEvent,
kVoiceEvent,
kSoundEvent,
kSceneEvent,
kTextEvent,
kPalEvent,
kPalAnimEvent,
kTransitionEvent,
kInterfaceEvent,
kActorEvent,
kScriptEvent,
kCursorEvent,
kGraphicsEvent,
kCutawayEvent,
kPsychicProfileBgEvent
};
enum EventOps {
// INSTANTANEOUS events
// BG events
kEventDisplay = 1,
// ANIM events
// kEventPlay = 1, // reused
// kEventStop = 2, // reused
kEventFrame = 3,
kEventSetFlag = 4,
kEventClearFlag = 5,
kEventResumeAll = 6,
// MUISC & SOUND events
kEventPlay = 1,
kEventStop = 2,
// SCENE events
kEventDraw = 1,
kEventEnd = 2,
// TEXT events
kEventHide = 2,
kEventRemove = 3,
// PALANIM events
kEventCycleStart = 1,
kEventCycleStep = 2,
// INTERFACE events
kEventActivate = 1,
kEventDeactivate = 2,
kEventSetStatus = 3,
kEventClearStatus = 4,
kEventSetFadeMode = 5,
// ACTOR events
kEventMove = 1,
// SCRIPT events
kEventExecBlocking = 1,
kEventExecNonBlocking = 2,
kEventThreadWake = 3,
// CURSOR events
kEventShow = 1,
// kEventHide = 2, // reused
kEventSetNormalCursor = 3,
kEventSetBusyCursor = 4,
// GRAPHICS events
kEventFillRect = 1,
// kEventSetFlag = 4, // reused
// kEventClearFlag = 5, // reused
// CONTINUOUS events
// PALETTE events
kEventPalToBlack = 1,
kEventBlackToPal = 2,
// TRANSITION events
kEventDissolve = 1,
kEventDissolveBGMask = 2,
// CUTAWAY events
kEventClear = 1
};
enum EventParams {
kEvPNoSetPalette,
kEvPSetPalette
};
struct Event {
unsigned int type;
unsigned int code; // Event operation category & flags
int op; // Event operation
long param; // Optional event parameter
long param2;
long param3;
long param4;
long param5;
long param6;
void *data; // Optional event data
long time; // Elapsed time until event
long duration; // Duration of event
long d_reserved;
Event *chain; // Event chain (For consecutive events)
Event() {
memset(this, 0, sizeof(*this));
}
};
typedef SortedList<Event> EventList;
#define EVENT_WARNINGCOUNT 1000
#define EVENT_MASK 0x00FF
enum EventStatusCode {
kEvStInvalidCode = 0,
kEvStDelete,
kEvStContinue,
kEvStBreak
};
class Events {
public:
Events(SagaEngine *vm);
~Events(void);
int handleEvents(long msec);
int clearList();
int freeList();
Event *queue(Event *event);
Event *chain(Event *headEvent, Event *addEvent);
private:
int handleContinuous(Event *event);
int handleOneShot(Event *event);
int handleInterval(Event *event);
int handleImmediate(Event *event);
int processEventTime(long msec);
int initializeEvent(Event *event);
private:
SagaEngine *_vm;
bool _initialized;
EventList _eventList;
};
} // End of namespace Saga
#endif
|