diff options
author | Paul Gilbert | 2015-05-01 18:47:13 -1000 |
---|---|---|
committer | Paul Gilbert | 2015-05-01 18:47:13 -1000 |
commit | 850bd739687129542c37db0beebd17369c71ed15 (patch) | |
tree | c573bad59118367ca7cfa39491892eea1b4322b2 /engines | |
parent | 86dab70eae4791b84ca3891cad7db70a9683679a (diff) | |
download | scummvm-rg350-850bd739687129542c37db0beebd17369c71ed15.tar.gz scummvm-rg350-850bd739687129542c37db0beebd17369c71ed15.tar.bz2 scummvm-rg350-850bd739687129542c37db0beebd17369c71ed15.zip |
SHERLOCK: Move Settings dialog event handling into Settings class
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sherlock/settings.cpp | 138 | ||||
-rw-r--r-- | engines/sherlock/settings.h | 5 | ||||
-rw-r--r-- | engines/sherlock/sherlock.cpp | 3 | ||||
-rw-r--r-- | engines/sherlock/user_interface.cpp | 146 | ||||
-rw-r--r-- | engines/sherlock/user_interface.h | 2 |
5 files changed, 146 insertions, 148 deletions
diff --git a/engines/sherlock/settings.cpp b/engines/sherlock/settings.cpp index 769c2c82e3..aeeb92d3c1 100644 --- a/engines/sherlock/settings.cpp +++ b/engines/sherlock/settings.cpp @@ -209,4 +209,142 @@ int Settings::drawButtons(const Common::Point &pt, int _key) { return found; } + +/** +* Handles input when the settings window is being shown +* @remarks Whilst this would in theory be better in the Journal class, since it displays in +* the user interface, it uses so many internal UI fields, that it sort of made some sense +* to put it in the UserInterface class. +*/ +void Settings::show(SherlockEngine *vm) { + Events &events = *vm->_events; + People &people = *vm->_people; + Scene &scene = *vm->_scene; + Screen &screen = *vm->_screen; + Sound &sound = *vm->_sound; + Talk &talk = *vm->_talk; + UserInterface &ui = *vm->_ui; + int found; + bool updateConfig = false; + + Settings settings(vm); + settings.drawInteface(false); + + do { + if (ui._menuCounter) + ui.whileMenuCounter(); + + found = -1; + ui._key = -1; + + scene.doBgAnim(); + if (talk._talkToAbort) + return; + + events.setButtonState(); + Common::Point pt = events.mousePos(); + + if (events._pressed || events._released || events.kbHit()) { + ui.clearInfo(); + ui._key = -1; + + if (events.kbHit()) { + Common::KeyState keyState = events.getKey(); + ui._key = toupper(keyState.keycode); + + if (ui._key == Common::KEYCODE_RETURN || ui._key == Common::KEYCODE_SPACE) { + events._pressed = false; + events._oldButtons = 0; + ui._keycode = Common::KEYCODE_INVALID; + events._released = true; + } + } + + // Handle highlighting button under mouse + found = settings.drawButtons(pt, ui._key); + } + + if ((found == 0 && events._released) || (ui._key == 'E' || ui._key == Common::KEYCODE_ESCAPE)) + // Exit + break; + + if ((found == 1 && events._released) || ui._key == 'M') { + // Toggle music + if (sound._music) { + sound.stopSound(); + sound._music = false; + } + else { + sound._music = true; + sound.startSong(); + } + + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 2 && events._released) || ui._key == 'V') { + sound._voices = !sound._voices; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 3 && events._released) || ui._key == 'S') { + // Toggle sound effects + sound._digitized = !sound._digitized; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 4 && events._released) || ui._key == 'A') { + // Help button style + ui._helpStyle ^= 1; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 5 && events._released) || ui._key == 'N') { + // New font style + int fontNum = screen.fontNumber() + 1; + if (fontNum == 3) + fontNum = 0; + + screen.setFont(fontNum); + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 8 && events._released) || ui._key == 'F') { + // Toggle fade style + screen._fadeStyle = !screen._fadeStyle; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 9 && events._released) || ui._key == 'W') { + // Window style + ui._windowStyle ^= 1; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 10 && events._released) || ui._key == 'P') { + // Toggle portraits being shown + people._portraitsOn = !people._portraitsOn; + updateConfig = true; + settings.drawInteface(true); + } + } while (!vm->shouldQuit()); + + ui.banishWindow(); + + if (updateConfig) + vm->saveConfig(); + + ui._keycode = Common::KEYCODE_INVALID; + ui._keyboardInput = false; + ui._windowBounds.top = CONTROLS_Y1; + ui._key = -1; +} + } // End of namespace Sherlock diff --git a/engines/sherlock/settings.h b/engines/sherlock/settings.h index 51157f4cae..90928452c4 100644 --- a/engines/sherlock/settings.h +++ b/engines/sherlock/settings.h @@ -28,16 +28,19 @@ namespace Sherlock { class SherlockEngine; +class UserInterface; class Settings { private: SherlockEngine *_vm; -public: + Settings(SherlockEngine *vm) : _vm(vm) {} void drawInteface(bool flag); int drawButtons(const Common::Point &pt, int key); +public: + static void show(SherlockEngine *vm); }; } // End of namespace Sherlock diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index 0282d3e5f0..f546e0d878 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -214,6 +214,8 @@ void SherlockEngine::loadConfig() { // Load other settings if (ConfMan.hasKey("font")) _screen->setFont(ConfMan.getInt("font")); + if (ConfMan.hasKey("fade_style")) + _screen->_fadeStyle = ConfMan.getBool("fade_style"); if (ConfMan.hasKey("help_style")) _ui->_helpStyle = ConfMan.getInt("help_style"); if (ConfMan.hasKey("window_style")) @@ -231,6 +233,7 @@ void SherlockEngine::saveConfig() { ConfMan.setBool("speech_mute", _sound->_voices); ConfMan.setInt("font", _screen->fontNumber()); + ConfMan.setBool("fade_style", _screen->_fadeStyle); ConfMan.setInt("help_style", _ui->_helpStyle); ConfMan.setInt("window_style", _ui->_windowStyle); ConfMan.setBool("portraits_on", _people->_portraitsOn); diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index cab0fb0ad8..73058e8fd8 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1440,7 +1440,7 @@ void UserInterface::doMainControl() { case 'S': pushButton(11); _menuMode = SETUP_MODE; - doControls(); + Settings::show(_vm); break; default: break; @@ -1838,150 +1838,6 @@ void UserInterface::journalControl() { } /** - * Handles input when the settings window is being shown - * @remarks Whilst this would in theory be better in the Journal class, since it displays in - * the user interface, it uses so many internal UI fields, that it sort of made some sense - * to put it in the UserInterface class. - */ -void UserInterface::doControls() { - Events &events = *_vm->_events; - People &people = *_vm->_people; - Scene &scene = *_vm->_scene; - Screen &screen = *_vm->_screen; - Sound &sound = *_vm->_sound; - Talk &talk = *_vm->_talk; - UserInterface &ui = *_vm->_ui; - int found; - bool updateConfig = false; - - Settings settings(_vm); - settings.drawInteface(false); - - do { - if (_menuCounter) - whileMenuCounter(); - - found = -1; - _key = -1; - - scene.doBgAnim(); - if (talk._talkToAbort) - return; - - events.setButtonState(); - Common::Point pt = events.mousePos(); - - if (events._pressed || events._released || events.kbHit()) { - clearInfo(); - _key = -1; - - if (events.kbHit()) { - Common::KeyState keyState = events.getKey(); - _key = toupper(keyState.keycode); - - if (_key == Common::KEYCODE_RETURN || _key == Common::KEYCODE_SPACE) { - events._pressed = false; - events._oldButtons = 0; - _keycode = Common::KEYCODE_INVALID; - events._released = true; - } - } - - // Handle highlighting button under mouse - found = settings.drawButtons(pt, _key); - } - - if ((found == 0 && events._released) || (_key == 'E' || _key == Common::KEYCODE_ESCAPE)) - // Exit - break; - - if ((found == 1 && events._released) || _key == 'M') { - // Toggle music - if (sound._music) { - sound.stopSound(); - sound._music = false; - } else { - sound._music = true; - sound.startSong(); - } - - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 2 && events._released) || _key == 'V') { - sound._voices = !sound._voices; - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 3 && events._released) || _key == 'S') { - // Toggle sound effects - sound._digitized = !sound._digitized; - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 4 && events._released) || _key == 'A') { - // Help button style - ui._helpStyle ^= 1; - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 5 && events._released) || _key == 'N') { - // New font style - int fontNum = screen.fontNumber() + 1; - if (fontNum == 3) - fontNum = 0; - - screen.setFont(fontNum); - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 6 && events._released) || _key == 'J') { - // Toggle joystick - not implemented under ScummVM - } - - if ((found == 7 && events._released) || _key == 'C') { - // Calibrate joystick - No implementation in ScummVM - } - - if ((found == 8 && events._released) || _key == 'F') { - // Toggle fade style - screen._fadeStyle = !screen._fadeStyle; - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 9 && events._released) || _key == 'W') { - // Window style - ui._windowStyle ^= 1; - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 10 && events._released) || _key == 'P') { - // Toggle portraits being shown - people._portraitsOn = !people._portraitsOn; - updateConfig = true; - settings.drawInteface(true); - } - } while (!_vm->shouldQuit()); - - banishWindow(); - - if (updateConfig) - _vm->saveConfig(); - - _keycode = Common::KEYCODE_INVALID; - _keyboardInput = false; - _windowBounds.top = CONTROLS_Y1; - _key = -1; -} - -/** * Print the description of an object */ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h index 4e8753199b..89a33801dd 100644 --- a/engines/sherlock/user_interface.h +++ b/engines/sherlock/user_interface.h @@ -111,8 +111,6 @@ private: void doTalkControl(); void journalControl(); - void doControls(); - void checkUseAction(const UseType *use, const Common::String &invName, const char *const messages[], int objNum, int giveMode); void checkAction(ActionType &action, const char *const messages[], int objNum); |