[Scummvm-cvs-logs] CVS: scummvm/scumm dialogs.cpp,1.123,1.124 dialogs.h,1.44,1.45 input.cpp,2.14,2.15
Max Horn
fingolfin at users.sourceforge.net
Sun Mar 6 10:01:44 CET 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1724/scumm
Modified Files:
dialogs.cpp dialogs.h input.cpp
Log Message:
Added dialogs which are shown when you modify the talkspeed or music volume using hotkeys (FR #1153300)
Index: dialogs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/dialogs.cpp,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- dialogs.cpp 18 Feb 2005 00:28:55 -0000 1.123
+++ dialogs.cpp 6 Mar 2005 18:00:52 -0000 1.124
@@ -598,6 +598,60 @@
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__
Index: dialogs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/dialogs.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- dialogs.h 18 Feb 2005 00:28:56 -0000 1.44
+++ dialogs.h 6 Mar 2005 18:00:54 -0000 1.45
@@ -119,6 +119,12 @@
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 @@
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 @@
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
Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/input.cpp,v
retrieving revision 2.14
retrieving revision 2.15
diff -u -d -r2.14 -r2.15
--- input.cpp 2 Mar 2005 21:46:50 -0000 2.14
+++ input.cpp 6 Mar 2005 18:00:54 -0000 2.15
@@ -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 @@
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
More information about the Scummvm-git-logs
mailing list