Ticket #8385: subtitles-new-fixed.patch

File subtitles-new-fixed.patch, 29.4 KB (added by salty-horse, 18 years ago)

Fixed small talkspeed=255 bug

  • gui/options.h

     
    6464        void addAudioControls(GuiObject *boss, String prefix);
    6565        void addMIDIControls(GuiObject *boss, String prefix);
    6666        void addVolumeControls(GuiObject *boss, String prefix);
     67        // The default value is the launcher's non-scaled talkspeed value. When SCUMM uses the widget,
     68        // it uses its own scale
     69        void addSubtitleControls(GuiObject *boss, String prefix, int maxSliderVal = 255);
    6770
    6871        void setGraphicSettingsState(bool enabled);
    6972        void setAudioSettingsState(bool enabled);
    7073        void setMIDISettingsState(bool enabled);
    7174        void setVolumeSettingsState(bool enabled);
     75        void setSubtitleSettingsState(bool enabled);
    7276
    7377private:
    7478        //
     
    8589        //
    8690        bool _enableAudioSettings;
    8791        PopUpWidget *_midiPopUp;
    88         CheckboxWidget *_subCheckbox;
    8992
    9093        //
    9194        // MIDI controls
     
    9497        CheckboxWidget *_multiMidiCheckbox;
    9598        CheckboxWidget *_mt32Checkbox;
    9699        CheckboxWidget *_enableGSCheckbox;
     100       
     101        //
     102        // Subtitle controls
     103        //
     104        int getSubtitleMode(bool subtitles, bool speech_mute);
     105        bool _enableSubtitleSettings;
     106        StaticTextWidget *_subToggleDesc;
     107        ButtonWidget *_subToggleButton;
     108        int _subMode;
     109        static const char *_subModeDesc[];
     110        StaticTextWidget *_subSpeedDesc;
     111        SliderWidget *_subSpeedSlider;
     112        StaticTextWidget *_subSpeedLabel;
    97113
    98114        //
    99115        // Volume controls
    100116        //
    101117        bool _enableVolumeSettings;
    102118
     119        StaticTextWidget *_musicVolumeDesc;
    103120        SliderWidget *_musicVolumeSlider;
    104121        StaticTextWidget *_musicVolumeLabel;
    105122
     123        StaticTextWidget *_sfxVolumeDesc;
    106124        SliderWidget *_sfxVolumeSlider;
    107125        StaticTextWidget *_sfxVolumeLabel;
    108126
     127        StaticTextWidget *_speechVolumeDesc;
    109128        SliderWidget *_speechVolumeSlider;
    110129        StaticTextWidget *_speechVolumeLabel;
    111130};
  • gui/themes/modern.ini

     
    217217opYoffset=vBorder
    218218useWithPrefix=audioControls globaloptions_
    219219useWithPrefix=volumeControls globaloptions_
     220useWithPrefix=subtitleControls globaloptions_
    220221
    221222# MIDI tab
    222223opYoffset=vBorder
     
    285286gameoptions_audioCheckbox=gox opYoffset (kFontHeight + 10 + 180) buttonHeight
    286287opYoffset=(opYoffset + buttonHeight + 6)
    287288useWithPrefix=audioControls gameoptions_
     289useWithPrefix=subtitleControls gameoptions_
    288290
    289291# midi tab
    290292opYoffset=vBorder
     
    324326# hence it is on the end of the list
    325327opYoffset=8
    326328useWithPrefix=volumeControls scummconfig_
    327 scummconfig_subtitlesCheckbox=15 opYoffset (kFontHeight + 10 + 89) buttonHeight
     329useWithPrefix=subtitleControls scummconfig_
    328330opYoffset=(opYoffset + buttonHeight)
    329 scummconfig_speechCheckbox=prev.x opYoffset (kFontHeight + 10 + 85) buttonHeight
    330331opYoffset=(opYoffset + buttonHeight + 4)
    331332soWidth=(8 + 3 * buttonWidth + 4)
    332333scummconfig_keys=(soWidth - 3 * (buttonWidth + 4) + 6) opYoffset (buttonWidth - 10) buttonHeight
     
    373374chooser_cancel=(chooserW - 2 * (buttonWidth + 10)) (opHeight - buttonHeight - 8) buttonWidth buttonHeight
    374375chooser_ok=(prev.x2 + 10) prev.y prev.w prev.h
    375376
    376 
    377377[graphicsControls]
    378378gcx=(opXoffset + 10)
    379379gcw=(parent.w - gcx - 25)
     
    388388
    389389[audioControls]
    390390aux=(opXoffset + 10)
    391 auw=(parent.w - aux - 25)
    392 auMidiPopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2)
    393 opYoffset=(opYoffset + kLineHeight + 16)
    394 auSubtitlesCheckbox=aux opYoffset (kFontHeight + 10 + 102) buttonHeight
    395 opYoffset=(opYoffset + buttonHeight + 18)
     391auw=(parent.w - aux - 30)
     392auMidiPopup=(aux) (opYoffset - 1) (auw + 5) (kLineHeight + 2)
     393opYoffset=(opYoffset + buttonHeight + 4)
    396394
    397395[volumeControls]
    398 vctextw=95
    399 vcxoff=(vctextw + 15)
    400 vcMusicText=10 (opYoffset + 2) vctextw kLineHeight
     396vctextw=110
     397vcxoff=(opXoffset + vctextw + 10)
     398vcx=(opXoffset + 10)
     399vcMusicText=vcx (opYoffset + 2) vctextw kLineHeight
    401400vcMusicText.align=kTextAlignRight
    402401vcMusicSlider=vcxoff opYoffset sliderWidth sliderHeight
    403402vcMusicLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight
    404403opYoffset=(opYoffset + sliderHeight + 8)
    405 vcSfxText=10 (opYoffset + 2) vctextw kLineHeight
     404vcSfxText=vcx (opYoffset + 2) vctextw kLineHeight
    406405vcSfxText.align=kTextAlignRight
    407406vcSfxSlider=vcxoff opYoffset sliderWidth sliderHeight
    408407vcSfxLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight
    409408opYoffset=(opYoffset + sliderHeight + 8)
    410 vcSpeechText=10 (opYoffset + 2) vctextw kLineHeight
     409vcSpeechText=vcx (opYoffset + 2) vctextw kLineHeight
    411410vcSpeechText.align=kTextAlignRight
    412411vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight
    413412vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight
     
    426425mcGSCheckbox=mcx opYoffset (kFontHeight + 10 + 142) buttonHeight
    427426opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)
    428427
     428[subtitleControls]
     429sbx=(opXoffset + 10)
     430sbtextw=110
     431sbYoff=(buttonHeight / 8)
     432sbOff=((sliderHeight - kLineHeight) / 2)
     433opYoffset=(opYoffset + sbYoff)
     434subToggleDesc=sbx (opYoffset + sbYoff) sbtextw buttonHeight
     435subToggleButton=prev.x2 opYoffset (buttonWidth + 34) sliderHeight
     436opYoffset=(opYoffset + buttonHeight + 6)
     437subSubtitleSpeedDesc=sbx (opYoffset + sbOff) sbtextw kLineHeight
     438subSubtitleSpeedDesc.align=kTextAlignRight
     439subSubtitleSpeedSlider=prev.x2 opYoffset sliderWidth sliderHeight
     440subSubtitleSpeedLabel=(prev.x2 + 10) (opYoffset + sbOff) 24 kLineHeight
     441opYoffset=(opYoffset + sliderHeight + 8)
     442
    429443[scummmain]
    430444## Main dialog
    431445# 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                _subMode = getSubtitleMode(ConfMan.getBool("subtitles", _domain), ConfMan.getBool("speech_mute"));
     224                _subToggleButton->setLabel(_subModeDesc[_subMode]);
     225                speed = ConfMan.getInt("talkspeed", _domain);
     226                _subSpeedSlider->setValue(speed);
     227                _subSpeedLabel->setValue(speed);
     228        }
    205229}
    206230
    207231void OptionsDialog::close() {
    208232        if (getResult()) {
     233
     234                // Graphic options
    209235                if (_fullscreenCheckbox) {
    210236                        if (_enableGraphicSettings) {
    211237                                ConfMan.setBool("fullscreen", _fullscreenCheckbox->getState(), _domain);
     
    224250                        }
    225251                }
    226252
     253                // Volume options
    227254                if (_musicVolumeSlider) {
    228255                        if (_enableVolumeSettings) {
    229256                                ConfMan.setInt("music_volume", _musicVolumeSlider->getValue(), _domain);
     
    236263                        }
    237264                }
    238265
    239                 if (_subCheckbox) {
     266                // Audio options
     267                if (_midiPopUp) {
    240268                        if (_enableAudioSettings) {
    241                                 ConfMan.setBool("subtitles", _subCheckbox->getState(), _domain);
    242269                                const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers();
    243270                                while (md->name && md->id != (int)_midiPopUp->getSelectedTag())
    244271                                        md++;
     
    248275                                        ConfMan.removeKey("music_driver", _domain);
    249276                        } else {
    250277                                ConfMan.removeKey("music_driver", _domain);
    251                                 ConfMan.removeKey("subtitles", _domain);
    252278                        }
    253279                }
    254280
     
    270296                        }
    271297                }
    272298
     299                // Subtitle options
     300                if (_subToggleButton) {
     301                        if (_enableSubtitleSettings) {
     302                                bool subtitles, speech_mute;
     303
     304                                switch (_subMode) {
     305                                case 0:
     306                                        subtitles = speech_mute = false;
     307                                        break;
     308                                case 1:
     309                                        subtitles = true;
     310                                        speech_mute = false;
     311                                        break;
     312                                case 2:
     313                                default:
     314                                        subtitles = speech_mute = true;
     315                                        break;
     316                                }
     317
     318                                ConfMan.setBool("subtitles", subtitles, _domain);
     319                                ConfMan.setBool("speech_mute", speech_mute, _domain);
     320                                ConfMan.setInt("talkspeed", _subSpeedSlider->getValue(), _domain);
     321                        } else {
     322                                ConfMan.removeKey("subtitles", _domain);
     323                                ConfMan.removeKey("talkspeed", _domain);
     324                                ConfMan.removeKey("speech_mute", _domain);
     325                        }
     326                }
     327
    273328                // Save config file
    274329                ConfMan.flushToDisk();
    275330        }
     
    291346                _speechVolumeLabel->setValue(_speechVolumeSlider->getValue());
    292347                _speechVolumeLabel->draw();
    293348                break;
     349        case kSubtitleToggle:
     350                if (_subMode < 2)
     351                        _subMode++;
     352                else
     353                        _subMode = 0;   
     354
     355                _subToggleButton->setLabel(_subModeDesc[_subMode]);
     356                _subToggleButton->draw();
     357                _subSpeedDesc->draw();
     358                _subSpeedSlider->draw();
     359                _subSpeedLabel->draw();
     360                break;
     361        case kSubtitleSpeedChanged:
     362                _subSpeedLabel->setValue(_subSpeedSlider->getValue());
     363                _subSpeedLabel->draw();
     364                break;
    294365        case kOKCmd:
    295366                setResult(1);
    296367                close();
     
    315386        _enableAudioSettings = enabled;
    316387
    317388        _midiPopUp->setEnabled(enabled);
    318         _subCheckbox->setEnabled(enabled);
    319389}
    320390
    321391void OptionsDialog::setMIDISettingsState(bool enabled) {
     
    331401void OptionsDialog::setVolumeSettingsState(bool enabled) {
    332402        _enableVolumeSettings = enabled;
    333403
     404        _musicVolumeDesc->setEnabled(enabled);
    334405        _musicVolumeSlider->setEnabled(enabled);
    335406        _musicVolumeLabel->setEnabled(enabled);
     407        _sfxVolumeDesc->setEnabled(enabled);
    336408        _sfxVolumeSlider->setEnabled(enabled);
    337409        _sfxVolumeLabel->setEnabled(enabled);
     410        _speechVolumeDesc->setEnabled(enabled);
    338411        _speechVolumeSlider->setEnabled(enabled);
    339412        _speechVolumeLabel->setEnabled(enabled);
    340413}
    341414
     415void OptionsDialog::setSubtitleSettingsState(bool enabled) {
     416        _enableSubtitleSettings = enabled;
     417
     418        _subToggleButton->setEnabled(enabled);
     419        _subToggleDesc->setEnabled(enabled);
     420        _subSpeedDesc->setEnabled(enabled);
     421        _subSpeedSlider->setEnabled(enabled);
     422        _subSpeedLabel->setEnabled(enabled);
     423}
     424
    342425void OptionsDialog::addGraphicControls(GuiObject *boss, String prefix) {
    343426        const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
    344427
     
    391474                md++;
    392475        }
    393476
    394         // Subtitles on/off
    395         _subCheckbox = new CheckboxWidget(boss, prefix + "auSubtitlesCheckbox", "Display subtitles", 0, 0);
    396 
    397477        _enableAudioSettings = true;
    398478}
    399479
     
    414494        _enableMIDISettings = true;
    415495}
    416496
     497// The function has an extra slider range parameter, since both the launcher and SCUMM engine
     498// make use of the widgets. The launcher range is 0-255. SCUMM's 0-9
     499void OptionsDialog::addSubtitleControls(GuiObject *boss, String prefix, int maxSliderVal) {
     500
     501        _subToggleDesc = new StaticTextWidget(boss, prefix + "subToggleDesc", "Text and Speech:");
     502        _subToggleButton = new ButtonWidget(boss, prefix + "subToggleButton", "", kSubtitleToggle, 0);
     503
     504        // Subtitle speed
     505        _subSpeedDesc = new StaticTextWidget(boss, prefix + "subSubtitleSpeedDesc", "Subtitle speed:");
     506        _subSpeedSlider = new SliderWidget(boss, prefix + "subSubtitleSpeedSlider", kSubtitleSpeedChanged);
     507        _subSpeedLabel = new StaticTextWidget(boss, prefix + "subSubtitleSpeedLabel", "100%");
     508        _subSpeedSlider->setMinValue(0); _subSpeedSlider->setMaxValue(maxSliderVal);
     509        _subSpeedLabel->setFlags(WIDGET_CLEARBG);
     510
     511        _enableSubtitleSettings = true;
     512}
     513
    417514void OptionsDialog::addVolumeControls(GuiObject *boss, String prefix) {
    418         const char *slider_labels[] = {
    419                 "Music volume:",
    420                 "SFX volume:",
    421                 "Speech volume:"
    422         };
    423515
    424516        // Volume controllers
    425         new StaticTextWidget(boss, prefix + "vcMusicText", slider_labels[0]);
     517        _musicVolumeDesc = new StaticTextWidget(boss, prefix + "vcMusicText", "Music volume:");
    426518        _musicVolumeSlider = new SliderWidget(boss, prefix + "vcMusicSlider", kMusicVolumeChanged);
    427519        _musicVolumeLabel = new StaticTextWidget(boss, prefix + "vcMusicLabel", "100%");
    428520        _musicVolumeSlider->setMinValue(0);
    429521        _musicVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume);
    430522        _musicVolumeLabel->setFlags(WIDGET_CLEARBG);
    431523
    432         new StaticTextWidget(boss, prefix + "vcSfxText", slider_labels[1]);
     524        _sfxVolumeDesc = new StaticTextWidget(boss, prefix + "vcSfxText", "SFX volume:");
    433525        _sfxVolumeSlider = new SliderWidget(boss, prefix + "vcSfxSlider", kSfxVolumeChanged);
    434526        _sfxVolumeLabel = new StaticTextWidget(boss, prefix + "vcSfxLabel", "100%");
    435527        _sfxVolumeSlider->setMinValue(0);
    436528        _sfxVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume);
    437529        _sfxVolumeLabel->setFlags(WIDGET_CLEARBG);
    438530
    439         new StaticTextWidget(boss, prefix + "vcSpeechText" , slider_labels[2]);
     531        _speechVolumeDesc = new StaticTextWidget(boss, prefix + "vcSpeechText" , "Speech volume:");
    440532        _speechVolumeSlider = new SliderWidget(boss, prefix + "vcSpeechSlider", kSpeechVolumeChanged);
    441533        _speechVolumeLabel = new StaticTextWidget(boss, prefix + "vcSpeechLabel", "100%");
    442534        _speechVolumeSlider->setMinValue(0);
     
    446538        _enableVolumeSettings = true;
    447539}
    448540
     541int OptionsDialog::getSubtitleMode(bool subtitles, bool speech_mute) {
     542        if (!subtitles && !speech_mute) // Speech only
     543                return 0;
     544        else if (subtitles && !speech_mute) // Speech and subtitles
     545                return 1;
     546        else if (subtitles && speech_mute) // Subtitles only
     547                return 2;
     548        else
     549                warning("Wrong configuration: Both subtitles and speech are off. Assuming subtitles only");
     550        return 2;
     551}
     552
    449553#pragma mark -
    450554
    451555
     
    468572        tab->addTab("Audio");
    469573        addAudioControls(tab, "globaloptions_");
    470574        addVolumeControls(tab, "globaloptions_");
     575        addSubtitleControls(tab, "globaloptions_");
     576
    471577        // TODO: cd drive setting
    472578
    473579        //
  • 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"\n"
    5556"[XxY]\n"
     
    7677"def_scummhelpW=370\n"
    7778"def_scummhelpX=((w - scummhelpW) / 2)\n"
    7879"def_midiControlsSpacing=2\n"
     80"def_vcAudioTabIndent=10\n"
    7981"##### Widgets config\n"
    8082"ListWidget.leftPadding=4\n"
    8183"ListWidget.rightPadding=0\n"
     
    132134"\n"
    133135"# graphics tab\n"
    134136"opYoffset=vBorder\n"
     137"opXoffset=0\n"
    135138"useWithPrefix=graphicsControls globaloptions_\n"
    136139"\n"
    137140"# audio tab\n"
    138141"opYoffset=vBorder\n"
    139142"useWithPrefix=audioControls globaloptions_\n"
    140143"useWithPrefix=volumeControls globaloptions_\n"
     144"useWithPrefix=subtitleControls globaloptions_\n"
    141145"\n"
    142146"# MIDI tab\n"
    143147"opYoffset=vBorder\n"
     
    196200"\n"
    197201"# graphics tab\n"
    198202"opYoffset=vBorder\n"
     203"opXoffset=gox\n"
    199204"gameoptions_graphicsCheckbox=gox opYoffset (kFontHeight + 10 + 192) buttonHeight\n"
    200205"opYoffset=(opYoffset + buttonHeight)\n"
    201206"useWithPrefix=graphicsControls gameoptions_\n"
     
    205210"gameoptions_audioCheckbox=gox opYoffset (kFontHeight + 10 + 180) buttonHeight\n"
    206211"opYoffset=(opYoffset + buttonHeight)\n"
    207212"useWithPrefix=audioControls gameoptions_\n"
     213"useWithPrefix=subtitleControls gameoptions_\n"
    208214"\n"
    209215"# midi tab\n"
    210216"opYoffset=vBorder\n"
     
    242248"# hence it is on the end of the list\n"
    243249"opYoffset=8\n"
    244250"useWithPrefix=volumeControls scummconfig_\n"
    245 "scummconfig_subtitlesCheckbox=15 opYoffset (kFontHeight + 10 + 89) buttonHeight\n"
     251"useWithPrefix=subtitleControls scummconfig_\n"
    246252"opYoffset=(opYoffset + buttonHeight)\n"
    247 "scummconfig_speechCheckbox=prev.x opYoffset (kFontHeight + 10 + 85) buttonHeight\n"
    248253"opYoffset=(opYoffset + buttonHeight + 4)\n"
    249254"soWidth=(8 + 3 * buttonWidth + 4)\n"
    250255"scummconfig_keys=(soWidth - 3 * (buttonWidth + 4) + 6) opYoffset (buttonWidth - 10) buttonHeight\n"
     
    291296"chooser_cancel=(chooserW - 2 * (buttonWidth + 10)) (opHeight - buttonHeight - 8) buttonWidth buttonHeight\n"
    292297"chooser_ok=(prev.x2 + 10) prev.y prev.w prev.h\n"
    293298"\n"
    294 "\n"
    295299"[graphicsControls]\n"
    296300"gcx=10\n"
    297301"gcw=(parent.w - 2 * 10)\n"
     
    301305"opYoffset=(opYoffset + kLineHeight + 4)\n"
    302306"grFullscreenCheckbox=gcx opYoffset (kFontHeight + 10 + 96) buttonHeight\n"
    303307"opYoffset=(opYoffset + buttonHeight)\n"
    304 "grAspectCheckbox=prev.x opYoffset (kFontHeight + 10 + 136) prev.h\n"
     308"grAspectCheckbox=prev.x opYoffset (kFontHeight + 10 + 140) prev.h\n"
    305309"opYoffset=(opYoffset + buttonHeight)\n"
    306310"\n"
    307311"[audioControls]\n"
    308312"aux=10\n"
    309313"auw=(parent.w - 2 * 10)\n"
    310314"auMidiPopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2)\n"
    311 "opYoffset=(opYoffset + kLineHeight + 4)\n"
    312 "auSubtitlesCheckbox=aux opYoffset (kFontHeight + 10 + 102) buttonHeight\n"
    313 "opYoffset=(opYoffset + buttonHeight + 18)\n"
     315"opYoffset=(opYoffset + buttonHeight + 4)\n"
    314316"\n"
    315317"[volumeControls]\n"
    316 "vctextw=95\n"
    317 "vcxoff=(vctextw + 15)\n"
    318 "vcMusicText=10 (opYoffset + 2) vctextw kLineHeight\n"
     318"vctextw=(95 + vcAudioTabIndent)\n"
     319"vcxoff=(opXoffset + vctextw + 15)\n"
     320"vcx=(opXoffset + 10)\n"
     321"vcMusicText=vcx (opYoffset + 2) vctextw kLineHeight\n"
    319322"vcMusicText.align=kTextAlignRight\n"
    320323"vcMusicSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
    321324"vcMusicLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
    322325"opYoffset=(opYoffset + sliderHeight + 4)\n"
    323 "vcSfxText=10 (opYoffset + 2) vctextw kLineHeight\n"
     326"vcSfxText=vcx (opYoffset + 2) vctextw kLineHeight\n"
    324327"vcSfxText.align=kTextAlignRight\n"
    325328"vcSfxSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
    326329"vcSfxLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
    327330"opYoffset=(opYoffset + sliderHeight + 4)\n"
    328 "vcSpeechText=10 (opYoffset + 2) vctextw kLineHeight\n"
     331"vcSpeechText=vcx (opYoffset + 2) vctextw kLineHeight\n"
    329332"vcSpeechText.align=kTextAlignRight\n"
    330333"vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight\n"
    331334"vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n"
     
    343346"mcGSCheckbox=mcx opYoffset (kFontHeight + 10 + 142) buttonHeight\n"
    344347"opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)\n"
    345348"\n"
     349"[subtitleControls]\n"
     350"sbx=(opXoffset + 10)\n"
     351"sbYoff=(buttonHeight / 8)\n"
     352"sbOff=((sliderHeight - kLineHeight) / 2 + 2)\n"
     353"sbtextw=(100 + vcAudioTabIndent)\n"
     354"opYoffset=(opYoffset + sbYoff)\n"
     355"subToggleDesc=sbx (opYoffset + sbYoff) sbtextw buttonHeight\n"
     356"subToggleButton=prev.x2 (opYoffset - sbYoff) (buttonWidth + 54) buttonHeight\n"
     357"opYoffset=(opYoffset + buttonHeight + 6)\n"
     358"subSubtitleSpeedDesc=sbx (opYoffset + sbOff) sbtextw kLineHeight\n"
     359"subSubtitleSpeedDesc.align=kTextAlignRight\n"
     360"subSubtitleSpeedSlider=prev.x2 opYoffset sliderWidth sliderHeight\n"
     361"subSubtitleSpeedLabel=(prev.x2 + 10) (opYoffset + sbOff) 24 kLineHeight\n"
     362"opYoffset=(opYoffset + sliderHeight + 8)\n"
     363"\n"
    346364"[scummmain]\n"
    347365"## Main dialog\n"
    348366"# note that scummmain size depends on overall height\n"
  • 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
     
    508525}
    509526
    510527void ConfigManager::setInt(const String &key, int value, const String &domName) {
     528
     529        // TalkSpeed values are given in the engine's scale.
     530        // They are scaled back to a global 0-255 scale
     531        if (key == String("talkspeed")) {
     532                if (value == _talkspeedMinEngineValue)
     533                        value = 0;
     534                else if (value == _talkspeedMaxEngineValue)
     535                        value = 255;
     536                else if (_talkspeedScale != 1.0)
     537                        value = (int)((value - _talkspeedMinEngineValue) / _talkspeedScale + 0.5);
     538        }
     539
    511540        char tmp[128];
    512541        snprintf(tmp, sizeof(tmp), "%i", value);
    513542        set(key, String(tmp), domName);
     
    530559}
    531560
    532561void ConfigManager::registerDefault(const String &key, int value) {
     562        int scaledValue = value;
     563
     564        // TalkSpeed values are given in the engine's scale.
     565        // They are scaled back to a global 0-255 scale
     566        if (key == String("talkspeed")) {
     567                scaledValue = (int)((value - _talkspeedMinEngineValue) / _talkspeedScale + 0.5);
     568        }
     569
    533570        char tmp[128];
    534         snprintf(tmp, sizeof(tmp), "%i", value);
     571        snprintf(tmp, sizeof(tmp), "%i", scaledValue);
    535572        registerDefault(key, tmp);
    536573}
    537574
     
    626663        return _keyValueComments.contains(key);
    627664}
    628665
     666void ConfigManager::setTalkspeedScale(int minValue, int maxValue) {
     667        _talkspeedMinEngineValue = minValue;
     668        _talkspeedMaxEngineValue = maxValue;
     669        _talkspeedScale = (maxValue - minValue) / 255.0;
     670}
     671
    629672}       // End of namespace Common
  • 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                ConfMan.setInt("talkspeed", 9 - _defaultTalkDelay);
    448451
    449452                if (VAR_CHARINC != 0xFF)
    450453                        VAR(VAR_CHARINC) = _defaultTalkDelay;
  • engines/scumm/dialogs.cpp

     
    649649#pragma mark -
    650650
    651651enum {
    652         kOKCmd                                  = 'ok  '
     652        kOKCmd = 'ok  '
    653653};
    654654
    655655enum {
     
    694694        // Some misc options
    695695        //
    696696
    697         _subtitlesCheckbox = new GUI::CheckboxWidget(this, "scummconfig_subtitlesCheckbox", "Show subtitles", 0, 'S');
    698         _speechCheckbox = new GUI::CheckboxWidget(this, "scummconfig_speechCheckbox", "Enable speech", 0, 'E');
     697        // SCUMM has a talkspeed range of 0-9
     698        addSubtitleControls(this, "scummconfig_", 9);
    699699
    700700        //
    701701        // Add the buttons
     
    724724
    725725void ConfigDialog::open() {
    726726        GUI_OptionsDialog::open();
    727 
    728         // update checkboxes, too
    729         _subtitlesCheckbox->setState(ConfMan.getBool("subtitles", _domain));
    730         _speechCheckbox->setState(!ConfMan.getBool("speech_mute", _domain));
    731727}
    732728
    733729void ConfigDialog::close() {
    734         if (getResult()) {
    735                 // Subtitles
    736                 ConfMan.setBool("subtitles", _subtitlesCheckbox->getState(), _domain);
     730        GUI_OptionsDialog::close();
    737731
    738                 // Sync with current setting
    739                 if (!_speechCheckbox->getState()) {
    740                         ConfMan.setBool("speech_mute", true, _domain);
     732        if (getResult()) {
     733                // Apply new settings to engine
     734                if (ConfMan.getBool("speech_mute", _domain))
    741735                        _vm->_voiceMode = 2;
    742                 } else {
    743                         ConfMan.setBool("speech_mute", false, _domain);
    744                         _vm->_voiceMode = _subtitlesCheckbox->getState();
    745                 }
    746 
     736                else
     737                        _vm->_voiceMode = ConfMan.getBool("subtitles", _domain);
     738           
    747739                if (_vm->_game.version >= 7)
    748740                        _vm->VAR(_vm->VAR_VOICE_MODE) = _vm->_voiceMode;
    749         }
     741           
     742                _vm->_defaultTalkDelay = 9 - ConfMan.getInt("talkspeed", _domain);
     743                _vm->VAR(_vm->VAR_CHARINC) = _vm->_defaultTalkDelay;
    750744
    751         GUI_OptionsDialog::close();
    752 
    753         _vm->setupVolumes();
     745                _vm->setupVolumes();
     746        }
    754747}
    755748
    756749void ConfigDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
     
    941934}
    942935
    943936void ValueDisplayDialog::handleTickle() {
    944         if (getMillis() > _timer)
     937        if (getMillis() > _timer) {
    945938                close();
     939        }
    946940}
    947941
    948942void ValueDisplayDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
  • engines/scumm/scumm.cpp

     
    460460        VAR_SOUNDPARAM3 = 0xFF;
    461461        VAR_MOUSEPRESENT = 0xFF;
    462462        VAR_MEMORY_PERFORMANCE = 0xFF;
     463        // Set talkspeed range and load values from ConfMan
     464        ConfMan.setTalkspeedScale(0, 9);
     465
     466        if (ConfMan.hasKey("talkspeed")) {
     467                _defaultTalkDelay = 9 - ConfMan.getInt("talkspeed");
     468                VAR_CHARINC = _defaultTalkDelay;
     469        }
     470
    463471        VAR_VIDEO_PERFORMANCE = 0xFF;
    464472        VAR_ROOM_FLAG = 0xFF;
    465473        VAR_GAME_LOADED = 0xFF;
  • engines/scumm/dialogs.h

     
    124124        virtual void open();
    125125        virtual void close();
    126126        virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
    127 
    128 protected:
    129         GUI::CheckboxWidget *_subtitlesCheckbox;
    130         GUI::CheckboxWidget *_speechCheckbox;
    131127};
    132128
    133129/**
  • engines/scumm/scumm.h

     
    407407        friend class ScummDebugger;
    408408        friend class SmushPlayer;
    409409        friend class Insane;
     410        friend class ConfigDialog;
    410411        friend class CharsetRenderer;
    411412        friend class ResourceManager;
    412413
  • engines/queen/queen.cpp

     
    445445
    446446        _sound = Sound::giveSound(_mixer, this, _resource->compression());
    447447        _walk = new Walk(this);
     448        ConfMan.setTalkspeedScale(QueenEngine::MIN_TEXT_SPEED, QueenEngine::MAX_TEXT_SPEED);
    448449
    449450        registerDefaultSettings();
    450451        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;