From c14804e22f5171e6aa7b2cf5d383a4e28180aa7a Mon Sep 17 00:00:00 2001 From: Christopher Page Date: Tue, 24 Jun 2008 23:19:23 +0000 Subject: Added main menu dialog files. Gob is now using the new _quit flag svn-id: r32771 --- engines/cine/main_loop.cpp | 3 - engines/cine/various.cpp | 1 - engines/cine/various.h | 2 - engines/dialogs.cpp | 184 +++++++++++++++++++++++++++++++++++++++++++ engines/dialogs.h | 72 +++++++++++++++++ engines/gob/game_v1.cpp | 4 +- engines/gob/game_v2.cpp | 10 +-- engines/gob/gob.cpp | 5 +- engines/gob/gob.h | 1 - engines/gob/inter.cpp | 4 +- engines/gob/inter_bargon.cpp | 6 +- engines/gob/inter_v1.cpp | 4 +- engines/gob/inter_v2.cpp | 2 +- engines/gob/mult.cpp | 2 +- engines/gob/palanim.cpp | 2 +- engines/gob/sound/sound.cpp | 2 +- engines/gob/util.cpp | 4 +- engines/gob/videoplayer.cpp | 2 +- 18 files changed, 279 insertions(+), 31 deletions(-) create mode 100644 engines/dialogs.cpp create mode 100644 engines/dialogs.h diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp index 1e8ddb9418..54925e3df1 100644 --- a/engines/cine/main_loop.cpp +++ b/engines/cine/main_loop.cpp @@ -181,12 +181,9 @@ int getKeyData() { void CineEngine::mainLoop(int bootScriptIdx) { bool playerAction; - //uint16 quitFlag; byte di; uint16 mouseButton; - //quitFlag = 0; - if (_preLoad == false) { resetBgIncrustList(); diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 9f8edf854b..d8091c6b86 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -110,7 +110,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]; diff --git a/engines/cine/various.h b/engines/cine/various.h index 2252febfe1..f4d1649aab 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..53dc413236 --- /dev/null +++ b/engines/dialogs.cpp @@ -0,0 +1,184 @@ +/* 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: + _engine->_quit = true; + _engine->_rtl = true; + close(); + break; + case kQuitCmd: + _engine->_quit = true; + 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..5bacd45c2e --- /dev/null +++ b/engines/dialogs.h @@ -0,0 +1,72 @@ +/* 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/gob/game_v1.cpp b/engines/gob/game_v1.cpp index 66deea8ec4..16865eb7a2 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..e794bda17c 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..b43539e8f2 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -82,7 +82,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 +111,11 @@ GobEngine::~GobEngine() { int GobEngine::go() { _init->initGame(0); - return 0; + return _rtl; } void GobEngine::shutdown() { - _quitRequested = true; + _quit = true; } const char *GobEngine::getLangDesc(int16 language) const { diff --git a/engines/gob/gob.h b/engines/gob/gob.h index ae2b53bc31..d55d2b874a 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; diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp index 9c39653a1d..d5daed2d97 100644 --- a/engines/gob/inter.cpp +++ b/engines/gob/inter.cpp @@ -249,7 +249,7 @@ void Inter::funcBlock(int16 retFlag) { if (executeFuncOpcode(cmd2, cmd, params)) return; - if (_vm->_quitRequested) + if (_vm->_quit) break; if (_break) { @@ -269,7 +269,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..c2bc4ca01d 100644 --- a/engines/gob/inter_bargon.cpp +++ b/engines/gob/inter_bargon.cpp @@ -750,7 +750,7 @@ void Inter_Bargon::oBargon_intro2(OpGobParams ¶ms) { 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 ¶ms) { 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 ¶ms) { _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 e2b8d65112..ab63bd0e1b 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1225,7 +1225,7 @@ bool Inter_v1::o1_repeatUntil(OpFuncParams ¶ms) { 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]--; @@ -1260,7 +1260,7 @@ bool Inter_v1::o1_whileDo(OpFuncParams ¶ms) { } 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 d8c33fcce6..cf74252e09 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -1483,7 +1483,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 3d6a7942f9..c4d45ee4bd 100644 --- a/engines/gob/mult.cpp +++ b/engines/gob/mult.cpp @@ -197,7 +197,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..2b1b34872a 100644 --- a/engines/gob/palanim.cpp +++ b/engines/gob/palanim.cpp @@ -131,7 +131,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..d25628fe81 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -72,7 +72,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)); } @@ -119,7 +119,7 @@ void Util::processInput(bool scroll) { case Common::EVENT_KEYUP: break; case Common::EVENT_QUIT: - _vm->_quitRequested = true; + _vm->_quit = true; break; default: break; diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index aa47e6cf84..1b1c061524 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -568,7 +568,7 @@ bool VideoPlayer::doPlay(int16 frame, int16 breakKey, _vm->_util->processInput(); - if (_vm->_quitRequested) { + if (_vm->_quit) { _primaryVideo->getVideo()->disableSound(); return true; } -- cgit v1.2.3