aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.cpp18
-rw-r--r--engines/agi/agi.h3
-rw-r--r--engines/agi/cycle.cpp8
-rw-r--r--engines/agi/loader_v3.cpp4
-rw-r--r--engines/agi/op_cmd.cpp8
-rw-r--r--engines/agi/op_test.cpp3
-rw-r--r--engines/agi/preagi.cpp3
-rw-r--r--engines/agi/preagi_common.cpp6
-rw-r--r--engines/agi/preagi_mickey.cpp11
-rw-r--r--engines/agi/preagi_troll.cpp9
-rw-r--r--engines/agi/preagi_winnie.cpp10
-rw-r--r--engines/agi/saveload.cpp5
-rw-r--r--engines/agos/agos.cpp17
-rw-r--r--engines/agos/agos.h3
-rw-r--r--engines/agos/animation.cpp4
-rw-r--r--engines/agos/event.cpp5
-rw-r--r--engines/agos/gfx.cpp2
-rw-r--r--engines/agos/input.cpp4
-rw-r--r--engines/agos/script.cpp8
-rw-r--r--engines/agos/script_e1.cpp5
-rw-r--r--engines/agos/script_s1.cpp5
-rw-r--r--engines/agos/subroutine.cpp2
-rw-r--r--engines/cine/anim.cpp2
-rw-r--r--engines/cine/cine.cpp4
-rw-r--r--engines/cine/main_loop.cpp12
-rw-r--r--engines/cine/prc.cpp5
-rw-r--r--engines/cine/various.cpp4
-rw-r--r--engines/cine/various.h2
-rw-r--r--engines/dialogs.cpp189
-rw-r--r--engines/dialogs.h73
-rw-r--r--engines/engine.cpp47
-rw-r--r--engines/engine.h27
-rw-r--r--engines/gob/game_v1.cpp4
-rw-r--r--engines/gob/game_v2.cpp10
-rw-r--r--engines/gob/gob.cpp8
-rw-r--r--engines/gob/gob.h3
-rw-r--r--engines/gob/inter.cpp4
-rw-r--r--engines/gob/inter_bargon.cpp6
-rw-r--r--engines/gob/inter_v1.cpp4
-rw-r--r--engines/gob/inter_v2.cpp3
-rw-r--r--engines/gob/mult.cpp2
-rw-r--r--engines/gob/palanim.cpp3
-rw-r--r--engines/gob/sound/sound.cpp2
-rw-r--r--engines/gob/util.cpp6
-rw-r--r--engines/gob/videoplayer.cpp3
-rw-r--r--engines/kyra/gui.cpp3
-rw-r--r--engines/kyra/gui_hof.cpp2
-rw-r--r--engines/kyra/gui_lok.cpp16
-rw-r--r--engines/kyra/gui_mr.cpp2
-rw-r--r--engines/kyra/gui_v2.cpp6
-rw-r--r--engines/kyra/kyra_hof.cpp9
-rw-r--r--engines/kyra/kyra_lok.cpp25
-rw-r--r--engines/kyra/kyra_mr.cpp10
-rw-r--r--engines/kyra/kyra_v1.cpp9
-rw-r--r--engines/kyra/kyra_v1.h5
-rw-r--r--engines/kyra/kyra_v2.cpp8
-rw-r--r--engines/kyra/saveload.cpp2
-rw-r--r--engines/kyra/saveload_lok.cpp2
-rw-r--r--engines/kyra/scene_hof.cpp2
-rw-r--r--engines/kyra/scene_mr.cpp2
-rw-r--r--engines/kyra/script_mr.cpp2
-rw-r--r--engines/kyra/sequences_hof.cpp22
-rw-r--r--engines/kyra/sequences_lok.cpp16
-rw-r--r--engines/kyra/sprites.cpp1
-rw-r--r--engines/kyra/text.cpp1
-rw-r--r--engines/kyra/text_hof.cpp12
-rw-r--r--engines/kyra/text_lok.cpp1
-rw-r--r--engines/kyra/text_mr.cpp10
-rw-r--r--engines/kyra/vqa.cpp2
-rw-r--r--engines/lure/events.cpp16
-rw-r--r--engines/lure/events.h2
-rw-r--r--engines/lure/fights.cpp8
-rw-r--r--engines/lure/game.cpp17
-rw-r--r--engines/lure/intro.cpp3
-rw-r--r--engines/lure/lure.cpp12
-rw-r--r--engines/lure/lure.h1
-rw-r--r--engines/lure/menu.cpp6
-rw-r--r--engines/lure/scripts.cpp6
-rw-r--r--engines/lure/sound.cpp48
-rw-r--r--engines/lure/sound.h4
-rw-r--r--engines/lure/surface.cpp14
-rw-r--r--engines/module.mk4
-rw-r--r--engines/parallaction/dialogue.cpp13
-rw-r--r--engines/parallaction/exec_ns.cpp11
-rw-r--r--engines/parallaction/gui_br.cpp3
-rw-r--r--engines/parallaction/input.cpp2
-rw-r--r--engines/parallaction/parallaction.cpp15
-rw-r--r--engines/parallaction/parallaction.h6
-rw-r--r--engines/parallaction/parallaction_br.cpp10
-rw-r--r--engines/parallaction/parallaction_ns.cpp16
-rw-r--r--engines/parallaction/saveload.cpp8
-rw-r--r--engines/queen/input.cpp3
-rw-r--r--engines/queen/journal.cpp1
-rw-r--r--engines/queen/logic.cpp10
-rw-r--r--engines/queen/queen.cpp10
-rw-r--r--engines/queen/queen.h5
-rw-r--r--engines/queen/sound.cpp3
-rw-r--r--engines/queen/talk.cpp2
-rw-r--r--engines/saga/input.cpp3
-rw-r--r--engines/saga/interface.cpp4
-rw-r--r--engines/saga/introproc_ihnm.cpp9
-rw-r--r--engines/saga/music.cpp14
-rw-r--r--engines/saga/music.h3
-rw-r--r--engines/saga/saga.cpp33
-rw-r--r--engines/saga/saga.h5
-rw-r--r--engines/saga/scene.cpp2
-rw-r--r--engines/saga/sfuncs.cpp4
-rw-r--r--engines/scumm/dialogs.cpp12
-rw-r--r--engines/scumm/dialogs.h6
-rw-r--r--engines/scumm/he/cup_player_he.cpp6
-rw-r--r--engines/scumm/he/script_v100he.cpp4
-rw-r--r--engines/scumm/he/script_v70he.cpp4
-rw-r--r--engines/scumm/he/script_v72he.cpp4
-rw-r--r--engines/scumm/input.cpp8
-rw-r--r--engines/scumm/resource.cpp2
-rw-r--r--engines/scumm/saveload.cpp2
-rw-r--r--engines/scumm/script_v5.cpp2
-rw-r--r--engines/scumm/script_v6.cpp2
-rw-r--r--engines/scumm/script_v8.cpp4
-rw-r--r--engines/scumm/scumm.cpp42
-rw-r--r--engines/scumm/scumm.h10
-rw-r--r--engines/scumm/smush/smush_player.cpp2
-rw-r--r--engines/sky/control.cpp11
-rw-r--r--engines/sky/intro.cpp2
-rw-r--r--engines/sky/intro.h1
-rw-r--r--engines/sky/logic.cpp2
-rw-r--r--engines/sky/mouse.cpp1
-rw-r--r--engines/sky/sky.cpp16
-rw-r--r--engines/sky/sky.h1
-rw-r--r--engines/sword1/animation.cpp3
-rw-r--r--engines/sword1/control.cpp9
-rw-r--r--engines/sword1/credits.cpp15
-rw-r--r--engines/sword1/logic.cpp2
-rw-r--r--engines/sword1/sword1.cpp18
-rw-r--r--engines/sword1/sword1.h1
-rw-r--r--engines/sword2/animation.cpp3
-rw-r--r--engines/sword2/controls.cpp8
-rw-r--r--engines/sword2/function.cpp2
-rw-r--r--engines/sword2/palette.cpp2
-rw-r--r--engines/sword2/resman.cpp2
-rw-r--r--engines/sword2/screen.cpp8
-rw-r--r--engines/sword2/sword2.cpp14
-rw-r--r--engines/sword2/sword2.h3
-rw-r--r--engines/touche/menu.cpp8
-rw-r--r--engines/touche/opcodes.cpp4
-rw-r--r--engines/touche/saveload.cpp2
-rw-r--r--engines/touche/touche.cpp41
-rw-r--r--engines/touche/touche.h1
148 files changed, 817 insertions, 545 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 9d88dd73ef..3838285610 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -25,7 +25,6 @@
#include "common/md5.h"
-#include "common/events.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/config-manager.h"
@@ -61,9 +60,6 @@ void AgiEngine::processEvents() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_QUIT:
- _game.quitProgNow = true;
- break;
case Common::EVENT_PREDICTIVE_DIALOG:
if (_predictiveDialogRunning)
break;
@@ -622,6 +618,7 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
// Setup mixer
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
+ _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, ConfMan.getInt("music_volume"));
const GameSettings *g;
@@ -809,7 +806,18 @@ int AgiEngine::go() {
runGame();
- return 0;
+ return _eventMan->shouldRTL();
+}
+
+void AgiEngine::syncSoundSettings() {
+ int soundVolumeMusic = ConfMan.getInt("music_volume");
+ int soundVolumeSFX = ConfMan.getInt("music_volume");
+ int soundVolumeSpeech = ConfMan.getInt("music_volume");
+
+ _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, soundVolumeMusic);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolumeSFX);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech);
}
} // End of namespace Agi
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 9240d562af..ec290b812d 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -530,7 +530,6 @@ struct AgiGame {
/* internal flags */
int playerControl; /**< player is in control */
- int quitProgNow; /**< quit now */
int statusLine; /**< status line on/off */
int clockEnabled; /**< clock is on/off */
int exitAllLogics; /**< break cycle after new.room */
@@ -754,6 +753,8 @@ public:
return _gameId;
}
+ virtual void syncSoundSettings();
+
private:
int _keyQueue[KEY_QUEUE_SIZE];
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index e0babdf926..3ceaaa8c90 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -24,7 +24,6 @@
*/
-
#include "agi/agi.h"
#include "agi/sprite.h"
#include "agi/graphics.h"
@@ -116,7 +115,7 @@ void AgiEngine::interpretCycle() {
oldSound = getflag(fSoundOn);
_game.exitAllLogics = false;
- while (runLogic(0) == 0 && !_game.quitProgNow) {
+ while (runLogic(0) == 0 && !quit()) {
_game.vars[vWordNotFound] = 0;
_game.vars[vBorderTouchObj] = 0;
_game.vars[vBorderCode] = 0;
@@ -314,7 +313,6 @@ int AgiEngine::playGame() {
setvar(vTimeDelay, 2); /* "normal" speed */
_game.gfxMode = true;
- _game.quitProgNow = false;
_game.clockEnabled = true;
_game.lineUserInput = 22;
@@ -354,10 +352,10 @@ int AgiEngine::playGame() {
_game.vars[vKey] = 0;
}
- if (_game.quitProgNow == 0xff)
+ if (quit() == 0xff)
ec = errRestartGame;
- } while (_game.quitProgNow == 0);
+ } while (quit() == 0);
_sound->stopSound();
diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp
index dcf7d83809..9f1255a43a 100644
--- a/engines/agi/loader_v3.cpp
+++ b/engines/agi/loader_v3.cpp
@@ -230,8 +230,8 @@ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {
debugC(3, kDebugLevelResources, "offset = %d", agid->offset);
debugC(3, kDebugLevelResources, "x = %x %x", x[0], x[1]);
error("ACK! BAD RESOURCE");
-
- g_system->quit();
+
+ _vm->quitGame();
}
agid->len = READ_LE_UINT16((uint8 *) x + 3); /* uncompressed size */
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 7ecedfbc8c..758bff0cb6 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -1213,11 +1213,11 @@ cmd(quit) {
g_sound->stopSound();
if (p0) {
- game.quitProgNow = true;
+ g_agi->quitGame();
} else {
if (g_agi->selectionBox
(" Quit the game, or continue? \n\n\n", buttons) == 0) {
- game.quitProgNow = true;
+ g_agi->quitGame();
}
}
}
@@ -1231,7 +1231,7 @@ cmd(restart_game) {
g_agi->selectionBox(" Restart game, or continue? \n\n\n", buttons);
if (sel == 0) {
- game.quitProgNow = 0xff;
+ g_agi->quitGame();
g_agi->setflag(fRestartGame, true);
g_agi->_menu->enableAll();
}
@@ -1739,7 +1739,7 @@ int AgiEngine::runLogic(int n) {
curLogic->cIP = curLogic->sIP;
timerHack = 0;
- while (ip < _game.logics[n].size && !_game.quitProgNow) {
+ while (ip < _game.logics[n].size && !quit()) {
if (_debug.enabled) {
if (_debug.steps > 0) {
if (_debug.logic0 || n) {
diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp
index 7ba3e625bf..393057ed9c 100644
--- a/engines/agi/op_test.cpp
+++ b/engines/agi/op_test.cpp
@@ -24,7 +24,6 @@
*/
-
#include "agi/agi.h"
#include "agi/keyboard.h"
#include "agi/opcodes.h"
@@ -232,7 +231,7 @@ int AgiEngine::testIfCode(int lognum) {
uint8 p[16] = { 0 };
bool end_test = false;
- while (retval && !game.quitProgNow && !end_test) {
+ while (retval && !quit() && !end_test) {
if (_debug.enabled && (_debug.logic0 || lognum))
debugConsole(lognum, lTEST_MODE, NULL);
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp
index f2301e012a..f391cd974a 100644
--- a/engines/agi/preagi.cpp
+++ b/engines/agi/preagi.cpp
@@ -23,7 +23,6 @@
*
*/
-#include "common/events.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/config-manager.h"
@@ -228,7 +227,7 @@ FIXME (Fingolfin asks): Why are Mickey, Winnie and Troll standalone classes
error("Unknown preagi engine");
break;
}
- return 0;
+ return _eventMan->shouldRTL();
}
} // End of namespace Agi
diff --git a/engines/agi/preagi_common.cpp b/engines/agi/preagi_common.cpp
index 5d99dfa7f9..7817a7594f 100644
--- a/engines/agi/preagi_common.cpp
+++ b/engines/agi/preagi_common.cpp
@@ -23,8 +23,6 @@
*
*/
-#include "common/events.h"
-
#include "agi/preagi.h"
#include "agi/font.h"
#include "agi/graphics.h"
@@ -122,11 +120,11 @@ void PreAgiEngine::printStrXOR(char *szMsg) {
int PreAgiEngine::getSelection(SelectionTypes type) {
Common::Event event;
- for (;;) {
+ while (!quit()) {
while (_eventMan->pollEvent(event)) {
switch(event.type) {
case Common::EVENT_QUIT:
- _system->quit();
+ return 0;
case Common::EVENT_RBUTTONUP:
return 0;
case Common::EVENT_LBUTTONUP:
diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp
index 08f8969ca3..6055d21197 100644
--- a/engines/agi/preagi_mickey.cpp
+++ b/engines/agi/preagi_mickey.cpp
@@ -23,7 +23,6 @@
*
*/
-#include "common/events.h"
#include "common/savefile.h"
#include "common/stream.h"
@@ -343,11 +342,11 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
drawMenu(menu, *sel0, *sel1);
- for (;;) {
+ while (!_vm->quit()) {
while (_vm->_system->getEventManager()->pollEvent(event)) {
switch(event.type) {
case Common::EVENT_QUIT:
- exit(0);
+ return 0;
case Common::EVENT_MOUSEMOVE:
if (iRow < 2) {
x = event.mouse.x / 8;
@@ -641,7 +640,6 @@ void Mickey::playSound(ENUM_MSA_SOUND iSound) {
while (_vm->_system->getEventManager()->pollEvent(event)) {
switch(event.type) {
case Common::EVENT_QUIT:
- _vm->_system->quit();
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
case Common::EVENT_KEYDOWN:
@@ -1214,7 +1212,7 @@ void Mickey::gameOver() {
}
waitAnyKey();
- exit(0);
+ _vm->quitGame();
}
void Mickey::flipSwitch() {
@@ -2054,7 +2052,6 @@ void Mickey::waitAnyKey(bool anim) {
while (_vm->_system->getEventManager()->pollEvent(event)) {
switch(event.type) {
case Common::EVENT_QUIT:
- _vm->_system->quit();
case Common::EVENT_KEYDOWN:
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
@@ -2153,7 +2150,7 @@ void Mickey::run() {
intro();
// Game loop
- for (;;) {
+ while (!_vm->quit()) {
drawRoom();
if (_game.fIntro) {
diff --git a/engines/agi/preagi_troll.cpp b/engines/agi/preagi_troll.cpp
index 7502c63c6c..418f174a94 100644
--- a/engines/agi/preagi_troll.cpp
+++ b/engines/agi/preagi_troll.cpp
@@ -30,8 +30,6 @@
#include "graphics/cursorman.h"
-#include "common/events.h"
-
namespace Agi {
Troll::Troll(PreAgiEngine* vm) : _vm(vm) {
@@ -58,11 +56,11 @@ bool Troll::getMenuSel(const char *szMenu, int *iSel, int nSel) {
drawMenu(szMenu, *iSel);
- for (;;) {
+ while (!_vm->quit()) {
while (_vm->_system->getEventManager()->pollEvent(event)) {
switch(event.type) {
case Common::EVENT_QUIT:
- _vm->_system->quit();
+ return 0;
case Common::EVENT_MOUSEMOVE:
y = event.mouse.y / 8;
@@ -206,7 +204,6 @@ void Troll::waitAnyKeyIntro() {
while (_vm->_system->getEventManager()->pollEvent(event)) {
switch(event.type) {
case Common::EVENT_QUIT:
- _vm->_system->quit();
case Common::EVENT_LBUTTONUP:
case Common::EVENT_KEYDOWN:
return;
@@ -269,7 +266,7 @@ void Troll::tutorial() {
int iSel = 0;
//char szTreasure[16] = {0};
- for (;;) {
+ while (!_vm->quit()) {
_vm->clearScreen(0xFF);
_vm->printStr(IDS_TRO_TUTORIAL_0);
diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp
index 87d13bff3d..bb0d375fc2 100644
--- a/engines/agi/preagi_winnie.cpp
+++ b/engines/agi/preagi_winnie.cpp
@@ -29,7 +29,6 @@
#include "graphics/cursorman.h"
-#include "common/events.h"
#include "common/savefile.h"
#include "common/stream.h"
@@ -241,7 +240,7 @@ int Winnie::parser(int pc, int index, uint8 *buffer) {
// extract header from buffer
parseRoomHeader(&hdr, buffer, sizeof(WTP_ROOM_HDR));
- for (;;) {
+ while (!_vm->quit()) {
pc = startpc;
// check if block is to be run
@@ -797,12 +796,11 @@ void Winnie::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {
// Show the mouse cursor for the menu
CursorMan.showMouse(true);
- for (;;) {
+ while (!_vm->quit()) {
while (_vm->_system->getEventManager()->pollEvent(event)) {
switch(event.type) {
case Common::EVENT_QUIT:
- _vm->_system->quit();
- break;
+ return;
case Common::EVENT_MOUSEMOVE:
x = event.mouse.x / 8;
y = event.mouse.y / 8;
@@ -1014,7 +1012,7 @@ phase2:
if (parser(hdr.ofsDesc[iBlock] - _roomOffset, iBlock, roomdata) == IDI_WTP_PAR_BACK)
goto phase1;
}
- for (;;) {
+ while (!_vm->quit()) {
for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
switch(parser(hdr.ofsBlock[iBlock] - _roomOffset, iBlock, roomdata)) {
case IDI_WTP_PAR_GOTO:
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index db7bba13e4..1589611c01 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -91,7 +91,7 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
out->writeSint16BE((int16)_game.lognum);
out->writeSint16BE((int16)_game.playerControl);
- out->writeSint16BE((int16)_game.quitProgNow);
+ out->writeSint16BE((int16)quit());
out->writeSint16BE((int16)_game.statusLine);
out->writeSint16BE((int16)_game.clockEnabled);
out->writeSint16BE((int16)_game.exitAllLogics);
@@ -281,7 +281,8 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
_game.lognum = in->readSint16BE();
_game.playerControl = in->readSint16BE();
- _game.quitProgNow = in->readSint16BE();
+ if (in->readSint16BE())
+ quitGame();
_game.statusLine = in->readSint16BE();
_game.clockEnabled = in->readSint16BE();
_game.exitAllLogics = in->readSint16BE();
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index 365f9fcde7..a6e559726a 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -97,8 +97,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_vc_get_out_of_code = 0;
_gameOffsetsPtr = 0;
- _quit = false;
-
_debugger = 0;
_gameFile = 0;
@@ -949,7 +947,7 @@ void AGOSEngine::pauseEngineIntern(bool pauseIt) {
void AGOSEngine::pause() {
pauseEngine(true);
- while (_pause && !_quit) {
+ while (_pause && !quit()) {
delay(1);
if (_keyPressed.keycode == Common::KEYCODE_p)
pauseEngine(false);
@@ -986,7 +984,7 @@ int AGOSEngine::go() {
(getFeatures() & GF_DEMO)) {
int i;
- while (!_quit) {
+ while (!quit()) {
for (i = 0; i < 4; i++) {
setWindowImage(3, 9902 + i);
debug(0, "Displaying image %d", 9902 + i);
@@ -1015,13 +1013,13 @@ int AGOSEngine::go() {
runSubroutine101();
permitInput();
- while (!_quit) {
+ while (!quit()) {
waitForInput();
handleVerbClicked(_verbHitArea);
delay(100);
}
- return 0;
+ return _eventMan->shouldRTL();
}
@@ -1081,4 +1079,11 @@ uint32 AGOSEngine::getTime() const {
return (uint32)time(NULL);
}
+
+void AGOSEngine::syncSoundSettings() {
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
+ _midi.setVolume(ConfMan.getInt("music_volume"));
+}
+
} // End of namespace AGOS
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index 74a0b026e9..fe1d36f281 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -269,7 +269,6 @@ protected:
uint16 _marks;
- bool _quit;
bool _scriptVar2;
bool _runScriptReturn1;
bool _runScriptCondition[40];
@@ -589,6 +588,8 @@ protected:
void loadSoundFile(const char *filename);
+ virtual void syncSoundSettings();
+
int getUserFlag(Item *item, int a);
int getUserFlag1(Item *item, int a);
int getUserItem(Item *item, int n);
diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp
index c92f834a3b..1b6626fa89 100644
--- a/engines/agos/animation.cpp
+++ b/engines/agos/animation.cpp
@@ -26,7 +26,6 @@
#include "common/endian.h"
-#include "common/events.h"
#include "common/system.h"
#include "graphics/cursorman.h"
@@ -279,9 +278,6 @@ void MoviePlayer::handleNextFrame() {
case Common::EVENT_RBUTTONUP:
_rightButtonDown = false;
break;
- case Common::EVENT_QUIT:
- _vm->_quit = true;
- break;
default:
break;
}
diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp
index 010b331cf8..5082db84be 100644
--- a/engines/agos/event.cpp
+++ b/engines/agos/event.cpp
@@ -142,7 +142,7 @@ bool AGOSEngine::kickoffTimeEvents() {
cur_time = getTime() - _gameStoppedClock;
- while ((te = _firstTimeStruct) != NULL && te->time <= cur_time && !_quit) {
+ while ((te = _firstTimeStruct) != NULL && te->time <= cur_time && !quit()) {
result = true;
_pendingDeleteTimeEvent = te;
invokeTimeEvent(te);
@@ -521,7 +521,6 @@ void AGOSEngine::delay(uint amount) {
_rightButtonDown++;
break;
case Common::EVENT_QUIT:
- _quit = true;
return;
default:
break;
@@ -544,7 +543,7 @@ void AGOSEngine::delay(uint amount) {
_system->delayMillis(this_delay);
cur = _system->getMillis();
- } while (cur < start + amount && !_quit);
+ } while (cur < start + amount && !quit());
}
void AGOSEngine::timer_callback() {
diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp
index c014413bdc..9d3dea3ee1 100644
--- a/engines/agos/gfx.cpp
+++ b/engines/agos/gfx.cpp
@@ -1263,7 +1263,7 @@ void AGOSEngine::setWindowImageEx(uint16 mode, uint16 vga_res) {
if (getGameType() == GType_WW && (mode == 6 || mode == 8 || mode == 9)) {
setWindowImage(mode, vga_res);
} else {
- while (_copyScnFlag && !_quit)
+ while (_copyScnFlag && !quit())
delay(1);
setWindowImage(mode, vga_res);
diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp
index d36549f187..4d1b1b17cb 100644
--- a/engines/agos/input.cpp
+++ b/engines/agos/input.cpp
@@ -189,12 +189,12 @@ void AGOSEngine::waitForInput() {
resetVerbs();
}
- while (!_quit) {
+ while (!quit()) {
_lastHitArea = NULL;
_lastHitArea3 = NULL;
_dragAccept = 1;
- while (!_quit) {
+ while (!quit()) {
if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) &&
_keyPressed.keycode == Common::KEYCODE_F10)
displayBoxStars();
diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp
index 6758aec511..a0151d7713 100644
--- a/engines/agos/script.cpp
+++ b/engines/agos/script.cpp
@@ -410,7 +410,7 @@ void AGOSEngine::o_msg() {
void AGOSEngine::o_end() {
// 68: exit interpreter
- _quit = true;
+ quitGame();
}
void AGOSEngine::o_done() {
@@ -965,7 +965,7 @@ void AGOSEngine::writeVariable(uint16 variable, uint16 contents) {
int AGOSEngine::runScript() {
bool flag;
- if (_quit)
+ if (quit())
return 1;
do {
@@ -1010,7 +1010,7 @@ int AGOSEngine::runScript() {
error("Invalid opcode '%d' encountered", _opcode);
executeOpcode(_opcode);
- } while (getScriptCondition() != flag && !getScriptReturn() && !_quit);
+ } while (getScriptCondition() != flag && !getScriptReturn() && !quit());
return getScriptReturn();
}
@@ -1066,7 +1066,7 @@ void AGOSEngine::waitForSync(uint a) {
_exitCutscene = false;
_rightButtonDown = false;
- while (_vgaWaitFor != 0 && !_quit) {
+ while (_vgaWaitFor != 0 && !quit()) {
if (_rightButtonDown) {
if (_vgaWaitFor == 200 && (getGameType() == GType_FF || !getBitFlag(14))) {
skipSpeech();
diff --git a/engines/agos/script_e1.cpp b/engines/agos/script_e1.cpp
index c7e1d6736e..9ac308b114 100644
--- a/engines/agos/script_e1.cpp
+++ b/engines/agos/script_e1.cpp
@@ -24,7 +24,6 @@
*/
-
#include "agos/agos.h"
#include "agos/vga.h"
@@ -565,7 +564,7 @@ void AGOSEngine_Elvira1::oe1_look() {
lobjFunc(l, "You can see "); /* Show objects */
}
if (r && (r->flags & 4) && levelOf(i) < 10000) {
- _quit = true;
+ quitGame();
}
}
@@ -944,7 +943,7 @@ restart:
windowPutChar(window, *message2);
if (confirmYesOrNo(120, 62) == 0x7FFF) {
- _quit = true;
+ quitGame();
} else {
goto restart;
}
diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp
index 51918b9515..8bd9159ad8 100644
--- a/engines/agos/script_s1.cpp
+++ b/engines/agos/script_s1.cpp
@@ -24,7 +24,6 @@
*/
-
#include "common/system.h"
#include "agos/agos.h"
@@ -345,14 +344,14 @@ void AGOSEngine_Simon1::os1_pauseGame() {
if (isSmartphone()) {
if (_keyPressed.keycode) {
if (_keyPressed.keycode == Common::KEYCODE_RETURN)
- _quit = true;
+ quitGame();
else
break;
}
}
#endif
if (_keyPressed.keycode == keyYes)
- _quit = true;
+ quitGame();
else if (_keyPressed.keycode == keyNo)
break;
}
diff --git a/engines/agos/subroutine.cpp b/engines/agos/subroutine.cpp
index cb71ed7efa..488ebf4edf 100644
--- a/engines/agos/subroutine.cpp
+++ b/engines/agos/subroutine.cpp
@@ -555,7 +555,7 @@ int AGOSEngine::startSubroutine(Subroutine *sub) {
_currentTable = sub;
restart:
- if (_quit)
+ if (quit())
return result;
while ((byte *)sl != (byte *)sub) {
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp
index 055eb733c3..10f4aa55b5 100644
--- a/engines/cine/anim.cpp
+++ b/engines/cine/anim.cpp
@@ -731,7 +731,7 @@ void loadResource(const char *resourceName) {
loadSeq(resourceName, -1);
return;
} else if (strstr(resourceName, "ECHEC")) { // Echec (French) means failure
- exitEngine = 1;
+ g_cine->quitGame();
return;
}
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp
index f6778b6457..50aefe5ff9 100644
--- a/engines/cine/cine.cpp
+++ b/engines/cine/cine.cpp
@@ -23,7 +23,6 @@
*
*/
-#include "common/events.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/config-manager.h"
@@ -102,7 +101,8 @@ int CineEngine::go() {
delete renderer;
delete[] page3Raw;
delete g_sound;
- return 0;
+
+ return _eventMan->shouldRTL();
}
diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp
index 6aa1ec1737..547379f02d 100644
--- a/engines/cine/main_loop.cpp
+++ b/engines/cine/main_loop.cpp
@@ -25,7 +25,6 @@
#include "common/scummsys.h"
-#include "common/events.h"
#include "common/system.h"
#include "cine/main_loop.h"
@@ -61,9 +60,6 @@ static void processEvent(Common::Event &event) {
break;
case Common::EVENT_MOUSEMOVE:
break;
- case Common::EVENT_QUIT:
- exitEngine = 1;
- break;
case Common::EVENT_KEYDOWN:
switch (event.kbd.keycode) {
case Common::KEYCODE_RETURN:
@@ -181,13 +177,9 @@ int getKeyData() {
void CineEngine::mainLoop(int bootScriptIdx) {
bool playerAction;
- uint16 quitFlag;
byte di;
uint16 mouseButton;
- quitFlag = 0;
- exitEngine = 0;
-
if (_preLoad == false) {
resetBgIncrustList();
@@ -303,7 +295,7 @@ void CineEngine::mainLoop(int bootScriptIdx) {
if ("quit"[menuCommandLen] == (char)di) {
++menuCommandLen;
if (menuCommandLen == 4) {
- quitFlag = 1;
+ quitGame();
}
} else {
menuCommandLen = 0;
@@ -312,7 +304,7 @@ void CineEngine::mainLoop(int bootScriptIdx) {
manageEvents();
- } while (!exitEngine && !quitFlag && _danKeysPressed != 7);
+ } while (!quit() && _danKeysPressed != 7);
hideMouse();
g_sound->stopMusic();
diff --git a/engines/cine/prc.cpp b/engines/cine/prc.cpp
index 402c97b1a6..42dcf1b491 100644
--- a/engines/cine/prc.cpp
+++ b/engines/cine/prc.cpp
@@ -25,6 +25,7 @@
#include "common/endian.h"
+#include "common/events.h"
#include "cine/cine.h"
#include "cine/various.h"
@@ -53,7 +54,9 @@ void loadPrc(const char *pPrcName) {
// This is copy protection. Used to hang the machine
if (!scumm_stricmp(pPrcName, "L201.ANI")) {
- exitEngine = 1;
+ Common::Event event;
+ event.type = Common::EVENT_RTL;
+ g_system->getEventManager()->pushEvent(event);
return;
}
diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp
index 4b5d4efe13..46168b306c 100644
--- a/engines/cine/various.cpp
+++ b/engines/cine/various.cpp
@@ -25,7 +25,6 @@
#include "common/endian.h"
-#include "common/events.h"
#include "common/savefile.h"
#include "cine/cine.h"
@@ -113,7 +112,6 @@ static const int16 canUseOnItemTable[] = { 1, 0, 0, 1, 1, 0, 0 };
CommandeType objectListCommand[20];
int16 objListTab[20];
-uint16 exitEngine;
uint16 zoneData[NUM_MAX_ZONE];
uint16 zoneQuery[NUM_MAX_ZONE]; //!< Only exists in Operation Stealth
@@ -765,7 +763,7 @@ void CineEngine::makeSystemMenu(void) {
{
getMouseData(mouseUpdateStatus, (uint16 *)&mouseButton, (uint16 *)&mouseX, (uint16 *)&mouseY);
if (!makeMenuChoice(confirmMenu, 2, mouseX, mouseY + 8, 100)) {
- exitEngine = 1;
+ quitGame();
}
break;
}
diff --git a/engines/cine/various.h b/engines/cine/various.h
index 840f1674a2..3befde7eb8 100644
--- a/engines/cine/various.h
+++ b/engines/cine/various.h
@@ -117,8 +117,6 @@ void mainLoopSub6(void);
void checkForPendingDataLoad(void);
-extern uint16 exitEngine;
-
void hideMouse(void);
void removeExtention(char *dest, const char *source);
diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp
new file mode 100644
index 0000000000..adcb7b54ee
--- /dev/null
+++ b/engines/dialogs.cpp
@@ -0,0 +1,189 @@
+/* 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$
+ */
+
+#include "common/config-manager.h"
+#include "common/savefile.h"
+#include "common/system.h"
+#include "common/events.h"
+
+#include "graphics/scaler.h"
+
+#include "gui/about.h"
+#include "gui/eval.h"
+#include "gui/newgui.h"
+#include "gui/ListWidget.h"
+
+#include "engines/dialogs.h"
+#include "engines/engine.h"
+
+#ifdef SMALL_SCREEN_DEVICE
+#include "gui/KeysDialog.h"
+#endif
+
+using GUI::CommandSender;
+using GUI::StaticTextWidget;
+using GUI::kButtonWidth;
+using GUI::kButtonHeight;
+using GUI::kBigButtonWidth;
+using GUI::kBigButtonHeight;
+using GUI::kCloseCmd;
+using GUI::kTextAlignCenter;
+using GUI::kTextAlignLeft;
+using GUI::WIDGET_ENABLED;
+
+typedef GUI::OptionsDialog GUI_OptionsDialog;
+typedef GUI::Dialog GUI_Dialog;
+
+GlobalDialog::GlobalDialog(String name)
+ : GUI::Dialog(name) {
+_drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;}
+
+enum {
+ kSaveCmd = 'SAVE',
+ kLoadCmd = 'LOAD',
+ kPlayCmd = 'PLAY',
+ kOptionsCmd = 'OPTN',
+ kHelpCmd = 'HELP',
+ kAboutCmd = 'ABOU',
+ kQuitCmd = 'QUIT',
+ kRTLCmd = 'RTL',
+ kChooseCmd = 'CHOS'
+};
+
+MainMenuDialog::MainMenuDialog(Engine *engine)
+ : GlobalDialog("globalmain"), _engine(engine) {
+
+ new GUI::ButtonWidget(this, "globalmain_resume", "Resume", kPlayCmd, 'P');
+
+// new GUI::ButtonWidget(this, "scummmain_load", "Load", kLoadCmd, 'L');
+// new GUI::ButtonWidget(this, "scummmain_save", "Save", kSaveCmd, 'S');
+
+ new GUI::ButtonWidget(this, "globalmain_options", "Options", kOptionsCmd, 'O');
+
+ new GUI::ButtonWidget(this, "globalmain_about", "About", kAboutCmd, 'A');
+
+ new GUI::ButtonWidget(this, "globalmain_rtl", "Return to Launcher", kRTLCmd, 'R');
+
+ new GUI::ButtonWidget(this, "globalmain_quit", "Quit", kQuitCmd, 'Q');
+
+ _aboutDialog = new GUI::AboutDialog();
+ _optionsDialog = new ConfigDialog();
+}
+
+MainMenuDialog::~MainMenuDialog() {
+ delete _aboutDialog;
+ delete _optionsDialog;
+}
+
+void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+ switch (cmd) {
+ case kPlayCmd:
+ close();
+ break;
+ case kOptionsCmd:
+ _optionsDialog->runModal();
+ break;
+ case kAboutCmd:
+ _aboutDialog->runModal();
+ break;
+ case kRTLCmd: {
+ Common::Event eventRTL;
+ eventRTL.type = Common::EVENT_RTL;
+ g_system->getEventManager()->pushEvent(eventRTL);
+ close();
+ }
+ break;
+ case kQuitCmd: {
+ Common::Event eventQ;
+ eventQ.type = Common::EVENT_QUIT;
+ g_system->getEventManager()->pushEvent(eventQ);
+ close();
+ }
+ break;
+ default:
+ GlobalDialog::handleCommand(sender, cmd, data);
+ }
+}
+
+enum {
+ kOKCmd = 'ok '
+};
+
+enum {
+ kKeysCmd = 'KEYS'
+};
+
+ConfigDialog::ConfigDialog()
+ : GUI::OptionsDialog("", "scummconfig") {
+
+ //
+ // Sound controllers
+ //
+
+ addVolumeControls(this, "scummconfig_");
+
+ //
+ // Some misc options
+ //
+
+ // SCUMM has a talkspeed range of 0-9
+ addSubtitleControls(this, "scummconfig_", 9);
+
+ //
+ // Add the buttons
+ //
+
+ new GUI::ButtonWidget(this, "scummconfig_ok", "OK", GUI::OptionsDialog::kOKCmd, 'O');
+ new GUI::ButtonWidget(this, "scummconfig_cancel", "Cancel", kCloseCmd, 'C');
+
+#ifdef SMALL_SCREEN_DEVICE
+ new GUI::ButtonWidget(this, "scummconfig_keys", "Keys", kKeysCmd, 'K');
+
+ //
+ // Create the sub dialog(s)
+ //
+
+ _keysDialog = new GUI::KeysDialog();
+#endif
+}
+
+ConfigDialog::~ConfigDialog() {
+#ifdef SMALL_SCREEN_DEVICE
+ delete _keysDialog;
+#endif
+}
+
+void ConfigDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+ switch (cmd) {
+ case kKeysCmd:
+
+#ifdef SMALL_SCREEN_DEVICE
+ _keysDialog->runModal();
+#endif
+ break;
+ default:
+ GUI_OptionsDialog::handleCommand (sender, cmd, data);
+ }
+}
+
diff --git a/engines/dialogs.h b/engines/dialogs.h
new file mode 100644
index 0000000000..dc6bff4dd6
--- /dev/null
+++ b/engines/dialogs.h
@@ -0,0 +1,73 @@
+/* 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$
+ */
+
+#ifndef GLOBAL_DIALOGS_H
+#define GLOBAL_DIALOGS_H
+
+#include "common/str.h"
+#include "gui/dialog.h"
+#include "gui/options.h"
+#include "gui/widget.h"
+
+#include "engines/engine.h"
+
+
+class GlobalDialog : public GUI::Dialog {
+public:
+ GlobalDialog(Common::String name);
+
+protected:
+ typedef Common::String String;
+};
+
+
+class MainMenuDialog : public GlobalDialog {
+public:
+ MainMenuDialog(Engine *engine);
+ ~MainMenuDialog();
+
+ virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
+
+protected:
+ Engine *_engine;
+
+ GUI::Dialog *_aboutDialog;
+ GUI::Dialog *_optionsDialog;
+
+};
+
+class ConfigDialog : public GUI::OptionsDialog {
+protected:
+#ifdef SMALL_SCREEN_DEVICE
+ GUI::Dialog *_keysDialog;
+#endif
+
+public:
+ ConfigDialog();
+ ~ConfigDialog();
+
+ virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
+};
+
+#endif
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 757a77f82b..ffc044a508 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -36,7 +36,9 @@
#include "common/savefile.h"
#include "common/system.h"
#include "gui/message.h"
+#include "gui/newgui.h"
#include "sound/mixer.h"
+#include "engines/dialogs.h"
#ifdef _WIN32_WCE
extern bool isSmartphone(void);
@@ -54,7 +56,10 @@ Engine::Engine(OSystem *syst)
_saveFileMan(_system->getSavefileManager()),
_targetName(ConfMan.getActiveDomainName()),
_gameDataPath(ConfMan.get("path")),
- _pauseLevel(0) {
+ _pauseLevel(0),
+ _mainMenuDialog(NULL),
+ _quit(false),
+ _rtl(false) {
g_engine = this;
_autosavePeriod = ConfMan.getInt("autosave_period");
@@ -72,7 +77,8 @@ Engine::Engine(OSystem *syst)
Engine::~Engine() {
_mixer->stopAll();
-
+
+ delete _mainMenuDialog;
g_engine = NULL;
}
@@ -210,3 +216,40 @@ void Engine::pauseEngineIntern(bool pause) {
// By default, just (un)pause all digital sounds
_mixer->pauseAll(pause);
}
+
+void Engine::mainMenuDialog() {
+ if (!_mainMenuDialog)
+ _mainMenuDialog = new MainMenuDialog(this);
+ runDialog(*_mainMenuDialog);
+ syncSoundSettings();
+}
+
+int Engine::runDialog(Dialog &dialog) {
+
+ pauseEngine(true);
+
+ int result = dialog.runModal();
+
+ pauseEngine(false);
+
+ return 0;
+}
+
+void Engine::syncSoundSettings() {
+
+ // Sync the engine with the config manager
+ int soundVolumeMusic = ConfMan.getInt("music_volume");
+ int soundVolumeSFX = ConfMan.getInt("sfx_volume");
+ int soundVolumeSpeech = ConfMan.getInt("speech_volume");
+
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolumeSFX);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech);
+}
+
+void Engine::quitGame() {
+ Common::Event event;
+
+ event.type = Common::EVENT_QUIT;
+ _eventMan->pushEvent(event);
+}
diff --git a/engines/engine.h b/engines/engine.h
index 73d529cc62..0968642a08 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -25,6 +25,7 @@
#ifndef ENGINES_ENGINE_H
#define ENGINES_ENGINE_H
+#include "common/events.h"
#include "common/scummsys.h"
#include "common/str.h"
@@ -39,17 +40,25 @@ namespace Common {
}
namespace GUI {
class Debugger;
+ class Dialog;
}
+using GUI::Dialog;
+
class Engine {
public:
OSystem *_system;
Audio::Mixer *_mixer;
Common::TimerManager * _timer;
+ bool _quit, _rtl;
+
protected:
Common::EventManager *_eventMan;
Common::SaveFileManager *_saveFileMan;
+
+ Dialog *_mainMenuDialog;
+ virtual int runDialog(Dialog &dialog);
const Common::String _targetName; // target name for saves
const Common::String _gameDataPath;
@@ -109,10 +118,28 @@ public:
void pauseEngine(bool pause);
/**
+ * Quit the engine, sends a Quit event to the Event Manager
+ */
+ void quitGame();
+
+ /**
* Return whether the engine is currently paused or not.
*/
bool isPaused() const { return _pauseLevel != 0; }
+ /**
+ * Return whether or not the engine should quit
+ */
+ bool quit() const { return _eventMan->shouldQuit(); }
+
+ /** Run the Global Main Menu Dialog
+ */
+ virtual void mainMenuDialog();
+
+ /** Sync the engine's sound settings with the config manager
+ */
+ virtual void syncSoundSettings();
+
public:
/** Setup the backend's graphics mode. */
diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp
index 66deea8ec4..0ecbc81358 100644
--- a/engines/gob/game_v1.cpp
+++ b/engines/gob/game_v1.cpp
@@ -63,7 +63,7 @@ void Game_v1::playTot(int16 skipPlay) {
strcpy(savedTotName, _curTotFile);
if (skipPlay <= 0) {
- while (!_vm->_quitRequested) {
+ while (!_vm->quit()) {
for (int i = 0; i < 4; i++) {
_vm->_draw->_fontToSprite[i].sprite = -1;
_vm->_draw->_fontToSprite[i].base = -1;
@@ -997,7 +997,7 @@ void Game_v1::collisionsBlock(void) {
WRITE_VAR(16, 0);
_activeCollResId = 0;
}
- while ((_activeCollResId == 0) && !_vm->_inter->_terminate && !_vm->_quitRequested);
+ while ((_activeCollResId == 0) && !_vm->_inter->_terminate && !_vm->quit());
if (((uint16) _activeCollResId & ~0x8000) == collResId) {
collStackPos = 0;
diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp
index adf75176ab..7d9419b592 100644
--- a/engines/gob/game_v2.cpp
+++ b/engines/gob/game_v2.cpp
@@ -70,7 +70,7 @@ void Game_v2::playTot(int16 skipPlay) {
strcpy(savedTotName, _curTotFile);
if (skipPlay <= 0) {
- while (!_vm->_quitRequested) {
+ while (!_vm->quit()) {
if (_vm->_inter->_variables)
_vm->_draw->animateCursor(4);
@@ -438,7 +438,7 @@ int16 Game_v2::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
timeKey = _vm->_util->getTimeKey();
while (1) {
- if (_vm->_inter->_terminate || _vm->_quitRequested) {
+ if (_vm->_inter->_terminate || _vm->quit()) {
if (handleMouse)
_vm->_draw->blitCursor();
return 0;
@@ -1043,7 +1043,7 @@ void Game_v2::collisionsBlock(void) {
WRITE_VAR(16, 0);
_activeCollResId = 0;
}
- while ((_activeCollResId == 0) && !_vm->_inter->_terminate && !_vm->_quitRequested);
+ while ((_activeCollResId == 0) && !_vm->_inter->_terminate && !_vm->quit());
if ((_activeCollResId & 0xFFF) == collResId) {
collStackPos = 0;
@@ -1465,7 +1465,7 @@ int16 Game_v2::inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
key = checkCollisions(handleMouse, -300, collResId, collIndex);
if ((key != 0) || (*collResId != 0) ||
- _vm->_inter->_terminate || _vm->_quitRequested)
+ _vm->_inter->_terminate || _vm->quit())
break;
if (*pTotTime > 0) {
@@ -1479,7 +1479,7 @@ int16 Game_v2::inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
}
if ((key == 0) || (*collResId != 0) ||
- _vm->_inter->_terminate || _vm->_quitRequested)
+ _vm->_inter->_terminate || _vm->quit())
return 0;
switch (key) {
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index a3fe0ebbe2..a8cbfa0550 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -24,7 +24,6 @@
*/
#include "common/endian.h"
-#include "common/events.h"
#include "base/plugins.h"
#include "common/config-manager.h"
@@ -82,7 +81,6 @@ GobEngine::GobEngine(OSystem *syst) : Engine(syst) {
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
_copyProtection = ConfMan.getBool("copy_protection");
- _quitRequested = false;
Common::addSpecialDebugLevel(kDebugFuncOp, "FuncOpcodes", "Script FuncOpcodes debug level");
Common::addSpecialDebugLevel(kDebugDrawOp, "DrawOpcodes", "Script DrawOpcodes debug level");
@@ -112,11 +110,7 @@ GobEngine::~GobEngine() {
int GobEngine::go() {
_init->initGame(0);
- return 0;
-}
-
-void GobEngine::shutdown() {
- _quitRequested = true;
+ return _eventMan->shouldRTL();
}
const char *GobEngine::getLangDesc(int16 language) const {
diff --git a/engines/gob/gob.h b/engines/gob/gob.h
index ae2b53bc31..842a1dc59f 100644
--- a/engines/gob/gob.h
+++ b/engines/gob/gob.h
@@ -204,7 +204,6 @@ public:
char *_startTot0;
bool _copyProtection;
bool _noMusic;
- bool _quitRequested;
Global *_global;
Util *_util;
@@ -224,8 +223,6 @@ public:
SaveLoad *_saveLoad;
VideoPlayer *_vidPlayer;
- void shutdown();
-
const char *getLangDesc(int16 language) const;
void validateLanguage();
void validateVideoMode(int16 videoMode);
diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp
index df9c1353a0..c0a1bfc21a 100644
--- a/engines/gob/inter.cpp
+++ b/engines/gob/inter.cpp
@@ -259,7 +259,7 @@ void Inter::funcBlock(int16 retFlag) {
if (executeFuncOpcode(cmd2, cmd, params))
return;
- if (_vm->_quitRequested)
+ if (_vm->quit())
break;
if (_break) {
@@ -279,7 +279,7 @@ void Inter::funcBlock(int16 retFlag) {
void Inter::callSub(int16 retFlag) {
byte block;
- while (!_vm->_quitRequested && _vm->_global->_inter_execPtr &&
+ while (!_vm->quit() && _vm->_global->_inter_execPtr &&
(_vm->_global->_inter_execPtr != _vm->_game->_totFileData)) {
block = *_vm->_global->_inter_execPtr;
diff --git a/engines/gob/inter_bargon.cpp b/engines/gob/inter_bargon.cpp
index d493fb00d3..d23841efd6 100644
--- a/engines/gob/inter_bargon.cpp
+++ b/engines/gob/inter_bargon.cpp
@@ -750,7 +750,7 @@ void Inter_Bargon::oBargon_intro2(OpGobParams &params) {
for (i = 320; i >= 0; i--) {
_vm->_util->setScrollOffset(i, 0);
if ((_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == 0x11B) ||
- _vm->_quitRequested) {
+ _vm->quit()) {
_vm->_palAnim->fade(0, -2, 0);
_vm->_video->clearSurf(_vm->_draw->_frontSurface);
memset((char *) _vm->_draw->_vgaPalette, 0, 768);
@@ -760,7 +760,7 @@ void Inter_Bargon::oBargon_intro2(OpGobParams &params) {
break;
}
}
- if (!_vm->_quitRequested)
+ if (!_vm->quit())
_vm->_util->setScrollOffset(0, 0);
surface = 0;
if (VAR(57) == ((uint32) -1))
@@ -799,7 +799,7 @@ void Inter_Bargon::oBargon_intro3(OpGobParams &params) {
_vm->_util->longDelay(_vm->_util->getRandom(200));
}
if ((_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == 0x11B) ||
- _vm->_quitRequested) {
+ _vm->quit()) {
_vm->_sound->blasterStop(10);
_vm->_palAnim->fade(0, -2, 0);
_vm->_video->clearSurf(_vm->_draw->_frontSurface);
diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp
index 865d188a2e..cc114f0afc 100644
--- a/engines/gob/inter_v1.cpp
+++ b/engines/gob/inter_v1.cpp
@@ -1234,7 +1234,7 @@ bool Inter_v1::o1_repeatUntil(OpFuncParams &params) {
funcBlock(1);
_vm->_global->_inter_execPtr = blockPtr + size + 1;
flag = evalBoolResult();
- } while (!flag && !_break && !_terminate && !_vm->_quitRequested);
+ } while (!flag && !_break && !_terminate && !_vm->quit());
_nestLevel[0]--;
@@ -1269,7 +1269,7 @@ bool Inter_v1::o1_whileDo(OpFuncParams &params) {
} else
_vm->_global->_inter_execPtr += size;
- if (_break || _terminate || _vm->_quitRequested) {
+ if (_break || _terminate || _vm->quit()) {
_vm->_global->_inter_execPtr = blockPtr;
_vm->_global->_inter_execPtr += size;
break;
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index 2f1d2ec0be..b245001653 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -24,6 +24,7 @@
*/
#include "common/endian.h"
+
#include "sound/mixer.h"
#include "sound/mods/infogrames.h"
@@ -1489,7 +1490,7 @@ void Inter_v2::o2_scroll() {
curX = startX;
curY = startY;
- while (!_vm->_quitRequested && ((curX != endX) || (curY != endY))) {
+ while (!_vm->quit() && ((curX != endX) || (curY != endY))) {
curX = stepX > 0 ? MIN(curX + stepX, (int) endX) :
MAX(curX + stepX, (int) endX);
curY = stepY > 0 ? MIN(curY + stepY, (int) endY) :
diff --git a/engines/gob/mult.cpp b/engines/gob/mult.cpp
index b9373d48b3..a502e92188 100644
--- a/engines/gob/mult.cpp
+++ b/engines/gob/mult.cpp
@@ -209,7 +209,7 @@ void Mult::playMult(int16 startFrame, int16 endFrame, char checkEscape,
_frame++;
_vm->_util->waitEndFrame();
- } while (!stop && !stopNoClear && !_vm->_quitRequested);
+ } while (!stop && !stopNoClear && !_vm->quit());
if (!stopNoClear) {
if (_animDataAllocated) {
diff --git a/engines/gob/palanim.cpp b/engines/gob/palanim.cpp
index 71e73adf53..4f2e921dcb 100644
--- a/engines/gob/palanim.cpp
+++ b/engines/gob/palanim.cpp
@@ -23,6 +23,7 @@
*
*/
+
#include "gob/gob.h"
#include "gob/palanim.h"
#include "gob/global.h"
@@ -131,7 +132,7 @@ void PalAnim::fade(Video::PalDesc *palDesc, int16 fadeV, int16 allColors) {
bool stop;
int16 i;
- if (_vm->_quitRequested)
+ if (_vm->quit())
return;
_fadeValue = (fadeV < 0) ? -fadeV : 2;
diff --git a/engines/gob/sound/sound.cpp b/engines/gob/sound/sound.cpp
index 2d2bf8e043..e0c18b155f 100644
--- a/engines/gob/sound/sound.cpp
+++ b/engines/gob/sound/sound.cpp
@@ -369,7 +369,7 @@ void Sound::blasterWaitEndPlay(bool interruptible, bool stopComp) {
if (stopComp)
_blaster->endComposition();
- while (_blaster->isPlaying() && !_vm->_quitRequested) {
+ while (_blaster->isPlaying() && !_vm->_quit) {
if (interruptible && (_vm->_util->checkKey() == 0x11B)) {
WRITE_VAR(57, (uint32) -1);
return;
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index 4987426fe0..0a7b889031 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -23,7 +23,6 @@
*
*/
-#include "common/events.h"
#include "gob/gob.h"
#include "gob/util.h"
@@ -72,7 +71,7 @@ void Util::longDelay(uint16 msecs) {
_vm->_video->waitRetrace();
processInput();
delay(15);
- } while (!_vm->_quitRequested &&
+ } while (!_vm->quit() &&
((g_system->getMillis() * _vm->_global->_speedFactor) < time));
}
@@ -118,9 +117,6 @@ void Util::processInput(bool scroll) {
break;
case Common::EVENT_KEYUP:
break;
- case Common::EVENT_QUIT:
- _vm->_quitRequested = true;
- break;
default:
break;
}
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp
index aa47e6cf84..daf7bdd801 100644
--- a/engines/gob/videoplayer.cpp
+++ b/engines/gob/videoplayer.cpp
@@ -23,6 +23,7 @@
*
*/
+
#include "gob/videoplayer.h"
#include "gob/global.h"
#include "gob/util.h"
@@ -568,7 +569,7 @@ bool VideoPlayer::doPlay(int16 frame, int16 breakKey,
_vm->_util->processInput();
- if (_vm->_quitRequested) {
+ if (_vm->quit()) {
_primaryVideo->getVideo()->disableSound();
return true;
}
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp
index 96ea233025..8a5a4dfc91 100644
--- a/engines/kyra/gui.cpp
+++ b/engines/kyra/gui.cpp
@@ -378,9 +378,6 @@ bool MainMenu::getInput() {
while (_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_QUIT:
- _vm->quitGame();
- break;
case Common::EVENT_LBUTTONUP:
return true;
default:
diff --git a/engines/kyra/gui_hof.cpp b/engines/kyra/gui_hof.cpp
index 7d56743af5..cb3cef2fb3 100644
--- a/engines/kyra/gui_hof.cpp
+++ b/engines/kyra/gui_hof.cpp
@@ -512,7 +512,7 @@ void KyraEngine_HoF::bookLoop() {
showBookPage();
_bookShown = true;
- while (_bookShown && !_quitFlag) {
+ while (_bookShown && !quit()) {
checkInput(buttonList);
removeInputTop();
diff --git a/engines/kyra/gui_lok.cpp b/engines/kyra/gui_lok.cpp
index 35b343fc25..092aaedb23 100644
--- a/engines/kyra/gui_lok.cpp
+++ b/engines/kyra/gui_lok.cpp
@@ -34,7 +34,6 @@
#include "common/config-manager.h"
#include "common/savefile.h"
-#include "common/events.h"
#include "common/system.h"
namespace Kyra {
@@ -460,7 +459,7 @@ int GUI_LoK::buttonMenuCallback(Button *caller) {
updateAllMenuButtons();
}
- while (_displayMenu && !_vm->_quitFlag) {
+ while (_displayMenu && !_vm->quit()) {
Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[_toplevelMenu], mouse.x, mouse.y);
processButtonList(_menuButtonList, 0, 0);
@@ -485,9 +484,6 @@ void GUI_LoK::getInput() {
_mouseWheel = 0;
while (_vm->_eventMan->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_QUIT:
- _vm->quitGame();
- break;
case Common::EVENT_LBUTTONDOWN:
_vm->_mousePressFlag = true;
break;
@@ -582,7 +578,7 @@ int GUI_LoK::saveGameMenu(Button *button) {
_displaySubMenu = true;
_cancelSubMenu = false;
- while (_displaySubMenu && !_vm->_quitFlag) {
+ while (_displaySubMenu && !_vm->quit()) {
getInput();
Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[2], mouse.x, mouse.y);
@@ -631,7 +627,7 @@ int GUI_LoK::loadGameMenu(Button *button) {
_vm->_gameToLoad = -1;
- while (_displaySubMenu && !_vm->_quitFlag) {
+ while (_displaySubMenu && !_vm->quit()) {
getInput();
Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[2], mouse.x, mouse.y);
@@ -719,7 +715,7 @@ int GUI_LoK::saveGame(Button *button) {
}
redrawTextfield();
- while (_displaySubMenu && !_vm->_quitFlag) {
+ while (_displaySubMenu && !_vm->quit()) {
getInput();
updateSavegameString();
Common::Point mouse = _vm->getMousePos();
@@ -795,7 +791,7 @@ bool GUI_LoK::quitConfirm(const char *str) {
_displaySubMenu = true;
_cancelSubMenu = true;
- while (_displaySubMenu && !_vm->_quitFlag) {
+ while (_displaySubMenu && !_vm->quit()) {
getInput();
Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[1], mouse.x, mouse.y);
@@ -861,7 +857,7 @@ int GUI_LoK::gameControlsMenu(Button *button) {
_displaySubMenu = true;
_cancelSubMenu = false;
- while (_displaySubMenu && !_vm->_quitFlag) {
+ while (_displaySubMenu && !_vm->quit()) {
getInput();
Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[5], mouse.x, mouse.y);
diff --git a/engines/kyra/gui_mr.cpp b/engines/kyra/gui_mr.cpp
index 6822b303c3..40fe78c439 100644
--- a/engines/kyra/gui_mr.cpp
+++ b/engines/kyra/gui_mr.cpp
@@ -868,7 +868,7 @@ void KyraEngine_MR::processAlbum() {
albumNewPage();
_album.running = true;
- while (_album.running && !_quitFlag) {
+ while (_album.running && !quit()) {
updateInput();
checkInput(buttonList);
removeInputTop();
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp
index 2819c4f077..11f430040c 100644
--- a/engines/kyra/gui_v2.cpp
+++ b/engines/kyra/gui_v2.cpp
@@ -821,13 +821,9 @@ void GUI_v2::checkTextfieldInput() {
int keys = 0;
while (_vm->_eventMan->pollEvent(event) && running) {
switch (event.type) {
- case Common::EVENT_QUIT:
- _vm->_quitFlag = true;
- break;
-
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == 'q' && event.kbd.flags == Common::KBD_CTRL)
- _vm->_quitFlag = true;
+ _vm->quitGame();
else
_keyPressed = event.kbd;
running = false;
diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp
index 879efab86e..ac69272ef4 100644
--- a/engines/kyra/kyra_hof.cpp
+++ b/engines/kyra/kyra_hof.cpp
@@ -314,7 +314,7 @@ int KyraEngine_HoF::go() {
seq_playSequences(kSequenceFunters, kSequenceFrash);
}
- return 0;
+ return _eventMan->shouldRTL();
}
void KyraEngine_HoF::startup() {
@@ -443,9 +443,8 @@ void KyraEngine_HoF::startup() {
void KyraEngine_HoF::runLoop() {
_screen->updateScreen();
- _quitFlag = false;
_runFlag = true;
- while (!_quitFlag && _runFlag) {
+ while (!quit() && _runFlag) {
if (_deathHandler >= 0) {
removeHandItem();
delay(5);
@@ -1606,7 +1605,7 @@ void KyraEngine_HoF::loadInvWsa(const char *filename, int run, int delayTime, in
_invWsa.timer = _system->getMillis();
if (run) {
- while (_invWsa.running && !skipFlag() && !_quitFlag) {
+ while (_invWsa.running && !skipFlag() && !quit()) {
update();
_system->delayMillis(10);
}
@@ -1980,7 +1979,7 @@ void KyraEngine_HoF::playTim(const char *filename) {
return;
_tim->resetFinishedFlag();
- while (!_quitFlag && !_tim->finished()) {
+ while (!quit() && !_tim->finished()) {
_tim->exec(tim, 0);
if (_chatText)
updateWithText();
diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp
index c852f6e3ee..afd164958c 100644
--- a/engines/kyra/kyra_lok.cpp
+++ b/engines/kyra/kyra_lok.cpp
@@ -26,7 +26,6 @@
#include "kyra/kyra_lok.h"
#include "common/file.h"
-#include "common/events.h"
#include "common/system.h"
#include "common/savefile.h"
@@ -300,8 +299,8 @@ int KyraEngine_LoK::go() {
if (_gameToLoad == -1) {
setGameFlag(0xEF);
seq_intro();
- if (_quitFlag)
- return 0;
+ if (quit())
+ return _eventMan->shouldRTL();
if (_skipIntroFlag && _abortIntroFlag)
resetGameFlag(0xEF);
}
@@ -309,7 +308,7 @@ int KyraEngine_LoK::go() {
resetGameFlag(0xEF);
mainLoop();
}
- return 0;
+ return _eventMan->shouldRTL();
}
@@ -399,7 +398,7 @@ void KyraEngine_LoK::startup() {
void KyraEngine_LoK::mainLoop() {
debugC(9, kDebugLevelMain, "KyraEngine_LoK::mainLoop()");
- while (!_quitFlag) {
+ while (!quit()) {
int32 frameTime = (int32)_system->getMillis();
_skipFlag = false;
@@ -444,7 +443,7 @@ void KyraEngine_LoK::mainLoop() {
}
void KyraEngine_LoK::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) {
- while (_system->getMillis() < timestamp && !_quitFlag) {
+ while (_system->getMillis() < timestamp && !quit()) {
if (updateTimers)
_timer->update();
@@ -476,7 +475,7 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) {
if (event.kbd.keycode == 'd')
_debugger->attach();
else if (event.kbd.keycode == 'q')
- _quitFlag = true;
+ quitGame();
} else if (event.kbd.keycode == '.') {
_skipFlag = true;
} else if (event.kbd.keycode == Common::KEYCODE_RETURN || event.kbd.keycode == Common::KEYCODE_SPACE || event.kbd.keycode == Common::KEYCODE_ESCAPE) {
@@ -488,9 +487,6 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) {
case Common::EVENT_MOUSEMOVE:
_animator->_updateScreen = true;
break;
- case Common::EVENT_QUIT:
- quitGame();
- break;
case Common::EVENT_LBUTTONDOWN:
_mousePressFlag = true;
break;
@@ -529,27 +525,24 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) {
if (_skipFlag && !_abortIntroFlag && !queryGameFlag(0xFE))
_skipFlag = false;
- if (amount > 0 && !_skipFlag && !_quitFlag)
+ if (amount > 0 && !_skipFlag && !quit())
_system->delayMillis(10);
if (_skipFlag)
_sound->voiceStop();
- } while (!_skipFlag && _system->getMillis() < start + amount && !_quitFlag);
+ } while (!_skipFlag && _system->getMillis() < start + amount && !quit());
}
void KyraEngine_LoK::waitForEvent() {
bool finished = false;
Common::Event event;
- while (!finished && !_quitFlag) {
+ while (!finished && !quit()) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
finished = true;
break;
- case Common::EVENT_QUIT:
- quitGame();
- break;
case Common::EVENT_LBUTTONDOWN:
finished = true;
_skipFlag = true;
diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp
index a4e5b58364..7097543750 100644
--- a/engines/kyra/kyra_mr.cpp
+++ b/engines/kyra/kyra_mr.cpp
@@ -263,7 +263,7 @@ int KyraEngine_MR::go() {
running = false;
}
- while (running && !_quitFlag) {
+ while (running && !quit()) {
_screen->_curPage = 0;
_screen->clearPage(0);
@@ -272,14 +272,14 @@ int KyraEngine_MR::go() {
// XXX
playMenuAudioFile();
- for (int i = 0; i < 64 && !_quitFlag; ++i) {
+ for (int i = 0; i < 64 && !quit(); ++i) {
uint32 nextRun = _system->getMillis() + 3 * _tickLength;
_menuAnim->displayFrame(i, 0);
_screen->updateScreen();
delayUntil(nextRun);
}
- for (int i = 64; i > 29 && !_quitFlag; --i) {
+ for (int i = 64; i > 29 && !quit(); --i) {
uint32 nextRun = _system->getMillis() + 3 * _tickLength;
_menuAnim->displayFrame(i, 0);
_screen->updateScreen();
@@ -324,7 +324,7 @@ int KyraEngine_MR::go() {
if (_showOutro)
playVQA("CREDITS");
- return 0;
+ return _eventMan->shouldRTL();
}
void KyraEngine_MR::initMainMenu() {
@@ -995,7 +995,7 @@ void KyraEngine_MR::runLoop() {
_eventList.clear();
_runFlag = true;
- while (_runFlag && !_quitFlag) {
+ while (_runFlag && !quit()) {
if (_deathHandler >= 0) {
removeHandItem();
delay(5);
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index 117194aea2..cc97f43a05 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -52,8 +52,6 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags)
_gameSpeed = 60;
_tickLength = (uint8)(1000.0 / _gameSpeed);
- _quitFlag = false;
-
_speechFile = "";
_trackMap = 0;
_trackMapSize = 0;
@@ -192,7 +190,10 @@ KyraEngine_v1::~KyraEngine_v1() {
void KyraEngine_v1::quitGame() {
debugC(9, kDebugLevelMain, "KyraEngine_v1::quitGame()");
- _quitFlag = true;
+ Common::Event event;
+
+ event.type = Common::EVENT_QUIT;
+ _eventMan->pushEvent(event);
// Nothing to do here
}
@@ -230,7 +231,7 @@ int KyraEngine_v1::resetGameFlag(int flag) {
}
void KyraEngine_v1::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) {
- while (_system->getMillis() < timestamp && !_quitFlag) {
+ while (_system->getMillis() < timestamp && !quit()) {
if (timestamp - _system->getMillis() >= 10)
delay(10, update, isMainLoop);
}
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index 09efc8cc97..8dd95c79b9 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -117,8 +117,6 @@ public:
virtual void pauseEngineIntern(bool pause);
- bool quit() const { return _quitFlag; }
-
uint8 game() const { return _flags.gameID; }
const GameFlags &gameFlags() const { return _flags; }
@@ -177,9 +175,6 @@ protected:
virtual int go() = 0;
virtual int init();
- // quit Handling
- bool _quitFlag;
-
// intern
Resource *_res;
Sound *_sound;
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 2e704f2aa2..08a4e9f4c5 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -159,7 +159,7 @@ void KyraEngine_v2::delay(uint32 amount, bool updateGame, bool isMainLoop) {
if (amount > 0)
_system->delayMillis(amount > 10 ? 10 : amount);
- } while (!skipFlag() && _system->getMillis() < start + amount && !_quitFlag);
+ } while (!skipFlag() && _system->getMillis() < start + amount && !quit());
}
int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) {
@@ -238,15 +238,11 @@ void KyraEngine_v2::updateInput() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_QUIT:
- _quitFlag = true;
- break;
-
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == '.' || event.kbd.keycode == Common::KEYCODE_ESCAPE)
_eventList.push_back(Event(event, true));
else if (event.kbd.keycode == 'q' && event.kbd.flags == Common::KBD_CTRL)
- _quitFlag = true;
+ quitGame();
else
_eventList.push_back(event);
break;
diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp
index 22f934ba69..147c774a52 100644
--- a/engines/kyra/saveload.cpp
+++ b/engines/kyra/saveload.cpp
@@ -161,7 +161,7 @@ Common::InSaveFile *KyraEngine_v1::openSaveForReading(const char *filename, Save
Common::OutSaveFile *KyraEngine_v1::openSaveForWriting(const char *filename, const char *saveName) const {
debugC(9, kDebugLevelMain, "KyraEngine_v1::openSaveForWriting('%s', '%s')", filename, saveName);
- if (_quitFlag)
+ if (quit())
return 0;
Common::OutSaveFile *out = 0;
diff --git a/engines/kyra/saveload_lok.cpp b/engines/kyra/saveload_lok.cpp
index 8af73acc61..74cf26646c 100644
--- a/engines/kyra/saveload_lok.cpp
+++ b/engines/kyra/saveload_lok.cpp
@@ -221,7 +221,7 @@ void KyraEngine_LoK::loadGame(const char *fileName) {
void KyraEngine_LoK::saveGame(const char *fileName, const char *saveName) {
debugC(9, kDebugLevelMain, "KyraEngine_LoK::saveGame('%s', '%s')", fileName, saveName);
- if (_quitFlag)
+ if (quit())
return;
Common::OutSaveFile *out = openSaveForWriting(fileName, saveName);
diff --git a/engines/kyra/scene_hof.cpp b/engines/kyra/scene_hof.cpp
index 62df683ea2..08df7b064e 100644
--- a/engines/kyra/scene_hof.cpp
+++ b/engines/kyra/scene_hof.cpp
@@ -277,7 +277,7 @@ int KyraEngine_HoF::trySceneChange(int *moveTable, int unk1, int updateChar) {
int changedScene = 0;
const int *moveTableStart = moveTable;
_unk4 = 0;
- while (running && !_quitFlag) {
+ while (running && !quit()) {
if (*moveTable >= 0 && *moveTable <= 7) {
_mainCharacter.facing = getOppositeFacingDirection(*moveTable);
unkFlag = true;
diff --git a/engines/kyra/scene_mr.cpp b/engines/kyra/scene_mr.cpp
index e4a3a5c54e..716c139129 100644
--- a/engines/kyra/scene_mr.cpp
+++ b/engines/kyra/scene_mr.cpp
@@ -653,7 +653,7 @@ int KyraEngine_MR::trySceneChange(int *moveTable, int unk1, int updateChar) {
const int *moveTableStart = moveTable;
_unk4 = 0;
- while (running && !_quitFlag) {
+ while (running && !quit()) {
if (*moveTable >= 0 && *moveTable <= 7) {
_mainCharacter.facing = getOppositeFacingDirection(*moveTable);
unkFlag = true;
diff --git a/engines/kyra/script_mr.cpp b/engines/kyra/script_mr.cpp
index 9a059ead2a..6dda6c8bd7 100644
--- a/engines/kyra/script_mr.cpp
+++ b/engines/kyra/script_mr.cpp
@@ -786,7 +786,7 @@ int KyraEngine_MR::o3_daggerWarning(EMCState *script) {
_screen->_curPage = curPageBackUp;
_screen->showMouse();
- while (!_quitFlag) {
+ while (!quit()) {
int keys = checkInput(0);
removeInputTop();
diff --git a/engines/kyra/sequences_hof.cpp b/engines/kyra/sequences_hof.cpp
index 169c319347..7e0220af8a 100644
--- a/engines/kyra/sequences_hof.cpp
+++ b/engines/kyra/sequences_hof.cpp
@@ -75,7 +75,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) {
_seqEndTime = 0;
_menuChoice = 0;
- for (int seqNum = startSeq; seqNum <= endSeq && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice); seqNum++) {
+ for (int seqNum = startSeq; seqNum <= endSeq && !((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice); seqNum++) {
_screen->clearPage(0);
_screen->clearPage(8);
memcpy(_screen->getPalette(1), _screen->getPalette(0), 0x300);
@@ -131,7 +131,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) {
seq_sequenceCommand(cseq.startupCommand);
- if (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ if (!((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_screen->copyPage(2, 0);
_screen->updateScreen();
}
@@ -165,7 +165,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) {
_seqWsaCurrentFrame = cseq.startFrame;
bool loop = true;
- while (loop && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ while (loop && !((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength;
if (_seqWsa || !cb)
@@ -189,16 +189,16 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) {
seq_processWSAs();
seq_processText();
- if ((_seqWsa || !cb) && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ if ((_seqWsa || !cb) && !((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_screen->copyPage(2, 0);
_screen->updateScreen();
}
bool loop2 = true;
- while (loop2 && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ while (loop2 && !((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
if (_seqWsa) {
seq_processText();
- if (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ if (!((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_screen->copyPage(2, 0);
_screen->updateScreen();
}
@@ -230,7 +230,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) {
} else {
_seqFrameDelay = cseq.frameDelay;
_seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength;
- while (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ while (!((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_seqSubFrameStartTime = _system->getMillis();
seq_processWSAs();
if (cb)
@@ -262,7 +262,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) {
dl = ct;
_seqEndTime = _system->getMillis() + dl;
- while (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+ while (!((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) {
_seqSubFrameStartTime = _system->getMillis();
seq_processWSAs();
@@ -2093,7 +2093,7 @@ void KyraEngine_HoF::seq_loadNestedSequence(int wsaNum, int seqNum) {
void KyraEngine_HoF::seq_nestedSequenceFrame(int command, int wsaNum) {
int xa = 0, ya = 0;
command--;
- if (!_activeWSA[wsaNum].movie || skipFlag() || _quitFlag || _abortIntroFlag)
+ if (!_activeWSA[wsaNum].movie || skipFlag() || quit() || _abortIntroFlag)
return;
switch (command) {
@@ -2293,7 +2293,7 @@ bool KyraEngine_HoF::seq_processNextSubFrame(int wsaNum) {
void KyraEngine_HoF::seq_printCreditsString(uint16 strIndex, int x, int y, const uint8 *colorMap, uint8 textcolor) {
uint8 colormap[16];
- if (skipFlag() || _quitFlag || _abortIntroFlag || _menuChoice)
+ if (skipFlag() || quit() || _abortIntroFlag || _menuChoice)
return;
memset(&_screen->getPalette(0)[0x2fa], 0x3f, 6);
@@ -2774,7 +2774,7 @@ void KyraEngine_HoF::seq_makeBookAppear() {
++_invWsa.curFrame;
- if (_invWsa.curFrame >= _invWsa.lastFrame && !_quitFlag)
+ if (_invWsa.curFrame >= _invWsa.lastFrame && !quit())
break;
switch (_invWsa.curFrame) {
diff --git a/engines/kyra/sequences_lok.cpp b/engines/kyra/sequences_lok.cpp
index 3a497a258f..577dcd827b 100644
--- a/engines/kyra/sequences_lok.cpp
+++ b/engines/kyra/sequences_lok.cpp
@@ -34,7 +34,6 @@
#include "kyra/text.h"
#include "kyra/timer.h"
-#include "common/events.h"
#include "common/system.h"
#include "common/savefile.h"
@@ -164,7 +163,7 @@ void KyraEngine_LoK::seq_introLogos() {
_screen->updateScreen();
_screen->fadeFromBlack();
- if (_seq->playSequence(_seq_WestwoodLogo, _skipFlag) || _quitFlag) {
+ if (_seq->playSequence(_seq_WestwoodLogo, _skipFlag) || quit()) {
_screen->fadeToBlack();
_screen->clearPage(0);
return;
@@ -176,14 +175,14 @@ void KyraEngine_LoK::seq_introLogos() {
_screen->setScreenPalette(_screen->_currentPalette);
}
- if ((_seq->playSequence(_seq_KyrandiaLogo, _skipFlag) && !seq_skipSequence()) || _quitFlag) {
+ if ((_seq->playSequence(_seq_KyrandiaLogo, _skipFlag) && !seq_skipSequence()) || quit()) {
_screen->fadeToBlack();
_screen->clearPage(0);
return;
}
_screen->fillRect(0, 179, 319, 199, 0);
- if (_quitFlag)
+ if (quit())
return;
if (_flags.platform == Common::kPlatformAmiga) {
@@ -223,10 +222,10 @@ void KyraEngine_LoK::seq_introLogos() {
oldDistance = distance;
delay(10);
- } while (!doneFlag && !_quitFlag && !_abortIntroFlag);
+ } while (!doneFlag && !quit() && !_abortIntroFlag);
}
- if (_quitFlag)
+ if (quit())
return;
_seq->playSequence(_seq_Forest, true);
@@ -1030,7 +1029,7 @@ void KyraEngine_LoK::seq_brandonToStone() {
void KyraEngine_LoK::seq_playEnding() {
debugC(9, kDebugLevelMain, "KyraEngine_LoK::seq_playEnding()");
- if (_quitFlag)
+ if (quit())
return;
_screen->hideMouse();
_screen->_curPage = 0;
@@ -1187,7 +1186,6 @@ void KyraEngine_LoK::seq_playCredits() {
finished = true;
break;
case Common::EVENT_QUIT:
- quitGame();
finished = true;
break;
default:
@@ -1211,7 +1209,7 @@ void KyraEngine_LoK::seq_playCredits() {
bool KyraEngine_LoK::seq_skipSequence() const {
debugC(9, kDebugLevelMain, "KyraEngine_LoK::seq_skipSequence()");
- return _quitFlag || _abortIntroFlag;
+ return quit() || _abortIntroFlag;
}
int KyraEngine_LoK::handleMalcolmFlag() {
diff --git a/engines/kyra/sprites.cpp b/engines/kyra/sprites.cpp
index 34c2986f25..05074d20b1 100644
--- a/engines/kyra/sprites.cpp
+++ b/engines/kyra/sprites.cpp
@@ -28,7 +28,6 @@
#include "common/stream.h"
#include "common/util.h"
#include "common/system.h"
-#include "common/events.h"
#include "kyra/screen.h"
#include "kyra/kyra_lok.h"
#include "kyra/sprites.h"
diff --git a/engines/kyra/text.cpp b/engines/kyra/text.cpp
index f8eb10a85e..eecb617942 100644
--- a/engines/kyra/text.cpp
+++ b/engines/kyra/text.cpp
@@ -29,7 +29,6 @@
#include "kyra/screen.h"
#include "kyra/text.h"
-#include "common/events.h"
#include "common/system.h"
#include "common/endian.h"
diff --git a/engines/kyra/text_hof.cpp b/engines/kyra/text_hof.cpp
index dd587c5112..b94b8a6258 100644
--- a/engines/kyra/text_hof.cpp
+++ b/engines/kyra/text_hof.cpp
@@ -335,7 +335,7 @@ void KyraEngine_HoF::objectChatWaitToFinish() {
const uint32 endTime = _chatEndTime;
resetSkipFlag();
- while (running && !_quitFlag) {
+ while (running && !quit()) {
if (!_emc->isValid(&_chatScriptState))
_emc->start(&_chatScriptState, 1);
@@ -353,7 +353,7 @@ void KyraEngine_HoF::objectChatWaitToFinish() {
uint32 nextFrame = _system->getMillis() + delayTime * _tickLength;
- while (_system->getMillis() < nextFrame && !_quitFlag) {
+ while (_system->getMillis() < nextFrame && !quit()) {
updateWithText();
const uint32 curTime = _system->getMillis();
@@ -593,7 +593,7 @@ void KyraEngine_HoF::initTalkObject(int index) {
if (_currentTalkSections.STATim) {
_tim->resetFinishedFlag();
- while (!_quitFlag && !_tim->finished()) {
+ while (!quit() && !_tim->finished()) {
_tim->exec(_currentTalkSections.STATim, false);
if (_chatText)
updateWithText();
@@ -609,7 +609,7 @@ void KyraEngine_HoF::deinitTalkObject(int index) {
if (_currentTalkSections.ENDTim) {
_tim->resetFinishedFlag();
- while (!_quitFlag && !_tim->finished()) {
+ while (!quit() && !_tim->finished()) {
_tim->exec(_currentTalkSections.ENDTim, false);
if (_chatText)
updateWithText();
@@ -647,10 +647,10 @@ void KyraEngine_HoF::npcChatSequence(const char *str, int objectId, int vocHigh,
_chatVocHigh = _chatVocLow = -1;
}
- while (((textEnabled() && _chatEndTime > _system->getMillis()) || (speechEnabled() && snd_voiceIsPlaying())) && !(_quitFlag || skipFlag())) {
+ while (((textEnabled() && _chatEndTime > _system->getMillis()) || (speechEnabled() && snd_voiceIsPlaying())) && !(quit() || skipFlag())) {
if ((!speechEnabled() && chatAnimEndTime > _system->getMillis()) || (speechEnabled() && snd_voiceIsPlaying())) {
_tim->resetFinishedFlag();
- while (!_tim->finished() && !skipFlag() && !_quitFlag) {
+ while (!_tim->finished() && !skipFlag() && !quit()) {
if (_currentTalkSections.TLKTim)
_tim->exec(_currentTalkSections.TLKTim, false);
else
diff --git a/engines/kyra/text_lok.cpp b/engines/kyra/text_lok.cpp
index f6b0407a75..d452109f91 100644
--- a/engines/kyra/text_lok.cpp
+++ b/engines/kyra/text_lok.cpp
@@ -121,7 +121,6 @@ void KyraEngine_LoK::waitForChatToFinish(int vocFile, int16 chatDuration, const
_skipFlag = true;
break;
case Common::EVENT_QUIT:
- quitGame();
runLoop = false;
break;
case Common::EVENT_LBUTTONDOWN:
diff --git a/engines/kyra/text_mr.cpp b/engines/kyra/text_mr.cpp
index 16c56da099..be306ceec1 100644
--- a/engines/kyra/text_mr.cpp
+++ b/engines/kyra/text_mr.cpp
@@ -349,7 +349,7 @@ void KyraEngine_MR::objectChatWaitToFinish() {
const uint32 endTime = _chatEndTime;
resetSkipFlag();
- while (running && !_quitFlag) {
+ while (running && !quit()) {
if (!_emc->isValid(&_chatScriptState))
_emc->start(&_chatScriptState, 1);
@@ -367,7 +367,7 @@ void KyraEngine_MR::objectChatWaitToFinish() {
uint32 nextFrame = _system->getMillis() + delayTime * _tickLength;
- while (_system->getMillis() < nextFrame && !_quitFlag) {
+ while (_system->getMillis() < nextFrame && !quit()) {
updateWithText();
const uint32 curTime = _system->getMillis();
@@ -419,7 +419,7 @@ void KyraEngine_MR::badConscienceChatWaitToFinish() {
uint32 nextFrame = _system->getMillis() + _rnd.getRandomNumberRng(4, 8) * _tickLength;
int frame = _badConscienceFrameTable[_badConscienceAnim+24];
- while (running && !_quitFlag) {
+ while (running && !quit()) {
if (nextFrame < _system->getMillis()) {
++frame;
if (_badConscienceFrameTable[_badConscienceAnim+32] < frame)
@@ -477,7 +477,7 @@ void KyraEngine_MR::goodConscienceChatWaitToFinish() {
uint32 nextFrame = _system->getMillis() + _rnd.getRandomNumberRng(3, 6) * _tickLength;
int frame = _goodConscienceFrameTable[_goodConscienceAnim+15];
- while (running && !_quitFlag) {
+ while (running && !quit()) {
if (nextFrame < _system->getMillis()) {
++frame;
if (_goodConscienceFrameTable[_goodConscienceAnim+20] < frame)
@@ -597,7 +597,7 @@ void KyraEngine_MR::albumChatWaitToFinish() {
uint32 nextFrame = 0;
int frame = 12;
- while (running && !_quitFlag) {
+ while (running && !quit()) {
if (nextFrame < _system->getMillis()) {
++frame;
if (frame > 22)
diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp
index 3d18f27c7e..9e2adfa71f 100644
--- a/engines/kyra/vqa.cpp
+++ b/engines/kyra/vqa.cpp
@@ -32,7 +32,6 @@
// The jung2.vqa movie does work, but only thanks to a grotesque hack.
-#include "common/events.h"
#include "common/system.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
@@ -672,7 +671,6 @@ void VQAMovie::play() {
return;
break;
case Common::EVENT_QUIT:
- _vm->quitGame();
return;
default:
break;
diff --git a/engines/lure/events.cpp b/engines/lure/events.cpp
index 30e0e571b7..eec9dbda11 100644
--- a/engines/lure/events.cpp
+++ b/engines/lure/events.cpp
@@ -29,6 +29,7 @@
#include "graphics/cursorman.h"
#include "lure/events.h"
+#include "lure/lure.h"
#include "lure/res.h"
namespace Lure {
@@ -137,11 +138,12 @@ void Mouse::setPosition(int newX, int newY) {
void Mouse::waitForRelease() {
Events &e = Events::getReference();
+ LureEngine &engine = LureEngine::getReference();
do {
- while (e.pollEvent() && !e.quitFlag) ;
+ while (e.pollEvent() && !engine.quit()) ;
g_system->delayMillis(20);
- } while (!e.quitFlag && (lButton() || rButton() || mButton()));
+ } while (!engine.quit() && (lButton() || rButton() || mButton()));
}
/*--------------------------------------------------------------------------*/
@@ -150,7 +152,6 @@ static Events *int_events = NULL;
Events::Events() {
int_events = this;
- quitFlag = false;
}
Events &Events::getReference() {
@@ -159,14 +160,12 @@ Events &Events::getReference() {
bool Events::pollEvent() {
+ LureEngine &engine = LureEngine::getReference();
+
if (!g_system->getEventManager()->pollEvent(_event)) return false;
// Handle keypress
switch (_event.type) {
- case Common::EVENT_QUIT:
- quitFlag = true;
- break;
-
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONDOWN:
@@ -210,10 +209,11 @@ void Events::waitForPress() {
bool Events::interruptableDelay(uint32 milliseconds) {
Events &events = Events::getReference();
+ LureEngine &engine = LureEngine::getReference();
uint32 delayCtr = g_system->getMillis() + milliseconds;
while (g_system->getMillis() < delayCtr) {
- if (events.quitFlag) return true;
+ if (engine.quit()) return true;
if (events.pollEvent()) {
if (((events.type() == Common::EVENT_KEYDOWN) && (events.event().kbd.ascii != 0)) ||
diff --git a/engines/lure/events.h b/engines/lure/events.h
index d1246f95d8..f04072aa0f 100644
--- a/engines/lure/events.h
+++ b/engines/lure/events.h
@@ -66,8 +66,6 @@ class Events {
private:
Common::Event _event;
public:
- bool quitFlag;
-
Events();
static Events &getReference();
diff --git a/engines/lure/fights.cpp b/engines/lure/fights.cpp
index dcf09ba50d..51fce850e6 100644
--- a/engines/lure/fights.cpp
+++ b/engines/lure/fights.cpp
@@ -22,6 +22,7 @@
#include "lure/fights.h"
#include "lure/luredefs.h"
#include "lure/game.h"
+#include "lure/lure.h"
#include "lure/res.h"
#include "lure/room.h"
#include "lure/sound.h"
@@ -108,15 +109,15 @@ bool FightsManager::isFighting() {
}
void FightsManager::fightLoop() {
+ LureEngine &engine = LureEngine::getReference();
Resources &res = Resources::getReference();
Game &game = Game::getReference();
Room &room = Room::getReference();
- Events &events = Events::getReference();
FighterRecord &playerFight = getDetails(PLAYER_ID);
uint32 timerVal = g_system->getMillis();
// Loop for the duration of the battle
- while (!events.quitFlag && (playerFight.fwhits != GENERAL_MAGIC_ID)) {
+ while (!engine.quit() && (playerFight.fwhits != GENERAL_MAGIC_ID)) {
checkEvents();
if (g_system->getMillis() > timerVal + GAME_FRAME_DELAY) {
@@ -184,6 +185,7 @@ const KeyMapping keyList[] = {
{Common::KEYCODE_INVALID, 0}};
void FightsManager::checkEvents() {
+ LureEngine &engine = LureEngine::getReference();
Game &game = Game::getReference();
Events &events = Events::getReference();
Mouse &mouse = Mouse::getReference();
@@ -196,7 +198,7 @@ void FightsManager::checkEvents() {
if (events.type() == Common::EVENT_KEYDOWN) {
switch (events.event().kbd.keycode) {
case Common::KEYCODE_ESCAPE:
- events.quitFlag = true;
+ engine.quitGame();
return;
case Common::KEYCODE_d:
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp
index f9b31c21c5..195ad0fd66 100644
--- a/engines/lure/game.cpp
+++ b/engines/lure/game.cpp
@@ -23,10 +23,10 @@
*
*/
-#include "lure/lure.h"
#include "lure/game.h"
#include "lure/animseq.h"
#include "lure/fights.h"
+#include "lure/lure.h"
#include "lure/res_struct.h"
#include "lure/room.h"
#include "lure/scripts.h"
@@ -125,6 +125,7 @@ void Game::nextFrame() {
void Game::execute() {
OSystem &system = *g_system;
+ LureEngine &engine = LureEngine::getReference();
Room &room = Room::getReference();
Resources &res = Resources::getReference();
Events &events = Events::getReference();
@@ -142,7 +143,7 @@ void Game::execute() {
setState(GS_RESTART);
bool initialRestart = true;
- while (!events.quitFlag) {
+ while (!engine.quit()) {
if ((_state & GS_RESTART) != 0) {
res.reset();
@@ -162,7 +163,7 @@ void Game::execute() {
mouse.cursorOn();
// Main game loop
- while (!events.quitFlag && ((_state & GS_RESTART) == 0)) {
+ while (!engine.quit() && ((_state & GS_RESTART) == 0)) {
// If time for next frame, allow everything to update
if (system.getMillis() > timerVal + GAME_FRAME_DELAY) {
timerVal = system.getMillis();
@@ -291,10 +292,7 @@ void Game::execute() {
if (restartFlag)
setState(GS_RESTART);
-
- } else if ((_state & GS_RESTART) == 0)
- // Exiting game
- events.quitFlag = true;
+ }
}
}
@@ -892,7 +890,7 @@ void Game::doShowCredits() {
void Game::doQuit() {
Sound.pause();
if (getYN())
- Events::getReference().quitFlag = true;
+ LureEngine::getReference().quitGame();
Sound.resume();
}
@@ -977,6 +975,7 @@ bool Game::getYN() {
Events &events = Events::getReference();
Screen &screen = Screen::getReference();
Resources &res = Resources::getReference();
+ LureEngine &engine = LureEngine::getReference();
Common::Language l = LureEngine::getReference().getLanguage();
Common::KeyCode y = Common::KEYCODE_y;
@@ -1018,7 +1017,7 @@ bool Game::getYN() {
}
g_system->delayMillis(10);
- } while (!events.quitFlag && !breakFlag);
+ } while (!engine.quit() && !breakFlag);
screen.update();
if (!vKbdFlag)
diff --git a/engines/lure/intro.cpp b/engines/lure/intro.cpp
index 4d3e172dc5..5b07dd3916 100644
--- a/engines/lure/intro.cpp
+++ b/engines/lure/intro.cpp
@@ -55,7 +55,6 @@ static const AnimRecord anim_screens[] = {
bool Introduction::showScreen(uint16 screenId, uint16 paletteId, uint16 delaySize) {
Screen &screen = Screen::getReference();
- Events &events = Events::getReference();
bool isEGA = LureEngine::getReference().isEGA();
screen.screen().loadScreen(screenId);
screen.update();
@@ -65,7 +64,7 @@ bool Introduction::showScreen(uint16 screenId, uint16 paletteId, uint16 delaySiz
else screen.paletteFadeIn(&p);
bool result = interruptableDelay(delaySize);
- if (events.quitFlag) return true;
+ if (LureEngine::getReference().quit()) return true;
if (!isEGA)
screen.paletteFadeOut();
diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp
index ea760ddb4f..90c0c34454 100644
--- a/engines/lure/lure.cpp
+++ b/engines/lure/lure.cpp
@@ -126,8 +126,8 @@ int LureEngine::go() {
CopyProtectionDialog *dialog = new CopyProtectionDialog();
bool result = dialog->show();
delete dialog;
- if (_events->quitFlag)
- return 0;
+ if (quit())
+ return _eventMan->shouldRTL();
if (!result)
error("Sorry - copy protection failed");
@@ -145,14 +145,14 @@ int LureEngine::go() {
}
// Play the game
- if (!_events->quitFlag) {
+ if (!quit()) {
// Play the game
Sound.loadSection(Sound.isRoland() ? ROLAND_MAIN_SOUND_RESOURCE_ID : ADLIB_MAIN_SOUND_RESOURCE_ID);
gameInstance->execute();
}
delete gameInstance;
- return 0;
+ return _eventMan->shouldRTL();
}
void LureEngine::pauseEngineIntern(bool pause) {
@@ -246,6 +246,10 @@ void LureEngine::GUIError(const char *msg, ...) {
Engine::GUIErrorMessage(buffer);
}
+void LureEngine::syncSoundSettings() {
+ Sound.syncSounds(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume"));
+}
+
Common::String *LureEngine::detectSave(int slotNumber) {
Common::ReadStream *f = this->_saveFileMan->openForLoading(
generateSaveName(slotNumber));
diff --git a/engines/lure/lure.h b/engines/lure/lure.h
index 1c5b40e54b..940e04edc7 100644
--- a/engines/lure/lure.h
+++ b/engines/lure/lure.h
@@ -70,6 +70,7 @@ public:
virtual int init();
virtual int go();
virtual void pauseEngineIntern(bool pause);
+ virtual void syncSoundSettings();
Disk &disk() { return *_disk; }
diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp
index 0b4ef06081..562f54da20 100644
--- a/engines/lure/menu.cpp
+++ b/engines/lure/menu.cpp
@@ -116,6 +116,7 @@ Menu &Menu::getReference() {
uint8 Menu::execute() {
OSystem &system = *g_system;
+ LureEngine &engine = LureEngine::getReference();
Mouse &mouse = Mouse::getReference();
Events &events = Events::getReference();
Screen &screen = Screen::getReference();
@@ -130,7 +131,7 @@ uint8 Menu::execute() {
while (mouse.lButton() || mouse.rButton()) {
while (events.pollEvent()) {
- if (events.quitFlag) return MENUITEM_NONE;
+ if (engine.quit()) return MENUITEM_NONE;
if (mouse.y() < MENUBAR_Y_SIZE) {
MenuRecord *p = getMenuAt(mouse.x());
@@ -467,6 +468,7 @@ Action PopupMenu::Show(int numEntries, Action *actions) {
uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
if (numEntries == 0) return 0xffff;
+ LureEngine &engine = LureEngine::getReference();
Events &e = Events::getReference();
Mouse &mouse = Mouse::getReference();
OSystem &system = *g_system;
@@ -545,7 +547,7 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
}
while (e.pollEvent()) {
- if (e.quitFlag) {
+ if (engine.quit()) {
selectedIndex = 0xffff;
goto bail_out;
diff --git a/engines/lure/scripts.cpp b/engines/lure/scripts.cpp
index 7490f05b24..495f8046bb 100644
--- a/engines/lure/scripts.cpp
+++ b/engines/lure/scripts.cpp
@@ -26,6 +26,7 @@
#include "lure/animseq.h"
#include "lure/fights.h"
#include "lure/game.h"
+#include "lure/lure.h"
#include "lure/res.h"
#include "lure/room.h"
#include "lure/screen.h"
@@ -190,6 +191,7 @@ void Script::addSound(uint16 soundIndex, uint16 v2, uint16 v3) {
}
void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) {
+ LureEngine &engine = LureEngine::getReference();
Screen &screen = Screen::getReference();
Mouse &mouse = Mouse::getReference();
Events &events = Events::getReference();
@@ -219,7 +221,7 @@ void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) {
anim->show();
if (!events.interruptableDelay(30000)) {
// No key yet pressed, so keep waiting
- while (Sound.musicInterface_CheckPlaying(6) && !events.quitFlag) {
+ while (Sound.musicInterface_CheckPlaying(6) && !engine.quit()) {
if (events.interruptableDelay(20))
break;
}
@@ -227,7 +229,7 @@ void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) {
delete anim;
screen.paletteFadeOut();
- events.quitFlag = true;
+ engine.quitGame();
}
// Setup the pig fight in the cave
diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp
index 285f66e4e2..d59d03f9c3 100644
--- a/engines/lure/sound.cpp
+++ b/engines/lure/sound.cpp
@@ -220,10 +220,12 @@ void SoundManager::addSound(uint8 soundIndex, bool tidyFlag) {
newEntry->channel = channelCtr;
newEntry->numChannels = numChannels;
newEntry->flags = rec.flags;
- if (_isRoland)
- newEntry->volume = rec.volume;
- else /* resource volumes do not seem to work well with our adlib emu */
- newEntry->volume = 240; /* 255 causes clipping with adlib */
+
+ if (newEntry->soundNumber & 0x80)
+ newEntry->volume = ConfMan.getInt("music_volume");
+ else
+ newEntry->volume = ConfMan.getInt("sfx_volume");
+
_activeSounds.push_back(SoundList::value_type(newEntry));
musicInterface_Play(rec.soundNumber, channelCtr, numChannels);
@@ -280,6 +282,22 @@ uint8 SoundManager::descIndexOf(uint8 soundNumber) {
return 0xff; // Couldn't find entry
}
+// Used to sync the volume for all channels with the Config Manager
+//
+void SoundManager::syncSounds(uint8 musicVol, uint8 sfxVol) {
+ musicInterface_TidySounds();
+
+ g_system->lockMutex(_soundMutex);
+ MusicListIterator i;
+ for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
+ if ((*i)->isMusic())
+ (*i)->setVolume(musicVol);
+ else
+ (*i)->setVolume(sfxVol);
+ }
+ g_system->unlockMutex(_soundMutex);
+}
+
SoundDescResource *SoundManager::findSound(uint8 soundNumber) {
debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::findSound soundNumber=%d", soundNumber);
SoundListIterator i;
@@ -402,9 +420,8 @@ void SoundManager::musicInterface_Play(uint8 soundNumber, uint8 channelNumber, u
return;
bool isMusic = (soundNumber & 0x80) != 0;
- uint8 volume = isMusic ? game.musicVolume() : game.sfxVolume();
-
- if (!game.soundFlag() || (volume == 0))
+
+ if (!game.soundFlag())
// Don't play sounds if sound is turned off
return;
@@ -563,12 +580,12 @@ void SoundManager::doTimer() {
/*------------------------------------------------------------------------*/
MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS],
- uint8 channelNum, uint8 soundNum, bool isMusic, uint8 numChannels, void *soundData, uint32 size) {
+ uint8 channelNum, uint8 soundNum, bool isMus, uint8 numChannels, void *soundData, uint32 size) {
_driver = driver;
_channels = channels;
_soundNumber = soundNum;
_channelNumber = channelNum;
- _isMusic = isMusic;
+ _isMusic = isMus;
_numChannels = numChannels;
_volume = 0;
@@ -576,7 +593,11 @@ MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS],
/* 90 is power on default for midi compliant devices */
_channels[_channelNumber + i].volume = 90;
}
- setVolume(240); /* 255 causes clipping with mastervol 192 and adlib */
+
+ if (_isMusic)
+ setVolume(ConfMan.getInt("music_volume"));
+ else
+ setVolume(ConfMan.getInt("sfx_volume"));
_passThrough = false;
@@ -634,14 +655,9 @@ void MidiMusic::setVolume(int volume) {
_volume = volume;
- Game &game = Game::getReference();
- volume *= _isMusic ? game.musicVolume() : game.sfxVolume();
-
for (int i = 0; i < _numChannels; ++i) {
if (_channels[_channelNumber + i].midiChannel != NULL)
- _channels[_channelNumber + i].midiChannel->volume(
- _channels[_channelNumber + i].volume *
- volume / 65025);
+ _channels[_channelNumber + i].midiChannel->volume(volume);
}
}
diff --git a/engines/lure/sound.h b/engines/lure/sound.h
index c5a31a6c28..9959417e67 100644
--- a/engines/lure/sound.h
+++ b/engines/lure/sound.h
@@ -66,7 +66,7 @@ private:
public:
MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS],
- uint8 channelNum, uint8 soundNum, bool isMusic, uint8 numChannels, void *soundData, uint32 size);
+ uint8 channelNum, uint8 soundNum, bool isMus, uint8 numChannels, void *soundData, uint32 size);
~MidiMusic();
void setVolume(int volume);
int getVolume() { return _volume; }
@@ -98,6 +98,7 @@ public:
uint8 channelNumber() { return _channelNumber; }
uint8 soundNumber() { return _soundNumber; }
bool isPlaying() { return _isPlaying; }
+ bool isMusic() {return _isMusic; }
};
class SoundManager: public Common::Singleton<SoundManager> {
@@ -142,6 +143,7 @@ public:
void stopSound(uint8 soundIndex);
void killSound(uint8 soundNumber);
void setVolume(uint8 soundNumber, uint8 volume);
+ void syncSounds(uint8 musicVol, uint8 sfxVol);
void tidySounds();
uint8 descIndexOf(uint8 soundNumber);
SoundDescResource *findSound(uint8 soundNumber);
diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp
index 64394545d1..23cc9043cf 100644
--- a/engines/lure/surface.cpp
+++ b/engines/lure/surface.cpp
@@ -506,6 +506,7 @@ Surface *Surface::getScreen(uint16 resourceId) {
bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool varLength, int16 x, int16 y) {
OSystem &system = *g_system;
+ LureEngine &engine = LureEngine::getReference();
Mouse &mouse = Mouse::getReference();
Events &events = Events::getReference();
Screen &screen = Screen::getReference();
@@ -533,7 +534,7 @@ bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool
// Loop until the input string changes
refreshFlag = false;
while (!refreshFlag && !abortFlag) {
- abortFlag = events.quitFlag;
+ abortFlag = engine.quit();
if (abortFlag) break;
while (events.pollEvent()) {
@@ -975,7 +976,7 @@ bool SaveRestoreDialog::show(bool saveDialog) {
// Provide highlighting of lines to select a save slot
while (!abortFlag && !(mouse.lButton() && (selectedLine != -1))
&& !mouse.rButton() && !mouse.mButton()) {
- abortFlag = events.quitFlag;
+ abortFlag = engine.quit();
if (abortFlag) break;
while (events.pollEvent()) {
@@ -1178,7 +1179,7 @@ bool RestartRestoreDialog::show() {
// Event loop for making selection
bool buttonPressed = false;
- while (!events.quitFlag) {
+ while (!engine.quit()) {
// Handle events
while (events.pollEvent()) {
if ((events.type() == Common::EVENT_LBUTTONDOWN) && (highlightedButton != -1)) {
@@ -1230,7 +1231,7 @@ bool RestartRestoreDialog::show() {
Sound.killSounds();
- if (!restartFlag && !events.quitFlag) {
+ if (!restartFlag && !engine.quit()) {
// Need to show Restore game dialog
if (!SaveRestoreDialog::show(false))
// User cancelled, so fall back on Restart
@@ -1299,6 +1300,7 @@ bool CopyProtectionDialog::show() {
Screen &screen = Screen::getReference();
Events &events = Events::getReference();
Common::RandomSource rnd;
+ LureEngine &engine = LureEngine::getReference();
screen.setPaletteEmpty();
Palette p(COPY_PROTECTION_RESOURCE_ID - 1);
@@ -1349,7 +1351,7 @@ bool CopyProtectionDialog::show() {
// Clear any prior try
_charIndex = 0;
- while (!events.quitFlag) {
+ while (!engine.quit()) {
while (events.pollEvent() && (_charIndex < 4)) {
if (events.type() == Common::EVENT_KEYDOWN) {
if ((events.event().kbd.keycode == Common::KEYCODE_BACKSPACE) && (_charIndex > 0)) {
@@ -1383,7 +1385,7 @@ bool CopyProtectionDialog::show() {
break;
}
- if (events.quitFlag)
+ if (engine.quit())
return false;
// At this point, two page numbers have been entered - validate them
diff --git a/engines/module.mk b/engines/module.mk
index 6cfe9b36fa..f7dd71f403 100644
--- a/engines/module.mk
+++ b/engines/module.mk
@@ -1,7 +1,7 @@
MODULE := engines
MODULE_OBJS := \
- engine.o
-
+ engine.o \
+ dialogs.o
# Include common rules
include $(srcdir)/rules.mk
diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp
index 6e91dd8a88..a771f960a9 100644
--- a/engines/parallaction/dialogue.cpp
+++ b/engines/parallaction/dialogue.cpp
@@ -104,11 +104,6 @@ uint16 DialogueManager::askPassword() {
e.kbd.ascii = 0;
if (g_system->getEventManager()->pollEvent(e)) {
- if (e.type == Common::EVENT_QUIT) {
- _engineFlags |= kEngineQuit;
- break;
- }
-
if ((e.type == Common::EVENT_KEYDOWN) && isdigit(e.kbd.ascii)) {
_password[passwordLen] = e.kbd.ascii;
passwordLen++;
@@ -230,7 +225,7 @@ void DialogueManager::run() {
displayQuestion();
- if (_engineFlags & kEngineQuit)
+ if (_vm->quit())
return;
if (_q->_answers[0] == NULL) break;
@@ -239,7 +234,7 @@ void DialogueManager::run() {
if (!displayAnswers()) break;
answer = getAnswer();
- if (_engineFlags & kEngineQuit)
+ if (_vm->quit())
return;
cmdlist = &_q->_answers[answer]->_commands;
@@ -272,8 +267,8 @@ int16 DialogueManager::selectAnswer() {
uint32 event;
Common::Point p;
- while ((_engineFlags & kEngineQuit) == 0) {
-
+ while (!_vm->quit()) {
+
_vm->_input->readInput();
_vm->_input->getCursorPos(p);
event = _vm->_input->getLastButtonEvent();
diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp
index d1cfb14557..b4578f80ad 100644
--- a/engines/parallaction/exec_ns.cpp
+++ b/engines/parallaction/exec_ns.cpp
@@ -306,7 +306,8 @@ DECLARE_COMMAND_OPCODE(drop){
DECLARE_COMMAND_OPCODE(quit) {
- _engineFlags |= kEngineQuit;
+ _vm->_quit = true;
+ _vm->quitGame();
}
@@ -430,11 +431,15 @@ void CommandExec::run(CommandList& list, ZonePtr z) {
CommandList::iterator it = list.begin();
for ( ; it != list.end(); it++) {
- if (_engineFlags & kEngineQuit)
+
+ if (_vm->quit())
break;
CommandPtr cmd = *it;
+ if (_vm->quit())
+ break;
+
if (cmd->_flagsOn & kFlagsGlobal) {
useFlags = _commandFlags | kFlagsGlobal;
useLocalFlags = false;
@@ -538,7 +543,7 @@ uint16 Parallaction::runZone(ZonePtr z) {
case kZoneSpeak:
runDialogue(z->u.speak);
- if (_engineFlags & kEngineQuit)
+ if (_vm->quit())
return 0;
break;
diff --git a/engines/parallaction/gui_br.cpp b/engines/parallaction/gui_br.cpp
index 0be070e345..391459a12f 100644
--- a/engines/parallaction/gui_br.cpp
+++ b/engines/parallaction/gui_br.cpp
@@ -50,7 +50,8 @@ void Parallaction_br::guiStart() {
int option = guiShowMenu();
switch (option) {
case kMenuQuit:
- _engineFlags |= kEngineQuit;
+ _quit = true;
+ _vm->quitGame();
break;
case kMenuLoadGame:
diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp
index 3797158661..9d5ff4ef80 100644
--- a/engines/parallaction/input.cpp
+++ b/engines/parallaction/input.cpp
@@ -80,7 +80,7 @@ uint16 Input::readInput() {
break;
case Common::EVENT_QUIT:
- _engineFlags |= kEngineQuit;
+ _vm->_quit = true;
return KeyDown;
default:
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 3cde21b49c..2fc809977f 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -120,6 +120,8 @@ int Parallaction::init() {
_location._comment = NULL;
_location._endComment = NULL;
+ _quit = false;
+
_pathBuffer = 0;
_screenSize = _screenWidth * _screenHeight;
@@ -340,7 +342,8 @@ void Parallaction::processInput(InputData *data) {
break;
case kEvQuitGame:
- _engineFlags |= kEngineQuit;
+ _quit = true;
+ _vm->quitGame();
break;
case kEvSaveGame:
@@ -367,19 +370,19 @@ void Parallaction::runGame() {
processInput(data);
}
- if (_engineFlags & kEngineQuit)
+ if (_vm->quit())
return;
runPendingZones();
- if (_engineFlags & kEngineQuit)
+ if (_vm->quit())
return;
if (_engineFlags & kEngineChangeLocation) {
changeLocation(_location._name);
}
- if (_engineFlags & kEngineQuit)
+ if (_vm->quit())
return;
_gfx->beginFrame();
@@ -479,7 +482,7 @@ ZonePtr Parallaction::findZone(const char *name) {
void Parallaction::freeZones() {
- debugC(2, kDebugExec, "freeZones: kEngineQuit = %i", _engineFlags & kEngineQuit);
+ debugC(2, kDebugExec, "freeZones: _vm->_quit = %i", _vm->_quit);
ZoneList::iterator it = _location._zones.begin();
@@ -488,7 +491,7 @@ void Parallaction::freeZones() {
// NOTE : this condition has been relaxed compared to the original, to allow the engine
// to retain special - needed - zones that were lost across location switches.
ZonePtr z = *it;
- if (((z->_top == -1) || (z->_left == -2)) && ((_engineFlags & kEngineQuit) == 0)) {
+ if (((z->_top == -1) || (z->_left == -2)) && ((_vm->_quit) == 0)) {
debugC(2, kDebugExec, "freeZones preserving zone '%s'", z->_name);
it++;
} else {
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index ef2dad9884..461ddc674f 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -99,7 +99,6 @@ enum {
};
enum EngineFlags {
- kEngineQuit = (1 << 0),
kEnginePauseJobs = (1 << 1),
kEngineInventory = (1 << 2),
kEngineWalking = (1 << 3),
@@ -259,6 +258,11 @@ public:
virtual bool loadGame() = 0;
virtual bool saveGame() = 0;
+ bool _quit; /* The only reason this flag exists is for freeZones() to properly
+ * delete all zones when necessary. THIS FLAG IS NOT THE ENGINE QUIT FLAG,
+ * use _eventMan->shouldQuit() for that.
+ */
+
Input *_input;
void processInput(InputData* data);
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 6606550132..090184e9fe 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -112,17 +112,17 @@ int Parallaction_br::go() {
guiSplash("dyna");
guiSplash("core");
- while ((_engineFlags & kEngineQuit) == 0) {
+ while (quit() == 0) {
guiStart();
- if (_engineFlags & kEngineQuit)
- return 0;
+ if (quit())
+ return _eventMan->shouldRTL();
// initCharacter();
_input->_inputMode = Input::kInputModeGame;
- while ((_engineFlags & (kEngineReturn | kEngineQuit)) == 0) {
+ while (((_engineFlags & kEngineReturn) == 0) && (!quit())) {
runGame();
}
_engineFlags &= ~kEngineReturn;
@@ -132,7 +132,7 @@ int Parallaction_br::go() {
}
- return 0;
+ return _eventMan->shouldRTL();
}
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index d1b25f189a..e5baf1864d 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -242,20 +242,20 @@ int Parallaction_ns::go() {
guiStart();
- if (_engineFlags & kEngineQuit)
- return 0;
+ if (quit())
+ return _eventMan->shouldRTL();
changeLocation(_location._name);
- if (_engineFlags & kEngineQuit)
- return 0;
+ if (quit())
+ return _eventMan->shouldRTL();
_input->_inputMode = Input::kInputModeGame;
- while ((_engineFlags & kEngineQuit) == 0) {
+ while (!quit()) {
runGame();
}
- return 0;
+ return _eventMan->shouldRTL();
}
void Parallaction_ns::switchBackground(const char* background, const char* mask) {
@@ -465,13 +465,13 @@ void Parallaction_ns::cleanupGame() {
memset(_locationNames, 0, sizeof(_locationNames));
// this flag tells freeZones to unconditionally remove *all* Zones
- _engineFlags |= kEngineQuit;
+ _vm->_quit = true;
freeZones();
freeAnimations();
// this dangerous flag can now be cleared
- _engineFlags &= ~kEngineQuit;
+ _vm->_quit = false;
// main character animation is restored
_location._animations.push_front(_char._ani);
diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp
index 002295315d..86700d6bb1 100644
--- a/engines/parallaction/saveload.cpp
+++ b/engines/parallaction/saveload.cpp
@@ -132,11 +132,13 @@ void Parallaction_ns::doLoadGame(uint16 slot) {
// TODO (LIST): unify (and parametrize) calls to freeZones.
// We aren't calling freeAnimations because it is not needed, since
// kChangeLocation will trigger a complete deletion. Anyway, we still
- // need to invoke freeZones here with kEngineQuit set, because the
+ // need to invoke freeZones here with _quit set, because the
// call in changeLocation preserve certain zones.
- _engineFlags |= kEngineQuit;
+ _quit = true;
+
freeZones();
- _engineFlags &= ~kEngineQuit;
+
+ _quit = false;
_numLocations = atoi(s);
diff --git a/engines/queen/input.cpp b/engines/queen/input.cpp
index 9f03c341c9..e7fcf84959 100644
--- a/engines/queen/input.cpp
+++ b/engines/queen/input.cpp
@@ -120,7 +120,8 @@ void Input::delay(uint amount) {
break;
case Common::EVENT_QUIT:
- _vm->quitGame();
+ if (_cutawayRunning)
+ _cutawayQuit = true;
return;
default:
diff --git a/engines/queen/journal.cpp b/engines/queen/journal.cpp
index 0327fb74b8..c0bd3837c1 100644
--- a/engines/queen/journal.cpp
+++ b/engines/queen/journal.cpp
@@ -85,7 +85,6 @@ void Journal::use() {
handleMouseWheel(1);
break;
case Common::EVENT_QUIT:
- _vm->quitGame();
return;
default:
break;
diff --git a/engines/queen/logic.cpp b/engines/queen/logic.cpp
index 9e4770553c..7fcc761018 100644
--- a/engines/queen/logic.cpp
+++ b/engines/queen/logic.cpp
@@ -2076,6 +2076,8 @@ bool LogicDemo::changeToSpecialRoom() {
displayRoom(currentRoom(), RDM_FADE_NOJOE, 100, 2, true);
playCutaway("CLOGO.CUT");
sceneReset();
+ if (_vm->quit())
+ return true;
currentRoom(ROOM_HOTEL_LOBBY);
entryObj(584);
displayRoom(currentRoom(), RDM_FADE_JOE, 100, 2, true);
@@ -2129,7 +2131,11 @@ bool LogicGame::changeToSpecialRoom() {
} else if (currentRoom() == FOTAQ_LOGO && gameState(VAR_INTRO_PLAYED) == 0) {
displayRoom(currentRoom(), RDM_FADE_NOJOE, 100, 2, true);
playCutaway("COPY.CUT");
+ if (_vm->quit())
+ return true;
playCutaway("CLOGO.CUT");
+ if (_vm->quit())
+ return true;
if (_vm->resource()->getPlatform() != Common::kPlatformAmiga) {
if (ConfMan.getBool("alt_intro") && _vm->resource()->isCD()) {
playCutaway("CINTR.CUT");
@@ -2137,7 +2143,11 @@ bool LogicGame::changeToSpecialRoom() {
playCutaway("CDINT.CUT");
}
}
+ if (_vm->quit())
+ return true;
playCutaway("CRED.CUT");
+ if (_vm->quit())
+ return true;
_vm->display()->palSetPanel();
sceneReset();
currentRoom(ROOM_HOTEL_LOBBY);
diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp
index c95e44b477..a164bcfcae 100644
--- a/engines/queen/queen.cpp
+++ b/engines/queen/queen.cpp
@@ -180,6 +180,10 @@ void QueenEngine::checkOptionSettings() {
}
}
+void QueenEngine::syncSoundSettings() {
+ _sound->setVolume(ConfMan.getInt("music_volume"));
+}
+
void QueenEngine::readOptionSettings() {
_sound->setVolume(ConfMan.getInt("music_volume"));
_sound->musicToggle(!ConfMan.getBool("music_mute"));
@@ -381,8 +385,8 @@ int QueenEngine::go() {
loadGameState(ConfMan.getInt("save_slot"));
}
_lastSaveTime = _lastUpdateTime = _system->getMillis();
- _quit = false;
- while (!_quit) {
+
+ while (!quit()) {
if (_logic->newRoom() > 0) {
_logic->update();
_logic->oldRoom(_logic->currentRoom());
@@ -400,7 +404,7 @@ int QueenEngine::go() {
update(true);
}
}
- return 0;
+ return _eventMan->shouldRTL();
}
int QueenEngine::init() {
diff --git a/engines/queen/queen.h b/engines/queen/queen.h
index 0beb557b36..5ec18c1230 100644
--- a/engines/queen/queen.h
+++ b/engines/queen/queen.h
@@ -97,13 +97,13 @@ public:
void checkOptionSettings();
void readOptionSettings();
void writeOptionSettings();
+ virtual void syncSoundSettings();
int talkSpeed() const { return _talkSpeed; }
void talkSpeed(int speed) { _talkSpeed = speed; }
bool subtitles() const { return _subtitles; }
void subtitles(bool enable) { _subtitles = enable; }
- void quitGame() { _quit = true; }
-
+
void update(bool checkPlayerInput = false);
bool canLoadOrSave() const;
@@ -137,7 +137,6 @@ protected:
int _talkSpeed;
bool _subtitles;
- bool _quit;
uint32 _lastSaveTime;
uint32 _lastUpdateTime;
diff --git a/engines/queen/sound.cpp b/engines/queen/sound.cpp
index d70fe7209d..0801d72ca4 100644
--- a/engines/queen/sound.cpp
+++ b/engines/queen/sound.cpp
@@ -224,8 +224,7 @@ void PCSound::playSpeech(const char *base) {
void PCSound::setVolume(int vol) {
Sound::setVolume(vol);
- // Set mixer music volume to maximum, since music volume is regulated by MusicPlayer's MIDI messages
- _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxMixerVolume);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, vol);
_music->setVolume(vol);
}
diff --git a/engines/queen/talk.cpp b/engines/queen/talk.cpp
index ff18ef37d1..fa2ca669cd 100644
--- a/engines/queen/talk.cpp
+++ b/engines/queen/talk.cpp
@@ -807,7 +807,7 @@ void Talk::speakSegment(
switch (command) {
case SPEAK_PAUSE:
- for (i = 0; i < 10 && !_vm->input()->talkQuit(); i++) {
+ for (i = 0; i < 10 && !_vm->input()->talkQuit() && !_vm->quit(); i++) {
_vm->update();
}
return;
diff --git a/engines/saga/input.cpp b/engines/saga/input.cpp
index ac80d87dd0..61b729b701 100644
--- a/engines/saga/input.cpp
+++ b/engines/saga/input.cpp
@@ -141,9 +141,6 @@ int SagaEngine::processInput() {
break;
case Common::EVENT_MOUSEMOVE:
break;
- case Common::EVENT_QUIT:
- shutDown();
- break;
default:
break;
}
diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp
index 1d048baaad..92ef960f48 100644
--- a/engines/saga/interface.cpp
+++ b/engines/saga/interface.cpp
@@ -688,7 +688,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
setMode(kPanelMain);
_vm->_script->setNoPendingVerb();
} else if (ascii == 'q' || ascii == 'Q') {
- _vm->shutDown();
+ _vm->quitGame();
}
break;
case kPanelBoss:
@@ -1081,7 +1081,7 @@ void Interface::setQuit(PanelButton *panelButton) {
if (_vm->getGameId() == GID_IHNM_DEMO)
_vm->_scene->creditsScene(); // display sales info for IHNM demo
else
- _vm->shutDown();
+ _vm->quitGame();
break;
}
}
diff --git a/engines/saga/introproc_ihnm.cpp b/engines/saga/introproc_ihnm.cpp
index 6614f4098f..079b355826 100644
--- a/engines/saga/introproc_ihnm.cpp
+++ b/engines/saga/introproc_ihnm.cpp
@@ -59,8 +59,12 @@ int Scene::IHNMStartProc() {
// Play Cyberdreams logo for 168 frames
if (!playTitle(0, logoLength, true)) {
+ if (_vm->quit())
+ return !SUCCESS;
// Play Dreamers Guild logo for 10 seconds
if (!playLoopingTitle(1, 10)) {
+ if (_vm->quit())
+ return !SUCCESS;
// Play the title music
_vm->_music->play(1, MUSIC_NORMAL);
// Play title screen
@@ -70,6 +74,8 @@ int Scene::IHNMStartProc() {
} else {
_vm->_music->play(1, MUSIC_NORMAL);
playTitle(0, 10);
+ if (_vm->quit())
+ return !SUCCESS;
playTitle(2, 12);
}
@@ -144,7 +150,6 @@ bool Scene::checkKey() {
switch (event.type) {
case Common::EVENT_QUIT:
res = true;
- _vm->shutDown();
break;
case Common::EVENT_KEYDOWN:
// Don't react to modifier keys alone. The original did
@@ -187,7 +192,7 @@ bool Scene::playTitle(int title, int time, int mode) {
_vm->_gfx->getCurrentPal(pal_cut);
- while (!done) {
+ while (!done && !_vm->quit()) {
curTime = _vm->_system->getMillis();
switch (phase) {
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp
index 732bd0b50c..1005b0ab5f 100644
--- a/engines/saga/music.cpp
+++ b/engines/saga/music.cpp
@@ -346,7 +346,7 @@ void MusicPlayer::stopMusic() {
}
}
-Music::Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver, int enabled) : _vm(vm), _mixer(mixer), _enabled(enabled), _adlib(false) {
+Music::Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver) : _vm(vm), _mixer(mixer), _adlib(false) {
_player = new MusicPlayer(driver);
_currentVolume = 0;
@@ -432,11 +432,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) {
uint32 loopStart;
debug(2, "Music::play %d, %d", resourceId, flags);
-
- if (!_enabled) {
- return;
- }
-
+
if (isPlaying() && _trackNumber == resourceId) {
return;
}
@@ -444,11 +440,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) {
_trackNumber = resourceId;
_player->stopMusic();
_mixer->stopHandle(_musicHandle);
-
- if (!_vm->_musicVolume) {
- return;
- }
-
+
int realTrackNumber;
if (_vm->getGameType() == GType_ITE) {
diff --git a/engines/saga/music.h b/engines/saga/music.h
index 1953dc6f91..57ff9e0671 100644
--- a/engines/saga/music.h
+++ b/engines/saga/music.h
@@ -105,7 +105,7 @@ protected:
class Music {
public:
- Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver, int enabled);
+ Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver);
~Music(void);
void setNativeMT32(bool b) { _player->setNativeMT32(b); }
bool hasNativeMT32() { return _player->hasNativeMT32(); }
@@ -133,7 +133,6 @@ private:
Audio::SoundHandle _musicHandle;
uint32 _trackNumber;
- int _enabled;
bool _adlib;
int _targetVolume;
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp
index fafbd02cec..c359bbb631 100644
--- a/engines/saga/saga.cpp
+++ b/engines/saga/saga.cpp
@@ -64,7 +64,6 @@ SagaEngine::SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc)
_leftMouseButtonPressed = _rightMouseButtonPressed = false;
_console = NULL;
- _quit = false;
_resource = NULL;
_sndRes = NULL;
@@ -194,14 +193,9 @@ int SagaEngine::init() {
if (native_mt32)
_driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
- _music = new Music(this, _mixer, _driver, _musicVolume);
+ _music = new Music(this, _mixer, _driver);
_music->setNativeMT32(native_mt32);
_music->setAdlib(adlib);
-
- if (!_musicVolume) {
- debug(1, "Music disabled.");
- }
-
_render = new Render(this, _system);
if (!_render->initialized()) {
return FAILURE;
@@ -209,14 +203,11 @@ int SagaEngine::init() {
// Initialize system specific sound
_sound = new Sound(this, _mixer, _soundVolume);
- if (!_soundVolume) {
- debug(1, "Sound disabled.");
- }
-
+
_interface->converseInit();
_script->setVerb(_script->getVerbType(kVerbWalkTo));
- _music->setVolume(-1, 1);
+ _music->setVolume(_musicVolume, 1);
_gfx->initPalette();
@@ -270,7 +261,7 @@ int SagaEngine::go() {
uint32 currentTicks;
- while (!_quit) {
+ while (!quit()) {
if (_console->isAttached())
_console->onFrame();
@@ -310,7 +301,7 @@ int SagaEngine::go() {
_system->delayMillis(10);
}
- return 0;
+ return _eventMan->shouldRTL();
}
void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPointer, size_t stringsLength) {
@@ -520,4 +511,18 @@ int SagaEngine::getTalkspeed() {
return (ConfMan.getInt("talkspeed") * 3 + 255 / 2) / 255;
}
+void SagaEngine::syncSoundSettings() {
+ _soundVolume = ConfMan.getInt("sfx_volume");
+ _musicVolume = ConfMan.getInt("music_volume");
+ _subtitlesEnabled = ConfMan.getBool("subtitles");
+ _readingSpeed = getTalkspeed();
+
+ if (_readingSpeed > 3)
+ _readingSpeed = 0;
+
+ _music->setVolume(_musicVolume, 1);
+ _sound->setVolume(_soundVolume);
+
+}
+
} // End of namespace Saga
diff --git a/engines/saga/saga.h b/engines/saga/saga.h
index 6b6eb6b3fb..cdbaaaa042 100644
--- a/engines/saga/saga.h
+++ b/engines/saga/saga.h
@@ -491,7 +491,6 @@ protected:
public:
SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc);
virtual ~SagaEngine();
- void shutDown() { _quit = true; }
void save(const char *fileName, const char *saveName);
void load(const char *fileName);
@@ -512,6 +511,8 @@ public:
return isSaveListFull() ? _saveFilesCount : _saveFilesCount + 1;
}
+ virtual void syncSoundSettings();
+
int16 _framesEsc;
uint32 _globalFlags;
@@ -610,8 +611,6 @@ public:
bool _rightMouseButtonPressed;
int _mouseClickCount;
- bool _quit;
-
//current game description
int _gameNumber;
const SAGAGameDescription *_gameDescription;
diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp
index c3c1587822..074b4c933a 100644
--- a/engines/saga/scene.cpp
+++ b/engines/saga/scene.cpp
@@ -315,7 +315,7 @@ void Scene::creditsScene() {
break;
}
- _vm->shutDown();
+ _vm->quitGame();
return;
}
diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp
index ea61f5ce04..9a304de8e1 100644
--- a/engines/saga/sfuncs.cpp
+++ b/engines/saga/sfuncs.cpp
@@ -356,7 +356,7 @@ void Script::sfMainMode(SCRIPTFUNC_PARAMS) {
// exit the game. Known non-interactive demos are GID_ITE_MACDEMO1 and
// GID_ITE_WINDEMO1
if (_vm->getFeatures() & GF_NON_INTERACTIVE)
- _vm->shutDown();
+ _vm->quitGame();
}
// Script function #6 (0x06) blocking
@@ -572,7 +572,7 @@ void Script::sfScriptGotoScene(SCRIPTFUNC_PARAMS) {
}
if (_vm->getGameType() == GType_ITE && sceneNumber < 0) {
- _vm->shutDown();
+ _vm->quitGame();
return;
}
diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp
index 6d1cf1bbd8..310cfc50a6 100644
--- a/engines/scumm/dialogs.cpp
+++ b/engines/scumm/dialogs.cpp
@@ -435,7 +435,7 @@ Common::StringList generateSavegameList(ScummEngine *scumm, bool saveMode) {
return descriptions;
}
-MainMenuDialog::MainMenuDialog(ScummEngine *scumm)
+ScummMenuDialog::ScummMenuDialog(ScummEngine *scumm)
: ScummDialog("scummmain"), _vm(scumm) {
new GUI::ButtonWidget(this, "scummmain_resume", "Resume", kPlayCmd, 'P');
@@ -463,7 +463,7 @@ MainMenuDialog::MainMenuDialog(ScummEngine *scumm)
_loadDialog = new SaveLoadChooser("Load game:", "Load", false, scumm);
}
-MainMenuDialog::~MainMenuDialog() {
+ScummMenuDialog::~ScummMenuDialog() {
delete _aboutDialog;
delete _optionsDialog;
#ifndef DISABLE_HELP
@@ -473,7 +473,7 @@ MainMenuDialog::~MainMenuDialog() {
delete _loadDialog;
}
-void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+void ScummMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kSaveCmd:
save();
@@ -496,7 +496,7 @@ void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
break;
#endif
case kQuitCmd:
- _vm->_quit = true;
+ _vm->quitGame();
close();
break;
default:
@@ -504,7 +504,7 @@ void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
}
}
-void MainMenuDialog::save() {
+void ScummMenuDialog::save() {
int idx;
_saveDialog->setList(generateSavegameList(_vm, true));
idx = _saveDialog->runModal();
@@ -523,7 +523,7 @@ void MainMenuDialog::save() {
}
}
-void MainMenuDialog::load() {
+void ScummMenuDialog::load() {
int idx;
_loadDialog->setList(generateSavegameList(_vm, false));
idx = _loadDialog->runModal();
diff --git a/engines/scumm/dialogs.h b/engines/scumm/dialogs.h
index 7c99a0ebcc..192bb8d0e1 100644
--- a/engines/scumm/dialogs.h
+++ b/engines/scumm/dialogs.h
@@ -82,10 +82,10 @@ public:
virtual void reflowLayout();
};
-class MainMenuDialog : public ScummDialog {
+class ScummMenuDialog : public ScummDialog {
public:
- MainMenuDialog(ScummEngine *scumm);
- ~MainMenuDialog();
+ ScummMenuDialog(ScummEngine *scumm);
+ ~ScummMenuDialog();
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
protected:
diff --git a/engines/scumm/he/cup_player_he.cpp b/engines/scumm/he/cup_player_he.cpp
index e611c85e9d..685bd00065 100644
--- a/engines/scumm/he/cup_player_he.cpp
+++ b/engines/scumm/he/cup_player_he.cpp
@@ -99,7 +99,7 @@ void CUP_Player::play() {
debug(1, "rate %d width %d height %d", _playbackRate, _width, _height);
int ticks = _system->getMillis();
- while (_dataSize != 0 && !_vm->_quit) {
+ while (_dataSize != 0 && !_vm->quit()) {
while (parseNextBlockTag(_fileStream)) {
if (_fileStream.ioFailed()) {
return;
@@ -190,7 +190,7 @@ void CUP_Player::waitForSfxChannel(int channel) {
CUP_SfxChannel *sfxChannel = &_sfxChannels[channel];
debug(1, "waitForSfxChannel %d", channel);
if ((sfxChannel->flags & kSfxFlagLoop) == 0) {
- while (_mixer->isSoundHandleActive(sfxChannel->handle) && !_vm->_quit) {
+ while (_mixer->isSoundHandleActive(sfxChannel->handle) && !_vm->quit()) {
_vm->parseEvents();
_system->delayMillis(10);
}
@@ -496,7 +496,7 @@ void CUP_Player::handleTOIL(Common::SeekableReadStream &dataStream, uint32 dataS
for (int i = 0; i < kSfxChannels; ++i) {
waitForSfxChannel(i);
}
- _vm->_quit = true;
+ _vm->quitGame();
break;
case 7: {
int channelSync = dataStream.readUint32LE();
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index f72701c229..5f907d7f04 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -2147,10 +2147,10 @@ void ScummEngine_v100he::o100_systemOps() {
break;
case 71:
// Confirm shutdown
- shutDown();
+ quitGame();
break;
case 72:
- shutDown();
+ quitGame();
break;
case 73:
copyScriptString(string, sizeof(string));
diff --git a/engines/scumm/he/script_v70he.cpp b/engines/scumm/he/script_v70he.cpp
index 3f22c16648..c7256835eb 100644
--- a/engines/scumm/he/script_v70he.cpp
+++ b/engines/scumm/he/script_v70he.cpp
@@ -634,10 +634,10 @@ void ScummEngine_v70he::o70_systemOps() {
break;
case 160:
// Confirm shutdown
- shutDown();
+ quitGame();
break;
case 244:
- shutDown();
+ quitGame();
break;
case 250:
id = pop();
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index df3d857642..6f68d56693 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -1485,10 +1485,10 @@ void ScummEngine_v72he::o72_systemOps() {
break;
case 160:
// Confirm shutdown
- shutDown();
+ quitGame();
break;
case 244:
- shutDown();
+ quitGame();
break;
case 251:
copyScriptString(string, sizeof(string));
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 35028c7e1c..cc98cc00ae 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -192,10 +192,6 @@ void ScummEngine::parseEvents() {
_keyPressed = Common::KeyState(Common::KEYCODE_6, 54); // '6'
break;
- case Common::EVENT_QUIT:
- _quit = true;
- break;
-
default:
break;
}
@@ -475,7 +471,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, 0);
- mainMenuDialog(); // Display NewGui
+ scummMenuDialog(); // Display NewGui
if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, 0);
@@ -514,7 +510,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
vol = Audio::Mixer::kMaxMixerVolume;
ConfMan.setInt("music_volume", vol);
- updateSoundSettings();
+ syncSoundSettings();
} else if (lastKeyHit.ascii == '-' || lastKeyHit.ascii == '+') { // Change text speed
if (lastKeyHit.ascii == '+' && _defaultTalkDelay > 0)
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index acdc2bc222..8f7617885a 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -291,7 +291,7 @@ void ScummEngine::readIndexFile() {
if (checkTryMedia(_fileHandle)) {
displayMessage(NULL, "You're trying to run game encrypted by ActiveMark. This is not supported.");
- _quit = true;
+ quitGame();
return;
}
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index f9e4eb415c..5894e837aa 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -275,7 +275,7 @@ bool ScummEngine::loadState(int slot, bool compat) {
delete in;
// Update volume settings
- updateSoundSettings();
+ syncSoundSettings();
// Init NES costume data
if (_game.platform == Common::kPlatformNES) {
diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp
index 431321f459..1d90b5e4af 100644
--- a/engines/scumm/script_v5.cpp
+++ b/engines/scumm/script_v5.cpp
@@ -1769,7 +1769,7 @@ void ScummEngine_v5::o5_systemOps() {
pauseGame();
break;
case 3: // SO_QUIT
- shutDown();
+ quitGame();
break;
default:
error("o5_systemOps: unknown subopcode %d", subOp);
diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp
index 04ea53137b..f8502cbbe7 100644
--- a/engines/scumm/script_v6.cpp
+++ b/engines/scumm/script_v6.cpp
@@ -2310,7 +2310,7 @@ void ScummEngine_v6::o6_systemOps() {
pauseGame();
break;
case 160: // SO_QUIT
- shutDown();
+ quitGame();
break;
default:
error("o6_systemOps invalid case %d", subOp);
diff --git a/engines/scumm/script_v8.cpp b/engines/scumm/script_v8.cpp
index 08629afb07..63e54417a9 100644
--- a/engines/scumm/script_v8.cpp
+++ b/engines/scumm/script_v8.cpp
@@ -1170,7 +1170,7 @@ void ScummEngine_v8::o8_systemOps() {
restart();
break;
case 0x29: // SO_SYSTEM_QUIT Quit game
- shutDown();
+ quitGame();
break;
default:
error("o8_systemOps: invalid case 0x%x", subOp);
@@ -1289,7 +1289,7 @@ void ScummEngine_v8::o8_kernelSetFunctions() {
if (ConfMan.getBool("confirm_exit"))
confirmExitDialog();
else
- _quit = true;
+ quitGame();
break;
case 108: // buildPaletteShadow
setShadowPalette(args[1], args[2], args[3], args[4], args[5], args[6]);
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 2f0593dca8..37e1fa862a 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -109,7 +109,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_language(dr.language),
_debugger(0),
_currentScript(0xFF), // Let debug() work on init stage
- _pauseDialog(0), _mainMenuDialog(0), _versionDialog(0) {
+ _pauseDialog(0), _scummMenuDialog(0), _versionDialog(0) {
if (_game.platform == Common::kPlatformNES) {
_gdi = new GdiNES(this);
@@ -143,9 +143,8 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_objs = NULL;
_sound = NULL;
memset(&vm, 0, sizeof(vm));
- _quit = false;
_pauseDialog = NULL;
- _mainMenuDialog = NULL;
+ _scummMenuDialog = NULL;
_versionDialog = NULL;
_fastMode = 0;
_actors = NULL;
@@ -561,7 +560,7 @@ ScummEngine::~ScummEngine() {
delete _2byteFontPtr;
delete _charset;
delete _pauseDialog;
- delete _mainMenuDialog;
+ delete _scummMenuDialog;
delete _versionDialog;
delete _fileHandle;
@@ -815,7 +814,6 @@ ScummEngine_vCUPhe::ScummEngine_vCUPhe(OSystem *syst, const DetectorResult &dr)
_syst = syst;
_game = dr.game;
_filenamePattern = dr.fp,
- _quit = false;
_cupPlayer = new CUP_Player(syst, this, _mixer);
}
@@ -846,9 +844,6 @@ void ScummEngine_vCUPhe::parseEvents() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_QUIT:
- _quit = true;
- break;
default:
break;
@@ -1108,7 +1103,7 @@ int ScummEngine::init() {
if (_game.version >= 5 && _game.version <= 7)
_sound->setupSound();
- updateSoundSettings();
+ syncSoundSettings();
return 0;
}
@@ -1667,7 +1662,7 @@ void ScummEngine::setupMusic(int midi) {
}
}
-void ScummEngine::updateSoundSettings() {
+void ScummEngine::syncSoundSettings() {
// Sync the engine with the config manager
int soundVolumeMusic = ConfMan.getInt("music_volume");
@@ -1678,6 +1673,7 @@ void ScummEngine::updateSoundSettings() {
_musicEngine->setMusicVolume(soundVolumeMusic);
}
+ _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, soundVolumeMusic);
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolumeSfx);
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech);
@@ -1721,7 +1717,7 @@ int ScummEngine::go() {
int diff = 0; // Duration of one loop iteration
- while (!_quit) {
+ while (!quit()) {
if (_debugger->isAttached())
_debugger->onFrame();
@@ -1754,12 +1750,12 @@ int ScummEngine::go() {
diff = _system->getMillis() - diff;
- if (_quit) {
+ if (quit()) {
// TODO: Maybe perform an autosave on exit?
}
}
- return 0;
+ return _eventMan->shouldRTL();
}
void ScummEngine::waitForTimer(int msec_delay) {
@@ -1772,7 +1768,7 @@ void ScummEngine::waitForTimer(int msec_delay) {
start_time = _system->getMillis();
- while (!_quit) {
+ while (!quit()) {
_sound->updateCD(); // Loop CD Audio if needed
parseEvents();
_system->updateScreen();
@@ -1895,7 +1891,7 @@ load_game:
checkExecVerbs();
checkAndRunSentenceScript();
- if (_quit)
+ if (quit())
return;
// HACK: If a load was requested, immediately perform it. This avoids
@@ -2160,10 +2156,6 @@ void ScummEngine::pauseGame() {
pauseDialog();
}
-void ScummEngine::shutDown() {
- _quit = true;
-}
-
void ScummEngine::restart() {
// TODO: Check this function - we should probably be reinitting a lot more stuff, and I suspect
// this leaks memory like a sieve
@@ -2305,18 +2297,18 @@ void ScummEngine::versionDialog() {
runDialog(*_versionDialog);
}
-void ScummEngine::mainMenuDialog() {
- if (!_mainMenuDialog)
- _mainMenuDialog = new MainMenuDialog(this);
- runDialog(*_mainMenuDialog);
- updateSoundSettings();
+void ScummEngine::scummMenuDialog() {
+ if (!_scummMenuDialog)
+ _scummMenuDialog = new ScummMenuDialog(this);
+ runDialog(*_scummMenuDialog);
+ syncSoundSettings();
}
void ScummEngine::confirmExitDialog() {
ConfirmDialog d(this, 6);
if (runDialog(d)) {
- _quit = true;
+ quitGame();
}
}
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 20824ffe74..b1ab9f7386 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -462,7 +462,7 @@ protected:
virtual void loadLanguageBundle() {}
void loadCJKFont();
void setupMusic(int midi);
- void updateSoundSettings();
+ virtual void syncSoundSettings();
void setTalkspeed(int talkspeed);
int getTalkspeed();
@@ -496,22 +496,18 @@ protected:
public:
void pauseGame();
void restart();
- void shutDown();
-
- /** We keep running until this is set to true. */
- bool _quit;
protected:
Dialog *_pauseDialog;
Dialog *_versionDialog;
- Dialog *_mainMenuDialog;
+ Dialog *_scummMenuDialog;
virtual int runDialog(Dialog &dialog);
void confirmExitDialog();
void confirmRestartDialog();
void pauseDialog();
void versionDialog();
- void mainMenuDialog();
+ void scummMenuDialog();
char displayMessage(const char *altButton, const char *message, ...);
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index 494357a90c..850b547021 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -1333,7 +1333,7 @@ void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 st
}
if (_endOfFile)
break;
- if (_vm->_quit || _vm->_saveLoadFlag || _vm->_smushVideoShouldFinish) {
+ if (_vm->quit() || _vm->_saveLoadFlag || _vm->_smushVideoShouldFinish) {
_smixer->stop();
_vm->_mixer->stopHandle(_compressedFileSoundHandle);
_vm->_mixer->stopHandle(_IACTchannel);
diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp
index 53169402e1..a6ab5429dd 100644
--- a/engines/sky/control.cpp
+++ b/engines/sky/control.cpp
@@ -492,7 +492,7 @@ void Control::doControlPanel(void) {
_curButtonText = 0;
uint16 clickRes = 0;
- while (!quitPanel && !SkyEngine::_systemVars.quitGame) {
+ while (!quitPanel && !g_engine->quit()) {
_text->drawToScreen(WITH_MASK);
_system->updateScreen();
_mouseClicked = false;
@@ -524,7 +524,7 @@ void Control::doControlPanel(void) {
}
memset(_screenBuf, 0, GAME_SCREEN_WIDTH * FULL_SCREEN_HEIGHT);
_system->copyRectToScreen(_screenBuf, GAME_SCREEN_WIDTH, 0, 0, GAME_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
- if (!SkyEngine::_systemVars.quitGame)
+ if (!g_engine->quit())
_system->updateScreen();
_skyScreen->forceRefresh();
_skyScreen->setPaletteEndian((uint8 *)_skyCompact->fetchCpt(SkyEngine::_systemVars.currentPalette));
@@ -603,7 +603,7 @@ uint16 Control::handleClick(ConResource *pButton) {
case QUIT_TO_DOS:
animClick(pButton);
if (getYesNo(quitDos))
- SkyEngine::_systemVars.quitGame = true;
+ g_engine->quitGame();
return 0;
default:
error("Control::handleClick: unknown routine: %X",pButton->_onClick);
@@ -875,7 +875,7 @@ uint16 Control::saveRestorePanel(bool allowSave) {
bool refreshNames = true;
bool refreshAll = true;
uint16 clickRes = 0;
- while (!quitPanel && !SkyEngine::_systemVars.quitGame) {
+ while (!quitPanel && !g_engine->quit()) {
clickRes = 0;
if (refreshNames || refreshAll) {
if (refreshAll) {
@@ -1546,9 +1546,6 @@ void Control::delay(unsigned int amount) {
case Common::EVENT_WHEELDOWN:
_mouseWheel = 1;
break;
- case Common::EVENT_QUIT:
- SkyEngine::_systemVars.quitGame = true;
- break;
default:
break;
}
diff --git a/engines/sky/intro.cpp b/engines/sky/intro.cpp
index 024360561c..51160924da 100644
--- a/engines/sky/intro.cpp
+++ b/engines/sky/intro.cpp
@@ -636,7 +636,6 @@ Intro::Intro(Disk *disk, Screen *screen, MusicBase *music, Sound *sound, Text *t
_textBuf = (uint8*)malloc(10000);
_saveBuf = (uint8*)malloc(10000);
_bgBuf = NULL;
- _quitProg = false;
_relDelay = 0;
}
@@ -913,7 +912,6 @@ bool Intro::escDelay(uint32 msecs) {
if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
return false;
} else if (event.type == Common::EVENT_QUIT) {
- _quitProg = true;
return false;
}
}
diff --git a/engines/sky/intro.h b/engines/sky/intro.h
index 4a54fb8dd3..796bcf7e36 100644
--- a/engines/sky/intro.h
+++ b/engines/sky/intro.h
@@ -43,7 +43,6 @@ public:
Intro(Disk *disk, Screen *screen, MusicBase *music, Sound *sound, Text *text, Audio::Mixer *mixer, OSystem *system);
~Intro(void);
bool doIntro(bool floppyIntro);
- bool _quitProg;
private:
static uint16 _mainIntroSeq[];
static uint16 _floppyIntroSeq[];
diff --git a/engines/sky/logic.cpp b/engines/sky/logic.cpp
index ed7e419f64..6cd4ce505a 100644
--- a/engines/sky/logic.cpp
+++ b/engines/sky/logic.cpp
@@ -2489,7 +2489,7 @@ bool Logic::fnFadeUp(uint32 a, uint32 b, uint32 c) {
}
bool Logic::fnQuitToDos(uint32 a, uint32 b, uint32 c) {
- SkyEngine::_systemVars.quitGame = true;
+ g_engine->quitGame();
return false;
}
diff --git a/engines/sky/mouse.cpp b/engines/sky/mouse.cpp
index b3be8b4f36..1fc9e47539 100644
--- a/engines/sky/mouse.cpp
+++ b/engines/sky/mouse.cpp
@@ -180,7 +180,6 @@ void Mouse::waitMouseNotPressed(int minDelay) {
while (mousePressed || _system->getMillis() < now + minDelay) {
if (eventMan->shouldQuit()) {
- SkyEngine::_systemVars.quitGame = true;
minDelay = 0;
mousePressed = false;
}
diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp
index d87ed06fef..421f6a5f08 100644
--- a/engines/sky/sky.cpp
+++ b/engines/sky/sky.cpp
@@ -257,7 +257,7 @@ namespace Sky {
void *SkyEngine::_itemList[300];
-SystemVars SkyEngine::_systemVars = {0, 0, 0, 0, 4316, 0, 0, false, false, false };
+SystemVars SkyEngine::_systemVars = {0, 0, 0, 0, 4316, 0, 0, false, false };
SkyEngine::SkyEngine(OSystem *syst)
: Engine(syst), _fastMode(0), _debugger(0) {
@@ -340,8 +340,6 @@ void SkyEngine::handleKey(void) {
int SkyEngine::go() {
- _systemVars.quitGame = false;
-
_keyPressed.reset();
uint16 result = 0;
@@ -353,12 +351,9 @@ int SkyEngine::go() {
if (_systemVars.gameVersion > 267) { // don't do intro for floppydemos
_skyIntro = new Intro(_skyDisk, _skyScreen, _skyMusic, _skySound, _skyText, _mixer, _system);
introSkipped = !_skyIntro->doIntro(_floppyIntro);
- _systemVars.quitGame = _skyIntro->_quitProg;
-
- delete _skyIntro;
}
- if (!_systemVars.quitGame) {
+ if (!quit()) {
_skyLogic->initScreen0();
if (introSkipped)
_skyControl->restartGame();
@@ -368,7 +363,7 @@ int SkyEngine::go() {
_lastSaveTime = _system->getMillis();
uint32 delayCount = _system->getMillis();
- while (!_systemVars.quitGame) {
+ while (!quit()) {
if (_debugger->isAttached())
_debugger->onFrame();
@@ -419,7 +414,7 @@ int SkyEngine::go() {
_skyMusic->stopMusic();
ConfMan.flushToDisk();
delay(1500);
- return 0;
+ return _eventMan->shouldRTL();
}
int SkyEngine::init() {
@@ -615,9 +610,6 @@ void SkyEngine::delay(int32 amount) {
_skyMouse->mouseMoved(event.mouse.x, event.mouse.y);
_skyMouse->buttonPressed(1);
break;
- case Common::EVENT_QUIT:
- _systemVars.quitGame = true;
- break;
default:
break;
}
diff --git a/engines/sky/sky.h b/engines/sky/sky.h
index b5d1701930..47aebaba77 100644
--- a/engines/sky/sky.h
+++ b/engines/sky/sky.h
@@ -41,7 +41,6 @@ struct SystemVars {
uint16 gameSpeed;
uint16 currentMusic;
bool pastIntro;
- bool quitGame;
bool paused;
};
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index 2bb027ddb4..caf766ed9f 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -300,9 +300,6 @@ void MoviePlayer::play(void) {
terminated = true;
}
break;
- case Common::EVENT_QUIT:
- _system->quit();
- break;
default:
break;
}
diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index 980e0b4f9f..3a26f4dd33 100644
--- a/engines/sword1/control.cpp
+++ b/engines/sword1/control.cpp
@@ -215,7 +215,7 @@ void Control::askForCd(void) {
notAccepted = false;
}
}
- } while (notAccepted && (!SwordEngine::_systemVars.engineQuit));
+ } while (notAccepted && (!g_engine->quit()));
_resMan->resClose(fontId);
free(_screenBuf);
@@ -317,7 +317,7 @@ uint8 Control::runPanel(void) {
}
delay(1000 / 12);
newMode = getClicks(mode, &retVal);
- } while ((newMode != BUTTON_DONE) && (retVal == 0) && (!SwordEngine::_systemVars.engineQuit));
+ } while ((newMode != BUTTON_DONE) && (retVal == 0) && (!g_engine->quit()));
if (SwordEngine::_systemVars.controlPanelMode == CP_NORMAL) {
uint8 volL, volR;
@@ -425,7 +425,7 @@ uint8 Control::handleButtonClick(uint8 id, uint8 mode, uint8 *retVal) {
_buttons[5]->setSelected(SwordEngine::_systemVars.showText);
} else if (id == BUTTON_QUIT) {
if (getConfirm(_lStrings[STR_QUIT]))
- SwordEngine::_systemVars.engineQuit = true;
+ g_engine->quitGame();
return mode;
}
break;
@@ -1091,9 +1091,6 @@ void Control::delay(uint32 msecs) {
_mouseDown = false;
_mouseState |= BS1_WHEEL_DOWN;
break;
- case Common::EVENT_QUIT:
- SwordEngine::_systemVars.engineQuit = true;
- break;
default:
break;
}
diff --git a/engines/sword1/credits.cpp b/engines/sword1/credits.cpp
index 14dd0ecd2b..55f1f7358b 100644
--- a/engines/sword1/credits.cpp
+++ b/engines/sword1/credits.cpp
@@ -125,7 +125,7 @@ void CreditsPlayer::play(void) {
uint16 renderY = BUFSIZE_Y / 2;
uint16 clearY = 0xFFFF;
bool clearLine = false;
- while (((*textData != FNT_EOB) || (scrollY != renderY)) && !SwordEngine::_systemVars.engineQuit) {
+ while (((*textData != FNT_EOB) || (scrollY != renderY)) && !g_engine->quit()) {
if ((int32)_mixer->getSoundElapsedTime(bgSound) - relDelay < (SCROLL_TIMING * 2)) { // sync to audio
if (scrollY < BUFSIZE_Y - CREDITS_Y)
_system->copyRectToScreen(screenBuf + scrollY * CREDITS_X, CREDITS_X, START_X, START_Y, CREDITS_X, CREDITS_Y);
@@ -175,7 +175,7 @@ void CreditsPlayer::play(void) {
uint8 *revoBuf = credFile.decompressFile(REVO_LOGO);
uint8 *revoPal = credFile.fetchFile(REVO_PAL, &_palLen);
_palLen /= 3;
- while ((_mixer->getSoundElapsedTime(bgSound) < LOGO_FADEUP_TIME) && !SwordEngine::_systemVars.engineQuit) {
+ while ((_mixer->getSoundElapsedTime(bgSound) < LOGO_FADEUP_TIME) && !g_engine->quit()) {
delay(100);
}
memset(_palette, 0, 256 * 4);
@@ -184,13 +184,13 @@ void CreditsPlayer::play(void) {
_system->updateScreen();
fadePalette(revoPal, true, _palLen);
- while ((_mixer->getSoundElapsedTime(bgSound) < LOGO_FADEDOWN_TIME) && !SwordEngine::_systemVars.engineQuit) {
+ while ((_mixer->getSoundElapsedTime(bgSound) < LOGO_FADEDOWN_TIME) && !g_engine->quit()) {
delay(100);
}
fadePalette(revoPal, false, _palLen);
delay(3000);
- if (SwordEngine::_systemVars.engineQuit)
+ if (g_engine->quit())
_mixer->stopAll();
free(revoBuf);
}
@@ -200,7 +200,7 @@ void CreditsPlayer::fadePalette(uint8 *srcPal, bool fadeup, uint16 len) {
int fadeStart = fadeup ? 0 : 12;
int relDelay = _system->getMillis();
- for (int fadeStep = fadeStart; (fadeStep >= 0) && (fadeStep <= 12) && !SwordEngine::_systemVars.engineQuit; fadeStep += fadeDir) {
+ for (int fadeStep = fadeStart; (fadeStep >= 0) && (fadeStep <= 12) && !g_engine->quit(); fadeStep += fadeDir) {
for (uint16 cnt = 0; cnt < len * 3; cnt++)
_palette[(cnt / 3) * 4 + (cnt % 3)] = (srcPal[cnt] * fadeStep) / 12;
_system->setPalette(_palette, 0, 256);
@@ -281,9 +281,6 @@ void CreditsPlayer::delay(int msecs) {
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_QUIT:
- SwordEngine::_systemVars.engineQuit = true;
- break;
default:
break;
}
@@ -294,7 +291,7 @@ void CreditsPlayer::delay(int msecs) {
if (msecs > 0)
_system->delayMillis(10);
- } while ((_system->getMillis() < start + msecs) && !SwordEngine::_systemVars.engineQuit);
+ } while ((_system->getMillis() < start + msecs) && !g_engine->quit());
}
ArcFile::ArcFile(void) {
diff --git a/engines/sword1/logic.cpp b/engines/sword1/logic.cpp
index e7e1fb39a4..2fa108ebdd 100644
--- a/engines/sword1/logic.cpp
+++ b/engines/sword1/logic.cpp
@@ -1636,7 +1636,7 @@ int Logic::fnQuitGame(Object *cpt, int32 id, int32 a, int32 b, int32 c, int32 d,
if (SwordEngine::_systemVars.isDemo) {
GUI::MessageDialog dialog("This is the end of the Broken Sword 1 Demo", "OK", NULL);
dialog.runModal();
- SwordEngine::_systemVars.engineQuit = true;
+ g_engine->quitGame();
} else
error("fnQuitGame() called");
return fnQuit(cpt, id, 0, 0, 0, 0, 0, 0);
diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp
index 7372779199..4d0eb1dc98 100644
--- a/engines/sword1/sword1.cpp
+++ b/engines/sword1/sword1.cpp
@@ -310,7 +310,6 @@ int SwordEngine::init() {
_systemVars.controlPanelMode = CP_NEWGAME;
_systemVars.forceRestart = false;
_systemVars.wantFade = true;
- _systemVars.engineQuit = false;
switch (Common::parseLanguage(ConfMan.get("language"))) {
case Common::DE_DEU:
@@ -645,7 +644,7 @@ int SwordEngine::go() {
_systemVars.controlPanelMode = CP_NEWGAME;
if (_control->runPanel() == CONTROL_GAME_RESTORED)
_control->doRestore();
- else if (!_systemVars.engineQuit)
+ else if (!quit())
_logic->startPositions(0);
} else {
// no savegames, start new game.
@@ -654,10 +653,10 @@ int SwordEngine::go() {
}
_systemVars.controlPanelMode = CP_NORMAL;
- while (!_systemVars.engineQuit) {
+ while (!quit()) {
uint8 action = mainLoop();
- if (!_systemVars.engineQuit) {
+ if (!quit()) {
// the mainloop was left, we have to reinitialize.
reinitialize();
if (action == CONTROL_GAME_RESTORED)
@@ -669,7 +668,7 @@ int SwordEngine::go() {
}
}
- return 0;
+ return _eventMan->shouldRTL();
}
void SwordEngine::checkCd(void) {
@@ -698,7 +697,7 @@ uint8 SwordEngine::mainLoop(void) {
uint8 retCode = 0;
_keyPressed.reset();
- while ((retCode == 0) && (!_systemVars.engineQuit)) {
+ while ((retCode == 0) && (!quit())) {
// do we need the section45-hack from sword.c here?
checkCd();
@@ -747,9 +746,9 @@ uint8 SwordEngine::mainLoop(void) {
}
_mouseState = 0;
_keyPressed.reset();
- } while ((Logic::_scriptVars[SCREEN] == Logic::_scriptVars[NEW_SCREEN]) && (retCode == 0) && (!_systemVars.engineQuit));
+ } while ((Logic::_scriptVars[SCREEN] == Logic::_scriptVars[NEW_SCREEN]) && (retCode == 0) && (!quit()));
- if ((retCode == 0) && (Logic::_scriptVars[SCREEN] != 53) && _systemVars.wantFade && (!_systemVars.engineQuit)) {
+ if ((retCode == 0) && (Logic::_scriptVars[SCREEN] != 53) && _systemVars.wantFade && (!quit())) {
_screen->fadeDownPalette();
int32 relDelay = (int32)_system->getMillis();
while (_screen->stillFading()) {
@@ -796,9 +795,6 @@ void SwordEngine::delay(int32 amount) { //copied and mutilated from sky.cpp
_mouseState |= BS1R_BUTTON_UP;
_mouseCoord = event.mouse;
break;
- case Common::EVENT_QUIT:
- _systemVars.engineQuit = true;
- break;
default:
break;
}
diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h
index cfb6750a47..6f12ecd564 100644
--- a/engines/sword1/sword1.h
+++ b/engines/sword1/sword1.h
@@ -58,7 +58,6 @@ struct SystemVars {
bool runningFromCd;
uint32 currentCD; // starts at zero, then either 1 or 2 depending on section being played
uint32 justRestoredGame; // see main() in sword.c & New_screen() in gtm_core.c
- bool engineQuit;
uint8 controlPanelMode; // 1 death screen version of the control panel, 2 = successful end of game, 3 = force restart
bool forceRestart;
diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp
index 48196a2f7d..47b71f4a33 100644
--- a/engines/sword2/animation.cpp
+++ b/engines/sword2/animation.cpp
@@ -358,7 +358,6 @@ bool MoviePlayer::userInterrupt() {
handleScreenChanged();
break;
case Common::EVENT_QUIT:
- _vm->closeGame();
terminate = true;
break;
case Common::EVENT_KEYDOWN:
@@ -379,7 +378,7 @@ void MoviePlayer::play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn
bool startNextText = false;
// This happens if the user quits during the "eye" cutscene.
- if (_vm->_quit)
+ if (_vm->quit())
return;
_numSpeechLines = numLines;
diff --git a/engines/sword2/controls.cpp b/engines/sword2/controls.cpp
index 6b466d6be0..dcacbc78d4 100644
--- a/engines/sword2/controls.cpp
+++ b/engines/sword2/controls.cpp
@@ -396,7 +396,7 @@ int Dialog::runModal() {
_vm->_system->delayMillis(20);
- if (_vm->_quit)
+ if (_vm->quit())
setResult(0);
}
@@ -842,7 +842,7 @@ int StartDialog::runModal() {
if (startDialog.runModal())
return 1;
- if (_vm->_quit)
+ if (_vm->quit())
return 0;
RestoreDialog restoreDialog(_vm);
@@ -850,7 +850,7 @@ int StartDialog::runModal() {
if (restoreDialog.runModal())
return 0;
- if (_vm->_quit)
+ if (_vm->quit())
return 0;
}
@@ -882,7 +882,7 @@ int QuitDialog::runModal() {
int result = MiniDialog::runModal();
if (result)
- _vm->closeGame();
+ _vm->quitGame();
return result;
}
diff --git a/engines/sword2/function.cpp b/engines/sword2/function.cpp
index 84a5b5af76..31b799386f 100644
--- a/engines/sword2/function.cpp
+++ b/engines/sword2/function.cpp
@@ -2388,7 +2388,7 @@ int32 Logic::fnPlayCredits(int32 *params) {
// params: none
if (readVar(DEMO)) {
- _vm->closeGame();
+ _vm->quitGame();
return IR_STOP;
}
diff --git a/engines/sword2/palette.cpp b/engines/sword2/palette.cpp
index 81f93c77ae..b66a3c9a81 100644
--- a/engines/sword2/palette.cpp
+++ b/engines/sword2/palette.cpp
@@ -212,7 +212,7 @@ uint8 Screen::getFadeStatus() {
}
void Screen::waitForFade() {
- while (getFadeStatus() != RDFADE_NONE && getFadeStatus() != RDFADE_BLACK && !_vm->_quit) {
+ while (getFadeStatus() != RDFADE_NONE && getFadeStatus() != RDFADE_BLACK && !_vm->quit()) {
updateDisplay();
_vm->_system->delayMillis(20);
}
diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp
index d6b8025cda..04205e8d0e 100644
--- a/engines/sword2/resman.cpp
+++ b/engines/sword2/resman.cpp
@@ -413,7 +413,7 @@ Common::File *ResourceManager::openCluFile(uint16 fileNum) {
// quit while the game is asking for the user to insert a CD.
// But recovering from this situation gracefully is just too
// much trouble, so quit now.
- if (_vm->_quit)
+ if (_vm->quit())
g_system->quit();
// If the file is supposed to be on hard disk, or we're
diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp
index fdabb3ee6f..b2fcc45c9c 100644
--- a/engines/sword2/screen.cpp
+++ b/engines/sword2/screen.cpp
@@ -389,7 +389,7 @@ void Screen::displayMsg(byte *text, int time) {
uint32 targetTime = _vm->getMillis() + (time * 1000);
_vm->sleepUntil(targetTime);
} else {
- while (!_vm->_quit) {
+ while (!_vm->quit()) {
MouseEvent *me = _vm->mouseEvent();
if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN)))
break;
@@ -1035,7 +1035,7 @@ void Screen::rollCredits() {
uint32 musicLength = MAX((int32)(1000 * (_vm->_sound->musicTimeRemaining() - 3)), 25 * (int32)scrollSteps);
- while (scrollPos < scrollSteps && !_vm->_quit) {
+ while (scrollPos < scrollSteps && !_vm->quit()) {
clearScene();
for (i = startLine; i < lineCount; i++) {
@@ -1123,13 +1123,13 @@ void Screen::rollCredits() {
// The music should either have stopped or be about to stop, so
// wait for it to really happen.
- while (_vm->_sound->musicTimeRemaining() && !_vm->_quit) {
+ while (_vm->_sound->musicTimeRemaining() && !_vm->quit()) {
updateDisplay(false);
_vm->_system->delayMillis(100);
}
}
- if (_vm->_quit)
+ if (_vm->quit())
return;
waitForFade();
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index 7331d1f761..fc0da92248 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -229,7 +229,6 @@ Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst) {
_gameCycle = 0;
_gameSpeed = 1;
- _quit = false;
syst->getEventManager()->registerRandomSource(_rnd, "sword2");
}
@@ -371,7 +370,7 @@ int Sword2Engine::init() {
// player will kill the music for us. Otherwise, the restore
// will either have killed the music, or done a crossfade.
- if (_quit)
+ if (quit())
return 0;
if (result)
@@ -443,7 +442,7 @@ int Sword2Engine::go() {
// because we want the break to happen before updating the
// screen again.
- if (_quit)
+ if (quit())
break;
// creates the debug text blocks
@@ -460,11 +459,7 @@ int Sword2Engine::go() {
#endif
}
- return 0;
-}
-
-void Sword2Engine::closeGame() {
- _quit = true;
+ return _eventMan->shouldRTL();
}
void Sword2Engine::restartGame() {
@@ -610,9 +605,6 @@ void Sword2Engine::parseInputEvents() {
_mouseEvent.buttons = RD_WHEELDOWN;
}
break;
- case Common::EVENT_QUIT:
- closeGame();
- break;
default:
break;
}
diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h
index 05c5d7fa47..9b589c347e 100644
--- a/engines/sword2/sword2.h
+++ b/engines/sword2/sword2.h
@@ -141,8 +141,6 @@ public:
bool getSubtitles() { return _useSubtitles; }
void setSubtitles(bool b) { _useSubtitles = b; }
- bool _quit;
-
uint32 _features;
MemoryManager *_memory;
@@ -210,7 +208,6 @@ public:
void startGame();
void gameCycle();
- void closeGame();
void restartGame();
void sleepUntil(uint32 time);
diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp
index 6d2d90a572..c3c14c61d3 100644
--- a/engines/touche/menu.cpp
+++ b/engines/touche/menu.cpp
@@ -297,7 +297,7 @@ void ToucheEngine::handleMenuAction(void *menu, int actionId) {
menuData->quit = true;
break;
case kActionQuitGame:
- _flagsTable[611] = 1;
+ quitGame();
menuData->quit = true;
break;
case kActionTextOnly:
@@ -398,7 +398,6 @@ void ToucheEngine::handleOptions(int forceDisplay) {
case Common::EVENT_QUIT:
menuData.quit = true;
menuData.exit = true;
- _flagsTable[611] = 1;
break;
case Common::EVENT_LBUTTONDOWN:
button = menuData.findButtonUnderCursor(event.mouse.x, event.mouse.y);
@@ -433,8 +432,9 @@ void ToucheEngine::handleOptions(int forceDisplay) {
_system->delayMillis(10);
}
_fullRedrawCounter = 2;
- if (!menuData.exit && _flagsTable[611] != 0) {
- _flagsTable[611] = displayQuitDialog();
+ if (!menuData.exit && quit()) {
+ if (displayQuitDialog())
+ quitGame();
}
}
}
diff --git a/engines/touche/opcodes.cpp b/engines/touche/opcodes.cpp
index 4405c614ac..b2b16eb29d 100644
--- a/engines/touche/opcodes.cpp
+++ b/engines/touche/opcodes.cpp
@@ -408,6 +408,10 @@ void ToucheEngine::op_setFlag() {
case 104:
_currentKeyCharNum = val;
break;
+ case 611:
+ if (val != 0)
+ quitGame();
+ break;
case 612:
_flagsTable[613] = getRandomNumber(val);
break;
diff --git a/engines/touche/saveload.cpp b/engines/touche/saveload.cpp
index 4fcf6e114d..c96a28bc8e 100644
--- a/engines/touche/saveload.cpp
+++ b/engines/touche/saveload.cpp
@@ -292,7 +292,7 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) {
if (stream->readUint32LE() != saveLoadEndMarker) {
warning("Corrupted gamestate data");
// if that ever happens, exit the game
- _flagsTable[611] = 1;
+ quitGame();
}
_flagsTable[614] = roomOffsX;
_flagsTable[615] = roomOffsY;
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index ac8e8a786a..a4a9b7df92 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -95,7 +95,7 @@ int ToucheEngine::init() {
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
- _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxMixerVolume);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
return 0;
}
@@ -111,7 +111,7 @@ int ToucheEngine::go() {
res_deallocateTables();
res_closeDataFile();
- return 0;
+ return _eventMan->shouldRTL();
}
void ToucheEngine::restart() {
@@ -234,6 +234,13 @@ Common::Point ToucheEngine::getMousePos() const {
return _eventMan->getMousePos();
}
+void ToucheEngine::syncSoundSettings() {
+ readConfigurationSettings();
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
+}
+
void ToucheEngine::mainLoop() {
restart();
@@ -258,7 +265,7 @@ void ToucheEngine::mainLoop() {
}
uint32 frameTimeStamp = _system->getMillis();
- for (uint32 cycleCounter = 0; _flagsTable[611] == 0; ++cycleCounter) {
+ for (uint32 cycleCounter = 0; !quit(); ++cycleCounter) {
if ((cycleCounter % 3) == 0) {
runCycle();
}
@@ -287,9 +294,6 @@ void ToucheEngine::processEvents(bool handleKeyEvents) {
Common::Event event;
while (_eventMan->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_QUIT:
- _flagsTable[611] = 1;
- break;
case Common::EVENT_KEYDOWN:
if (!handleKeyEvents) {
break;
@@ -297,7 +301,8 @@ void ToucheEngine::processEvents(bool handleKeyEvents) {
_flagsTable[600] = event.kbd.keycode;
if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
if (_displayQuitDialog) {
- _flagsTable[611] = displayQuitDialog();
+ if (displayQuitDialog())
+ quitGame();
}
} else if (event.kbd.keycode == Common::KEYCODE_F5) {
if (_flagsTable[618] == 0 && !_hideInventoryTexts) {
@@ -1828,7 +1833,7 @@ int ToucheEngine::handleActionMenuUnderCursor(const int16 *actions, int offs, in
_menuRedrawCounter = 2;
Common::Rect rect(0, y, kScreenWidth, y + h);
i = -1;
- while (_inp_rightMouseButtonPressed && _flagsTable[611] == 0) {
+ while (_inp_rightMouseButtonPressed && !quit()) {
Common::Point mousePos = getMousePos();
if (rect.contains(mousePos)) {
int c = (mousePos.y - y) / kTextHeight;
@@ -2691,10 +2696,10 @@ bool ToucheEngine::sortPointsData(int num1, int num2) {
const int md2 = _programWalkTable[num1].point2;
_programPointsTable[md2].order = 0;
}
- bool quit = false;
+ bool quitLoop = false;
int order = 1;
- while (!quit) {
- quit = true;
+ while (!quitLoop) {
+ quitLoop = true;
for (uint i = 0; i < _programWalkTable.size(); ++i) {
const int md1 = _programWalkTable[i].point1;
const int md2 = _programWalkTable[i].point2;
@@ -2702,11 +2707,11 @@ bool ToucheEngine::sortPointsData(int num1, int num2) {
assert((md2 & 0x4000) == 0);
if (_programPointsTable[md1].order == order - 1 && _programPointsTable[md2].order > order) {
_programPointsTable[md2].order = order;
- quit = false;
+ quitLoop = false;
}
if (_programPointsTable[md2].order == order - 1 && _programPointsTable[md1].order > order) {
_programPointsTable[md1].order = order;
- quit = false;
+ quitLoop = false;
}
}
}
@@ -2938,9 +2943,9 @@ void ToucheEngine::markWalkPoints(int keyChar) {
resetPointsData(0);
if (pointsDataNum != -1) {
_programPointsTable[pointsDataNum].order = 1;
- bool quit = false;
- while (!quit) {
- quit = true;
+ bool quitLoop = false;
+ while (!quitLoop) {
+ quitLoop = true;
for (uint i = 0; i < _programWalkTable.size(); ++i) {
int16 md1 = _programWalkTable[i].point1;
int16 md2 = _programWalkTable[i].point2;
@@ -2948,11 +2953,11 @@ void ToucheEngine::markWalkPoints(int keyChar) {
assert((md2 & 0x4000) == 0);
if (_programPointsTable[md1].order != 0 && _programPointsTable[md2].order == 0) {
_programPointsTable[md2].order = 1;
- quit = false;
+ quitLoop = false;
}
if (_programPointsTable[md2].order != 0 && _programPointsTable[md1].order == 0) {
_programPointsTable[md1].order = 1;
- quit = false;
+ quitLoop = false;
}
}
}
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index c1bc12655f..f5ac492550 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -356,6 +356,7 @@ public:
virtual int init();
virtual int go();
+ virtual void syncSoundSettings();
protected: