1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef OPTIONS_DIALOG_H 24 #define OPTIONS_DIALOG_H 25 26 #include "engines/metaengine.h" 27 28 #include "gui/dialog.h" 29 #include "common/str.h" 30 #include "audio/mididrv.h" 31 32 #ifdef USE_FLUIDSYNTH 33 #include "gui/fluidsynth-dialog.h" 34 #endif 35 36 #ifdef USE_LIBCURL 37 #include "backends/cloud/storage.h" 38 #endif 39 40 namespace Common { 41 class RemapWidget; 42 } 43 44 namespace GUI { 45 class LauncherDialog; 46 47 class CheckboxWidget; 48 class EditTextWidget; 49 class PopUpWidget; 50 class SliderWidget; 51 class StaticTextWidget; 52 class TabWidget; 53 class ButtonWidget; 54 class CommandSender; 55 class GuiObject; 56 class RadiobuttonGroup; 57 class RadiobuttonWidget; 58 class OptionsContainerWidget; 59 60 class OptionsDialog : public Dialog { 61 public: 62 OptionsDialog(const Common::String &domain, int x, int y, int w, int h); 63 OptionsDialog(const Common::String &domain, const Common::String &name); 64 ~OptionsDialog() override; 65 66 void init(); 67 68 void open() override; 69 virtual void apply(); 70 void close() override; 71 void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override; 72 void handleTickle() override; 73 void handleOtherEvent(const Common::Event &event) override; 74 getDomain()75 const Common::String& getDomain() const { return _domain; } 76 77 void reflowLayout() override; 78 79 protected: 80 /** Config domain this dialog is used to edit. */ 81 Common::String _domain; 82 83 ButtonWidget *_soundFontButton; 84 StaticTextWidget *_soundFont; 85 ButtonWidget *_soundFontClearButton; 86 87 virtual void build(); 88 virtual void clean(); 89 void rebuild(); 90 91 92 void addControlControls(GuiObject *boss, const Common::String &prefix); 93 void addKeyMapperControls(GuiObject *boss, const Common::String &prefix, const Common::Array<Common::Keymap *> &keymaps, const Common::String &domain); 94 void addAchievementsControls(GuiObject *boss, const Common::String &prefix); 95 void addStatisticsControls(GuiObject *boss, const Common::String &prefix); 96 void addGraphicControls(GuiObject *boss, const Common::String &prefix); 97 void addShaderControls(GuiObject *boss, const Common::String &prefix); 98 void addAudioControls(GuiObject *boss, const Common::String &prefix); 99 void addMIDIControls(GuiObject *boss, const Common::String &prefix); 100 void addMT32Controls(GuiObject *boss, const Common::String &prefix); 101 void addVolumeControls(GuiObject *boss, const Common::String &prefix); 102 // The default value is the launcher's non-scaled talkspeed value. When SCUMM uses the widget, 103 // it uses its own scale 104 void addSubtitleControls(GuiObject *boss, const Common::String &prefix, int maxSliderVal = 255); 105 106 void setGraphicSettingsState(bool enabled); 107 void setShaderSettingsState(bool enabled); 108 void setAudioSettingsState(bool enabled); 109 void setMIDISettingsState(bool enabled); 110 void setMT32SettingsState(bool enabled); 111 void setVolumeSettingsState(bool enabled); 112 void setSubtitleSettingsState(bool enabled); 113 114 virtual void setupGraphicsTab(); 115 void updateScaleFactors(uint32 tag); 116 117 bool loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicType preferredType = MT_AUTO); 118 void saveMusicDeviceSetting(PopUpWidget *popup, Common::String setting); 119 120 TabWidget *_tabWidget; 121 int _graphicsTabId; 122 int _midiTabId; 123 int _pathsTabId; 124 125 private: 126 127 // 128 // Control controls 129 // 130 bool _enableControlSettings; 131 132 CheckboxWidget *_touchpadCheckbox; 133 CheckboxWidget *_onscreenCheckbox; 134 CheckboxWidget *_swapMenuAndBackBtnsCheckbox; 135 136 StaticTextWidget *_kbdMouseSpeedDesc; 137 SliderWidget *_kbdMouseSpeedSlider; 138 StaticTextWidget *_kbdMouseSpeedLabel; 139 StaticTextWidget *_joystickDeadzoneDesc; 140 SliderWidget *_joystickDeadzoneSlider; 141 StaticTextWidget *_joystickDeadzoneLabel; 142 143 // 144 // KeyMapper controls 145 // 146 Common::RemapWidget *_keymapperWidget; 147 148 // 149 // Graphics controls 150 // 151 bool _enableGraphicSettings; 152 StaticTextWidget *_gfxPopUpDesc; 153 PopUpWidget *_gfxPopUp; 154 StaticTextWidget *_stretchPopUpDesc; 155 PopUpWidget *_stretchPopUp; 156 StaticTextWidget *_scalerPopUpDesc; 157 PopUpWidget *_scalerPopUp, *_scaleFactorPopUp; 158 CheckboxWidget *_fullscreenCheckbox; 159 CheckboxWidget *_filteringCheckbox; 160 CheckboxWidget *_aspectCheckbox; 161 CheckboxWidget *_vsyncCheckbox; 162 StaticTextWidget *_rendererTypePopUpDesc; 163 PopUpWidget *_rendererTypePopUp; 164 StaticTextWidget *_antiAliasPopUpDesc; 165 PopUpWidget *_antiAliasPopUp; 166 StaticTextWidget *_renderModePopUpDesc; 167 PopUpWidget *_renderModePopUp; 168 169 // 170 // Shader controls 171 // 172 bool _enableShaderSettings; 173 StaticTextWidget *_shaderPopUpDesc; 174 PopUpWidget *_shaderPopUp; 175 176 // 177 // Audio controls 178 // 179 bool _enableAudioSettings; 180 StaticTextWidget *_midiPopUpDesc; 181 PopUpWidget *_midiPopUp; 182 StaticTextWidget *_oplPopUpDesc; 183 PopUpWidget *_oplPopUp; 184 185 StaticTextWidget *_mt32DevicePopUpDesc; 186 PopUpWidget *_mt32DevicePopUp; 187 StaticTextWidget *_gmDevicePopUpDesc; 188 PopUpWidget *_gmDevicePopUp; 189 190 // 191 // MIDI controls 192 // 193 bool _enableMIDISettings; 194 CheckboxWidget *_multiMidiCheckbox; 195 StaticTextWidget *_midiGainDesc; 196 SliderWidget *_midiGainSlider; 197 StaticTextWidget *_midiGainLabel; 198 199 // 200 // MT-32 controls 201 // 202 bool _enableMT32Settings; 203 CheckboxWidget *_mt32Checkbox; 204 CheckboxWidget *_enableGSCheckbox; 205 206 // 207 // Subtitle controls 208 // 209 int getSubtitleMode(bool subtitles, bool speech_mute); 210 bool _enableSubtitleSettings; 211 bool _enableSubtitleToggle; 212 StaticTextWidget *_subToggleDesc; 213 RadiobuttonGroup *_subToggleGroup; 214 RadiobuttonWidget *_subToggleSubOnly; 215 RadiobuttonWidget *_subToggleSpeechOnly; 216 RadiobuttonWidget *_subToggleSubBoth; 217 static const char *_subModeDesc[]; 218 static const char *_lowresSubModeDesc[]; 219 StaticTextWidget *_subSpeedDesc; 220 SliderWidget *_subSpeedSlider; 221 StaticTextWidget *_subSpeedLabel; 222 223 // 224 // Volume controls 225 // 226 void updateMusicVolume(const int newValue) const; 227 void updateSfxVolume(const int newValue) const; 228 void updateSpeechVolume(const int newValue) const; 229 bool _enableVolumeSettings; 230 231 StaticTextWidget *_musicVolumeDesc; 232 SliderWidget *_musicVolumeSlider; 233 StaticTextWidget *_musicVolumeLabel; 234 235 StaticTextWidget *_sfxVolumeDesc; 236 SliderWidget *_sfxVolumeSlider; 237 StaticTextWidget *_sfxVolumeLabel; 238 239 StaticTextWidget *_speechVolumeDesc; 240 SliderWidget *_speechVolumeSlider; 241 StaticTextWidget *_speechVolumeLabel; 242 243 CheckboxWidget *_muteCheckbox; 244 245 protected: 246 // 247 // Game GUI options 248 // 249 Common::String _guioptions; 250 Common::String _guioptionsString; 251 252 // 253 // Backend controls 254 // 255 OptionsContainerWidget *_backendOptions; 256 }; 257 258 259 class GlobalOptionsDialog : public OptionsDialog, public CommandSender { 260 public: 261 GlobalOptionsDialog(LauncherDialog *launcher); 262 ~GlobalOptionsDialog() override; 263 264 void apply() override; 265 void close() override; 266 void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override; 267 void handleTickle() override; 268 269 void reflowLayout() override; 270 271 protected: 272 void build() override; 273 void clean() override; 274 275 Common::String _newTheme; 276 LauncherDialog *_launcher; 277 #ifdef USE_FLUIDSYNTH 278 FluidSynthSettingsDialog *_fluidSynthSettingsDialog; 279 #endif 280 281 void addMIDIControls(GuiObject *boss, const Common::String &prefix); 282 283 StaticTextWidget *_savePath; 284 ButtonWidget *_savePathClearButton; 285 StaticTextWidget *_themePath; 286 ButtonWidget *_themePathClearButton; 287 StaticTextWidget *_extraPath; 288 ButtonWidget *_extraPathClearButton; 289 #ifdef DYNAMIC_MODULES 290 StaticTextWidget *_pluginsPath; 291 ButtonWidget *_pluginsPathClearButton; 292 #endif 293 StaticTextWidget *_browserPath; 294 ButtonWidget *_browserPathClearButton; 295 296 void addPathsControls(GuiObject *boss, const Common::String &prefix, bool lowres); 297 298 // 299 // Misc controls 300 // 301 StaticTextWidget *_curTheme; 302 StaticTextWidget *_guiBasePopUpDesc; 303 PopUpWidget *_guiBasePopUp; 304 StaticTextWidget *_rendererPopUpDesc; 305 PopUpWidget *_rendererPopUp; 306 StaticTextWidget *_autosavePeriodPopUpDesc; 307 PopUpWidget *_autosavePeriodPopUp; 308 StaticTextWidget *_guiLanguagePopUpDesc; 309 PopUpWidget *_guiLanguagePopUp; 310 CheckboxWidget *_guiLanguageUseGameLanguageCheckbox; 311 CheckboxWidget *_useSystemDialogsCheckbox; 312 CheckboxWidget *_guiReturnToLauncherAtExit; 313 CheckboxWidget *_guiConfirmExit; 314 315 316 #ifdef USE_UPDATES 317 StaticTextWidget *_updatesPopUpDesc; 318 PopUpWidget *_updatesPopUp; 319 #endif 320 321 bool updateAutosavePeriod(int newValue); 322 void addMiscControls(GuiObject *boss, const Common::String &prefix, bool lowres); 323 324 #ifdef USE_CLOUD 325 #ifdef USE_LIBCURL 326 // 327 // Cloud controls 328 // 329 uint32 _selectedStorageIndex; 330 StaticTextWidget *_storagePopUpDesc; 331 PopUpWidget *_storagePopUp; 332 StaticTextWidget *_storageDisabledHint; 333 ButtonWidget *_storageEnableButton; 334 StaticTextWidget *_storageUsernameDesc; 335 StaticTextWidget *_storageUsername; 336 StaticTextWidget *_storageUsedSpaceDesc; 337 StaticTextWidget *_storageUsedSpace; 338 StaticTextWidget *_storageSyncHint; 339 StaticTextWidget *_storageLastSyncDesc; 340 StaticTextWidget *_storageLastSync; 341 ButtonWidget *_storageSyncSavesButton; 342 StaticTextWidget *_storageDownloadHint; 343 ButtonWidget *_storageDownloadButton; 344 StaticTextWidget *_storageDisconnectHint; 345 ButtonWidget *_storageDisconnectButton; 346 347 bool _connectingStorage; 348 StaticTextWidget *_storageWizardNotConnectedHint; 349 StaticTextWidget *_storageWizardOpenLinkHint; 350 StaticTextWidget *_storageWizardLink; 351 StaticTextWidget *_storageWizardCodeHint; 352 EditTextWidget *_storageWizardCodeBox; 353 ButtonWidget *_storageWizardPasteButton; 354 ButtonWidget *_storageWizardConnectButton; 355 StaticTextWidget *_storageWizardConnectionStatusHint; 356 bool _redrawCloudTab; 357 358 void addCloudControls(GuiObject *boss, const Common::String &prefix, bool lowres); 359 void setupCloudTab(); 360 void shiftWidget(Widget *widget, const char *widgetName, int32 xOffset, int32 yOffset); 361 362 void storageConnectionCallback(Networking::ErrorResponse response); 363 void storageSavesSyncedCallback(Cloud::Storage::BoolResponse response); 364 void storageErrorCallback(Networking::ErrorResponse response); 365 #endif // USE_LIBCURL 366 367 #ifdef USE_SDL_NET 368 // 369 // LAN controls 370 // 371 ButtonWidget *_runServerButton; 372 StaticTextWidget *_serverInfoLabel; 373 ButtonWidget *_rootPathButton; 374 StaticTextWidget *_rootPath; 375 ButtonWidget *_rootPathClearButton; 376 StaticTextWidget *_serverPortDesc; 377 EditTextWidget *_serverPort; 378 ButtonWidget *_serverPortClearButton; 379 StaticTextWidget *_featureDescriptionLine1; 380 StaticTextWidget *_featureDescriptionLine2; 381 bool _serverWasRunning; 382 383 void addNetworkControls(GuiObject *boss, const Common::String &prefix, bool lowres); 384 void reflowNetworkTabLayout(); 385 #endif // USE_SDL_NET 386 387 #endif // USE_CLOUD 388 // 389 // Accessibility controls 390 // 391 #ifdef USE_TTS 392 bool _enableTTS; 393 CheckboxWidget *_ttsCheckbox; 394 PopUpWidget *_ttsVoiceSelectionPopUp; 395 396 void addAccessibilityControls(GuiObject *boss, const Common::String &prefix); 397 #endif 398 #ifdef USE_DISCORD 399 bool _enableDiscordRpc; 400 CheckboxWidget *_discordRpcCheckbox; 401 #endif 402 }; 403 404 } // End of namespace GUI 405 406 #endif 407