Ticket #8385: subtitles-no-floats.cpp

File subtitles-no-floats.cpp, 28.5 KB (added by salty-horse, 13 years ago)

Removed floats usage

Line 
1Index: gui/options.h
2===================================================================
3--- gui/options.h (revision 22442)
4+++ gui/options.h (working copy)
5@@ -66,11 +66,15 @@
6 void addAudioControls(GuiObject *boss, String prefix);
7 void addMIDIControls(GuiObject *boss, String prefix);
8 void addVolumeControls(GuiObject *boss, String prefix);
9+ // The default value is the launcher's non-scaled talkspeed value. When SCUMM uses the widget,
10+ // it uses its own scale
11+ void addSubtitleControls(GuiObject *boss, String prefix, int maxSliderVal = 255);
12
13 void setGraphicSettingsState(bool enabled);
14 void setAudioSettingsState(bool enabled);
15 void setMIDISettingsState(bool enabled);
16 void setVolumeSettingsState(bool enabled);
17+ void setSubtitleSettingsState(bool enabled);
18
19 private:
20 //
21@@ -87,7 +91,6 @@
22 //
23 bool _enableAudioSettings;
24 PopUpWidget *_midiPopUp;
25- CheckboxWidget *_subCheckbox;
26
27 //
28 // MIDI controls
29@@ -96,18 +99,34 @@
30 CheckboxWidget *_multiMidiCheckbox;
31 CheckboxWidget *_mt32Checkbox;
32 CheckboxWidget *_enableGSCheckbox;
33+
34+ //
35+ // Subtitle controls
36+ //
37+ int getSubtitleMode(bool subtitles, bool speech_mute);
38+ bool _enableSubtitleSettings;
39+ StaticTextWidget *_subToggleDesc;
40+ ButtonWidget *_subToggleButton;
41+ int _subMode;
42+ static const char *_subModeDesc[];
43+ StaticTextWidget *_subSpeedDesc;
44+ SliderWidget *_subSpeedSlider;
45+ StaticTextWidget *_subSpeedLabel;
46
47 //
48 // Volume controls
49 //
50 bool _enableVolumeSettings;
51
52+ StaticTextWidget *_musicVolumeDesc;
53 SliderWidget *_musicVolumeSlider;
54 StaticTextWidget *_musicVolumeLabel;
55
56+ StaticTextWidget *_sfxVolumeDesc;
57 SliderWidget *_sfxVolumeSlider;
58 StaticTextWidget *_sfxVolumeLabel;
59
60+ StaticTextWidget *_speechVolumeDesc;
61 SliderWidget *_speechVolumeSlider;
62 StaticTextWidget *_speechVolumeLabel;
63 };
64Index: gui/themes/modern.ini
65===================================================================
66--- gui/themes/modern.ini (revision 22442)
67+++ gui/themes/modern.ini (working copy)
68@@ -234,6 +234,7 @@
69 opYoffset=vBorder
70 useWithPrefix=audioControls globaloptions_
71 useWithPrefix=volumeControls globaloptions_
72+useWithPrefix=subtitleControls globaloptions_
73
74 # MIDI tab
75 opYoffset=vBorder
76@@ -302,6 +303,7 @@
77 gameoptions_audioCheckbox=gox opYoffset (kFontHeight + 10 + 180) buttonHeight
78 opYoffset=(opYoffset + buttonHeight + 6)
79 useWithPrefix=audioControls gameoptions_
80+useWithPrefix=subtitleControls gameoptions_
81
82 # midi tab
83 opYoffset=vBorder
84@@ -341,9 +343,8 @@
85 # hence it is on the end of the list
86 opYoffset=8
87 useWithPrefix=volumeControls scummconfig_
88-scummconfig_subtitlesCheckbox=15 opYoffset (kFontHeight + 10 + 89) buttonHeight
89+useWithPrefix=subtitleControls scummconfig_
90 opYoffset=(opYoffset + buttonHeight)
91-scummconfig_speechCheckbox=prev.x opYoffset (kFontHeight + 10 + 85) buttonHeight
92 opYoffset=(opYoffset + buttonHeight + 4)
93 soWidth=(8 + 3 * buttonWidth + 4)
94 scummconfig_keys=(soWidth - 3 * (buttonWidth + 4) + 6) opYoffset (buttonWidth - 10) buttonHeight
95@@ -389,7 +390,6 @@
96 chooser_cancel=(chooserW - 2 * (buttonWidth + 10)) (opHeight - buttonHeight - 8) buttonWidth buttonHeight
97 chooser_ok=(prev.x2 + 10) prev.y prev.w prev.h
98
99-
100 [graphicsControls]
101 gcx=(opXoffset + 10)
102 gcw=(parent.w - gcx - 25)
103@@ -404,26 +404,25 @@
104
105 [audioControls]
106 aux=(opXoffset + 10)
107-auw=(parent.w - aux - 25)
108-auMidiPopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2)
109-opYoffset=(opYoffset + kLineHeight + 16)
110-auSubtitlesCheckbox=aux opYoffset (kFontHeight + 10 + 102) buttonHeight
111-opYoffset=(opYoffset + buttonHeight + 18)
112+auw=(parent.w - aux - 30)
113+auMidiPopup=(aux) (opYoffset - 1) (auw + 5) (kLineHeight + 2)
114+opYoffset=(opYoffset + buttonHeight + 4)
115
116 [volumeControls]
117-vctextw=95
118-vcxoff=(vctextw + 15)
119-vcMusicText=10 (opYoffset + 2) vctextw kLineHeight
120+vctextw=110
121+vcxoff=(opXoffset + vctextw + 10)
122+vcx=(opXoffset + 10)
123+vcMusicText=vcx (opYoffset + 2) vctextw kLineHeight
124 vcMusicText.align=kTextAlignRight
125 vcMusicSlider=vcxoff opYoffset sliderWidth sliderHeight
126 vcMusicLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight
127 opYoffset=(opYoffset + sliderHeight + 8)
128-vcSfxText=10 (opYoffset + 2) vctextw kLineHeight
129+vcSfxText=vcx (opYoffset + 2) vctextw kLineHeight
130 vcSfxText.align=kTextAlignRight
131 vcSfxSlider=vcxoff opYoffset sliderWidth sliderHeight
132 vcSfxLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight
133 opYoffset=(opYoffset + sliderHeight + 8)
134-vcSpeechText=10 (opYoffset + 2) vctextw kLineHeight
135+vcSpeechText=vcx (opYoffset + 2) vctextw kLineHeight
136 vcSpeechText.align=kTextAlignRight
137 vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight
138 vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight
139@@ -442,6 +441,21 @@
140 mcGSCheckbox=mcx opYoffset (kFontHeight + 10 + 142) buttonHeight
141 opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)
142
143+[subtitleControls]
144+sbx=(opXoffset + 10)
145+sbtextw=110
146+sbYoff=(buttonHeight / 8)
147+sbOff=((sliderHeight - kLineHeight) / 2)
148+opYoffset=(opYoffset + sbYoff)
149+subToggleDesc=sbx (opYoffset + sbYoff) sbtextw buttonHeight
150+subToggleButton=prev.x2 opYoffset (buttonWidth + 34) sliderHeight
151+opYoffset=(opYoffset + buttonHeight + 6)
152+subSubtitleSpeedDesc=sbx (opYoffset + sbOff) sbtextw kLineHeight
153+subSubtitleSpeedDesc.align=kTextAlignRight
154+subSubtitleSpeedSlider=prev.x2 opYoffset sliderWidth sliderHeight
155+subSubtitleSpeedLabel=(prev.x2 + 10) (opYoffset + sbOff) 24 kLineHeight
156+opYoffset=(opYoffset + sliderHeight + 8)
157+
158 [scummmain]
159 ## Main dialog
160 # note that scummmain size depends on overall height
161Index: gui/options.cpp
162===================================================================
163--- gui/options.cpp (revision 22442)
164+++ gui/options.cpp (working copy)
165@@ -55,11 +55,13 @@
166 // - music & graphics driver (but see also the comments on EditGameDialog
167 // for some techincal difficulties with this)
168 // - default volumes (sfx/speech/music)
169-// - aspect ratio, language, platform, subtitles, debug mode/level, cd drive, joystick, multi midi, native mt32
170+// - aspect ratio, language, platform, debug mode/level, cd drive, joystick, multi midi, native mt32
171
172 enum {
173 kMusicVolumeChanged = 'muvc',
174 kSfxVolumeChanged = 'sfvc',
175+ kSubtitleToggle = 'sttg',
176+ kSubtitleSpeedChanged = 'stsc',
177 kSpeechVolumeChanged = 'vcvc',
178 kChooseSoundFontCmd = 'chsf',
179 kChooseSaveDirCmd = 'chos',
180@@ -83,6 +85,12 @@
181 init();
182 }
183
184+const char *OptionsDialog::_subModeDesc[] = {
185+ "Speech Only",
186+ "Speech and Subtitles",
187+ "Subtitles Only"
188+};
189+
190 void OptionsDialog::init() {
191 _enableGraphicSettings = false;
192 _gfxPopUp = 0;
193@@ -90,19 +98,26 @@
194 _fullscreenCheckbox = 0;
195 _aspectCheckbox = 0;
196 _enableAudioSettings = false;
197- _subCheckbox = 0;
198 _midiPopUp = 0;
199 _enableMIDISettings = false;
200 _multiMidiCheckbox = 0;
201 _mt32Checkbox = 0;
202 _enableGSCheckbox = 0;
203 _enableVolumeSettings = false;
204+ _musicVolumeDesc = 0;
205 _musicVolumeSlider = 0;
206 _musicVolumeLabel = 0;
207+ _sfxVolumeDesc = 0;
208 _sfxVolumeSlider = 0;
209 _sfxVolumeLabel = 0;
210+ _speechVolumeDesc = 0;
211 _speechVolumeSlider = 0;
212 _speechVolumeLabel = 0;
213+ _subToggleDesc = 0;
214+ _subToggleButton = 0;
215+ _subSpeedDesc = 0;
216+ _subSpeedSlider = 0;
217+ _subSpeedLabel = 0;
218 }
219
220 void OptionsDialog::open() {
221@@ -111,6 +126,7 @@
222 // Reset result value
223 setResult(0);
224
225+ // Graphic options
226 if (_fullscreenCheckbox) {
227 _gfxPopUp->setSelected(0);
228
229@@ -150,7 +166,8 @@
230 #endif
231 }
232
233- if (_subCheckbox) {
234+ // Audio options
235+ if (_midiPopUp) {
236 // Music driver
237 const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers();
238 int i = 0;
239@@ -163,9 +180,6 @@
240 md++;
241 }
242 _midiPopUp->setSelected(md->name ? i : 0);
243-
244- // Subtitles setting
245- _subCheckbox->setState(ConfMan.getBool("subtitles", _domain));
246 }
247
248 if (_multiMidiCheckbox) {
249@@ -202,10 +216,27 @@
250 _speechVolumeSlider->setValue(vol);
251 _speechVolumeLabel->setValue(vol);
252 }
253+
254+ // Subtitle options
255+ if (_subToggleButton) {
256+ int speed;
257+ int sliderMaxValue = _subSpeedSlider->getMaxValue();
258+
259+ _subMode = getSubtitleMode(ConfMan.getBool("subtitles", _domain), ConfMan.getBool("speech_mute"));
260+ _subToggleButton->setLabel(_subModeDesc[_subMode]);
261+
262+ // Engines that reuse the subtitle speed widget set their own max value.
263+ // Scale the config value accordingly (see addSubtitleControls)
264+ speed = (ConfMan.getInt("talkspeed", _domain) * sliderMaxValue + 255 / 2) / 255;
265+ _subSpeedSlider->setValue(speed);
266+ _subSpeedLabel->setValue(speed);
267+ }
268 }
269
270 void OptionsDialog::close() {
271 if (getResult()) {
272+
273+ // Graphic options
274 if (_fullscreenCheckbox) {
275 if (_enableGraphicSettings) {
276 ConfMan.setBool("fullscreen", _fullscreenCheckbox->getState(), _domain);
277@@ -224,6 +255,7 @@
278 }
279 }
280
281+ // Volume options
282 if (_musicVolumeSlider) {
283 if (_enableVolumeSettings) {
284 ConfMan.setInt("music_volume", _musicVolumeSlider->getValue(), _domain);
285@@ -236,9 +268,9 @@
286 }
287 }
288
289- if (_subCheckbox) {
290+ // Audio options
291+ if (_midiPopUp) {
292 if (_enableAudioSettings) {
293- ConfMan.setBool("subtitles", _subCheckbox->getState(), _domain);
294 const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers();
295 while (md->name && md->id != (int)_midiPopUp->getSelectedTag())
296 md++;
297@@ -248,7 +280,6 @@
298 ConfMan.removeKey("music_driver", _domain);
299 } else {
300 ConfMan.removeKey("music_driver", _domain);
301- ConfMan.removeKey("subtitles", _domain);
302 }
303 }
304
305@@ -270,6 +301,42 @@
306 }
307 }
308
309+ // Subtitle options
310+ if (_subToggleButton) {
311+ if (_enableSubtitleSettings) {
312+ bool subtitles, speech_mute;
313+ int talkspeed;
314+ int sliderMaxValue = _subSpeedSlider->getMaxValue();
315+
316+ switch (_subMode) {
317+ case 0:
318+ subtitles = speech_mute = false;
319+ break;
320+ case 1:
321+ subtitles = true;
322+ speech_mute = false;
323+ break;
324+ case 2:
325+ default:
326+ subtitles = speech_mute = true;
327+ break;
328+ }
329+
330+ ConfMan.setBool("subtitles", subtitles, _domain);
331+ ConfMan.setBool("speech_mute", speech_mute, _domain);
332+
333+ // Engines that reuse the subtitle speed widget set their own max value.
334+ // Scale the config value accordingly (see addSubtitleControls)
335+ talkspeed = (_subSpeedSlider->getValue() * 255 + sliderMaxValue / 2) / sliderMaxValue;
336+ ConfMan.setInt("talkspeed", talkspeed, _domain);
337+
338+ } else {
339+ ConfMan.removeKey("subtitles", _domain);
340+ ConfMan.removeKey("talkspeed", _domain);
341+ ConfMan.removeKey("speech_mute", _domain);
342+ }
343+ }
344+
345 // Save config file
346 ConfMan.flushToDisk();
347 }
348@@ -291,6 +358,22 @@
349 _speechVolumeLabel->setValue(_speechVolumeSlider->getValue());
350 _speechVolumeLabel->draw();
351 break;
352+ case kSubtitleToggle:
353+ if (_subMode < 2)
354+ _subMode++;
355+ else
356+ _subMode = 0;
357+
358+ _subToggleButton->setLabel(_subModeDesc[_subMode]);
359+ _subToggleButton->draw();
360+ _subSpeedDesc->draw();
361+ _subSpeedSlider->draw();
362+ _subSpeedLabel->draw();
363+ break;
364+ case kSubtitleSpeedChanged:
365+ _subSpeedLabel->setValue(_subSpeedSlider->getValue());
366+ _subSpeedLabel->draw();
367+ break;
368 case kOKCmd:
369 setResult(1);
370 close();
371@@ -315,7 +398,6 @@
372 _enableAudioSettings = enabled;
373
374 _midiPopUp->setEnabled(enabled);
375- _subCheckbox->setEnabled(enabled);
376 }
377
378 void OptionsDialog::setMIDISettingsState(bool enabled) {
379@@ -331,14 +413,27 @@
380 void OptionsDialog::setVolumeSettingsState(bool enabled) {
381 _enableVolumeSettings = enabled;
382
383+ _musicVolumeDesc->setEnabled(enabled);
384 _musicVolumeSlider->setEnabled(enabled);
385 _musicVolumeLabel->setEnabled(enabled);
386+ _sfxVolumeDesc->setEnabled(enabled);
387 _sfxVolumeSlider->setEnabled(enabled);
388 _sfxVolumeLabel->setEnabled(enabled);
389+ _speechVolumeDesc->setEnabled(enabled);
390 _speechVolumeSlider->setEnabled(enabled);
391 _speechVolumeLabel->setEnabled(enabled);
392 }
393
394+void OptionsDialog::setSubtitleSettingsState(bool enabled) {
395+ _enableSubtitleSettings = enabled;
396+
397+ _subToggleButton->setEnabled(enabled);
398+ _subToggleDesc->setEnabled(enabled);
399+ _subSpeedDesc->setEnabled(enabled);
400+ _subSpeedSlider->setEnabled(enabled);
401+ _subSpeedLabel->setEnabled(enabled);
402+}
403+
404 void OptionsDialog::addGraphicControls(GuiObject *boss, String prefix) {
405 const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
406
407@@ -391,9 +486,6 @@
408 md++;
409 }
410
411- // Subtitles on/off
412- _subCheckbox = new CheckboxWidget(boss, prefix + "auSubtitlesCheckbox", "Display subtitles", 0, 0);
413-
414 _enableAudioSettings = true;
415 }
416
417@@ -414,29 +506,41 @@
418 _enableMIDISettings = true;
419 }
420
421+// The function has an extra slider range parameter, since both the launcher and SCUMM engine
422+// make use of the widgets. The launcher range is 0-255. SCUMM's 0-9
423+void OptionsDialog::addSubtitleControls(GuiObject *boss, String prefix, int maxSliderVal) {
424+
425+ _subToggleDesc = new StaticTextWidget(boss, prefix + "subToggleDesc", "Text and Speech:");
426+ _subToggleButton = new ButtonWidget(boss, prefix + "subToggleButton", "", kSubtitleToggle, 0);
427+
428+ // Subtitle speed
429+ _subSpeedDesc = new StaticTextWidget(boss, prefix + "subSubtitleSpeedDesc", "Subtitle speed:");
430+ _subSpeedSlider = new SliderWidget(boss, prefix + "subSubtitleSpeedSlider", kSubtitleSpeedChanged);
431+ _subSpeedLabel = new StaticTextWidget(boss, prefix + "subSubtitleSpeedLabel", "100%");
432+ _subSpeedSlider->setMinValue(0); _subSpeedSlider->setMaxValue(maxSliderVal);
433+ _subSpeedLabel->setFlags(WIDGET_CLEARBG);
434+
435+ _enableSubtitleSettings = true;
436+}
437+
438 void OptionsDialog::addVolumeControls(GuiObject *boss, String prefix) {
439- const char *slider_labels[] = {
440- "Music volume:",
441- "SFX volume:",
442- "Speech volume:"
443- };
444
445 // Volume controllers
446- new StaticTextWidget(boss, prefix + "vcMusicText", slider_labels[0]);
447+ _musicVolumeDesc = new StaticTextWidget(boss, prefix + "vcMusicText", "Music volume:");
448 _musicVolumeSlider = new SliderWidget(boss, prefix + "vcMusicSlider", kMusicVolumeChanged);
449 _musicVolumeLabel = new StaticTextWidget(boss, prefix + "vcMusicLabel", "100%");
450 _musicVolumeSlider->setMinValue(0);
451 _musicVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume);
452 _musicVolumeLabel->setFlags(WIDGET_CLEARBG);
453
454- new StaticTextWidget(boss, prefix + "vcSfxText", slider_labels[1]);
455+ _sfxVolumeDesc = new StaticTextWidget(boss, prefix + "vcSfxText", "SFX volume:");
456 _sfxVolumeSlider = new SliderWidget(boss, prefix + "vcSfxSlider", kSfxVolumeChanged);
457 _sfxVolumeLabel = new StaticTextWidget(boss, prefix + "vcSfxLabel", "100%");
458 _sfxVolumeSlider->setMinValue(0);
459 _sfxVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume);
460 _sfxVolumeLabel->setFlags(WIDGET_CLEARBG);
461
462- new StaticTextWidget(boss, prefix + "vcSpeechText" , slider_labels[2]);
463+ _speechVolumeDesc = new StaticTextWidget(boss, prefix + "vcSpeechText" , "Speech volume:");
464 _speechVolumeSlider = new SliderWidget(boss, prefix + "vcSpeechSlider", kSpeechVolumeChanged);
465 _speechVolumeLabel = new StaticTextWidget(boss, prefix + "vcSpeechLabel", "100%");
466 _speechVolumeSlider->setMinValue(0);
467@@ -446,6 +550,18 @@
468 _enableVolumeSettings = true;
469 }
470
471+int OptionsDialog::getSubtitleMode(bool subtitles, bool speech_mute) {
472+ if (!subtitles && !speech_mute) // Speech only
473+ return 0;
474+ else if (subtitles && !speech_mute) // Speech and subtitles
475+ return 1;
476+ else if (subtitles && speech_mute) // Subtitles only
477+ return 2;
478+ else
479+ warning("Wrong configuration: Both subtitles and speech are off. Assuming subtitles only");
480+ return 2;
481+}
482+
483 void OptionsDialog::handleScreenChanged() {
484 Dialog::handleScreenChanged();
485
486@@ -481,6 +597,8 @@
487 tab->addTab("Audio");
488 addAudioControls(tab, "globaloptions_");
489 addVolumeControls(tab, "globaloptions_");
490+ addSubtitleControls(tab, "globaloptions_");
491+
492 // TODO: cd drive setting
493
494 //
495Index: gui/launcher.cpp
496===================================================================
497--- gui/launcher.cpp (revision 22442)
498+++ gui/launcher.cpp (working copy)
499@@ -189,7 +189,9 @@
500 _platformPopUp->appendEntry(p->description, p->id);
501 }
502
503+ //
504 // 2) The 'Path' tab
505+ //
506 tab->addTab("Paths");
507
508 // These buttons have to be extra wide, or the text will be truncated
509@@ -230,6 +232,7 @@
510 _globalAudioOverride = new CheckboxWidget(tab, "gameoptions_audioCheckbox", "Override global audio settings", kCmdGlobalAudioOverride, 0);
511
512 addAudioControls(tab, "gameoptions_");
513+ addSubtitleControls(tab, "gameoptions_");
514
515 //
516 // 5) The MIDI tab
517@@ -249,7 +252,6 @@
518
519 addVolumeControls(tab, "gameoptions_");
520
521-
522 // Activate the first tab
523 tab->setActiveTab(0);
524
525@@ -271,7 +273,8 @@
526 _globalGraphicsOverride->setState(e);
527
528 e = ConfMan.hasKey("music_driver", _domain) ||
529- ConfMan.hasKey("subtitles", _domain);
530+ ConfMan.hasKey("subtitles", _domain) ||
531+ ConfMan.hasKey("talkspeed", _domain);
532 _globalAudioOverride->setState(e);
533
534 e = ConfMan.hasKey("multi_midi", _domain) ||
535@@ -346,6 +349,7 @@
536 break;
537 case kCmdGlobalAudioOverride:
538 setAudioSettingsState(data != 0);
539+ setSubtitleSettingsState(data != 0);
540 draw();
541 break;
542 case kCmdGlobalMIDIOverride:
543@@ -356,7 +360,6 @@
544 setVolumeSettingsState(data != 0);
545 draw();
546 break;
547-
548 case kCmdChooseSoundFontCmd: {
549 BrowserDialog browser("Select SoundFont", false);
550
551Index: gui/theme-config.cpp
552===================================================================
553--- gui/theme-config.cpp (revision 22442)
554+++ gui/theme-config.cpp (working copy)
555@@ -50,6 +50,7 @@
556 "def_scummhelpX=5\n"
557 "def_scummhelpW=(w - 2 * 5)\n"
558 "def_midiControlsSpacing=1\n"
559+"def_vcAudioTabIndent=0\n"
560 "use=XxY\n"
561 "# Scumm Saveload dialog\n"
562 "scummsaveload=8 8 (w - 2 * 8) (h - 16)\n"
563@@ -85,6 +86,7 @@
564 "def_scummhelpW=370\n"
565 "def_scummhelpX=((w - scummhelpW) / 2)\n"
566 "def_midiControlsSpacing=2\n"
567+"def_vcAudioTabIndent=10\n"
568 "##### Widgets config\n"
569 "ListWidget.leftPadding=4\n"
570 "ListWidget.rightPadding=0\n"
571@@ -141,12 +143,14 @@
572 "\n"
573 "# graphics tab\n"
574 "opYoffset=vBorder\n"
575+"opXoffset=0\n"
576 "useWithPrefix=graphicsControls globaloptions_\n"
577 "\n"
578 "# audio tab\n"
579 "opYoffset=vBorder\n"
580 "useWithPrefix=audioControls globaloptions_\n"
581 "useWithPrefix=volumeControls globaloptions_\n"
582+"useWithPrefix=subtitleControls globaloptions_\n"
583 "\n"
584 "# MIDI tab\n"
585 "opYoffset=vBorder\n"
586@@ -205,6 +209,7 @@
587 "\n"
588 "# graphics tab\n"
589 "opYoffset=vBorder\n"
590+"opXoffset=gox\n"
591 "gameoptions_graphicsCheckbox=gox opYoffset (kFontHeight + 10 + 192) buttonHeight\n"
592 "opYoffset=(opYoffset + buttonHeight)\n"
593 "useWithPrefix=graphicsControls gameoptions_\n"
594@@ -214,6 +219,7 @@
595 "gameoptions_audioCheckbox=gox opYoffset (kFontHeight + 10 + 180) buttonHeight\n"
596 "opYoffset=(opYoffset + buttonHeight)\n"
597 "useWithPrefix=audioControls gameoptions_\n"
598+"useWithPrefix=subtitleControls gameoptions_\n"
599 "\n"
600 "# midi tab\n"
601 "opYoffset=vBorder\n"
602@@ -251,9 +257,8 @@
603 "# hence it is on the end of the list\n"
604 "opYoffset=8\n"
605 "useWithPrefix=volumeControls scummconfig_\n"
606-"scummconfig_subtitlesCheckbox=15 opYoffset (kFontHeight + 10 + 89) buttonHeight\n"
607+"useWithPrefix=subtitleControls scummconfig_\n"
608 "opYoffset=(opYoffset + buttonHeight)\n"
609-"scummconfig_speechCheckbox=prev.x opYoffset (kFontHeight + 10 + 85) buttonHeight\n"
610 "opYoffset=(opYoffset + buttonHeight + 4)\n"
611 "soWidth=(8 + 3 * buttonWidth + 4)\n"
612 "scummconfig_keys=(soWidth - 3 * (buttonWidth + 4) + 6) opYoffset (buttonWidth - 10) buttonHeight\n"
613@@ -299,7 +304,6 @@
614 "chooser_cancel=(chooserW - 2 * (buttonWidth + 10)) (opHeight - buttonHeight - 8) buttonWidth buttonHeight\n"
615 "chooser_ok=(prev.x2 + 10) prev.y prev.w prev.h\n"
616 "\n"
617-"\n"
618 "[graphicsControls]\n"
619 "gcx=10\n"
620 "gcw=(parent.w - 2 * 10)\n"
621@@ -316,24 +320,23 @@
622 "aux=10\n"
623 "auw=(parent.w - 2 * 10)\n"
624 "auMidiPopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2)\n"
625-"opYoffset=(opYoffset + kLineHeight + 4)\n"
626-"auSubtitlesCheckbox=aux opYoffset (kFontHeight + 10 + 102) buttonHeight\n"
627-"opYoffset=(opYoffset + buttonHeight + 18)\n"
628+"opYoffset=(opYoffset + buttonHeight + 4)\n"
629 "\n"
630 "[volumeControls]\n"
631-"vctextw=95\n"
632-"vcxoff=(vctextw + 15)\n"
633-"vcMusicText=10 (opYoffset + 2) vctextw kLineHeight\n"
634+"vctextw=(95 + vcAudioTabIndent)\n"
635+"vcxoff=(opXoffset + vctextw + 15)\n"
636+"vcx=(opXoffset + 10)\n"
637+"vcMusicText=vcx (opYoffset + 2) vctextw kLineHeight\n"
638 "vcMusicText.align=kTextAlignRight\n"
639 "vcMusicSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
640 "vcMusicLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
641 "opYoffset=(opYoffset + sliderHeight + 4)\n"
642-"vcSfxText=10 (opYoffset + 2) vctextw kLineHeight\n"
643+"vcSfxText=vcx (opYoffset + 2) vctextw kLineHeight\n"
644 "vcSfxText.align=kTextAlignRight\n"
645 "vcSfxSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
646 "vcSfxLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
647 "opYoffset=(opYoffset + sliderHeight + 4)\n"
648-"vcSpeechText=10 (opYoffset + 2) vctextw kLineHeight\n"
649+"vcSpeechText=vcx (opYoffset + 2) vctextw kLineHeight\n"
650 "vcSpeechText.align=kTextAlignRight\n"
651 "vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
652 "vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
653@@ -351,6 +354,21 @@
654 "mcGSCheckbox=mcx opYoffset (kFontHeight + 10 + 142) buttonHeight\n"
655 "opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)\n"
656 "\n"
657+"[subtitleControls]\n"
658+"sbx=(opXoffset + 10)\n"
659+"sbYoff=(buttonHeight / 8)\n"
660+"sbOff=((sliderHeight - kLineHeight) / 2 + 2)\n"
661+"sbtextw=(100 + vcAudioTabIndent)\n"
662+"opYoffset=(opYoffset + sbYoff)\n"
663+"subToggleDesc=sbx (opYoffset + sbYoff) sbtextw buttonHeight\n"
664+"subToggleButton=prev.x2 (opYoffset - sbYoff) (buttonWidth + 54) buttonHeight\n"
665+"opYoffset=(opYoffset + buttonHeight + 6)\n"
666+"subSubtitleSpeedDesc=sbx (opYoffset + sbOff) sbtextw kLineHeight\n"
667+"subSubtitleSpeedDesc.align=kTextAlignRight\n"
668+"subSubtitleSpeedSlider=prev.x2 opYoffset sliderWidth sliderHeight\n"
669+"subSubtitleSpeedLabel=(prev.x2 + 10) (opYoffset + sbOff) 24 kLineHeight\n"
670+"opYoffset=(opYoffset + sliderHeight + 8)\n"
671+"\n"
672 "[scummmain]\n"
673 "## Main dialog\n"
674 "# note that scummmain size depends on overall height\n"
675Index: engines/scumm/input.cpp
676===================================================================
677--- engines/scumm/input.cpp (revision 22442)
678+++ engines/scumm/input.cpp (working copy)
679@@ -445,6 +445,9 @@
680 // Display the talk speed
681 ValueDisplayDialog dlg("Text speed: ", 0, 9, 9 - _defaultTalkDelay, '+', '-');
682 _defaultTalkDelay = 9 - runDialog(dlg);
683+
684+ // Save the new talkspeed value to ConfMan
685+ setTalkspeed(9 - _defaultTalkDelay);
686
687 if (VAR_CHARINC != 0xFF)
688 VAR(VAR_CHARINC) = _defaultTalkDelay;
689Index: engines/scumm/dialogs.cpp
690===================================================================
691--- engines/scumm/dialogs.cpp (revision 22442)
692+++ engines/scumm/dialogs.cpp (working copy)
693@@ -608,7 +608,7 @@
694 #pragma mark -
695
696 enum {
697- kOKCmd = 'ok '
698+ kOKCmd = 'ok '
699 };
700
701 enum {
702@@ -653,8 +653,8 @@
703 // Some misc options
704 //
705
706- _subtitlesCheckbox = new GUI::CheckboxWidget(this, "scummconfig_subtitlesCheckbox", "Show subtitles", 0, 'S');
707- _speechCheckbox = new GUI::CheckboxWidget(this, "scummconfig_speechCheckbox", "Enable speech", 0, 'E');
708+ // SCUMM has a talkspeed range of 0-9
709+ addSubtitleControls(this, "scummconfig_", 9);
710
711 //
712 // Add the buttons
713@@ -683,19 +683,9 @@
714
715 void ConfigDialog::open() {
716 GUI_OptionsDialog::open();
717-
718- // update checkboxes, too
719- _subtitlesCheckbox->setState(ConfMan.getBool("subtitles", _domain));
720- _speechCheckbox->setState(!ConfMan.getBool("speech_mute", _domain));
721 }
722
723 void ConfigDialog::close() {
724- if (getResult()) {
725- // Subtitles
726- ConfMan.setBool("subtitles", _subtitlesCheckbox->getState(), _domain);
727- ConfMan.setBool("speech_mute", !_speechCheckbox->getState(), _domain);
728- }
729-
730 GUI_OptionsDialog::close();
731 }
732
733@@ -927,8 +917,9 @@
734 }
735
736 void ValueDisplayDialog::handleTickle() {
737- if (getMillis() > _timer)
738+ if (getMillis() > _timer) {
739 close();
740+ }
741 }
742
743 void ValueDisplayDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
744Index: engines/scumm/scumm.cpp
745===================================================================
746--- engines/scumm/scumm.cpp (revision 22442)
747+++ engines/scumm/scumm.cpp (working copy)
748@@ -499,6 +499,12 @@
749 VAR_SOUNDPARAM3 = 0xFF;
750 VAR_MOUSEPRESENT = 0xFF;
751 VAR_MEMORY_PERFORMANCE = 0xFF;
752+
753+ if (ConfMan.hasKey("talkspeed")) {
754+ _defaultTalkDelay = 9 - getTalkspeed();
755+ VAR_CHARINC = _defaultTalkDelay;
756+ }
757+
758 VAR_VIDEO_PERFORMANCE = 0xFF;
759 VAR_ROOM_FLAG = 0xFF;
760 VAR_GAME_LOADED = 0xFF;
761@@ -1498,7 +1504,6 @@
762 _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
763 _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech);
764
765-
766 if (ConfMan.getBool("speech_mute"))
767 _voiceMode = 2;
768 else
769@@ -1506,10 +1511,33 @@
770
771 if (VAR_VOICE_MODE != 0xFF)
772 VAR(VAR_VOICE_MODE) = _voiceMode;
773+
774+ _defaultTalkDelay = 9 - getTalkspeed();
775+ VAR(VAR_CHARINC) = _defaultTalkDelay;
776 }
777
778+void ScummEngine::setTalkspeed(int talkspeed) {
779+ /*if (talkspeed != 0)
780+ if (talkspeed == 9)
781+ talkspeed = 255;
782+ else
783+ talkspeed = (int)(talkspeed * 255.0 / 9.0 + 0.5);*/
784+ ConfMan.setInt("talkspeed", (talkspeed * 255 + 9 / 2) / 9);
785+}
786
787+int ScummEngine::getTalkspeed() {
788+ /*int talkspeed = ConfMan.getInt("talkspeed");
789
790+ if (talkspeed != 0)
791+ if (talkspeed == 255)
792+ talkspeed = 9;
793+ else
794+ talkspeed = (int)(talkspeed * 9.0 / 255.0 + 0.5);
795+ return talkspeed;*/
796+ return (ConfMan.getInt("talkspeed") * 9 + 255 / 2) / 255;
797+}
798+
799+
800 #pragma mark -
801 #pragma mark --- Main loop ---
802 #pragma mark -
803Index: engines/scumm/dialogs.h
804===================================================================
805--- engines/scumm/dialogs.h (revision 22442)
806+++ engines/scumm/dialogs.h (working copy)
807@@ -140,10 +140,6 @@
808 virtual void open();
809 virtual void close();
810 virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
811-
812-protected:
813- GUI::CheckboxWidget *_subtitlesCheckbox;
814- GUI::CheckboxWidget *_speechCheckbox;
815 };
816
817 /**
818Index: engines/scumm/scumm.h
819===================================================================
820--- engines/scumm/scumm.h (revision 22442)
821+++ engines/scumm/scumm.h (working copy)
822@@ -470,6 +470,8 @@
823 void loadCJKFont();
824 void setupMusic(int midi);
825 void updateSoundSettings();
826+ void setTalkspeed(int talkspeed);
827+ int getTalkspeed();
828
829 protected:
830 // Scumm main loop & helper functions.
831Index: engines/scumm/script_v8.cpp
832===================================================================
833--- engines/scumm/script_v8.cpp (revision 22442)
834+++ engines/scumm/script_v8.cpp (working copy)
835@@ -420,7 +420,7 @@
836 checkRange(_numVariables - 1, 0, var, "Variable %d out of range(w)");
837
838 if (var == VAR_CHARINC && ConfMan.hasKey("talkspeed")) {
839- uint talkspeed = ConfMan.getInt("talkspeed");
840+ uint talkspeed = getTalkspeed();
841 if (talkspeed <= 9)
842 VAR(VAR_CHARINC) = talkspeed;
843 } else
844Index: engines/scumm/script.cpp
845===================================================================
846--- engines/scumm/script.cpp (revision 22442)
847+++ engines/scumm/script.cpp (working copy)
848@@ -617,7 +617,7 @@
849 }
850
851 if (var == VAR_CHARINC && ConfMan.hasKey("talkspeed")) {
852- uint talkspeed = ConfMan.getInt("talkspeed");
853+ uint talkspeed = getTalkspeed();
854 if (talkspeed <= 9)
855 VAR(VAR_CHARINC) = talkspeed;
856 } else {
857Index: engines/queen/queen.cpp
858===================================================================
859--- engines/queen/queen.cpp (revision 22442)
860+++ engines/queen/queen.cpp (working copy)
861@@ -186,7 +186,7 @@
862 _music->setVolume(ConfMan.getInt("music_volume"));
863 _sound->musicToggle(!ConfMan.getBool("music_mute"));
864 _sound->sfxToggle(!ConfMan.getBool("sfx_mute"));
865- _talkSpeed = ConfMan.getInt("talkspeed");
866+ _talkSpeed = (ConfMan.getInt("talkspeed") * (MAX_TEXT_SPEED - MIN_TEXT_SPEED) + 255 / 2) / 255 + MIN_TEXT_SPEED;
867 _sound->speechToggle(!ConfMan.getBool("speech_mute"));
868 _subtitles = ConfMan.getBool("subtitles");
869 checkOptionSettings();
870@@ -196,7 +196,7 @@
871 ConfMan.setInt("music_volume", _music->volume());
872 ConfMan.setBool("music_mute", !_sound->musicOn());
873 ConfMan.setBool("sfx_mute", !_sound->sfxOn());
874- ConfMan.setInt("talkspeed", _talkSpeed);
875+ ConfMan.setInt("talkspeed", ((_talkSpeed - MIN_TEXT_SPEED) * 255 + (MAX_TEXT_SPEED - MIN_TEXT_SPEED) / 2) / (MAX_TEXT_SPEED - MIN_TEXT_SPEED));
876 ConfMan.setBool("speech_mute", !_sound->speechOn());
877 ConfMan.setBool("subtitles", _subtitles);
878 ConfMan.flushToDisk();
879@@ -444,6 +444,7 @@
880
881 _sound = Sound::giveSound(_mixer, this, _resource->compression());
882 _walk = new Walk(this);
883+ //_talkspeedScale = (MAX_TEXT_SPEED - MIN_TEXT_SPEED) / 255.0;
884
885 registerDefaultSettings();
886 readOptionSettings();
887Index: engines/queen/journal.cpp
888===================================================================
889--- engines/queen/journal.cpp (revision 22442)
890+++ engines/queen/journal.cpp (working copy)
891@@ -310,7 +310,7 @@
892 enterYesNoPanelMode(zoneNum, TXT_GIVE_UP);
893 break;
894 case ZN_TEXT_SPEED:
895- val = (x - 136) * QueenEngine::MAX_TEXT_SPEED / (266 - 136);
896+ val = (x - 136) * QueenEngine::MAX_TEXT_SPEED / (266 - 136);
897 _vm->talkSpeed(val);
898 drawConfigPanel();
899 break;