diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | scumm/dialogs.cpp | 54 | ||||
-rw-r--r-- | scumm/dialogs.h | 45 | ||||
-rw-r--r-- | scumm/input.cpp | 45 |
4 files changed, 129 insertions, 17 deletions
@@ -15,6 +15,8 @@ For a more comprehensive changelog for the latest experimental CVS code, see: - Added support for Mac Humongous Entertainment titles - Added support for multiple filenames/versions using a single target - Implemented CGA and Hercules render modes in early LEC titles + - Added dialogs which are shown when you modify the talkspeed or music + volume using hotkeys. Sword2: - Made the resource manager expire resources more intelligently. diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index 6ef9a7de00..daa4d87044 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -598,6 +598,60 @@ void ConfirmDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { ScummDialog::handleKeyDown(ascii, keycode, modifiers); } +#pragma mark - + +ValueDisplayDialog::ValueDisplayDialog(const Common::String& label, int minVal, int maxVal, int val, uint16 incKey, uint16 decKey) + : GUI::Dialog(0, 80, 0, 16), _label(label), _min(minVal), _max(maxVal), _value(val), _incKey(incKey), _decKey(decKey) { + assert(_min <= _value && _value <= _max); + + int width = g_gui.getStringWidth(label) + 16 + kPercentBarWidth; + + _x = (320 - width) / 2; + _w = width; + setResult(_value); + + _timer = getMillis() + kDisplayDelay; +} + +void ValueDisplayDialog::drawDialog() { + g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor); + g_gui.box(_x, _y, _w, _h, g_gui._color, g_gui._shadowcolor); + + const int labelWidth = _w - 8 - kPercentBarWidth; + + // Draw the label + g_gui.drawString(_label, _x + 4, _y + 4, labelWidth, g_gui._textcolor); + + // Draw the percentage bar + g_gui.fillRect(_x + 4 + labelWidth, _y + 4, kPercentBarWidth * (_value - _min) / (_max - _min), 8, g_gui._textcolorhi); + g_gui.frameRect(_x + 4 + labelWidth, _y + 4, kPercentBarWidth, 8, g_gui._textcolor); + + // Flag the draw area as dirty + g_gui.addDirtyRect(_x, _y, _w, _h); +} + +void ValueDisplayDialog::handleTickle() { + if (getMillis() > _timer) + close(); +} + +void ValueDisplayDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { + if (ascii == _incKey || ascii == _decKey) { + if (ascii == _incKey && _value < _max) + _value++; + else if (ascii == _decKey && _value > _min) + _value--; + + setResult(_value); + _timer = getMillis() + kDisplayDelay; + draw(); + } else { + close(); + } +} + + + } // End of namespace Scumm #ifdef __PALM_OS__ diff --git a/scumm/dialogs.h b/scumm/dialogs.h index e9eedeecb3..05ba1c08d7 100644 --- a/scumm/dialogs.h +++ b/scumm/dialogs.h @@ -119,6 +119,12 @@ protected: GUI::CheckboxWidget *subtitlesCheckbox; }; +/** + * A dialog which displays an arbitrary message to the user and returns + * ther users reply as its result value. More specifically, it returns + * the ASCII code of the key used to close the dialog (0 if a mouse + * click closed the dialog). + */ class InfoDialog : public ScummDialog { public: // arbitrary message @@ -127,6 +133,7 @@ public: InfoDialog(ScummEngine *scumm, int res); virtual void handleMouseDown(int x, int y, int button, int clickCount) { + setResult(0); close(); } virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers) { @@ -138,18 +145,56 @@ protected: void setInfoText (const String& message); }; +/** + * The pause dialog, visible whenever the user activates pause mode. Goes + * away uon any key or mouse button press. + */ class PauseDialog : public InfoDialog { public: PauseDialog(ScummEngine *scumm, int res); virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); }; +/** + * A simple yes/no dialog, used to ask the user whether to really + * quit/restart ScummVM. + */ class ConfirmDialog : public InfoDialog { public: ConfirmDialog(ScummEngine *scumm, const String& message); virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); }; +/** + * A dialog used to display the music volume / text speed. + * Given a label string, and a float value in the range of 0.0 to 1.0, + * it will display a corresponding graphic. + * Automatically closes after a brief time passed. + */ +class ValueDisplayDialog : public GUI::Dialog { +public: + ValueDisplayDialog(const Common::String& label, int minVal, int maxVal, int val, uint16 incKey, uint16 decKey); + + void drawDialog(); + void handleTickle(); + + virtual void handleMouseDown(int x, int y, int button, int clickCount) { + close(); + } + virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); + +protected: + enum { + kPercentBarWidth = 50, + kDisplayDelay = 1500 + }; + Common::String _label; + const int _min, _max; + const uint16 _incKey, _decKey; + int _value; + uint32 _timer; +}; + } // End of namespace Scumm #endif diff --git a/scumm/input.cpp b/scumm/input.cpp index ef5aa4bdb0..3836c40636 100644 --- a/scumm/input.cpp +++ b/scumm/input.cpp @@ -26,6 +26,7 @@ #include "common/system.h" #include "scumm/debugger.h" +#include "scumm/dialogs.h" #include "scumm/imuse.h" #include "scumm/insane/insane.h" #include "scumm/scumm.h" @@ -383,27 +384,37 @@ void ScummEngine::processKbd(bool smushMode) { if (_sound->_sfxMode & 2) stopTalk(); return; - } else if (_lastKeyHit == '[') { // [ Music volume down - int vol = ConfMan.getInt("music_volume"); - if (!(vol & 0xF) && vol) - vol -= 16; - vol = vol & 0xF0; - ConfMan.set("music_volume", vol); - setupVolumes(); - } else if (_lastKeyHit == ']') { // ] Music volume up - int vol = ConfMan.getInt("music_volume"); - vol = (vol + 16) & 0xFF0; - if (vol > 255) vol = 255; + } else if (_lastKeyHit == '[' || _lastKeyHit == ']') { // Change music volume + int vol = ConfMan.getInt("music_volume") / 16; + if (_lastKeyHit == ']' && vol < 16) + vol++; + else if (_lastKeyHit == '[' && vol > 0) + vol--; + + // Display the music volume + // FIXME: Should we use runDialog here? It'll pause the sound/music and video + // which is both good and bad... + ValueDisplayDialog dlg("Music volume: ", 0, 16, vol, ']', '['); + vol = runDialog(dlg); + + vol *= 16; + if (vol > SoundMixer::kMaxMixerVolume) + vol = SoundMixer::kMaxMixerVolume; + ConfMan.set("music_volume", vol); setupVolumes(); - } else if (_lastKeyHit == '-') { // - text speed down - if (_defaultTalkDelay < 9) + } else if (_lastKeyHit == '-' || _lastKeyHit == '+') { // Change text speed + if (_lastKeyHit == '+' && _defaultTalkDelay < 9) _defaultTalkDelay++; - if (VAR_CHARINC != 0xFF) - VAR(VAR_CHARINC) = _defaultTalkDelay; - } else if (_lastKeyHit == '+') { // + text speed up - if (_defaultTalkDelay > 0) + else if (_lastKeyHit == '-' && _defaultTalkDelay > 0) _defaultTalkDelay--; + + // Display the talk speed + // FIXME: Should we use runDialog here? It'll pause the sound/music and video + // which is both good and bad... + ValueDisplayDialog dlg("Talk speed: ", 0, 10, _defaultTalkDelay, '+', '-'); + _defaultTalkDelay = runDialog(dlg); + if (VAR_CHARINC != 0xFF) VAR(VAR_CHARINC) = _defaultTalkDelay; } else if (_lastKeyHit == '~' || _lastKeyHit == '#') { // Debug console |