2004-04-12 21:40:49 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:20:17 +00:00
|
|
|
* Copyright (C) 2004-2005 The ScummVM project
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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-01-06 16:07:46 +00:00
|
|
|
ONESHOT_EVENT, // Event takes no time
|
|
|
|
CONTINUOUS_EVENT, // Event takes time; next event starts immediately
|
|
|
|
INTERVAL_EVENT, // Not yet implemented
|
|
|
|
IMMEDIATE_EVENT // Event takes time; next event starts when event is done
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
enum EVENT_FLAGS {
|
|
|
|
SIGNALED = 0x8000,
|
|
|
|
NODESTROY = 0x4000
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
enum EventCodes {
|
2004-10-27 21:32:28 +00:00
|
|
|
BG_EVENT = 1,
|
|
|
|
ANIM_EVENT,
|
|
|
|
MUSIC_EVENT,
|
|
|
|
VOICE_EVENT,
|
|
|
|
SOUND_EVENT,
|
|
|
|
SCENE_EVENT,
|
|
|
|
TEXT_EVENT,
|
|
|
|
PAL_EVENT,
|
|
|
|
PALANIM_EVENT,
|
|
|
|
TRANSITION_EVENT,
|
|
|
|
INTERFACE_EVENT,
|
2004-11-20 00:05:50 +00:00
|
|
|
ACTOR_EVENT,
|
|
|
|
SCRIPT_EVENT,
|
2005-01-06 16:07:46 +00:00
|
|
|
CURSOR_EVENT,
|
|
|
|
GRAPHICS_EVENT
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
enum EVENT_OPS {
|
2004-08-10 19:00:30 +00:00
|
|
|
// INSTANTANEOUS events
|
|
|
|
// BG events
|
|
|
|
EVENT_DISPLAY = 1,
|
|
|
|
// ANIM events
|
2005-01-02 14:36:00 +00:00
|
|
|
// EVENT_PLAY = 1, // reused
|
2005-01-02 15:45:38 +00:00
|
|
|
// EVENT_STOP = 2, // reused
|
|
|
|
EVENT_FRAME = 3,
|
|
|
|
EVENT_SETFLAG = 4,
|
|
|
|
EVENT_CLEARFLAG = 5,
|
2004-08-10 19:00:30 +00:00
|
|
|
// MUISC & SOUND events
|
|
|
|
EVENT_PLAY = 1,
|
|
|
|
EVENT_STOP = 2,
|
|
|
|
// SCENE events
|
|
|
|
EVENT_END = 2,
|
|
|
|
// TEXT events
|
|
|
|
EVENT_HIDE = 2,
|
|
|
|
EVENT_REMOVE = 3,
|
|
|
|
// PALANIM events
|
|
|
|
EVENT_CYCLESTART = 1,
|
|
|
|
EVENT_CYCLESTEP = 2,
|
|
|
|
// INTERFACE events
|
|
|
|
EVENT_ACTIVATE = 1,
|
2005-01-06 16:07:46 +00:00
|
|
|
EVENT_DEACTIVATE = 2,
|
|
|
|
EVENT_SET_STATUS = 3,
|
|
|
|
EVENT_CLEAR_STATUS = 4,
|
2005-06-04 15:02:17 +00:00
|
|
|
EVENT_SET_FADE_MODE = 5,
|
2004-08-10 19:00:30 +00:00
|
|
|
// ACTOR events
|
|
|
|
EVENT_MOVE = 1,
|
2004-10-16 07:46:52 +00:00
|
|
|
// SCRIPT events
|
2005-01-06 16:07:46 +00:00
|
|
|
EVENT_EXEC_BLOCKING = 1,
|
|
|
|
EVENT_EXEC_NONBLOCKING = 2,
|
|
|
|
EVENT_THREAD_WAKE = 3,
|
2004-11-20 00:05:50 +00:00
|
|
|
// CURSOR events
|
|
|
|
EVENT_SHOW = 1,
|
|
|
|
// EVENT_HIDE = 2, // reused
|
2005-01-06 16:07:46 +00:00
|
|
|
// GRAPHICS events
|
|
|
|
EVENT_FILL_RECT = 1,
|
|
|
|
// EVENT_SETFLAG = 4, // reused
|
|
|
|
// EVENT_CLEARFLAG = 5, // reused
|
2004-08-10 19:00:30 +00:00
|
|
|
|
|
|
|
// CONTINUOUS events
|
|
|
|
// PALETTE events
|
|
|
|
EVENT_PALTOBLACK = 1,
|
|
|
|
EVENT_BLACKTOPAL = 2,
|
|
|
|
// TRANSITION events
|
2004-08-10 23:04:52 +00:00
|
|
|
EVENT_DISSOLVE = 1,
|
|
|
|
EVENT_DISSOLVE_BGMASK = 2
|
2004-08-10 19:00:30 +00:00
|
|
|
};
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
enum EVENT_PARAMS {
|
2004-08-10 19:00:30 +00:00
|
|
|
NO_SET_PALETTE,
|
|
|
|
SET_PALETTE
|
|
|
|
};
|
|
|
|
|
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 {
|
2004-10-27 21:32:28 +00:00
|
|
|
EVENT_INVALIDCODE = 0,
|
|
|
|
EVENT_DELETE,
|
|
|
|
EVENT_CONTINUE,
|
|
|
|
EVENT_BREAK
|
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-08-10 14:11:22 +00:00
|
|
|
int handleContinuous(Event * event);
|
|
|
|
int handleOneShot(Event * event);
|
|
|
|
int handleInterval(Event * event);
|
|
|
|
int handleImmediate(Event *event);
|
2004-08-10 19:00:30 +00:00
|
|
|
int processEventTime(long msec);
|
2005-08-10 14:11:22 +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
|