diff options
Diffstat (limited to 'engines/sherlock/tattoo')
-rw-r--r-- | engines/sherlock/tattoo/tattoo.h | 8 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_user_interface.cpp | 16 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_user_interface.h | 10 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_options.cpp | 197 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_options.h | 7 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_quit.cpp | 36 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_quit.h | 50 |
7 files changed, 318 insertions, 6 deletions
diff --git a/engines/sherlock/tattoo/tattoo.h b/engines/sherlock/tattoo/tattoo.h index 6885f51e2e..923afa3d90 100644 --- a/engines/sherlock/tattoo/tattoo.h +++ b/engines/sherlock/tattoo/tattoo.h @@ -87,7 +87,15 @@ public: TattooEngine(OSystem *syst, const SherlockGameDescription *gameDesc); virtual ~TattooEngine(); + /** + * Shows the hangman puzzle + */ void doHangManPuzzle(); + + /** + * Save the game configuration + */ + void saveConfig() {} }; } // End of namespace Tattoo diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp index 528be5f14e..ef9e895870 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.cpp +++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp @@ -374,15 +374,13 @@ void TattooUserInterface::doStandardControl() { case Common::KEYCODE_F5: // Save game freeMenu(); - _fileMode = SAVEMODE_SAVE; - initFileMenu(); + saveGame(); return; case Common::KEYCODE_F7: // Load game freeMenu(); - _fileMode = SAVEMODE_LOAD; - initFileMenu(); + loadGame(); return; case Common::KEYCODE_F1: @@ -882,6 +880,16 @@ void TattooUserInterface::clearWindow() { banishWindow(); } +void TattooUserInterface::loadGame() { + _fileMode = SAVEMODE_LOAD; + // TODO +} + +void TattooUserInterface::saveGame() { + _fileMode = SAVEMODE_SAVE; + // TODO +} + } // End of namespace Tattoo } // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h index 5b3c7ea401..790c892ec8 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.h +++ b/engines/sherlock/tattoo/tattoo_user_interface.h @@ -204,6 +204,16 @@ public: * If there is no object being pointed it, clear any previously displayed name */ void displayObjectNames(); + + /** + * Show the load game dialog, and allow the user to load a game + */ + void loadGame(); + + /** + * Show the save game dialog, and allow the user to save the game + */ + void saveGame(); public: /** * Resets the user interface diff --git a/engines/sherlock/tattoo/widget_options.cpp b/engines/sherlock/tattoo/widget_options.cpp index 16d1d1476b..a96fcf4eaa 100644 --- a/engines/sherlock/tattoo/widget_options.cpp +++ b/engines/sherlock/tattoo/widget_options.cpp @@ -23,13 +23,14 @@ #include "sherlock/tattoo/widget_options.h" #include "sherlock/tattoo/tattoo.h" #include "sherlock/tattoo/tattoo_fixed_text.h" +#include "sherlock/tattoo/tattoo_scene.h" #include "sherlock/tattoo/tattoo_user_interface.h" namespace Sherlock { namespace Tattoo { -WidgetOptions::WidgetOptions(SherlockEngine *vm) : WidgetBase(vm) { +WidgetOptions::WidgetOptions(SherlockEngine *vm) : WidgetBase(vm), _quitWidget(vm) { _midiSliderX = _digiSliderX = 0; _selector = _oldSelector = -1; } @@ -56,8 +57,192 @@ void WidgetOptions::load() { } void WidgetOptions::handleEvents() { + TattooEngine &vm = *(TattooEngine *)_vm; Events &events = *_vm->_events; - // TODO + Music &music = *_vm->_music; + Screen &screen = *_vm->_screen; + Sound &sound = *_vm->_sound; + Talk &talk = *_vm->_talk; + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + Common::Point mousePos = events.mousePos(); + + if (talk._talkToAbort) { + sound.stopSound(); + return; + } + + // Flag if they started pressing outside the window + if (events._firstPress && !_bounds.contains(mousePos)) + _outsideMenu = true; + + if (events.kbHit()) { + ui._keyState = events.getKey(); + + // Emulate a mouse release if Enter or Space Bar is pressed + if (ui._keyState.keycode == Common::KEYCODE_RETURN || ui._keyState.keycode == Common::KEYCODE_SPACE) { + events._pressed = events._oldButtons = false; + events._released = true; + } else if (ui._keyState.keycode == Common::KEYCODE_ESCAPE) { + close(); + return; + } else { + checkTabbingKeys(11); + } + } + + // Check highlighting the various controls + if (_bounds.contains(mousePos)) { + _selector = (mousePos.y - _bounds.top) / (_surface.fontHeight() + 7); + + // If one of the sliders has been selected, & the mouse is not pressed, reset the selector to -1 + if ((_selector == 3 || _selector == 6) && !events._pressed) + _selector = -1; + } else { + _selector = -1; + if (_outsideMenu && (events._released || events._rightReleased)) { + close(); + return; + } + } + + // If the selected control has changed, redraw the dialog contents + if (_selector != _oldSelector) + render(OP_CONTENTS); + _oldSelector = _selector; + + // Adjust the Volume Sliders (if neccessary) here + switch (_selector) { + case 3: { + // Set Music Volume + _midiSliderX = mousePos.x - _bounds.left; + if (_midiSliderX < _surface.widestChar()) + _midiSliderX = _surface.widestChar(); + else + if (_midiSliderX > _bounds.width() - _surface.widestChar()) + _midiSliderX = _bounds.width() - _surface.widestChar(); + + int temp = music._musicVolume; + music._musicVolume = (_midiSliderX - _surface.widestChar()) * 127 / (_bounds.width() - _surface.widestChar() * 2); + if (music._musicVolume != temp) { + music.setMIDIVolume(music._musicVolume); + vm.saveConfig(); + } + + render(OP_NAMES); + break; + } + + case 6: { + // Set Digitized Volume + _digiSliderX = mousePos.x - _bounds.left; + if (_digiSliderX < _surface.widestChar()) + _digiSliderX = _surface.widestChar(); + else if (_digiSliderX > _bounds.width() - _surface.widestChar()) + _digiSliderX = _bounds.width() - _surface.widestChar(); + + int temp = sound._soundVolume; + sound._soundVolume = (_digiSliderX - _surface.widestChar()) * 15 / (_bounds.width() - _surface.widestChar() * 2); + if (sound._soundVolume != temp) { + sound.setVolume(sound._soundVolume); + vm.saveConfig(); + } + + render(OP_NAMES); + break; + } + + default: + break; + } + + // Option selected + if (events._released || events._rightReleased) { + _outsideMenu = false; + int temp = _selector; + _selector = 255; + + switch (temp) { + case 0: + // Load Game + close(); + ui.loadGame(); + break; + + case 1: + // Save Game + close(); + ui.saveGame(); + break; + + case 2: + // Toggle Music + music._musicOn = !music._musicOn; + if (!music._musicOn) + music.stopMusic(); + else + music.startSong(); + + render(OP_NAMES); + vm.saveConfig(); + break; + + case 4: + // Toggle Sound Effects + sound.stopSound(); + sound._digitized = !sound._digitized; + + render(OP_NAMES); + vm.saveConfig(); + break; + + case 5: + // Toggle Voices + sound._voices = !sound._voices; + + render(OP_NAMES); + vm.saveConfig(); + break; + + case 7: + // Toggle Text Windows + vm._textWindowsOn = !vm._textWindowsOn; + + render(OP_NAMES); + vm.saveConfig(); + break; + + case 8: { + // New Font Style + int fontNumber = screen.fontNumber() + 1; + if (fontNumber == 7) + fontNumber = 0; + screen.setFont(fontNumber); + + render(OP_CONTENTS); + vm.saveConfig(); + break; + } + + case 9: + // Toggle Transparent Menus + vm._transparentMenus = !vm._transparentMenus; + + render(OP_CONTENTS); + vm.saveConfig(); + break; + + case 10: + // Quit + banishWindow(); + _quitWidget.show(); + break; + + default: + break; + } + + _oldSelector = -1; + } } void WidgetOptions::render(OptionRenderMode mode) { @@ -192,6 +377,14 @@ void WidgetOptions::render(OptionRenderMode mode) { } } +void WidgetOptions::close() { + TattooScene &scene = *(TattooScene *)_vm->_scene; + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + + banishWindow(); + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; +} + } // End of namespace Tattoo } // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/widget_options.h b/engines/sherlock/tattoo/widget_options.h index b76aed9bc8..213704f2ee 100644 --- a/engines/sherlock/tattoo/widget_options.h +++ b/engines/sherlock/tattoo/widget_options.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "sherlock/tattoo/widget_base.h" +#include "sherlock/tattoo/widget_quit.h" namespace Sherlock { @@ -41,11 +42,17 @@ class WidgetOptions : public WidgetBase { private: int _midiSliderX, _digiSliderX; int _selector, _oldSelector; + WidgetQuit _quitWidget; /** * Render the contents of the dialog onto the widget's surface */ void render(OptionRenderMode mode = OP_ALL); + + /** + * Close the dialog + */ + void close(); public: WidgetOptions(SherlockEngine *vm); virtual ~WidgetOptions() {} diff --git a/engines/sherlock/tattoo/widget_quit.cpp b/engines/sherlock/tattoo/widget_quit.cpp new file mode 100644 index 0000000000..f1217ffb81 --- /dev/null +++ b/engines/sherlock/tattoo/widget_quit.cpp @@ -0,0 +1,36 @@ +/* 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. + * + */ + +#include "sherlock/tattoo/widget_quit.h" +#include "sherlock/tattoo/tattoo.h" + +namespace Sherlock { + +namespace Tattoo { + +void WidgetQuit::show() { + // TODO +} + +} // End of namespace Tattoo + +} // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/widget_quit.h b/engines/sherlock/tattoo/widget_quit.h new file mode 100644 index 0000000000..ab3702af10 --- /dev/null +++ b/engines/sherlock/tattoo/widget_quit.h @@ -0,0 +1,50 @@ +/* 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. + * + */ + +#ifndef SHERLOCK_TATTOO_WIDGET_QUIT_H +#define SHERLOCK_TATTOO_WIDGET_QUIT_H + +#include "common/scummsys.h" +#include "sherlock/tattoo/widget_base.h" + +namespace Sherlock { + +class SherlockEngine; + +namespace Tattoo { + +class WidgetQuit: public WidgetBase { +public: + WidgetQuit(SherlockEngine *vm) : WidgetBase(vm) {} + virtual ~WidgetQuit() {} + + /** + * Prompt the user whether to quit + */ + void show(); +}; + +} // End of namespace Tattoo + +} // End of namespace Sherlock + +#endif |