diff options
Diffstat (limited to 'gui/options.cpp')
-rw-r--r-- | gui/options.cpp | 531 |
1 files changed, 370 insertions, 161 deletions
diff --git a/gui/options.cpp b/gui/options.cpp index 212e90f9f0..072b20b393 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -35,10 +35,12 @@ #include "common/fs.h" #include "common/config-manager.h" #include "common/system.h" +#include "common/translation.h" #include "graphics/scaler.h" #include "sound/mididrv.h" +#include "sound/musicplugin.h" #include "sound/mixer.h" #include "sound/fmopl.h" @@ -61,15 +63,21 @@ enum { kChooseThemeCmd = 'chtf' }; +enum { + kSubtitlesSpeech, + kSubtitlesSubs, + kSubtitlesBoth +}; + #ifdef SMALL_SCREEN_DEVICE enum { kChooseKeyMappingCmd = 'chma' }; #endif -static const char *savePeriodLabels[] = { "Never", "every 5 mins", "every 10 mins", "every 15 mins", "every 30 mins", 0 }; +static const char *savePeriodLabels[] = { _s("Never"), _s("every 5 mins"), _s("every 10 mins"), _s("every 15 mins"), _s("every 30 mins"), 0 }; static const int savePeriodValues[] = { 0, 5 * 60, 10 * 60, 15 * 60, 30 * 60, -1 }; -static const char *outputRateLabels[] = { "<default>", "8 kHz", "11kHz", "22 kHz", "44 kHz", "48 kHz", 0 }; +static const char *outputRateLabels[] = { _s("<default>"), _s("8 kHz"), _s("11kHz"), _s("22 kHz"), _s("44 kHz"), _s("48 kHz"), 0 }; static const int outputRateValues[] = { 0, 8000, 11025, 22050, 44100, 48000, -1 }; @@ -84,18 +92,6 @@ OptionsDialog::OptionsDialog(const Common::String &domain, const Common::String init(); } -const char *OptionsDialog::_subModeDesc[] = { - "Speech Only", - "Speech and Subtitles", - "Subtitles Only" -}; - -const char *OptionsDialog::_lowresSubModeDesc[] = { - "Speech Only", - "Speech & Subs", - "Subtitles Only" -}; - void OptionsDialog::init() { _enableGraphicSettings = false; _gfxPopUp = 0; @@ -107,8 +103,11 @@ void OptionsDialog::init() { _oplPopUp = 0; _outputRatePopUp = 0; _enableMIDISettings = false; + _gmDevicePopUp = 0; _multiMidiCheckbox = 0; + _enableMT32Settings = false; _mt32Checkbox = 0; + _mt32DevicePopUp = 0; _enableGSCheckbox = 0; _enableVolumeSettings = false; _musicVolumeDesc = 0; @@ -122,15 +121,20 @@ void OptionsDialog::init() { _speechVolumeLabel = 0; _muteCheckbox = 0; _subToggleDesc = 0; - _subToggleButton = 0; + _subToggleGroup = 0; + _subToggleSubOnly = 0; + _subToggleSpeechOnly = 0; + _subToggleSubBoth = 0; _subSpeedDesc = 0; _subSpeedSlider = 0; _subSpeedLabel = 0; // Retrieve game GUI options _guioptions = 0; - if (ConfMan.hasKey("guioptions", _domain)) - _guioptions = parseGameGUIOptions(ConfMan.get("guioptions", _domain)); + if (ConfMan.hasKey("guioptions", _domain)) { + _guioptionsString = ConfMan.get("guioptions", _domain); + _guioptions = parseGameGUIOptions(_guioptionsString); + } } void OptionsDialog::open() { @@ -141,8 +145,10 @@ void OptionsDialog::open() { // Retrieve game GUI options _guioptions = 0; - if (ConfMan.hasKey("guioptions", _domain)) - _guioptions = parseGameGUIOptions(ConfMan.get("guioptions", _domain)); + if (ConfMan.hasKey("guioptions", _domain)) { + _guioptionsString = ConfMan.get("guioptions", _domain); + _guioptions = parseGameGUIOptions(_guioptionsString); + } // Graphic options if (_fullscreenCheckbox) { @@ -189,11 +195,8 @@ void OptionsDialog::open() { } // Audio options - if (_midiPopUp) { - // Music driver - MidiDriverType id = MidiDriver::parseMusicDriver(ConfMan.get("music_driver", _domain)); - _midiPopUp->setSelectedTag(id); - } + if (!loadMusicDeviceSetting(_midiPopUp, "music_driver")) + _midiPopUp->setSelected(0); if (_oplPopUp) { OPL::Config::DriverId id = MAX<OPL::Config::DriverId>(OPL::Config::parse(ConfMan.get("opl_driver", _domain)), 0); @@ -210,19 +213,21 @@ void OptionsDialog::open() { } if (_multiMidiCheckbox) { + if (!loadMusicDeviceSetting(_gmDevicePopUp, "gm_device")) { + if (_domain.equals(Common::ConfigManager::kApplicationDomain)) { + if (!loadMusicDeviceSetting(_gmDevicePopUp, Common::String(), MT_GM)) + _gmDevicePopUp->setSelected(0); + } else { + _gmDevicePopUp->setSelected(0); + } + } // Multi midi setting _multiMidiCheckbox->setState(ConfMan.getBool("multi_midi", _domain)); - // Native mt32 setting - _mt32Checkbox->setState(ConfMan.getBool("native_mt32", _domain)); - - // GS extensions setting - _enableGSCheckbox->setState(ConfMan.getBool("enable_gs", _domain)); - Common::String soundFont(ConfMan.get("soundfont", _domain)); if (soundFont.empty() || !ConfMan.hasKey("soundfont", _domain)) { - _soundFont->setLabel("None"); + _soundFont->setLabel(_("None")); _soundFontClearButton->setEnabled(false); } else { _soundFont->setLabel(soundFont); @@ -237,6 +242,24 @@ void OptionsDialog::open() { _midiGainLabel->setLabel(buf); } + // MT-32 options + if (_mt32DevicePopUp) { + if (!loadMusicDeviceSetting(_mt32DevicePopUp, "mt32_device")) { + if (_domain.equals(Common::ConfigManager::kApplicationDomain)) { + if (!loadMusicDeviceSetting(_mt32DevicePopUp, Common::String(), MT_MT32)) + _mt32DevicePopUp->setSelected(0); + } else { + _mt32DevicePopUp->setSelected(0); + } + } + + // Native mt32 setting + _mt32Checkbox->setState(ConfMan.getBool("native_mt32", _domain)); + + // GS extensions setting + _enableGSCheckbox->setState(ConfMan.getBool("enable_gs", _domain)); + } + // Volume options if (_musicVolumeSlider) { int vol; @@ -263,11 +286,12 @@ void OptionsDialog::open() { } // Subtitle options - if (_subToggleButton) { - int speed; int sliderMaxValue = _subSpeedSlider->getMaxValue(); + if (_subToggleGroup) { + int speed; + int sliderMaxValue = _subSpeedSlider->getMaxValue(); - _subMode = getSubtitleMode(ConfMan.getBool("subtitles", _domain), ConfMan.getBool("speech_mute", _domain)); - _subToggleButton->setLabel(_subModeDesc[_subMode]); + int subMode = getSubtitleMode(ConfMan.getBool("subtitles", _domain), ConfMan.getBool("speech_mute", _domain)); + _subToggleGroup->setValue(subMode); // Engines that reuse the subtitle speed widget set their own max value. // Scale the config value accordingly (see addSubtitleControls) @@ -331,13 +355,7 @@ void OptionsDialog::close() { // Audio options if (_midiPopUp) { if (_enableAudioSettings) { - const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers(); - while (md->name && md->id != (int)_midiPopUp->getSelectedTag()) - md++; - if (md->name) - ConfMan.set("music_driver", md->name, _domain); - else - ConfMan.removeKey("music_driver", _domain); + saveMusicDeviceSetting(_midiPopUp, "music_driver"); } else { ConfMan.removeKey("music_driver", _domain); } @@ -372,41 +390,53 @@ void OptionsDialog::close() { // MIDI options if (_multiMidiCheckbox) { if (_enableMIDISettings) { + saveMusicDeviceSetting(_gmDevicePopUp, "gm_device"); + ConfMan.setBool("multi_midi", _multiMidiCheckbox->getState(), _domain); - ConfMan.setBool("native_mt32", _mt32Checkbox->getState(), _domain); - ConfMan.setBool("enable_gs", _enableGSCheckbox->getState(), _domain); ConfMan.setInt("midi_gain", _midiGainSlider->getValue(), _domain); Common::String soundFont(_soundFont->getLabel()); - if (!soundFont.empty() && (soundFont != "None")) + if (!soundFont.empty() && (soundFont != _("None"))) ConfMan.set("soundfont", soundFont, _domain); else ConfMan.removeKey("soundfont", _domain); } else { + ConfMan.removeKey("gm_device", _domain); ConfMan.removeKey("multi_midi", _domain); - ConfMan.removeKey("native_mt32", _domain); - ConfMan.removeKey("enable_gs", _domain); ConfMan.removeKey("midi_gain", _domain); ConfMan.removeKey("soundfont", _domain); } } + // MT-32 options + if (_mt32DevicePopUp) { + if (_enableMT32Settings) { + saveMusicDeviceSetting(_mt32DevicePopUp, "mt32_device"); + ConfMan.setBool("native_mt32", _mt32Checkbox->getState(), _domain); + ConfMan.setBool("enable_gs", _enableGSCheckbox->getState(), _domain); + } else { + ConfMan.removeKey("mt32_device", _domain); + ConfMan.removeKey("native_mt32", _domain); + ConfMan.removeKey("enable_gs", _domain); + } + } + // Subtitle options - if (_subToggleButton) { + if (_subToggleGroup) { if (_enableSubtitleSettings) { bool subtitles, speech_mute; int talkspeed; int sliderMaxValue = _subSpeedSlider->getMaxValue(); - switch (_subMode) { - case 0: + switch (_subToggleGroup->getValue()) { + case kSubtitlesSpeech: subtitles = speech_mute = false; break; - case 1: + case kSubtitlesBoth: subtitles = true; speech_mute = false; break; - case 2: + case kSubtitlesSubs: default: subtitles = speech_mute = true; break; @@ -459,24 +489,12 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data // 'true' because if control is disabled then event do not pass setVolumeSettingsState(true); break; - case kSubtitleToggle: - if (_subMode < 2) - _subMode++; - else - _subMode = 0; - - _subToggleButton->setLabel(g_system->getOverlayWidth() > 320 ? _subModeDesc[_subMode] : _lowresSubModeDesc[_subMode]); - _subToggleButton->draw(); - _subSpeedDesc->draw(); - _subSpeedSlider->draw(); - _subSpeedLabel->draw(); - break; case kSubtitleSpeedChanged: _subSpeedLabel->setValue(_subSpeedSlider->getValue()); _subSpeedLabel->draw(); break; case kClearSoundFontCmd: - _soundFont->setLabel("None"); + _soundFont->setLabel(_("None")); _soundFontClearButton->setEnabled(false); draw(); break; @@ -504,11 +522,20 @@ void OptionsDialog::setGraphicSettingsState(bool enabled) { void OptionsDialog::setAudioSettingsState(bool enabled) { _enableAudioSettings = enabled; - _midiPopUpDesc->setEnabled(enabled); _midiPopUp->setEnabled(enabled); - _oplPopUpDesc->setEnabled(enabled); - _oplPopUp->setEnabled(enabled); + + uint32 allFlags = MidiDriver::musicType2GUIO((uint32)-1); + + if (_domain != Common::ConfigManager::kApplicationDomain && // global dialog + (_guioptions & allFlags) && // No flags are specified + !(_guioptions & Common::GUIO_MIDIADLIB)) { + _oplPopUpDesc->setEnabled(false); + _oplPopUp->setEnabled(false); + } else { + _oplPopUpDesc->setEnabled(enabled); + _oplPopUp->setEnabled(enabled); + } _outputRatePopUpDesc->setEnabled(enabled); _outputRatePopUp->setEnabled(enabled); } @@ -517,24 +544,35 @@ void OptionsDialog::setMIDISettingsState(bool enabled) { if (_guioptions & Common::GUIO_NOMIDI) enabled = false; + _gmDevicePopUpDesc->setEnabled(_domain.equals(Common::ConfigManager::kApplicationDomain) ? enabled : false); + _gmDevicePopUp->setEnabled(_domain.equals(Common::ConfigManager::kApplicationDomain) ? enabled : false); + _enableMIDISettings = enabled; _soundFontButton->setEnabled(enabled); _soundFont->setEnabled(enabled); - if (enabled && !_soundFont->getLabel().empty() && (_soundFont->getLabel() != "None")) + if (enabled && !_soundFont->getLabel().empty() && (_soundFont->getLabel() != _("None"))) _soundFontClearButton->setEnabled(enabled); else _soundFontClearButton->setEnabled(false); _multiMidiCheckbox->setEnabled(enabled); - _mt32Checkbox->setEnabled(enabled); - _enableGSCheckbox->setEnabled(enabled); _midiGainDesc->setEnabled(enabled); _midiGainSlider->setEnabled(enabled); _midiGainLabel->setEnabled(enabled); } +void OptionsDialog::setMT32SettingsState(bool enabled) { + _enableMT32Settings = enabled; + + _mt32DevicePopUpDesc->setEnabled(_domain.equals(Common::ConfigManager::kApplicationDomain) ? enabled : false); + _mt32DevicePopUp->setEnabled(_domain.equals(Common::ConfigManager::kApplicationDomain) ? enabled : false); + + _mt32Checkbox->setEnabled(enabled); + _enableGSCheckbox->setEnabled(enabled); +} + void OptionsDialog::setVolumeSettingsState(bool enabled) { bool ena; @@ -575,7 +613,7 @@ void OptionsDialog::setSubtitleSettingsState(bool enabled) { if ((_guioptions & Common::GUIO_NOSUBTITLES) || (_guioptions & Common::GUIO_NOSPEECH)) ena = false; - _subToggleButton->setEnabled(ena); + _subToggleGroup->setEnabled(ena); _subToggleDesc->setEnabled(ena); ena = enabled; @@ -591,87 +629,115 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes(); // The GFX mode popup - _gfxPopUpDesc = new StaticTextWidget(boss, prefix + "grModePopupDesc", "Graphics mode:"); + _gfxPopUpDesc = new StaticTextWidget(boss, prefix + "grModePopupDesc", _("Graphics mode:")); _gfxPopUp = new PopUpWidget(boss, prefix + "grModePopup"); - _gfxPopUp->appendEntry("<default>"); + _gfxPopUp->appendEntry(_("<default>")); _gfxPopUp->appendEntry(""); while (gm->name) { - _gfxPopUp->appendEntry(gm->description, gm->id); + _gfxPopUp->appendEntry(_(gm->description), gm->id); gm++; } // RenderMode popup - _renderModePopUpDesc = new StaticTextWidget(boss, prefix + "grRenderPopupDesc", "Render mode:"); - _renderModePopUp = new PopUpWidget(boss, prefix + "grRenderPopup"); - _renderModePopUp->appendEntry("<default>", Common::kRenderDefault); + _renderModePopUpDesc = new StaticTextWidget(boss, prefix + "grRenderPopupDesc", _("Render mode:"), _("Special dithering modes supported by some games")); + _renderModePopUp = new PopUpWidget(boss, prefix + "grRenderPopup", _("Special dithering modes supported by some games")); + _renderModePopUp->appendEntry(_("<default>"), Common::kRenderDefault); _renderModePopUp->appendEntry(""); const Common::RenderModeDescription *rm = Common::g_renderModes; for (; rm->code; ++rm) { - _renderModePopUp->appendEntry(rm->description, rm->id); + _renderModePopUp->appendEntry(_(rm->description), rm->id); } // Fullscreen checkbox - _fullscreenCheckbox = new CheckboxWidget(boss, prefix + "grFullscreenCheckbox", "Fullscreen mode", 0, 0); + _fullscreenCheckbox = new CheckboxWidget(boss, prefix + "grFullscreenCheckbox", _("Fullscreen mode")); // Aspect ratio checkbox - _aspectCheckbox = new CheckboxWidget(boss, prefix + "grAspectCheckbox", "Aspect ratio correction", 0, 0); + _aspectCheckbox = new CheckboxWidget(boss, prefix + "grAspectCheckbox", _("Aspect ratio correction"), _("Correct aspect ratio for 320x200 games")); _enableGraphicSettings = true; } void OptionsDialog::addAudioControls(GuiObject *boss, const Common::String &prefix) { // The MIDI mode popup & a label - _midiPopUpDesc = new StaticTextWidget(boss, prefix + "auMidiPopupDesc", "Music driver:"); - _midiPopUp = new PopUpWidget(boss, prefix + "auMidiPopup"); + _midiPopUpDesc = new StaticTextWidget(boss, prefix + "auMidiPopupDesc", _domain == Common::ConfigManager::kApplicationDomain ? _("Preferred Device:") : _("Music Device:"), _domain == Common::ConfigManager::kApplicationDomain ? _("Specifies preferred sound device or sound card emulator") : _("Specifies output sound device or sound card emulator")); + _midiPopUp = new PopUpWidget(boss, prefix + "auMidiPopup", _("Specifies output sound device or sound card emulator")); // Populate it - const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers(); - while (md->name) { - _midiPopUp->appendEntry(md->description, md->id); - md++; + uint32 allFlags = MidiDriver::musicType2GUIO((uint32)-1); + + const MusicPlugin::List p = MusicMan.getPlugins(); + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { + const uint32 deviceGuiOption = MidiDriver::musicType2GUIO(d->getMusicType()); + + if ((_domain == Common::ConfigManager::kApplicationDomain && d->getMusicType() != MT_TOWNS) // global dialog - skip useless FM-Towns option there + || (_domain != Common::ConfigManager::kApplicationDomain && !(_guioptions & allFlags)) // No flags are specified + || (_guioptions & deviceGuiOption) // flag is present + // HACK/FIXME: For now we have to show GM devices, even when the game only has GUIO_MIDIMT32 set, + // else we would not show for example external devices connected via ALSA, since they are always + // marked as General MIDI device. + || (deviceGuiOption == Common::GUIO_MIDIGM && (_guioptions & Common::GUIO_MIDIMT32)) + || d->getMusicDriverId() == "auto" || d->getMusicDriverId() == "null") // always add default and null device + _midiPopUp->appendEntry(d->getCompleteName(), d->getHandle()); + } } // The OPL emulator popup & a label - _oplPopUpDesc = new StaticTextWidget(boss, prefix + "auOPLPopupDesc", "AdLib emulator:"); - _oplPopUp = new PopUpWidget(boss, prefix + "auOPLPopup"); + _oplPopUpDesc = new StaticTextWidget(boss, prefix + "auOPLPopupDesc", _("AdLib emulator:"), _("AdLib is used for music in many games")); + _oplPopUp = new PopUpWidget(boss, prefix + "auOPLPopup", _("AdLib is used for music in many games")); // Populate it const OPL::Config::EmulatorDescription *ed = OPL::Config::getAvailable(); while (ed->name) { - _oplPopUp->appendEntry(ed->description, ed->id); + _oplPopUp->appendEntry(_(ed->description), ed->id); ++ed; } // Sample rate settings - _outputRatePopUpDesc = new StaticTextWidget(boss, prefix + "auSampleRatePopupDesc", "Output rate:"); - _outputRatePopUp = new PopUpWidget(boss, prefix + "auSampleRatePopup"); + _outputRatePopUpDesc = new StaticTextWidget(boss, prefix + "auSampleRatePopupDesc", _("Output rate:"), _("Higher value specifies better sound quality but may be not supported by your soundcard")); + _outputRatePopUp = new PopUpWidget(boss, prefix + "auSampleRatePopup", _("Higher value specifies better sound quality but may be not supported by your soundcard")); for (int i = 0; outputRateLabels[i]; i++) { - _outputRatePopUp->appendEntry(outputRateLabels[i], outputRateValues[i]); + _outputRatePopUp->appendEntry(_(outputRateLabels[i]), outputRateValues[i]); } _enableAudioSettings = true; } void OptionsDialog::addMIDIControls(GuiObject *boss, const Common::String &prefix) { - // SoundFont - _soundFontButton = new ButtonWidget(boss, prefix + "mcFontButton", "SoundFont:", kChooseSoundFontCmd, 0); - _soundFont = new StaticTextWidget(boss, prefix + "mcFontPath", "None"); - _soundFontClearButton = new ButtonWidget(boss, prefix + "mcFontClearButton", "C", kClearSoundFontCmd, 0); + _gmDevicePopUpDesc = new StaticTextWidget(boss, prefix + "auPrefGmPopupDesc", _("GM Device:"), _("Specifies default sound device for General MIDI output")); + _gmDevicePopUp = new PopUpWidget(boss, prefix + "auPrefGmPopup"); + + // Populate + const MusicPlugin::List p = MusicMan.getPlugins(); + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { + if (d->getMusicType() >= MT_GM || d->getMusicDriverId() == "auto") { + if (d->getMusicType() != MT_MT32) + _gmDevicePopUp->appendEntry(d->getCompleteName(), d->getHandle()); + } + } + } - // Multi midi setting - _multiMidiCheckbox = new CheckboxWidget(boss, prefix + "mcMixedCheckbox", "Mixed AdLib/MIDI mode", 0, 0); + if (!_domain.equals(Common::ConfigManager::kApplicationDomain)) { + _gmDevicePopUpDesc->setEnabled(false); + _gmDevicePopUp->setEnabled(false); + } - // Native mt32 setting - _mt32Checkbox = new CheckboxWidget(boss, prefix + "mcMt32Checkbox", "True Roland MT-32 (disable GM emulation)", 0, 0); + // SoundFont + _soundFontButton = new ButtonWidget(boss, prefix + "mcFontButton", _("SoundFont:"), _("SoundFont is supported by some audio cards, Fluidsynth and Timidity"), kChooseSoundFontCmd); + _soundFont = new StaticTextWidget(boss, prefix + "mcFontPath", _("None"), _("SoundFont is supported by some audio cards, Fluidsynth and Timidity")); + _soundFontClearButton = new ButtonWidget(boss, prefix + "mcFontClearButton", "C", _("Clear value"), kClearSoundFontCmd); - // GS Extensions setting - _enableGSCheckbox = new CheckboxWidget(boss, prefix + "mcGSCheckbox", "Enable Roland GS Mode", 0, 0); + // Multi midi setting + _multiMidiCheckbox = new CheckboxWidget(boss, prefix + "mcMixedCheckbox", _("Mixed AdLib/MIDI mode"), _("Use both MIDI and AdLib sound generation")); // MIDI gain setting (FluidSynth uses this) - _midiGainDesc = new StaticTextWidget(boss, prefix + "mcMidiGainText", "MIDI gain:"); - _midiGainSlider = new SliderWidget(boss, prefix + "mcMidiGainSlider", kMidiGainChanged); + _midiGainDesc = new StaticTextWidget(boss, prefix + "mcMidiGainText", _("MIDI gain:")); + _midiGainSlider = new SliderWidget(boss, prefix + "mcMidiGainSlider", 0, kMidiGainChanged); _midiGainSlider->setMinValue(0); _midiGainSlider->setMaxValue(1000); _midiGainLabel = new StaticTextWidget(boss, prefix + "mcMidiGainLabel", "1.00"); @@ -679,16 +745,57 @@ void OptionsDialog::addMIDIControls(GuiObject *boss, const Common::String &prefi _enableMIDISettings = true; } +void OptionsDialog::addMT32Controls(GuiObject *boss, const Common::String &prefix) { + _mt32DevicePopUpDesc = new StaticTextWidget(boss, prefix + "auPrefMt32PopupDesc", _("MT-32 Device:"), _("Specifies default sound device for Roland MT-32/LAPC1/CM32l/CM64 output")); + _mt32DevicePopUp = new PopUpWidget(boss, prefix + "auPrefMt32Popup"); + + // Native mt32 setting + _mt32Checkbox = new CheckboxWidget(boss, prefix + "mcMt32Checkbox", _("True Roland MT-32 (disable GM emulation)"), _("Check if you want to use your real hardware Roland-compatible sound device connected to your computer")); + + // GS Extensions setting + _enableGSCheckbox = new CheckboxWidget(boss, prefix + "mcGSCheckbox", _("Enable Roland GS Mode"), _("Turns off General MIDI mapping for games with Roland MT-32 soundtrack")); + + const MusicPlugin::List p = MusicMan.getPlugins(); + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { + if (d->getMusicType() >= MT_GM || d->getMusicDriverId() == "auto") { + _mt32DevicePopUp->appendEntry(d->getCompleteName(), d->getHandle()); + } + } + } + + if (!_domain.equals(Common::ConfigManager::kApplicationDomain)) { + _mt32DevicePopUpDesc->setEnabled(false); + _mt32DevicePopUp->setEnabled(false); + } + + _enableMIDISettings = true; +} + // The function has an extra slider range parameter, since both the launcher and SCUMM engine // make use of the widgets. The launcher range is 0-255. SCUMM's 0-9 void OptionsDialog::addSubtitleControls(GuiObject *boss, const Common::String &prefix, int maxSliderVal) { - _subToggleDesc = new StaticTextWidget(boss, prefix + "subToggleDesc", "Text and Speech:"); - _subToggleButton = new ButtonWidget(boss, prefix + "subToggleButton", "", kSubtitleToggle, 0); + _subToggleDesc = new StaticTextWidget(boss, prefix + "subToggleDesc", _("Text and Speech:")); + + if (g_system->getOverlayWidth() > 320) { + _subToggleGroup = new RadiobuttonGroup(boss, kSubtitleToggle); + + _subToggleSpeechOnly = new RadiobuttonWidget(boss, prefix + "subToggleSpeechOnly", _subToggleGroup, kSubtitlesSpeech, _("Speech")); + _subToggleSubOnly = new RadiobuttonWidget(boss, prefix + "subToggleSubOnly", _subToggleGroup, kSubtitlesSubs, _("Subtitles")); + _subToggleSubBoth = new RadiobuttonWidget(boss, prefix + "subToggleSubBoth", _subToggleGroup, kSubtitlesBoth, _("Both")); + } else { + _subToggleGroup = new RadiobuttonGroup(boss, kSubtitleToggle); + + _subToggleSpeechOnly = new RadiobuttonWidget(boss, prefix + "subToggleSpeechOnly", _subToggleGroup, kSubtitlesSpeech, _("Spch"), _("Speech")); + _subToggleSubOnly = new RadiobuttonWidget(boss, prefix + "subToggleSubOnly", _subToggleGroup, kSubtitlesSubs, _("Subs"), _("Subtitles")); + _subToggleSubBoth = new RadiobuttonWidget(boss, prefix + "subToggleSubBoth", _subToggleGroup, kSubtitlesBoth, _("Both"), _("Show subtitles and play speech")); + } // Subtitle speed - _subSpeedDesc = new StaticTextWidget(boss, prefix + "subSubtitleSpeedDesc", "Subtitle speed:"); - _subSpeedSlider = new SliderWidget(boss, prefix + "subSubtitleSpeedSlider", kSubtitleSpeedChanged); + _subSpeedDesc = new StaticTextWidget(boss, prefix + "subSubtitleSpeedDesc", _("Subtitle speed:")); + _subSpeedSlider = new SliderWidget(boss, prefix + "subSubtitleSpeedSlider", 0, kSubtitleSpeedChanged); _subSpeedLabel = new StaticTextWidget(boss, prefix + "subSubtitleSpeedLabel", "100%"); _subSpeedSlider->setMinValue(0); _subSpeedSlider->setMaxValue(maxSliderVal); _subSpeedLabel->setFlags(WIDGET_CLEARBG); @@ -699,25 +806,25 @@ void OptionsDialog::addSubtitleControls(GuiObject *boss, const Common::String &p void OptionsDialog::addVolumeControls(GuiObject *boss, const Common::String &prefix) { // Volume controllers - _musicVolumeDesc = new StaticTextWidget(boss, prefix + "vcMusicText", "Music volume:"); - _musicVolumeSlider = new SliderWidget(boss, prefix + "vcMusicSlider", kMusicVolumeChanged); + _musicVolumeDesc = new StaticTextWidget(boss, prefix + "vcMusicText", _("Music volume:")); + _musicVolumeSlider = new SliderWidget(boss, prefix + "vcMusicSlider", 0, kMusicVolumeChanged); _musicVolumeLabel = new StaticTextWidget(boss, prefix + "vcMusicLabel", "100%"); _musicVolumeSlider->setMinValue(0); _musicVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume); _musicVolumeLabel->setFlags(WIDGET_CLEARBG); - _muteCheckbox = new CheckboxWidget(boss, prefix + "vcMuteCheckbox", "Mute All", kMuteAllChanged, 0); + _muteCheckbox = new CheckboxWidget(boss, prefix + "vcMuteCheckbox", _("Mute All"), 0, kMuteAllChanged); - _sfxVolumeDesc = new StaticTextWidget(boss, prefix + "vcSfxText", "SFX volume:"); - _sfxVolumeSlider = new SliderWidget(boss, prefix + "vcSfxSlider", kSfxVolumeChanged); + _sfxVolumeDesc = new StaticTextWidget(boss, prefix + "vcSfxText", _("SFX volume:"), _("Special sound effects volume")); + _sfxVolumeSlider = new SliderWidget(boss, prefix + "vcSfxSlider", _("Special sound effects volume"), kSfxVolumeChanged); _sfxVolumeLabel = new StaticTextWidget(boss, prefix + "vcSfxLabel", "100%"); _sfxVolumeSlider->setMinValue(0); _sfxVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume); _sfxVolumeLabel->setFlags(WIDGET_CLEARBG); - _speechVolumeDesc = new StaticTextWidget(boss, prefix + "vcSpeechText" , "Speech volume:"); - _speechVolumeSlider = new SliderWidget(boss, prefix + "vcSpeechSlider", kSpeechVolumeChanged); + _speechVolumeDesc = new StaticTextWidget(boss, prefix + "vcSpeechText" , _("Speech volume:")); + _speechVolumeSlider = new SliderWidget(boss, prefix + "vcSpeechSlider", 0, kSpeechVolumeChanged); _speechVolumeLabel = new StaticTextWidget(boss, prefix + "vcSpeechLabel", "100%"); _speechVolumeSlider->setMinValue(0); _speechVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume); @@ -726,26 +833,69 @@ void OptionsDialog::addVolumeControls(GuiObject *boss, const Common::String &pre _enableVolumeSettings = true; } +bool OptionsDialog::loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicType preferredType) { + if (!popup || !popup->isEnabled()) + return true; + + if (_domain != Common::ConfigManager::kApplicationDomain || ConfMan.hasKey(setting, _domain) || preferredType) { + const Common::String drv = ConfMan.get(setting, (_domain != Common::ConfigManager::kApplicationDomain && !ConfMan.hasKey(setting, _domain)) ? Common::ConfigManager::kApplicationDomain : _domain); + const MusicPlugin::List p = MusicMan.getPlugins(); + + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { + if (setting.empty() ? (preferredType == d->getMusicType()) : (drv == d->getCompleteId())) { + popup->setSelectedTag(d->getHandle()); + return popup->getSelected() == -1 ? false : true; + } + } + } + } + + return false; +} + +void OptionsDialog::saveMusicDeviceSetting(PopUpWidget *popup, Common::String setting) { + if (!popup || !_enableAudioSettings) + return; + + const MusicPlugin::List p = MusicMan.getPlugins(); + bool found = false; + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end() && !found; ++m) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { + if (d->getHandle() == popup->getSelectedTag()) { + ConfMan.set(setting, d->getCompleteId(), _domain); + found = true; + break; + } + } + } + + if (!found) + ConfMan.removeKey(setting, _domain); +} + int OptionsDialog::getSubtitleMode(bool subtitles, bool speech_mute) { if (_guioptions & Common::GUIO_NOSUBTITLES) - return 0; // Speech only + return kSubtitlesSpeech; // Speech only if (_guioptions & Common::GUIO_NOSPEECH) - return 2; // Subtitles only + return kSubtitlesSubs; // Subtitles only if (!subtitles && !speech_mute) // Speech only - return 0; + return kSubtitlesSpeech; else if (subtitles && !speech_mute) // Speech and subtitles - return 1; + return kSubtitlesBoth; else if (subtitles && speech_mute) // Subtitles only - return 2; + return kSubtitlesSubs; else warning("Wrong configuration: Both subtitles and speech are off. Assuming subtitles only"); - return 2; + return kSubtitlesSubs; } void OptionsDialog::reflowLayout() { if (_graphicsTabId != -1 && _tabWidget) - _tabWidget->setTabTitle(_graphicsTabId, g_system->getOverlayWidth() > 320 ? "Graphics" : "GFX"); + _tabWidget->setTabTitle(_graphicsTabId, g_system->getOverlayWidth() > 320 ? _("Graphics") : _("GFX")); Dialog::reflowLayout(); } @@ -762,17 +912,17 @@ GlobalOptionsDialog::GlobalOptionsDialog() // // 1) The graphics tab // - _graphicsTabId = tab->addTab(g_system->getOverlayWidth() > 320 ? "Graphics" : "GFX"); + _graphicsTabId = tab->addTab(g_system->getOverlayWidth() > 320 ? _("Graphics") : _("GFX")); addGraphicControls(tab, "GlobalOptions_Graphics."); // // 2) The audio tab // - tab->addTab("Audio"); + tab->addTab(_("Audio")); addAudioControls(tab, "GlobalOptions_Audio."); addSubtitleControls(tab, "GlobalOptions_Audio."); - tab->addTab("Volume"); + tab->addTab(_("Volume")); addVolumeControls(tab, "GlobalOptions_Volume."); // TODO: cd drive setting @@ -780,67 +930,104 @@ GlobalOptionsDialog::GlobalOptionsDialog() // // 3) The MIDI tab // - tab->addTab("MIDI"); + tab->addTab(_("MIDI")); addMIDIControls(tab, "GlobalOptions_MIDI."); // - // 4) The miscellaneous tab + // 4) The MT-32 tab + // + tab->addTab(_("MT-32")); + addMT32Controls(tab, "GlobalOptions_MT32."); + + // + // 5) The Paths tab // - tab->addTab("Paths"); + tab->addTab(_("Paths")); #if !( defined(__DC__) || defined(__GP32__) ) // These two buttons have to be extra wide, or the text will be // truncated in the small version of the GUI. // Save game path - new ButtonWidget(tab, "GlobalOptions_Paths.SaveButton", "Save Path: ", kChooseSaveDirCmd, 0); - _savePath = new StaticTextWidget(tab, "GlobalOptions_Paths.SavePath", "/foo/bar"); + new ButtonWidget(tab, "GlobalOptions_Paths.SaveButton", _("Save Path: "), _("Specifies where your savegames are put"), kChooseSaveDirCmd); + _savePath = new StaticTextWidget(tab, "GlobalOptions_Paths.SavePath", "/foo/bar", _("Specifies where your savegames are put")); - new ButtonWidget(tab, "GlobalOptions_Paths.ThemeButton", "Theme Path:", kChooseThemeDirCmd, 0); - _themePath = new StaticTextWidget(tab, "GlobalOptions_Paths.ThemePath", "None"); + new ButtonWidget(tab, "GlobalOptions_Paths.ThemeButton", _("Theme Path:"), 0, kChooseThemeDirCmd); + _themePath = new StaticTextWidget(tab, "GlobalOptions_Paths.ThemePath", _("None")); - new ButtonWidget(tab, "GlobalOptions_Paths.ExtraButton", "Extra Path:", kChooseExtraDirCmd, 0); - _extraPath = new StaticTextWidget(tab, "GlobalOptions_Paths.ExtraPath", "None"); + new ButtonWidget(tab, "GlobalOptions_Paths.ExtraButton", _("Extra Path:"), _("Specifies path to additional data used by all games or ScummVM"), kChooseExtraDirCmd); + _extraPath = new StaticTextWidget(tab, "GlobalOptions_Paths.ExtraPath", _("None"), _("Specifies path to additional data used by all games or ScummVM")); #ifdef DYNAMIC_MODULES - new ButtonWidget(tab, "GlobalOptions_Paths.PluginsButton", "Plugins Path:", kChoosePluginsDirCmd, 0); - _pluginsPath = new StaticTextWidget(tab, "GlobalOptions_Paths.PluginsPath", "None"); + new ButtonWidget(tab, "GlobalOptions_Paths.PluginsButton", _("Plugins Path:"), 0, kChoosePluginsDirCmd); + _pluginsPath = new StaticTextWidget(tab, "GlobalOptions_Paths.PluginsPath", _("None")); #endif #endif - tab->addTab("Misc"); + // + // 6) The miscellaneous tab + // + tab->addTab(_("Misc")); - new ButtonWidget(tab, "GlobalOptions_Misc.ThemeButton", "Theme:", kChooseThemeCmd, 0); + new ButtonWidget(tab, "GlobalOptions_Misc.ThemeButton", _("Theme:"), 0, kChooseThemeCmd); _curTheme = new StaticTextWidget(tab, "GlobalOptions_Misc.CurTheme", g_gui.theme()->getThemeName()); - _rendererPopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Misc.RendererPopupDesc", "GUI Renderer:"); + _rendererPopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Misc.RendererPopupDesc", _("GUI Renderer:")); _rendererPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.RendererPopup"); for (uint i = 1; i < GUI::ThemeEngine::_rendererModesSize; ++i) - _rendererPopUp->appendEntry(GUI::ThemeEngine::_rendererModes[i].name, GUI::ThemeEngine::_rendererModes[i].mode); + _rendererPopUp->appendEntry(_(GUI::ThemeEngine::_rendererModes[i].name), GUI::ThemeEngine::_rendererModes[i].mode); - _autosavePeriodPopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Misc.AutosavePeriodPopupDesc", "Autosave:"); + _autosavePeriodPopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Misc.AutosavePeriodPopupDesc", _("Autosave:")); _autosavePeriodPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.AutosavePeriodPopup"); for (int i = 0; savePeriodLabels[i]; i++) { - _autosavePeriodPopUp->appendEntry(savePeriodLabels[i], savePeriodValues[i]); + _autosavePeriodPopUp->appendEntry(_(savePeriodLabels[i]), savePeriodValues[i]); } #ifdef SMALL_SCREEN_DEVICE - new ButtonWidget(tab, "GlobalOptions_Misc.KeysButton", "Keys", kChooseKeyMappingCmd, 0); + new ButtonWidget(tab, "GlobalOptions_Misc.KeysButton", _("Keys"), 0, kChooseKeyMappingCmd); #endif // TODO: joystick setting +#ifdef USE_TRANSLATION + _guiLanguagePopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Misc.GuiLanguagePopupDesc", _("GUI Language:"), _("Language of ScummVM GUI")); + _guiLanguagePopUp = new PopUpWidget(tab, "GlobalOptions_Misc.GuiLanguagePopup"); +#ifdef USE_DETECTLANG + _guiLanguagePopUp->appendEntry(_("<default>"), Common::kTranslationAutodetectId); +#endif // USE_DETECTLANG + _guiLanguagePopUp->appendEntry(_("English"), Common::kTranslationBuiltinId); + _guiLanguagePopUp->appendEntry("", 0); + Common::TLangArray languages = TransMan.getSupportedLanguageNames(); + Common::TLangArray::iterator lang = languages.begin(); + while (lang != languages.end()) { + _guiLanguagePopUp->appendEntry(lang->name, lang->id); + lang++; + } + + // Select the currently configured language or default/English if + // nothing is specified. + if (ConfMan.hasKey("gui_language")) + _guiLanguagePopUp->setSelectedTag(TransMan.parseLanguage(ConfMan.get("gui_language"))); + else +#ifdef USE_DETECTLANG + _guiLanguagePopUp->setSelectedTag(Common::kTranslationAutodetectId); +#else // !USE_DETECTLANG + _guiLanguagePopUp->setSelectedTag(Common::kTranslationBuiltinId); +#endif // USE_DETECTLANG + +#endif // USE_TRANSLATION + // Activate the first tab tab->setActiveTab(0); _tabWidget = tab; // Add OK & Cancel buttons - new ButtonWidget(this, "GlobalOptions.Cancel", "Cancel", kCloseCmd, 0); - new ButtonWidget(this, "GlobalOptions.Ok", "OK", kOKCmd, 0); + new ButtonWidget(this, "GlobalOptions.Cancel", _("Cancel"), 0, kCloseCmd); + new ButtonWidget(this, "GlobalOptions.Ok", _("OK"), 0, kOKCmd); #ifdef SMALL_SCREEN_DEVICE _keysDialog = new KeysDialog(); @@ -863,19 +1050,19 @@ void GlobalOptionsDialog::open() { Common::String extraPath(ConfMan.get("extrapath", _domain)); if (savePath.empty() || !ConfMan.hasKey("savepath", _domain)) { - _savePath->setLabel("None"); + _savePath->setLabel(_("None")); } else { _savePath->setLabel(savePath); } if (themePath.empty() || !ConfMan.hasKey("themepath", _domain)) { - _themePath->setLabel("None"); + _themePath->setLabel(_("None")); } else { _themePath->setLabel(themePath); } if (extraPath.empty() || !ConfMan.hasKey("extrapath", _domain)) { - _extraPath->setLabel("None"); + _extraPath->setLabel(_("None")); } else { _extraPath->setLabel(extraPath); } @@ -883,7 +1070,7 @@ void GlobalOptionsDialog::open() { #ifdef DYNAMIC_MODULES Common::String pluginsPath(ConfMan.get("pluginspath", _domain)); if (pluginsPath.empty() || !ConfMan.hasKey("pluginspath", _domain)) { - _pluginsPath->setLabel("None"); + _pluginsPath->setLabel(_("None")); } else { _pluginsPath->setLabel(pluginsPath); } @@ -907,24 +1094,24 @@ void GlobalOptionsDialog::open() { void GlobalOptionsDialog::close() { if (getResult()) { Common::String savePath(_savePath->getLabel()); - if (!savePath.empty() && (savePath != "None")) + if (!savePath.empty() && (savePath != _("None"))) ConfMan.set("savepath", savePath, _domain); Common::String themePath(_themePath->getLabel()); - if (!themePath.empty() && (themePath != "None")) + if (!themePath.empty() && (themePath != _("None"))) ConfMan.set("themepath", themePath, _domain); else ConfMan.removeKey("themepath", _domain); Common::String extraPath(_extraPath->getLabel()); - if (!extraPath.empty() && (extraPath != "None")) + if (!extraPath.empty() && (extraPath != _("None"))) ConfMan.set("extrapath", extraPath, _domain); else ConfMan.removeKey("extrapath", _domain); #ifdef DYNAMIC_MODULES Common::String pluginsPath(_pluginsPath->getLabel()); - if (!pluginsPath.empty() && (pluginsPath != "None")) + if (!pluginsPath.empty() && (pluginsPath != _("None"))) ConfMan.set("pluginspath", pluginsPath, _domain); else ConfMan.removeKey("pluginspath", _domain); @@ -940,6 +1127,28 @@ void GlobalOptionsDialog::close() { g_gui.loadNewTheme(g_gui.theme()->getThemeId(), selected); ConfMan.set("gui_renderer", cfg, _domain); } +#ifdef USE_TRANSLATION + Common::String oldLang = ConfMan.get("gui_language"); + int selLang = _guiLanguagePopUp->getSelectedTag(); + + ConfMan.set("gui_language", TransMan.getLangById(selLang)); + + Common::String newLang = ConfMan.get("gui_language").c_str(); + if (newLang != oldLang) { +#if 0 + // Activate the selected language + TransMan.setLanguage(selLang); + + // FIXME: Actually, any changes (including the theme change) should + // only become active *after* the options dialog has closed. + g_gui.loadNewTheme(g_gui.theme()->getThemeId(), ThemeEngine::kGfxDisabled, true); +#else + MessageDialog error(_("You have to restart ScummVM to take the effect.")); + error.runModal(); +#endif + } +#endif // USE_TRANSLATION + } OptionsDialog::close(); } @@ -947,14 +1156,14 @@ void GlobalOptionsDialog::close() { void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case kChooseSaveDirCmd: { - BrowserDialog browser("Select directory for savegames", true); + BrowserDialog browser(_("Select directory for savegames"), true); if (browser.runModal() > 0) { // User made his choice... Common::FSNode dir(browser.getResult()); if (dir.isWritable()) { _savePath->setLabel(dir.getPath()); } else { - MessageDialog error("The chosen directory cannot be written to. Please select another one."); + MessageDialog error(_("The chosen directory cannot be written to. Please select another one.")); error.runModal(); return; } @@ -963,7 +1172,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 break; } case kChooseThemeDirCmd: { - BrowserDialog browser("Select directory for GUI themes", true); + BrowserDialog browser(_("Select directory for GUI themes"), true); if (browser.runModal() > 0) { // User made his choice... Common::FSNode dir(browser.getResult()); @@ -973,7 +1182,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 break; } case kChooseExtraDirCmd: { - BrowserDialog browser("Select directory for extra files", true); + BrowserDialog browser(_("Select directory for extra files"), true); if (browser.runModal() > 0) { // User made his choice... Common::FSNode dir(browser.getResult()); @@ -984,7 +1193,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 } #ifdef DYNAMIC_MODULES case kChoosePluginsDirCmd: { - BrowserDialog browser("Select directory for plugins", true); + BrowserDialog browser(_("Select directory for plugins"), true); if (browser.runModal() > 0) { // User made his choice... Common::FSNode dir(browser.getResult()); @@ -995,13 +1204,13 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 } #endif case kChooseSoundFontCmd: { - BrowserDialog browser("Select SoundFont", false); + BrowserDialog browser(_("Select SoundFont"), false); if (browser.runModal() > 0) { // User made his choice... Common::FSNode file(browser.getResult()); _soundFont->setLabel(file.getPath()); - if (!file.getPath().empty() && (file.getPath() != "None")) + if (!file.getPath().empty() && (file.getPath() != _("None"))) _soundFontClearButton->setEnabled(true); else _soundFontClearButton->setEnabled(false); |