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