Ticket #8385: scumm-subtitles-hack-for-review.patch

File scumm-subtitles-hack-for-review.patch, 31.1 KB (added by salty-horse, 18 years ago)

possible SCUMM talkspeed solution for review

  • gui/options.h

     
    6666        void addAudioControls(GuiObject *boss, String prefix);
    6767        void addMIDIControls(GuiObject *boss, String prefix);
    6868        void addVolumeControls(GuiObject *boss, String prefix);
     69        // The default value is the launcher's non-scaled talkspeed value. When SCUMM uses the widget,
     70        // it uses its own scale
     71        void addSubtitleControls(GuiObject *boss, String prefix, int maxSliderVal = 255);
    6972
    7073        void setGraphicSettingsState(bool enabled);
    7174        void setAudioSettingsState(bool enabled);
    7275        void setMIDISettingsState(bool enabled);
    7376        void setVolumeSettingsState(bool enabled);
     77        void setSubtitleSettingsState(bool enabled);
    7478
    7579private:
    7680        //
     
    8791        //
    8892        bool _enableAudioSettings;
    8993        PopUpWidget *_midiPopUp;
    90         CheckboxWidget *_subCheckbox;
    9194
    9295        //
    9396        // MIDI controls
     
    9699        CheckboxWidget *_multiMidiCheckbox;
    97100        CheckboxWidget *_mt32Checkbox;
    98101        CheckboxWidget *_enableGSCheckbox;
     102       
     103        //
     104        // Subtitle controls
     105        //
     106        int getSubtitleMode(bool subtitles, bool speech_mute);
     107        bool _enableSubtitleSettings;
     108        StaticTextWidget *_subToggleDesc;
     109        ButtonWidget *_subToggleButton;
     110        int _subMode;
     111        static const char *_subModeDesc[];
     112        StaticTextWidget *_subSpeedDesc;
     113        SliderWidget *_subSpeedSlider;
     114        StaticTextWidget *_subSpeedLabel;
    99115
    100116        //
    101117        // Volume controls
    102118        //
    103119        bool _enableVolumeSettings;
    104120
     121        StaticTextWidget *_musicVolumeDesc;
    105122        SliderWidget *_musicVolumeSlider;
    106123        StaticTextWidget *_musicVolumeLabel;
    107124
     125        StaticTextWidget *_sfxVolumeDesc;
    108126        SliderWidget *_sfxVolumeSlider;
    109127        StaticTextWidget *_sfxVolumeLabel;
    110128
     129        StaticTextWidget *_speechVolumeDesc;
    111130        SliderWidget *_speechVolumeSlider;
    112131        StaticTextWidget *_speechVolumeLabel;
    113132};
  • gui/themes/modern.ini

     
    234234opYoffset=vBorder
    235235useWithPrefix=audioControls globaloptions_
    236236useWithPrefix=volumeControls globaloptions_
     237useWithPrefix=subtitleControls globaloptions_
    237238
    238239# MIDI tab
    239240opYoffset=vBorder
     
    302303gameoptions_audioCheckbox=gox opYoffset (kFontHeight + 10 + 180) buttonHeight
    303304opYoffset=(opYoffset + buttonHeight + 6)
    304305useWithPrefix=audioControls gameoptions_
     306useWithPrefix=subtitleControls gameoptions_
    305307
    306308# midi tab
    307309opYoffset=vBorder
     
    341343# hence it is on the end of the list
    342344opYoffset=8
    343345useWithPrefix=volumeControls scummconfig_
    344 scummconfig_subtitlesCheckbox=15 opYoffset (kFontHeight + 10 + 89) buttonHeight
     346useWithPrefix=subtitleControls scummconfig_
    345347opYoffset=(opYoffset + buttonHeight)
    346 scummconfig_speechCheckbox=prev.x opYoffset (kFontHeight + 10 + 85) buttonHeight
    347348opYoffset=(opYoffset + buttonHeight + 4)
    348349soWidth=(8 + 3 * buttonWidth + 4)
    349350scummconfig_keys=(soWidth - 3 * (buttonWidth + 4) + 6) opYoffset (buttonWidth - 10) buttonHeight
     
    389390chooser_cancel=(chooserW - 2 * (buttonWidth + 10)) (opHeight - buttonHeight - 8) buttonWidth buttonHeight
    390391chooser_ok=(prev.x2 + 10) prev.y prev.w prev.h
    391392
    392 
    393393[graphicsControls]
    394394gcx=(opXoffset + 10)
    395395gcw=(parent.w - gcx - 25)
     
    404404
    405405[audioControls]
    406406aux=(opXoffset + 10)
    407 auw=(parent.w - aux - 25)
    408 auMidiPopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2)
    409 opYoffset=(opYoffset + kLineHeight + 16)
    410 auSubtitlesCheckbox=aux opYoffset (kFontHeight + 10 + 102) buttonHeight
    411 opYoffset=(opYoffset + buttonHeight + 18)
     407auw=(parent.w - aux - 30)
     408auMidiPopup=(aux) (opYoffset - 1) (auw + 5) (kLineHeight + 2)
     409opYoffset=(opYoffset + buttonHeight + 4)
    412410
    413411[volumeControls]
    414 vctextw=95
    415 vcxoff=(vctextw + 15)
    416 vcMusicText=10 (opYoffset + 2) vctextw kLineHeight
     412vctextw=110
     413vcxoff=(opXoffset + vctextw + 10)
     414vcx=(opXoffset + 10)
     415vcMusicText=vcx (opYoffset + 2) vctextw kLineHeight
    417416vcMusicText.align=kTextAlignRight
    418417vcMusicSlider=vcxoff opYoffset sliderWidth sliderHeight
    419418vcMusicLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight
    420419opYoffset=(opYoffset + sliderHeight + 8)
    421 vcSfxText=10 (opYoffset + 2) vctextw kLineHeight
     420vcSfxText=vcx (opYoffset + 2) vctextw kLineHeight
    422421vcSfxText.align=kTextAlignRight
    423422vcSfxSlider=vcxoff opYoffset sliderWidth sliderHeight
    424423vcSfxLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight
    425424opYoffset=(opYoffset + sliderHeight + 8)
    426 vcSpeechText=10 (opYoffset + 2) vctextw kLineHeight
     425vcSpeechText=vcx (opYoffset + 2) vctextw kLineHeight
    427426vcSpeechText.align=kTextAlignRight
    428427vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight
    429428vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight
     
    442441mcGSCheckbox=mcx opYoffset (kFontHeight + 10 + 142) buttonHeight
    443442opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)
    444443
     444[subtitleControls]
     445sbx=(opXoffset + 10)
     446sbtextw=110
     447sbYoff=(buttonHeight / 8)
     448sbOff=((sliderHeight - kLineHeight) / 2)
     449opYoffset=(opYoffset + sbYoff)
     450subToggleDesc=sbx (opYoffset + sbYoff) sbtextw buttonHeight
     451subToggleButton=prev.x2 opYoffset (buttonWidth + 34) sliderHeight
     452opYoffset=(opYoffset + buttonHeight + 6)
     453subSubtitleSpeedDesc=sbx (opYoffset + sbOff) sbtextw kLineHeight
     454subSubtitleSpeedDesc.align=kTextAlignRight
     455subSubtitleSpeedSlider=prev.x2 opYoffset sliderWidth sliderHeight
     456subSubtitleSpeedLabel=(prev.x2 + 10) (opYoffset + sbOff) 24 kLineHeight
     457opYoffset=(opYoffset + sliderHeight + 8)
     458
    445459[scummmain]
    446460## Main dialog
    447461# note that scummmain size depends on overall height
  • gui/options.cpp

     
    5555// - music & graphics driver (but see also the comments on EditGameDialog
    5656//   for some techincal difficulties with this)
    5757// - default volumes (sfx/speech/music)
    58 // - aspect ratio, language, platform, subtitles, debug mode/level, cd drive, joystick, multi midi, native mt32
     58// - aspect ratio, language, platform, debug mode/level, cd drive, joystick, multi midi, native mt32
    5959
    6060enum {
    6161        kMusicVolumeChanged             = 'muvc',
    6262        kSfxVolumeChanged               = 'sfvc',
     63        kSubtitleToggle                 = 'sttg',
     64        kSubtitleSpeedChanged   = 'stsc',
    6365        kSpeechVolumeChanged    = 'vcvc',
    6466        kChooseSoundFontCmd             = 'chsf',
    6567        kChooseSaveDirCmd               = 'chos',
     
    8385        init();
    8486}
    8587
     88const char *OptionsDialog::_subModeDesc[] = {
     89        "Speech Only",
     90        "Speech and Subtitles",
     91        "Subtitles Only"
     92};
     93
    8694void OptionsDialog::init() {
    8795        _enableGraphicSettings = false;
    8896        _gfxPopUp = 0;
     
    9098        _fullscreenCheckbox = 0;
    9199        _aspectCheckbox = 0;
    92100        _enableAudioSettings = false;
    93         _subCheckbox = 0;
    94101        _midiPopUp = 0;
    95102        _enableMIDISettings = false;
    96103        _multiMidiCheckbox = 0;
    97104        _mt32Checkbox = 0;
    98105        _enableGSCheckbox = 0;
    99106        _enableVolumeSettings = false;
     107        _musicVolumeDesc = 0;
    100108        _musicVolumeSlider = 0;
    101109        _musicVolumeLabel = 0;
     110        _sfxVolumeDesc = 0;
    102111        _sfxVolumeSlider = 0;
    103112        _sfxVolumeLabel = 0;
     113        _speechVolumeDesc = 0;
    104114        _speechVolumeSlider = 0;
    105115        _speechVolumeLabel = 0;
     116        _subToggleDesc = 0;
     117        _subToggleButton = 0;
     118        _subSpeedDesc = 0;
     119        _subSpeedSlider = 0;
     120        _subSpeedLabel = 0;
    106121}
    107122
    108123void OptionsDialog::open() {
     
    111126        // Reset result value
    112127        setResult(0);
    113128
     129        // Graphic options
    114130        if (_fullscreenCheckbox) {
    115131                _gfxPopUp->setSelected(0);
    116132
     
    150166#endif
    151167        }
    152168
    153         if (_subCheckbox) {
     169        // Audio options
     170        if (_midiPopUp) {
    154171                // Music driver
    155172                const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers();
    156173                int i = 0;
     
    163180                        md++;
    164181                }
    165182                _midiPopUp->setSelected(md->name ? i : 0);
    166 
    167                 // Subtitles setting
    168                 _subCheckbox->setState(ConfMan.getBool("subtitles", _domain));
    169183        }
    170184
    171185        if (_multiMidiCheckbox) {
     
    202216                _speechVolumeSlider->setValue(vol);
    203217                _speechVolumeLabel->setValue(vol);
    204218        }
     219
     220        // Subtitle options
     221        if (_subToggleButton) {
     222                int speed;
     223                int sliderMaxValue = _subSpeedSlider->getMaxValue();
     224
     225                _subMode = getSubtitleMode(ConfMan.getBool("subtitles", _domain), ConfMan.getBool("speech_mute"));
     226                _subToggleButton->setLabel(_subModeDesc[_subMode]);
     227
     228                // Engines that reuse the subtitle speed widget set their own max value.
     229                // Scale the config value accordingly (see addSubtitleControls)
     230                speed = ConfMan.getInt("talkspeed", _domain);
     231                if (speed != 0)
     232                        if (speed == 255)
     233                                speed = sliderMaxValue;
     234                        else if (sliderMaxValue != 255)
     235                                speed = (int)(speed * (sliderMaxValue / 255.0) + 0.5);
     236
     237                _subSpeedSlider->setValue(speed);
     238                _subSpeedLabel->setValue(speed);
     239        }
    205240}
    206241
    207242void OptionsDialog::close() {
    208243        if (getResult()) {
     244
     245                // Graphic options
    209246                if (_fullscreenCheckbox) {
    210247                        if (_enableGraphicSettings) {
    211248                                ConfMan.setBool("fullscreen", _fullscreenCheckbox->getState(), _domain);
     
    224261                        }
    225262                }
    226263
     264                // Volume options
    227265                if (_musicVolumeSlider) {
    228266                        if (_enableVolumeSettings) {
    229267                                ConfMan.setInt("music_volume", _musicVolumeSlider->getValue(), _domain);
     
    236274                        }
    237275                }
    238276
    239                 if (_subCheckbox) {
     277                // Audio options
     278                if (_midiPopUp) {
    240279                        if (_enableAudioSettings) {
    241                                 ConfMan.setBool("subtitles", _subCheckbox->getState(), _domain);
    242280                                const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers();
    243281                                while (md->name && md->id != (int)_midiPopUp->getSelectedTag())
    244282                                        md++;
     
    248286                                        ConfMan.removeKey("music_driver", _domain);
    249287                        } else {
    250288                                ConfMan.removeKey("music_driver", _domain);
    251                                 ConfMan.removeKey("subtitles", _domain);
    252289                        }
    253290                }
    254291
     
    270307                        }
    271308                }
    272309
     310                // Subtitle options
     311                if (_subToggleButton) {
     312                        if (_enableSubtitleSettings) {
     313                                bool subtitles, speech_mute;
     314                                int talkspeed;
     315                                int sliderMaxValue = _subSpeedSlider->getMaxValue();
     316
     317                                switch (_subMode) {
     318                                case 0:
     319                                        subtitles = speech_mute = false;
     320                                        break;
     321                                case 1:
     322                                        subtitles = true;
     323                                        speech_mute = false;
     324                                        break;
     325                                case 2:
     326                                default:
     327                                        subtitles = speech_mute = true;
     328                                        break;
     329                                }
     330
     331                                ConfMan.setBool("subtitles", subtitles, _domain);
     332                                ConfMan.setBool("speech_mute", speech_mute, _domain);
     333
     334                                // Engines that reuse the subtitle speed widget set their own max value.
     335                                // Scale the config value accordingly (see addSubtitleControls)
     336                                talkspeed = _subSpeedSlider->getValue();
     337                                if (talkspeed != 0)
     338                                        if (talkspeed == sliderMaxValue)
     339                                                talkspeed = 255;
     340                                        else if (sliderMaxValue != 255)
     341                                                talkspeed = (int)(talkspeed / (sliderMaxValue / 255.0) + 0.5);
     342                                ConfMan.setInt("talkspeed", talkspeed, _domain);
     343
     344                        } else {
     345                                ConfMan.removeKey("subtitles", _domain);
     346                                ConfMan.removeKey("talkspeed", _domain);
     347                                ConfMan.removeKey("speech_mute", _domain);
     348                        }
     349                }
     350
    273351                // Save config file
    274352                ConfMan.flushToDisk();
    275353        }
     
    291369                _speechVolumeLabel->setValue(_speechVolumeSlider->getValue());
    292370                _speechVolumeLabel->draw();
    293371                break;
     372        case kSubtitleToggle:
     373                if (_subMode < 2)
     374                        _subMode++;
     375                else
     376                        _subMode = 0;   
     377
     378                _subToggleButton->setLabel(_subModeDesc[_subMode]);
     379                _subToggleButton->draw();
     380                _subSpeedDesc->draw();
     381                _subSpeedSlider->draw();
     382                _subSpeedLabel->draw();
     383                break;
     384        case kSubtitleSpeedChanged:
     385                _subSpeedLabel->setValue(_subSpeedSlider->getValue());
     386                _subSpeedLabel->draw();
     387                break;
    294388        case kOKCmd:
    295389                setResult(1);
    296390                close();
     
    315409        _enableAudioSettings = enabled;
    316410
    317411        _midiPopUp->setEnabled(enabled);
    318         _subCheckbox->setEnabled(enabled);
    319412}
    320413
    321414void OptionsDialog::setMIDISettingsState(bool enabled) {
     
    331424void OptionsDialog::setVolumeSettingsState(bool enabled) {
    332425        _enableVolumeSettings = enabled;
    333426
     427        _musicVolumeDesc->setEnabled(enabled);
    334428        _musicVolumeSlider->setEnabled(enabled);
    335429        _musicVolumeLabel->setEnabled(enabled);
     430        _sfxVolumeDesc->setEnabled(enabled);
    336431        _sfxVolumeSlider->setEnabled(enabled);
    337432        _sfxVolumeLabel->setEnabled(enabled);
     433        _speechVolumeDesc->setEnabled(enabled);
    338434        _speechVolumeSlider->setEnabled(enabled);
    339435        _speechVolumeLabel->setEnabled(enabled);
    340436}
    341437
     438void OptionsDialog::setSubtitleSettingsState(bool enabled) {
     439        _enableSubtitleSettings = enabled;
     440
     441        _subToggleButton->setEnabled(enabled);
     442        _subToggleDesc->setEnabled(enabled);
     443        _subSpeedDesc->setEnabled(enabled);
     444        _subSpeedSlider->setEnabled(enabled);
     445        _subSpeedLabel->setEnabled(enabled);
     446}
     447
    342448void OptionsDialog::addGraphicControls(GuiObject *boss, String prefix) {
    343449        const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
    344450
     
    391497                md++;
    392498        }
    393499
    394         // Subtitles on/off
    395         _subCheckbox = new CheckboxWidget(boss, prefix + "auSubtitlesCheckbox", "Display subtitles", 0, 0);
    396 
    397500        _enableAudioSettings = true;
    398501}
    399502
     
    414517        _enableMIDISettings = true;
    415518}
    416519
     520// The function has an extra slider range parameter, since both the launcher and SCUMM engine
     521// make use of the widgets. The launcher range is 0-255. SCUMM's 0-9
     522void OptionsDialog::addSubtitleControls(GuiObject *boss, String prefix, int maxSliderVal) {
     523
     524        _subToggleDesc = new StaticTextWidget(boss, prefix + "subToggleDesc", "Text and Speech:");
     525        _subToggleButton = new ButtonWidget(boss, prefix + "subToggleButton", "", kSubtitleToggle, 0);
     526
     527        // Subtitle speed
     528        _subSpeedDesc = new StaticTextWidget(boss, prefix + "subSubtitleSpeedDesc", "Subtitle speed:");
     529        _subSpeedSlider = new SliderWidget(boss, prefix + "subSubtitleSpeedSlider", kSubtitleSpeedChanged);
     530        _subSpeedLabel = new StaticTextWidget(boss, prefix + "subSubtitleSpeedLabel", "100%");
     531        _subSpeedSlider->setMinValue(0); _subSpeedSlider->setMaxValue(maxSliderVal);
     532        _subSpeedLabel->setFlags(WIDGET_CLEARBG);
     533
     534        _enableSubtitleSettings = true;
     535}
     536
    417537void OptionsDialog::addVolumeControls(GuiObject *boss, String prefix) {
    418         const char *slider_labels[] = {
    419                 "Music volume:",
    420                 "SFX volume:",
    421                 "Speech volume:"
    422         };
    423538
    424539        // Volume controllers
    425         new StaticTextWidget(boss, prefix + "vcMusicText", slider_labels[0]);
     540        _musicVolumeDesc = new StaticTextWidget(boss, prefix + "vcMusicText", "Music volume:");
    426541        _musicVolumeSlider = new SliderWidget(boss, prefix + "vcMusicSlider", kMusicVolumeChanged);
    427542        _musicVolumeLabel = new StaticTextWidget(boss, prefix + "vcMusicLabel", "100%");
    428543        _musicVolumeSlider->setMinValue(0);
    429544        _musicVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume);
    430545        _musicVolumeLabel->setFlags(WIDGET_CLEARBG);
    431546
    432         new StaticTextWidget(boss, prefix + "vcSfxText", slider_labels[1]);
     547        _sfxVolumeDesc = new StaticTextWidget(boss, prefix + "vcSfxText", "SFX volume:");
    433548        _sfxVolumeSlider = new SliderWidget(boss, prefix + "vcSfxSlider", kSfxVolumeChanged);
    434549        _sfxVolumeLabel = new StaticTextWidget(boss, prefix + "vcSfxLabel", "100%");
    435550        _sfxVolumeSlider->setMinValue(0);
    436551        _sfxVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume);
    437552        _sfxVolumeLabel->setFlags(WIDGET_CLEARBG);
    438553
    439         new StaticTextWidget(boss, prefix + "vcSpeechText" , slider_labels[2]);
     554        _speechVolumeDesc = new StaticTextWidget(boss, prefix + "vcSpeechText" , "Speech volume:");
    440555        _speechVolumeSlider = new SliderWidget(boss, prefix + "vcSpeechSlider", kSpeechVolumeChanged);
    441556        _speechVolumeLabel = new StaticTextWidget(boss, prefix + "vcSpeechLabel", "100%");
    442557        _speechVolumeSlider->setMinValue(0);
     
    446561        _enableVolumeSettings = true;
    447562}
    448563
     564int OptionsDialog::getSubtitleMode(bool subtitles, bool speech_mute) {
     565        if (!subtitles && !speech_mute) // Speech only
     566                return 0;
     567        else if (subtitles && !speech_mute) // Speech and subtitles
     568                return 1;
     569        else if (subtitles && speech_mute) // Subtitles only
     570                return 2;
     571        else
     572                warning("Wrong configuration: Both subtitles and speech are off. Assuming subtitles only");
     573        return 2;
     574}
     575
    449576void OptionsDialog::handleScreenChanged() {
    450577        Dialog::handleScreenChanged();
    451578
     
    481608        tab->addTab("Audio");
    482609        addAudioControls(tab, "globaloptions_");
    483610        addVolumeControls(tab, "globaloptions_");
     611        addSubtitleControls(tab, "globaloptions_");
     612
    484613        // TODO: cd drive setting
    485614
    486615        //
  • gui/launcher.cpp

     
    189189                _platformPopUp->appendEntry(p->description, p->id);
    190190        }
    191191
     192        //
    192193        // 2) The 'Path' tab
     194        //
    193195        tab->addTab("Paths");
    194196
    195197        // These buttons have to be extra wide, or the text will be truncated
     
    230232        _globalAudioOverride = new CheckboxWidget(tab, "gameoptions_audioCheckbox", "Override global audio settings", kCmdGlobalAudioOverride, 0);
    231233
    232234        addAudioControls(tab, "gameoptions_");
     235        addSubtitleControls(tab, "gameoptions_");
    233236
    234237        //
    235238        // 5) The MIDI tab
     
    249252
    250253        addVolumeControls(tab, "gameoptions_");
    251254
    252 
    253255        // Activate the first tab
    254256        tab->setActiveTab(0);
    255257
     
    271273        _globalGraphicsOverride->setState(e);
    272274
    273275        e = ConfMan.hasKey("music_driver", _domain) ||
    274                 ConfMan.hasKey("subtitles", _domain);
     276                ConfMan.hasKey("subtitles", _domain) ||
     277                ConfMan.hasKey("talkspeed", _domain);
    275278        _globalAudioOverride->setState(e);
    276279
    277280        e = ConfMan.hasKey("multi_midi", _domain) ||
     
    346349                break;
    347350        case kCmdGlobalAudioOverride:
    348351                setAudioSettingsState(data != 0);
     352                setSubtitleSettingsState(data != 0);
    349353                draw();
    350354                break;
    351355        case kCmdGlobalMIDIOverride:
     
    356360                setVolumeSettingsState(data != 0);
    357361                draw();
    358362                break;
    359 
    360363        case kCmdChooseSoundFontCmd: {
    361364                BrowserDialog browser("Select SoundFont", false);
    362365
  • gui/theme-config.cpp

     
    5050"def_scummhelpX=5\n"
    5151"def_scummhelpW=(w - 2 * 5)\n"
    5252"def_midiControlsSpacing=1\n"
     53"def_vcAudioTabIndent=0\n"
    5354"use=XxY\n"
    5455"# Scumm Saveload dialog\n"
    5556"scummsaveload=8 8 (w - 2 * 8) (h - 16)\n"
     
    8586"def_scummhelpW=370\n"
    8687"def_scummhelpX=((w - scummhelpW) / 2)\n"
    8788"def_midiControlsSpacing=2\n"
     89"def_vcAudioTabIndent=10\n"
    8890"##### Widgets config\n"
    8991"ListWidget.leftPadding=4\n"
    9092"ListWidget.rightPadding=0\n"
     
    141143"\n"
    142144"# graphics tab\n"
    143145"opYoffset=vBorder\n"
     146"opXoffset=0\n"
    144147"useWithPrefix=graphicsControls globaloptions_\n"
    145148"\n"
    146149"# audio tab\n"
    147150"opYoffset=vBorder\n"
    148151"useWithPrefix=audioControls globaloptions_\n"
    149152"useWithPrefix=volumeControls globaloptions_\n"
     153"useWithPrefix=subtitleControls globaloptions_\n"
    150154"\n"
    151155"# MIDI tab\n"
    152156"opYoffset=vBorder\n"
     
    205209"\n"
    206210"# graphics tab\n"
    207211"opYoffset=vBorder\n"
     212"opXoffset=gox\n"
    208213"gameoptions_graphicsCheckbox=gox opYoffset (kFontHeight + 10 + 192) buttonHeight\n"
    209214"opYoffset=(opYoffset + buttonHeight)\n"
    210215"useWithPrefix=graphicsControls gameoptions_\n"
     
    214219"gameoptions_audioCheckbox=gox opYoffset (kFontHeight + 10 + 180) buttonHeight\n"
    215220"opYoffset=(opYoffset + buttonHeight)\n"
    216221"useWithPrefix=audioControls gameoptions_\n"
     222"useWithPrefix=subtitleControls gameoptions_\n"
    217223"\n"
    218224"# midi tab\n"
    219225"opYoffset=vBorder\n"
     
    251257"# hence it is on the end of the list\n"
    252258"opYoffset=8\n"
    253259"useWithPrefix=volumeControls scummconfig_\n"
    254 "scummconfig_subtitlesCheckbox=15 opYoffset (kFontHeight + 10 + 89) buttonHeight\n"
     260"useWithPrefix=subtitleControls scummconfig_\n"
    255261"opYoffset=(opYoffset + buttonHeight)\n"
    256 "scummconfig_speechCheckbox=prev.x opYoffset (kFontHeight + 10 + 85) buttonHeight\n"
    257262"opYoffset=(opYoffset + buttonHeight + 4)\n"
    258263"soWidth=(8 + 3 * buttonWidth + 4)\n"
    259264"scummconfig_keys=(soWidth - 3 * (buttonWidth + 4) + 6) opYoffset (buttonWidth - 10) buttonHeight\n"
     
    299304"chooser_cancel=(chooserW - 2 * (buttonWidth + 10)) (opHeight - buttonHeight - 8) buttonWidth buttonHeight\n"
    300305"chooser_ok=(prev.x2 + 10) prev.y prev.w prev.h\n"
    301306"\n"
    302 "\n"
    303307"[graphicsControls]\n"
    304308"gcx=10\n"
    305309"gcw=(parent.w - 2 * 10)\n"
     
    316320"aux=10\n"
    317321"auw=(parent.w - 2 * 10)\n"
    318322"auMidiPopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2)\n"
    319 "opYoffset=(opYoffset + kLineHeight + 4)\n"
    320 "auSubtitlesCheckbox=aux opYoffset (kFontHeight + 10 + 102) buttonHeight\n"
    321 "opYoffset=(opYoffset + buttonHeight + 18)\n"
     323"opYoffset=(opYoffset + buttonHeight + 4)\n"
    322324"\n"
    323325"[volumeControls]\n"
    324 "vctextw=95\n"
    325 "vcxoff=(vctextw + 15)\n"
    326 "vcMusicText=10 (opYoffset + 2) vctextw kLineHeight\n"
     326"vctextw=(95 + vcAudioTabIndent)\n"
     327"vcxoff=(opXoffset + vctextw + 15)\n"
     328"vcx=(opXoffset + 10)\n"
     329"vcMusicText=vcx (opYoffset + 2) vctextw kLineHeight\n"
    327330"vcMusicText.align=kTextAlignRight\n"
    328331"vcMusicSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
    329332"vcMusicLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
    330333"opYoffset=(opYoffset + sliderHeight + 4)\n"
    331 "vcSfxText=10 (opYoffset + 2) vctextw kLineHeight\n"
     334"vcSfxText=vcx (opYoffset + 2) vctextw kLineHeight\n"
    332335"vcSfxText.align=kTextAlignRight\n"
    333336"vcSfxSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
    334337"vcSfxLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
    335338"opYoffset=(opYoffset + sliderHeight + 4)\n"
    336 "vcSpeechText=10 (opYoffset + 2) vctextw kLineHeight\n"
     339"vcSpeechText=vcx (opYoffset + 2) vctextw kLineHeight\n"
    337340"vcSpeechText.align=kTextAlignRight\n"
    338341"vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
    339342"vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
     
    351354"mcGSCheckbox=mcx opYoffset (kFontHeight + 10 + 142) buttonHeight\n"
    352355"opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)\n"
    353356"\n"
     357"[subtitleControls]\n"
     358"sbx=(opXoffset + 10)\n"
     359"sbYoff=(buttonHeight / 8)\n"
     360"sbOff=((sliderHeight - kLineHeight) / 2 + 2)\n"
     361"sbtextw=(100 + vcAudioTabIndent)\n"
     362"opYoffset=(opYoffset + sbYoff)\n"
     363"subToggleDesc=sbx (opYoffset + sbYoff) sbtextw buttonHeight\n"
     364"subToggleButton=prev.x2 (opYoffset - sbYoff) (buttonWidth + 54) buttonHeight\n"
     365"opYoffset=(opYoffset + buttonHeight + 6)\n"
     366"subSubtitleSpeedDesc=sbx (opYoffset + sbOff) sbtextw kLineHeight\n"
     367"subSubtitleSpeedDesc.align=kTextAlignRight\n"
     368"subSubtitleSpeedSlider=prev.x2 opYoffset sliderWidth sliderHeight\n"
     369"subSubtitleSpeedLabel=(prev.x2 + 10) (opYoffset + sbOff) 24 kLineHeight\n"
     370"opYoffset=(opYoffset + sliderHeight + 8)\n"
     371"\n"
    354372"[scummmain]\n"
    355373"## Main dialog\n"
    356374"# note that scummmain size depends on overall height\n"
  • engines/scumm/input.cpp

     
    445445                // Display the talk speed
    446446                ValueDisplayDialog dlg("Text speed: ", 0, 9, 9 - _defaultTalkDelay, '+', '-');
    447447                _defaultTalkDelay = 9 - runDialog(dlg);
     448               
     449                // Save the new talkspeed value to ConfMan
     450                setEngineTalkspeed(9 - _defaultTalkDelay);
    448451
    449452                if (VAR_CHARINC != 0xFF)
    450453                        VAR(VAR_CHARINC) = _defaultTalkDelay;
  • engines/scumm/dialogs.cpp

     
    608608#pragma mark -
    609609
    610610enum {
    611         kOKCmd                                  = 'ok  '
     611        kOKCmd = 'ok  '
    612612};
    613613
    614614enum {
     
    653653        // Some misc options
    654654        //
    655655
    656         _subtitlesCheckbox = new GUI::CheckboxWidget(this, "scummconfig_subtitlesCheckbox", "Show subtitles", 0, 'S');
    657         _speechCheckbox = new GUI::CheckboxWidget(this, "scummconfig_speechCheckbox", "Enable speech", 0, 'E');
     656        // SCUMM has a talkspeed range of 0-9
     657        addSubtitleControls(this, "scummconfig_", 9);
    658658
    659659        //
    660660        // Add the buttons
     
    683683
    684684void ConfigDialog::open() {
    685685        GUI_OptionsDialog::open();
    686 
    687         // update checkboxes, too
    688         _subtitlesCheckbox->setState(ConfMan.getBool("subtitles", _domain));
    689         _speechCheckbox->setState(!ConfMan.getBool("speech_mute", _domain));
    690686}
    691687
    692688void ConfigDialog::close() {
    693         if (getResult()) {
    694                 // Subtitles
    695                 ConfMan.setBool("subtitles", _subtitlesCheckbox->getState(), _domain);
    696                 ConfMan.setBool("speech_mute", !_speechCheckbox->getState(), _domain);
    697         }
    698 
    699689        GUI_OptionsDialog::close();
    700690}
    701691
     
    927917}
    928918
    929919void ValueDisplayDialog::handleTickle() {
    930         if (getMillis() > _timer)
     920        if (getMillis() > _timer) {
    931921                close();
     922        }
    932923}
    933924
    934925void ValueDisplayDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
  • engines/scumm/scumm.cpp

     
    498498        VAR_SOUNDPARAM3 = 0xFF;
    499499        VAR_MOUSEPRESENT = 0xFF;
    500500        VAR_MEMORY_PERFORMANCE = 0xFF;
     501
     502        // Set scumm's 0-9 talkspeed scale in relation to the engine's 0-255
     503        _talkspeedScale = 9.0 / 255.0;
     504
     505        if (ConfMan.hasKey("talkspeed")) {
     506                _defaultTalkDelay = 9 - getEngineTalkspeed();
     507                VAR_CHARINC = _defaultTalkDelay;
     508        }
     509
    501510        VAR_VIDEO_PERFORMANCE = 0xFF;
    502511        VAR_ROOM_FLAG = 0xFF;
    503512        VAR_GAME_LOADED = 0xFF;
     
    14891498        _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
    14901499        _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech);
    14911500
    1492 
    14931501        if (ConfMan.getBool("speech_mute"))
    14941502                _voiceMode = 2;
    14951503        else
     
    14971505
    14981506        if (VAR_VOICE_MODE != 0xFF)
    14991507                VAR(VAR_VOICE_MODE) = _voiceMode;
     1508
     1509        _defaultTalkDelay = 9 - getEngineTalkspeed();
     1510        VAR(VAR_CHARINC) = _defaultTalkDelay;
    15001511}
    15011512
     1513void ScummEngine::setEngineTalkspeed(int talkspeed) {
     1514        if (talkspeed != 0)
     1515                if (talkspeed == 9)
     1516                        talkspeed = 255;
     1517                else
     1518                        talkspeed = (int)(talkspeed / _talkspeedScale + 0.5);
     1519        ConfMan.setInt("talkspeed", talkspeed);
     1520}
    15021521
     1522int ScummEngine::getEngineTalkspeed() {
     1523        int talkspeed = ConfMan.getInt("talkspeed");
    15031524
     1525        if (talkspeed != 0)
     1526                if (talkspeed == 255)
     1527                        talkspeed = 9;
     1528                else
     1529                        talkspeed = (int)(talkspeed * _talkspeedScale + 0.5);
     1530        return talkspeed;
     1531}
     1532
     1533
    15041534#pragma mark -
    15051535#pragma mark --- Main loop ---
    15061536#pragma mark -
  • engines/scumm/dialogs.h

     
    140140        virtual void open();
    141141        virtual void close();
    142142        virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
    143 
    144 protected:
    145         GUI::CheckboxWidget *_subtitlesCheckbox;
    146         GUI::CheckboxWidget *_speechCheckbox;
    147143};
    148144
    149145/**
  • engines/scumm/scumm.h

     
    470470        void loadCJKFont();
    471471        void setupMusic(int midi);
    472472        void updateSoundSettings();
     473        void setEngineTalkspeed(int talkspeed);
     474        int getEngineTalkspeed();
     475        float _talkspeedScale;
    473476
    474477protected:
    475478        // Scumm main loop & helper functions.
  • engines/scumm/script_v8.cpp

     
    420420                checkRange(_numVariables - 1, 0, var, "Variable %d out of range(w)");
    421421
    422422                if (var == VAR_CHARINC && ConfMan.hasKey("talkspeed")) {
    423                         uint talkspeed = ConfMan.getInt("talkspeed");
     423                        uint talkspeed = getEngineTalkspeed();
    424424                        if (talkspeed <= 9)
    425425                                VAR(VAR_CHARINC) = talkspeed;
    426426                } else
  • engines/scumm/script.cpp

     
    617617                }
    618618
    619619                if (var == VAR_CHARINC && ConfMan.hasKey("talkspeed")) {
    620                         uint talkspeed = ConfMan.getInt("talkspeed");
     620                        uint talkspeed = getEngineTalkspeed();
    621621                        if (talkspeed <= 9)
    622622                                VAR(VAR_CHARINC) = talkspeed;
    623623                } else {
  • engines/queen/queen.cpp

     
    447447
    448448        _sound = Sound::giveSound(_mixer, this, _resource->compression());
    449449        _walk = new Walk(this);
     450        ConfMan.setTalkspeedScale(QueenEngine::MIN_TEXT_SPEED, QueenEngine::MAX_TEXT_SPEED);
    450451
    451452        registerDefaultSettings();
    452453        readOptionSettings();
  • engines/queen/journal.cpp

     
    310310                        enterYesNoPanelMode(zoneNum, TXT_GIVE_UP);
    311311                        break;
    312312                case ZN_TEXT_SPEED:
    313                          val = (x - 136) * QueenEngine::MAX_TEXT_SPEED / (266 - 136);
     313                        val = (x - 136) * QueenEngine::MAX_TEXT_SPEED / (266 - 136);
    314314                        _vm->talkSpeed(val);
    315315                        drawConfigPanel();
    316316                        break;
  • common/config-manager.h

     
    151151        void                            renameGameDomain(const String &oldName, const String &newName);
    152152        bool                            hasGameDomain(const String &domName) const;
    153153        const DomainMap &       getGameDomains() const { return _gameDomains; }
    154        
     154        void                            setTalkspeedScale(int minValue, int maxValue);
     155
    155156/*
    156157        TODO: Callback/change notification system
    157158        typedef void (*ConfigCallback)(const ConstString &key, void *refCon);
     
    177178        String                  _activeDomainName;
    178179        Domain *                _activeDomain;
    179180
     181        float                   _talkspeedScale;
     182        int                             _talkspeedMinEngineValue;
     183        int                             _talkspeedMaxEngineValue;
    180184        String                  _filename;
    181185};
    182186
  • common/config-manager.cpp

     
    8080
    8181ConfigManager::ConfigManager()
    8282 : _activeDomain(0) {
     83
     84        // When in the launcher, setTalkSpeedScale() isn't called by any engine.
     85        // talkspeed values won't be scaled
     86        _talkspeedMinEngineValue = 0;
     87        _talkspeedMaxEngineValue = 255;
     88        _talkspeedScale = 1.0;
    8389}
    8490
    8591
     
    433439                error("ConfigManager::getInt(%s,%s): '%s' is not a valid integer",
    434440                                        key.c_str(), domName.c_str(), errpos);
    435441
     442        // TalkSpeed values are given in the engine's scale.
     443        // They are saved on a 0-255 scale and need to be converted to the engine's scale
     444        if (key == String("talkspeed")) {
     445                if (ivalue == 0)
     446                        ivalue = _talkspeedMinEngineValue;
     447                else if (ivalue == 255)
     448                        ivalue = _talkspeedMaxEngineValue;
     449                else if (_talkspeedScale != 1.0)
     450                        ivalue = (int)(_talkspeedMinEngineValue + ivalue * _talkspeedScale + 0.5);
     451        }
     452
    436453        return ivalue;
    437454}
    438455
     
    510527}
    511528
    512529void ConfigManager::setInt(const String &key, int value, const String &domName) {
     530
     531        // TalkSpeed values are given in the engine's scale.
     532        // They are scaled back to a global 0-255 scale
     533        if (key == String("talkspeed")) {
     534                if (value == _talkspeedMinEngineValue)
     535                        value = 0;
     536                else if (value == _talkspeedMaxEngineValue)
     537                        value = 255;
     538                else if (_talkspeedScale != 1.0)
     539                        value = (int)((value - _talkspeedMinEngineValue) / _talkspeedScale + 0.5);
     540        }
     541
    513542        char tmp[128];
    514543        snprintf(tmp, sizeof(tmp), "%i", value);
    515544        set(key, String(tmp), domName);
     
    532561}
    533562
    534563void ConfigManager::registerDefault(const String &key, int value) {
     564        int scaledValue = value;
     565
     566        // TalkSpeed values are given in the engine's scale.
     567        // They are scaled back to a global 0-255 scale
     568        if (key == String("talkspeed")) {
     569                scaledValue = (int)((value - _talkspeedMinEngineValue) / _talkspeedScale + 0.5);
     570        }
     571
    535572        char tmp[128];
    536         snprintf(tmp, sizeof(tmp), "%i", value);
     573        snprintf(tmp, sizeof(tmp), "%i", scaledValue);
    537574        registerDefault(key, tmp);
    538575}
    539576
     
    628665        return _keyValueComments.contains(key);
    629666}
    630667
     668void ConfigManager::setTalkspeedScale(int minValue, int maxValue) {
     669        _talkspeedMinEngineValue = minValue;
     670        _talkspeedMaxEngineValue = maxValue;
     671        _talkspeedScale = (maxValue - minValue) / 255.0;
     672}
     673
    631674}       // End of namespace Common