2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 06:50:20 +00:00
|
|
|
// Event management module header file
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
#ifndef SAGA_EVENT_H
|
|
|
|
#define SAGA_EVENT_H
|
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
#include "saga/list.h"
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
namespace Saga {
|
2004-12-15 00:24:12 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
enum EventTypes {
|
2005-08-10 15:31:15 +00:00
|
|
|
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
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
enum EventFlags {
|
|
|
|
kEvFSignaled = 0x8000,
|
|
|
|
kEvFNoDestory = 0x4000
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
enum EventCodes {
|
2005-08-10 15:31:15 +00:00
|
|
|
kBgEvent = 1,
|
|
|
|
kAnimEvent,
|
|
|
|
kMusicEvent,
|
|
|
|
kVoiceEvent,
|
|
|
|
kSoundEvent,
|
|
|
|
kSceneEvent,
|
|
|
|
kTextEvent,
|
|
|
|
kPalEvent,
|
|
|
|
kPalAnimEvent,
|
|
|
|
kTransitionEvent,
|
|
|
|
kInterfaceEvent,
|
|
|
|
kActorEvent,
|
|
|
|
kScriptEvent,
|
|
|
|
kCursorEvent,
|
2007-06-16 08:53:46 +00:00
|
|
|
kGraphicsEvent,
|
2007-07-30 13:19:46 +00:00
|
|
|
kCutawayEvent,
|
|
|
|
kPsychicProfileBgEvent
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
enum EventOps {
|
2004-08-10 19:00:30 +00:00
|
|
|
// INSTANTANEOUS events
|
|
|
|
// BG events
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventDisplay = 1,
|
2004-08-10 19:00:30 +00:00
|
|
|
// ANIM events
|
2007-08-24 11:23:57 +00:00
|
|
|
kEventPlay = 1, // used in music and sound events too
|
|
|
|
kEventStop = 2, // used in music and sound events too
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventFrame = 3,
|
2007-08-24 11:23:57 +00:00
|
|
|
kEventSetFlag = 4, // used in graphics events too
|
|
|
|
kEventClearFlag = 5, // used in graphics events too
|
2007-06-16 14:06:17 +00:00
|
|
|
kEventResumeAll = 6,
|
2007-08-24 11:23:57 +00:00
|
|
|
// MUSIC and SOUND events
|
|
|
|
// Reused: kEventPlay, kEventStop
|
2004-08-10 19:00:30 +00:00
|
|
|
// SCENE events
|
2007-06-17 16:21:05 +00:00
|
|
|
kEventDraw = 1,
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventEnd = 2,
|
2004-08-10 19:00:30 +00:00
|
|
|
// TEXT events
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventRemove = 3,
|
2007-08-24 11:23:57 +00:00
|
|
|
// Reused: kEventHide
|
2004-08-10 19:00:30 +00:00
|
|
|
// PALANIM events
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventCycleStart = 1,
|
|
|
|
kEventCycleStep = 2,
|
2004-08-10 19:00:30 +00:00
|
|
|
// INTERFACE events
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventActivate = 1,
|
|
|
|
kEventDeactivate = 2,
|
|
|
|
kEventSetStatus = 3,
|
|
|
|
kEventClearStatus = 4,
|
|
|
|
kEventSetFadeMode = 5,
|
2004-08-10 19:00:30 +00:00
|
|
|
// ACTOR events
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventMove = 1,
|
2004-10-16 07:46:52 +00:00
|
|
|
// SCRIPT events
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventExecBlocking = 1,
|
|
|
|
kEventExecNonBlocking = 2,
|
|
|
|
kEventThreadWake = 3,
|
2004-11-20 00:05:50 +00:00
|
|
|
// CURSOR events
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventShow = 1,
|
2007-08-24 11:23:57 +00:00
|
|
|
kEventHide = 2, // used in text events too
|
2007-05-06 22:18:31 +00:00
|
|
|
kEventSetNormalCursor = 3,
|
|
|
|
kEventSetBusyCursor = 4,
|
2005-01-06 16:07:46 +00:00
|
|
|
// GRAPHICS events
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventFillRect = 1,
|
2007-08-24 11:23:57 +00:00
|
|
|
// Reused: kEventSetFlag, kEventClearFlag
|
2004-08-10 19:00:30 +00:00
|
|
|
// CONTINUOUS events
|
2007-08-24 11:23:57 +00:00
|
|
|
//
|
2004-08-10 19:00:30 +00:00
|
|
|
// PALETTE events
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventPalToBlack = 1,
|
|
|
|
kEventBlackToPal = 2,
|
2007-08-23 13:56:25 +00:00
|
|
|
kEventPalFade = 3,
|
2004-08-10 19:00:30 +00:00
|
|
|
// TRANSITION events
|
2005-08-10 15:31:15 +00:00
|
|
|
kEventDissolve = 1,
|
2007-06-16 08:53:46 +00:00
|
|
|
kEventDissolveBGMask = 2,
|
|
|
|
// CUTAWAY events
|
2007-06-17 16:21:05 +00:00
|
|
|
kEventClear = 1
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
enum EventParams {
|
|
|
|
kEvPNoSetPalette,
|
|
|
|
kEvPSetPalette
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
|
|
|
|
2005-08-10 14:11:22 +00:00
|
|
|
struct Event {
|
2004-08-10 19:00:30 +00:00
|
|
|
unsigned int type;
|
2005-07-30 21:11:48 +00:00
|
|
|
unsigned int code; // Event operation category & flags
|
2004-08-10 19:00:30 +00:00
|
|
|
int op; // Event operation
|
|
|
|
long param; // Optional event parameter
|
|
|
|
long param2;
|
2004-10-16 07:46:52 +00:00
|
|
|
long param3;
|
|
|
|
long param4;
|
|
|
|
long param5;
|
2005-01-21 21:55:54 +00:00
|
|
|
long param6;
|
2004-08-10 19:00:30 +00:00
|
|
|
void *data; // Optional event data
|
|
|
|
long time; // Elapsed time until event
|
|
|
|
long duration; // Duration of event
|
|
|
|
long d_reserved;
|
|
|
|
|
2005-08-10 14:11:22 +00:00
|
|
|
Event *chain; // Event chain (For consecutive events)
|
|
|
|
Event() {
|
2005-07-30 21:11:48 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2005-01-21 21:55:54 +00:00
|
|
|
}
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-10 14:11:22 +00:00
|
|
|
typedef SortedList<Event> EventList;
|
2004-12-15 00:24:12 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define EVENT_WARNINGCOUNT 1000
|
|
|
|
#define EVENT_MASK 0x00FF
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
enum EventStatusCode {
|
2005-08-10 15:31:15 +00:00
|
|
|
kEvStInvalidCode = 0,
|
|
|
|
kEvStDelete,
|
|
|
|
kEvStContinue,
|
|
|
|
kEvStBreak
|
2004-04-12 21:40:49 +00:00
|
|
|
};
|
|
|
|
|
2004-08-10 19:00:30 +00:00
|
|
|
class Events {
|
|
|
|
public:
|
|
|
|
Events(SagaEngine *vm);
|
|
|
|
~Events(void);
|
|
|
|
int handleEvents(long msec);
|
|
|
|
int clearList();
|
|
|
|
int freeList();
|
2005-08-10 14:11:22 +00:00
|
|
|
Event *queue(Event *event);
|
|
|
|
Event *chain(Event *headEvent, Event *addEvent);
|
2004-08-10 19:00:30 +00:00
|
|
|
|
|
|
|
private:
|
2005-09-24 19:26:00 +00:00
|
|
|
int handleContinuous(Event *event);
|
|
|
|
int handleOneShot(Event *event);
|
|
|
|
int handleInterval(Event *event);
|
2005-08-10 14:11:22 +00:00
|
|
|
int handleImmediate(Event *event);
|
2004-08-10 19:00:30 +00:00
|
|
|
int processEventTime(long msec);
|
2005-09-24 19:26:00 +00:00
|
|
|
int initializeEvent(Event *event);
|
2004-08-10 19:00:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SagaEngine *_vm;
|
|
|
|
bool _initialized;
|
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
EventList _eventList;
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
} // End of namespace Saga
|
|
|
|
|
2004-05-01 06:50:20 +00:00
|
|
|
#endif
|