diff options
author | Eugene Sandulenko | 2004-08-10 19:00:30 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2004-08-10 19:00:30 +0000 |
commit | fe7ac87bc76ec6f0d99322d0089ff640a4564eaa (patch) | |
tree | 53b98f7f399b8bf2ce82f906abc243e444c5db0b | |
parent | 632042dae47246ba313b7375831349f197b03678 (diff) | |
download | scummvm-rg350-fe7ac87bc76ec6f0d99322d0089ff640a4564eaa.tar.gz scummvm-rg350-fe7ac87bc76ec6f0d99322d0089ff640a4564eaa.tar.bz2 scummvm-rg350-fe7ac87bc76ec6f0d99322d0089ff640a4564eaa.zip |
Move EVENT_* to a class.
svn-id: r14539
-rw-r--r-- | saga/animation.cpp | 6 | ||||
-rw-r--r-- | saga/console.cpp | 6 | ||||
-rw-r--r-- | saga/events.cpp | 58 | ||||
-rw-r--r-- | saga/events.h | 105 | ||||
-rw-r--r-- | saga/events_mod.h | 119 | ||||
-rw-r--r-- | saga/ihnm_introproc.cpp | 22 | ||||
-rw-r--r-- | saga/ite_introproc.cpp | 98 | ||||
-rw-r--r-- | saga/palanim.cpp | 6 | ||||
-rw-r--r-- | saga/saga.cpp | 8 | ||||
-rw-r--r-- | saga/saga.h | 2 | ||||
-rw-r--r-- | saga/scene.cpp | 10 |
11 files changed, 208 insertions, 232 deletions
diff --git a/saga/animation.cpp b/saga/animation.cpp index d1a80aa8bd..4c71dede4c 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -28,7 +28,7 @@ #include "saga/cvar_mod.h" #include "saga/console.h" #include "saga/game_mod.h" -#include "saga/events_mod.h" +#include "saga/events.h" #include "saga/render.h" #include "saga/animation.h" @@ -257,7 +257,7 @@ int Anim::play(uint16 anim_id, int vector_time) { event.code = R_SCENE_EVENT; event.op = EVENT_END; event.time = anim->frame_time + vector_time; - EVENT_Queue(&event); + _vm->_events->queue(&event); } return R_SUCCESS; } @@ -269,7 +269,7 @@ int Anim::play(uint16 anim_id, int vector_time) { event.param = anim_id; event.time = anim->frame_time + vector_time; - EVENT_Queue(&event); + _vm->_events->queue(&event); return R_SUCCESS; } diff --git a/saga/console.cpp b/saga/console.cpp index d082a7ef70..bb7af21bdb 100644 --- a/saga/console.cpp +++ b/saga/console.cpp @@ -27,7 +27,7 @@ #include "saga/gfx.h" #include "saga/font.h" #include "saga/cvar_mod.h" -#include "saga/events_mod.h" +#include "saga/events.h" #include "saga/console.h" @@ -80,7 +80,7 @@ int Console::activate() { con_event.time = 0; con_event.duration = _droptime; - EVENT_Queue(&con_event); + _vm->_events->queue(&con_event); _active = true; @@ -100,7 +100,7 @@ int Console::deactivate() { con_event.time = 0; con_event.duration = _droptime; - EVENT_Queue(&con_event); + _vm->_events->queue(&con_event); return R_SUCCESS; } diff --git a/saga/events.cpp b/saga/events.cpp index 51713e0016..5af56f5633 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -40,29 +40,27 @@ #include "saga/sndres.h" #include "saga/music.h" -#include "saga/events_mod.h" #include "saga/events.h" namespace Saga { -static YS_DL_LIST *EventList; - -int EVENT_Init() { +Events::Events(SagaEngine *vm) : _vm(vm), _initialized(false) { debug(0, "Initializing event subsystem..."); - EventList = ys_dll_create(); - return (EventList != NULL) ? R_SUCCESS : R_FAILURE; + _eventList = ys_dll_create(); + + if (_eventList) + _initialized = true; } -int EVENT_Shutdown() { +Events::~Events(void) { debug(0, "Shutting down event subsystem..."); - EVENT_FreeList(); - return R_SUCCESS; + freeList(); } // Function to process event list once per frame. // First advances event times, then processes each event with the appropriate // handler depending on the type of event. -int EVENT_HandleEvents(long msec) { +int Events::handleEvents(long msec) { YS_DL_NODE *walk_node; YS_DL_NODE *next_node; @@ -72,10 +70,10 @@ int EVENT_HandleEvents(long msec) { int result; // Advance event times - ProcessEventTime(msec); + processEventTime(msec); // Process each event in list - for (walk_node = ys_dll_head(EventList); walk_node != NULL; walk_node = next_node) { + for (walk_node = ys_dll_head(_eventList); walk_node != NULL; walk_node = next_node) { event_p = (R_EVENT *)ys_dll_get_data(walk_node); // Save next event in case current event is handled and removed @@ -85,15 +83,15 @@ int EVENT_HandleEvents(long msec) { switch (event_p->type) { case R_ONESHOT_EVENT: - result = HandleOneShot(event_p); + result = handleOneShot(event_p); break; case R_CONTINUOUS_EVENT: - result = HandleContinuous(event_p); + result = handleContinuous(event_p); break; case R_INTERVAL_EVENT: - result = HandleInterval(event_p); + result = handleInterval(event_p); break; default: @@ -129,7 +127,7 @@ int EVENT_HandleEvents(long msec) { return R_SUCCESS; } -int HandleContinuous(R_EVENT *event) { +int Events::handleContinuous(R_EVENT *event) { double event_pc = 0.0; // Event completion percentage int event_done = 0; @@ -206,7 +204,7 @@ int HandleContinuous(R_EVENT *event) { return R_EVENT_CONTINUE; } -static int HandleOneShot(R_EVENT *event) { +int Events::handleOneShot(R_EVENT *event) { R_SURFACE *back_buf; static SCENE_BGINFO bginfo; @@ -313,18 +311,18 @@ static int HandleOneShot(R_EVENT *event) { return R_EVENT_DELETE; } -static int HandleInterval(R_EVENT *event) { +int Events::handleInterval(R_EVENT *event) { return R_EVENT_DELETE; } // Schedules an event in the event list; returns a pointer to the scheduled // event suitable for chaining if desired. -R_EVENT *EVENT_Queue(R_EVENT *event) { +R_EVENT *Events::queue(R_EVENT *event) { YS_DL_NODE *new_node; R_EVENT *queued_event; event->chain = NULL; - new_node = ys_dll_add_tail(EventList, event, sizeof *event); + new_node = ys_dll_add_tail(_eventList, event, sizeof *event); if (new_node == NULL) { return NULL; @@ -332,14 +330,14 @@ R_EVENT *EVENT_Queue(R_EVENT *event) { queued_event = (R_EVENT *)ys_dll_get_data(new_node); - InitializeEvent(queued_event); + initializeEvent(queued_event); return queued_event; } // Places a 'add_event' on the end of an event chain given by 'head_event' // (head_event may be in any position in the event chain) -R_EVENT *EVENT_Chain(R_EVENT *head_event, R_EVENT *add_event) { +R_EVENT *Events::chain(R_EVENT *head_event, R_EVENT *add_event) { R_EVENT *walk_event; R_EVENT *new_event; @@ -360,12 +358,12 @@ R_EVENT *EVENT_Chain(R_EVENT *head_event, R_EVENT *add_event) { // Place new event walk_event->chain = new_event; new_event->chain = NULL; - InitializeEvent(new_event); + initializeEvent(new_event); return new_event; } -static int InitializeEvent(R_EVENT *event) { +int Events::initializeEvent(R_EVENT *event) { switch (event->type) { case R_ONESHOT_EVENT: break; @@ -382,7 +380,7 @@ static int InitializeEvent(R_EVENT *event) { return R_SUCCESS; } -int EVENT_ClearList() { +int Events::clearList() { YS_DL_NODE *walk_node; YS_DL_NODE *next_node; R_EVENT *chain_walk; @@ -390,7 +388,7 @@ int EVENT_ClearList() { R_EVENT *event_p; // Walk down event list - for (walk_node = ys_dll_head(EventList); walk_node != NULL; walk_node = next_node) { + for (walk_node = ys_dll_head(_eventList); walk_node != NULL; walk_node = next_node) { next_node = ys_dll_next(walk_node); event_p = (R_EVENT *)ys_dll_get_data(walk_node); @@ -409,7 +407,7 @@ int EVENT_ClearList() { } // Removes all events from the list (even R_NODESTROY) -int EVENT_FreeList() { +int Events::freeList() { YS_DL_NODE *walk_node; YS_DL_NODE *next_node; R_EVENT *chain_walk; @@ -417,7 +415,7 @@ int EVENT_FreeList() { R_EVENT *event_p; // Walk down event list - for (walk_node = ys_dll_head(EventList); walk_node != NULL; walk_node = next_node) { + for (walk_node = ys_dll_head(_eventList); walk_node != NULL; walk_node = next_node) { event_p = (R_EVENT *)ys_dll_get_data(walk_node); // Remove any events chained off current node for (chain_walk = event_p->chain; chain_walk != NULL; chain_walk = next_chain) { @@ -434,12 +432,12 @@ int EVENT_FreeList() { } // Walks down the event list, updating event times by 'msec'. -static int ProcessEventTime(long msec) { +int Events::processEventTime(long msec) { YS_DL_NODE *walk_node; R_EVENT *event_p; uint16 event_count = 0; - for (walk_node = ys_dll_head(EventList); walk_node != NULL; walk_node = ys_dll_next(walk_node)) { + for (walk_node = ys_dll_head(_eventList); walk_node != NULL; walk_node = ys_dll_next(walk_node)) { event_p = (R_EVENT *)ys_dll_get_data(walk_node); event_p->time -= msec; event_count++; diff --git a/saga/events.h b/saga/events.h index 8d22151a6e..c2427d6f28 100644 --- a/saga/events.h +++ b/saga/events.h @@ -27,6 +27,83 @@ #define SAGA_EVENT_H namespace Saga { +enum R_EVENT_TYPES { + R_ONESHOT_EVENT, + R_CONTINUOUS_EVENT, + R_INTERVAL_EVENT +}; + +enum R_EVENT_FLAGS { + R_SIGNALED = 0x8000, + R_NODESTROY = 0x4000 +}; + +enum R_EVENT_CODES { + R_BG_EVENT = 1, + R_ANIM_EVENT, + R_MUSIC_EVENT, + R_VOICE_EVENT, + R_SOUND_EVENT, + R_SCENE_EVENT, + R_TEXT_EVENT, + R_PAL_EVENT, + R_PALANIM_EVENT, + R_TRANSITION_EVENT, + R_INTERFACE_EVENT, + R_CONSOLE_EVENT, + R_ACTOR_EVENT +}; + +enum R_EVENT_OPS { + // INSTANTANEOUS events + // BG events + EVENT_DISPLAY = 1, + // ANIM events + EVENT_FRAME = 1, + // 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, + EVENT_DEACTIVATE, + // ACTOR events + EVENT_MOVE = 1, + + // CONTINUOUS events + // PALETTE events + EVENT_PALTOBLACK = 1, + EVENT_BLACKTOPAL = 2, + // TRANSITION events + EVENT_DISSOLVE = 1 +}; + +enum R_EVENT_PARAMS { + NO_SET_PALETTE, + SET_PALETTE +}; + +struct R_EVENT { + unsigned int type; + unsigned int code; // Event operation category & flags + int op; // Event operation + long param; // Optional event parameter + long param2; + void *data; // Optional event data + long time; // Elapsed time until event + long duration; // Duration of event + long d_reserved; + + R_EVENT *chain; // Event chain (For consecutive events) + R_EVENT() { memset(this, 0, sizeof(*this)); } +}; #define R_EVENT_WARNINGCOUNT 1000 #define R_EVENT_MASK 0x00FF @@ -38,11 +115,29 @@ enum R_EVENT_STATUSCODE { R_EVENT_BREAK }; -static int HandleContinuous(R_EVENT * event); -static int HandleOneShot(R_EVENT * event); -static int HandleInterval(R_EVENT * event); -static int ProcessEventTime(long msec); -static int InitializeEvent(R_EVENT * event); +class Events { + public: + Events(SagaEngine *vm); + ~Events(void); + int handleEvents(long msec); + int clearList(); + int freeList(); + R_EVENT *queue(R_EVENT *event); + R_EVENT *chain(R_EVENT *eead_event, R_EVENT *add_event); + + private: + int handleContinuous(R_EVENT * event); + int handleOneShot(R_EVENT * event); + int handleInterval(R_EVENT * event); + int processEventTime(long msec); + int initializeEvent(R_EVENT * event); + + private: + SagaEngine *_vm; + bool _initialized; + + YS_DL_LIST *_eventList; +}; } // End of namespace Saga diff --git a/saga/events_mod.h b/saga/events_mod.h deleted file mode 100644 index 2fd0cf9c4b..0000000000 --- a/saga/events_mod.h +++ /dev/null @@ -1,119 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2004 The ScummVM project - * - * 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$ - * - */ - -// Event module public header - -#ifndef SAGA_EVENTS_MOD_H -#define SAGA_EVENTS_MOD_H - -namespace Saga { - -enum R_EVENT_TYPES { - R_ONESHOT_EVENT, - R_CONTINUOUS_EVENT, - R_INTERVAL_EVENT -}; - -enum R_EVENT_FLAGS { - R_SIGNALED = 0x8000, - R_NODESTROY = 0x4000 -}; - -enum R_EVENT_CODES { - R_BG_EVENT = 1, - R_ANIM_EVENT, - R_MUSIC_EVENT, - R_VOICE_EVENT, - R_SOUND_EVENT, - R_SCENE_EVENT, - R_TEXT_EVENT, - R_PAL_EVENT, - R_PALANIM_EVENT, - R_TRANSITION_EVENT, - R_INTERFACE_EVENT, - R_CONSOLE_EVENT, - R_ACTOR_EVENT -}; - -enum R_EVENT_OPS { - // INSTANTANEOUS events - // BG events - EVENT_DISPLAY = 1, - // ANIM events - EVENT_FRAME = 1, - // 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, - EVENT_DEACTIVATE, - // ACTOR events - EVENT_MOVE = 1, - - // CONTINUOUS events - // PALETTE events - EVENT_PALTOBLACK = 1, - EVENT_BLACKTOPAL = 2, - // TRANSITION events - EVENT_DISSOLVE = 1 -}; - -enum R_EVENT_PARAMS { - NO_SET_PALETTE, - SET_PALETTE -}; - -struct R_EVENT { - unsigned int type; - unsigned int code; // Event operation category & flags - int op; // Event operation - long param; // Optional event parameter - long param2; - void *data; // Optional event data - long time; // Elapsed time until event - long duration; // Duration of event - long d_reserved; - - R_EVENT *chain; // Event chain (For consecutive events) - R_EVENT() { memset(this, 0, sizeof(*this)); } -}; - -int EVENT_Init(); -int EVENT_Shutdown(); -int EVENT_HandleEvents(long msec); -int EVENT_ClearList(); -int EVENT_FreeList(); -R_EVENT *EVENT_Queue(R_EVENT *event); -R_EVENT *EVENT_Chain(R_EVENT *eead_event, R_EVENT *add_event); - -} // End of namespace Saga - -#endif diff --git a/saga/ihnm_introproc.cpp b/saga/ihnm_introproc.cpp index 025084e574..82d565a99a 100644 --- a/saga/ihnm_introproc.cpp +++ b/saga/ihnm_introproc.cpp @@ -29,7 +29,7 @@ #include "saga/animation.h" #include "saga/cvar_mod.h" -#include "saga/events_mod.h" +#include "saga/events.h" #include "saga/rscfile_mod.h" #include "saga/palanim_mod.h" @@ -119,7 +119,7 @@ int IHNM_IntroMovieProc1(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_DISPLAY; event.param = SET_PALETTE; event.time = 0; - EVENT_Queue(&event); + _vm->_events->queue(&event); _vm->_anim->setFrameTime(0, R_IHNM_INTRO_FRAMETIME); _vm->_anim->setFlag(0, ANIM_ENDSCENE); _vm->_anim->play(0, 0); @@ -150,7 +150,7 @@ int IHNM_IntroMovieProc2(int param, R_SCENE_INFO *scene_info) { event.duration = R_IHNM_PALFADE_TIME; event.data = current_pal; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); // Background for intro scene is the first frame of the // intro animation; display it but don't set palette @@ -160,7 +160,7 @@ int IHNM_IntroMovieProc2(int param, R_SCENE_INFO *scene_info) { event.param = NO_SET_PALETTE; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Fade in from black to the scene background palette _vm->_scene->getBGPal(&pal); @@ -172,7 +172,7 @@ int IHNM_IntroMovieProc2(int param, R_SCENE_INFO *scene_info) { event.duration = R_IHNM_PALFADE_TIME; event.data = pal; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); _vm->_anim->setFlag(0, ANIM_LOOP); _vm->_anim->play(0, R_IHNM_PALFADE_TIME * 2); @@ -183,7 +183,7 @@ int IHNM_IntroMovieProc2(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_END; event.time = R_IHNM_DGLOGO_TIME; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); break; default: break; @@ -210,7 +210,7 @@ int IHNM_IntroMovieProc3(int param, R_SCENE_INFO *scene_info) { event.duration = R_IHNM_PALFADE_TIME; event.data = current_pal; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); // Background for intro scene is the first frame of the // intro animation; display it but don't set palette @@ -220,7 +220,7 @@ int IHNM_IntroMovieProc3(int param, R_SCENE_INFO *scene_info) { event.param = NO_SET_PALETTE; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Fade in from black to the scene background palette _vm->_scene->getBGPal(&pal); @@ -232,7 +232,7 @@ int IHNM_IntroMovieProc3(int param, R_SCENE_INFO *scene_info) { event.duration = R_IHNM_PALFADE_TIME; event.data = pal; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); _vm->_anim->play(0, 0); @@ -242,7 +242,7 @@ int IHNM_IntroMovieProc3(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_END; event.time = R_IHNM_TITLE_TIME; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); break; default: break; @@ -265,7 +265,7 @@ int IHNM_HateProc(int param, R_SCENE_INFO *scene_info) { event.param = SET_PALETTE; event.time = 0; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); _vm->_anim->setFlag(0, ANIM_LOOP); _vm->_anim->play(0, 0); diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp index fe383a0c4b..8f88381b26 100644 --- a/saga/ite_introproc.cpp +++ b/saga/ite_introproc.cpp @@ -30,7 +30,7 @@ #include "saga/animation.h" #include "saga/cvar_mod.h" -#include "saga/events_mod.h" +#include "saga/events.h" #include "saga/font.h" #include "saga/game_mod.h" #include "saga/rscfile_mod.h" @@ -190,7 +190,7 @@ int ITE_IntroAnimProc(int param, R_SCENE_INFO *scene_info) { event.param = SET_PALETTE; event.time = 0; - EVENT_Queue(&event); + _vm->_events->queue(&event); debug(0, "Intro animation procedure started."); debug(0, "Linking animation resources..."); @@ -221,7 +221,7 @@ int ITE_IntroAnimProc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_PLAY; event.time = 0; - EVENT_Queue(&event); + _vm->_events->queue(&event); break; case SCENE_END: break; @@ -257,7 +257,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { event.time = 0; event.duration = PALETTE_FADE_DURATION; event.data = current_pal; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); // Display scene background, but stay with black palette event.type = R_ONESHOT_EVENT; @@ -265,7 +265,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_DISPLAY; event.param = NO_SET_PALETTE; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Fade in from black to the scene background palette _vm->_scene->getBGPal(&pal); @@ -276,7 +276,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { event.duration = PALETTE_FADE_DURATION; event.data = pal; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Begin palette cycling animation for candles event.type = R_ONESHOT_EVENT; @@ -284,7 +284,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_CYCLESTART; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Queue narrator dialogue list text_entry.color = 255; @@ -305,7 +305,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Play voice event.type = R_ONESHOT_EVENT; @@ -314,7 +314,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { event.param = IntroDiag[i].i_voice_rn; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); voice_len = _vm->_sndRes->getVoiceLength(IntroDiag[i].i_voice_rn); if (voice_len < 0) { @@ -328,7 +328,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = voice_len; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); event_time = voice_pad; } @@ -339,7 +339,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_END; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); break; case SCENE_END: break; @@ -373,7 +373,7 @@ int ITE_IntroCave2Proc(int param, R_SCENE_INFO *scene_info) { event.time = 0; event.duration = DISSOLVE_DURATION; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); // Begin palette cycling animation for candles event.type = R_ONESHOT_EVENT; @@ -381,7 +381,7 @@ int ITE_IntroCave2Proc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_CYCLESTART; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Queue narrator dialogue list text_entry.color = 255; @@ -402,7 +402,7 @@ int ITE_IntroCave2Proc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Play voice event.type = R_ONESHOT_EVENT; @@ -411,7 +411,7 @@ int ITE_IntroCave2Proc(int param, R_SCENE_INFO *scene_info) { event.param = IntroDiag[i].i_voice_rn; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); voice_len = _vm->_sndRes->getVoiceLength(IntroDiag[i].i_voice_rn); if (voice_len < 0) { @@ -425,7 +425,7 @@ int ITE_IntroCave2Proc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = voice_len; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); event_time = voice_pad; } @@ -436,7 +436,7 @@ int ITE_IntroCave2Proc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_END; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); break; case SCENE_END: break; @@ -469,7 +469,7 @@ int ITE_IntroCave3Proc(int param, R_SCENE_INFO *scene_info) { event.time = 0; event.duration = DISSOLVE_DURATION; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); // Begin palette cycling animation for candles event.type = R_ONESHOT_EVENT; @@ -477,7 +477,7 @@ int ITE_IntroCave3Proc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_CYCLESTART; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Queue narrator dialogue list text_entry.color = 255; @@ -498,7 +498,7 @@ int ITE_IntroCave3Proc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Play voice event.type = R_ONESHOT_EVENT; @@ -507,7 +507,7 @@ int ITE_IntroCave3Proc(int param, R_SCENE_INFO *scene_info) { event.param = IntroDiag[i].i_voice_rn; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); voice_len = _vm->_sndRes->getVoiceLength(IntroDiag[i].i_voice_rn); if (voice_len < 0) { @@ -521,7 +521,7 @@ int ITE_IntroCave3Proc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = voice_len; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); event_time = voice_pad; } @@ -532,7 +532,7 @@ int ITE_IntroCave3Proc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_END; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); break; case SCENE_END: @@ -566,7 +566,7 @@ int ITE_IntroCave4Proc(int param, R_SCENE_INFO *scene_info) { event.time = 0; event.duration = DISSOLVE_DURATION; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); // Begin palette cycling animation for candles event.type = R_ONESHOT_EVENT; @@ -574,7 +574,7 @@ int ITE_IntroCave4Proc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_CYCLESTART; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Queue narrator dialogue list text_entry.color = 255; @@ -595,7 +595,7 @@ int ITE_IntroCave4Proc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Play voice event.type = R_ONESHOT_EVENT; @@ -604,7 +604,7 @@ int ITE_IntroCave4Proc(int param, R_SCENE_INFO *scene_info) { event.param = IntroDiag[i].i_voice_rn; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); voice_len = _vm->_sndRes->getVoiceLength(IntroDiag[i].i_voice_rn); if (voice_len < 0) { @@ -618,7 +618,7 @@ int ITE_IntroCave4Proc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = voice_len; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); event_time = voice_pad; } @@ -629,7 +629,7 @@ int ITE_IntroCave4Proc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_END; event.time = event_time; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); break; case SCENE_END: @@ -678,7 +678,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { event.param = SET_PALETTE; event.time = 0; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); debug(0, "Beginning animation playback."); @@ -695,7 +695,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_PLAY; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Queue game credits list text_entry.color = 255; @@ -717,7 +717,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = event_delay += credits[i].delta_time; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); // Remove text event.type = R_ONESHOT_EVENT; @@ -726,7 +726,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = credits[i].duration; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); } // End scene after credit display @@ -735,7 +735,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_END; event.time = 1000; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); break; case SCENE_END: break; @@ -795,7 +795,7 @@ int ITE_IntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { event.time = 0; event.duration = DISSOLVE_DURATION; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); event_delay = DISSOLVE_DURATION; @@ -823,7 +823,7 @@ int ITE_IntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = event_delay += credits[i].delta_time; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); // Remove text event.type = R_ONESHOT_EVENT; @@ -832,7 +832,7 @@ int ITE_IntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = credits[i].duration; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); } // End scene after credit display @@ -841,7 +841,7 @@ int ITE_IntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_END; event.time = 1000; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); break; case SCENE_END: break; @@ -904,7 +904,7 @@ int ITE_IntroFairePathProc(int param, R_SCENE_INFO *scene_info) { event.time = 0; event.duration = DISSOLVE_DURATION; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); event_delay = DISSOLVE_DURATION; @@ -932,7 +932,7 @@ int ITE_IntroFairePathProc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = event_delay += credits[i].delta_time; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); // Remove text event.type = R_ONESHOT_EVENT; @@ -941,7 +941,7 @@ int ITE_IntroFairePathProc(int param, R_SCENE_INFO *scene_info) { event.data = entry_p; event.time = credits[i].duration; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); } // End scene after credit display @@ -950,7 +950,7 @@ int ITE_IntroFairePathProc(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_END; event.time = 1000; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); break; case SCENE_END: break; @@ -978,14 +978,14 @@ int ITE_IntroFaireTentProc(int param, R_SCENE_INFO *scene_info) { event.time = 0; event.duration = DISSOLVE_DURATION; - q_event_start = EVENT_Queue(&event); + q_event_start = _vm->_events->queue(&event); // End scene after momentary pause event.type = R_ONESHOT_EVENT; event.code = R_SCENE_EVENT; event.op = EVENT_END; event.time = 5000; - q_event = EVENT_Chain(q_event_start, &event); + q_event = _vm->_events->chain(q_event_start, &event); break; case SCENE_END: break; @@ -1021,7 +1021,7 @@ int initialScene(int param, R_SCENE_INFO *scene_info) { delay_time += PALETTE_FADE_DURATION; - q_event = EVENT_Queue(&event); + q_event = _vm->_events->queue(&event); // Activate user interface event.type = R_ONESHOT_EVENT; @@ -1029,7 +1029,7 @@ int initialScene(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_ACTIVATE; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Set first scene background w/o changing palette event.type = R_ONESHOT_EVENT; @@ -1038,7 +1038,7 @@ int initialScene(int param, R_SCENE_INFO *scene_info) { event.param = NO_SET_PALETTE; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); // Fade in to first scene background palette _vm->_scene->getBGPal(&pal); @@ -1050,13 +1050,13 @@ int initialScene(int param, R_SCENE_INFO *scene_info) { event.duration = PALETTE_FADE_DURATION; event.data = pal; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); event.code = R_PALANIM_EVENT; event.op = EVENT_CYCLESTART; event.time = 0; - q_event = EVENT_Chain(q_event, &event); + q_event = _vm->_events->chain(q_event, &event); _vm->_anim->setFlag(0, ANIM_LOOP); _vm->_anim->play(0, delay_time); diff --git a/saga/palanim.cpp b/saga/palanim.cpp index 1f2747b5d6..0a7145b388 100644 --- a/saga/palanim.cpp +++ b/saga/palanim.cpp @@ -25,7 +25,7 @@ #include "saga/saga.h" #include "saga/gfx.h" -#include "saga/events_mod.h" +#include "saga/events.h" #include "saga/game_mod.h" #include "saga/palanim_mod.h" @@ -124,7 +124,7 @@ int PALANIM_CycleStart() { event.op = EVENT_CYCLESTEP; event.time = PALANIM_CYCLETIME; - EVENT_Queue(&event); + _vm->_events->queue(&event); return R_SUCCESS; } @@ -174,7 +174,7 @@ int PALANIM_CycleStep(int vectortime) { event.op = EVENT_CYCLESTEP; event.time = vectortime + PALANIM_CYCLETIME; - EVENT_Queue(&event); + _vm->_events->queue(&event); return R_SUCCESS; } diff --git a/saga/saga.cpp b/saga/saga.cpp index 1834592d0c..68034f8d1b 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -39,7 +39,7 @@ #include "saga/animation.h" #include "saga/console.h" #include "saga/cvar_mod.h" -#include "saga/events_mod.h" +#include "saga/events.h" #include "saga/actionmap.h" #include "saga/font.h" #include "saga/game_mod.h" @@ -136,7 +136,7 @@ void SagaEngine::go() { // Initialize engine modules _sndRes = new SndRes(this); - EVENT_Init(); + _events = new Events(this); _font = new Font(this); _sprite = new Sprite(this); _anim = new Anim(this); @@ -226,7 +226,7 @@ void SagaEngine::go() { msec = R_MAX_TIME_DELTA; } _actor->direct(msec); - EVENT_HandleEvents(msec); + _vm->_events->handleEvents(msec); STHREAD_ExecThreads(msec); } // Per frame processing @@ -243,7 +243,7 @@ void SagaEngine::shutdown() { delete _font; delete _console; CVAR_Shutdown(); - EVENT_Shutdown(); + delete _events; delete _interface; delete _render; diff --git a/saga/saga.h b/saga/saga.h index 3fa74693c4..0a5353c484 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -57,6 +57,7 @@ class Sprite; class Scene; class Interface; class Console; +class Events; using Common::MemoryReadStream; @@ -116,6 +117,7 @@ public: Scene *_scene; Interface *_interface; Console *_console; + Events *_events; private: int decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len); diff --git a/saga/scene.cpp b/saga/scene.cpp index 50df78e496..d39af2e3f9 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -30,7 +30,7 @@ #include "saga/animation.h" #include "saga/console.h" #include "saga/cvar_mod.h" -#include "saga/events_mod.h" +#include "saga/events.h" #include "saga/actionmap.h" #include "saga/isomap.h" #include "saga/script_mod.h" @@ -812,7 +812,7 @@ int Scene::endScene() { _animEntries = 0; - EVENT_ClearList(); + _vm->_events->clearList(); _vm->textClearList(_textList); _sceneLoaded = false; @@ -879,7 +879,7 @@ int defaultScene(int param, R_SCENE_INFO *scene_info) { event.param = SET_PALETTE; event.time = 0; - EVENT_Queue(&event); + _vm->_events->queue(&event); // Activate user interface event.type = R_ONESHOT_EVENT; @@ -887,7 +887,7 @@ int defaultScene(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_ACTIVATE; event.time = 0; - EVENT_Queue(&event); + _vm->_events->queue(&event); // Begin palette cycle animation if present event.type = R_ONESHOT_EVENT; @@ -895,7 +895,7 @@ int defaultScene(int param, R_SCENE_INFO *scene_info) { event.op = EVENT_CYCLESTART; event.time = 0; - EVENT_Queue(&event); + _vm->_events->queue(&event); break; case SCENE_END: break; |