ScummVM API documentation
options.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef OPTIONS_DIALOG_H
23 #define OPTIONS_DIALOG_H
24 
25 #include "engines/metaengine.h"
26 
27 #include "gui/dialog.h"
28 #include "common/str.h"
29 #include "audio/mididrv.h"
30 
31 #ifdef USE_FLUIDSYNTH
32 #include "gui/fluidsynth-dialog.h"
33 #endif
34 
35 #ifdef USE_LIBCURL
36 #include "backends/cloud/storage.h"
37 #endif
38 
39 namespace Common {
40 class RemapWidget;
41 }
42 
43 namespace GUI {
44 class LauncherDialog;
45 
46 class CheckboxWidget;
47 class EditTextWidget;
48 class PopUpWidget;
49 class SliderWidget;
50 class StaticTextWidget;
51 class TabWidget;
52 class ButtonWidget;
53 class CommandSender;
54 class GuiObject;
55 class RadiobuttonGroup;
56 class RadiobuttonWidget;
57 class PathWidget;
58 class ScrollContainerWidget;
59 class OptionsContainerWidget;
60 
61 class OptionsDialog : public Dialog {
62 public:
63  OptionsDialog(const Common::String &domain, int x, int y, int w, int h);
64  OptionsDialog(const Common::String &domain, const Common::String &name);
65  ~OptionsDialog() override;
66 
67  void init();
68 
69  void open() override;
70  virtual void apply();
71  void close() override;
72  void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
73  void handleTickle() override;
74  void handleOtherEvent(const Common::Event &event) override;
75 
76  const Common::String& getDomain() const { return _domain; }
77 
78  void reflowLayout() override;
79 
80 protected:
83 
84  ButtonWidget *_soundFontButton;
85  PathWidget *_soundFont;
86  ButtonWidget *_soundFontClearButton;
87 
88  virtual void build();
89  virtual void clean();
90  void rebuild();
91  bool testGraphicsSettings();
92 
93  void addControlControls(GuiObject *boss, const Common::String &prefix);
94  void addKeyMapperControls(GuiObject *boss, const Common::String &prefix, const Common::Array<Common::Keymap *> &keymaps, const Common::String &domain);
95  void addAchievementsControls(GuiObject *boss, const Common::String &prefix);
96  void addStatisticsControls(GuiObject *boss, const Common::String &prefix);
97  void addGraphicControls(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 setAudioSettingsState(bool enabled);
108  void setMIDISettingsState(bool enabled);
109  void setMT32SettingsState(bool enabled);
110  void setVolumeSettingsState(bool enabled);
111  void setSubtitleSettingsState(bool enabled);
112 
113  void enableShaderControls(bool enabled);
114 
115  virtual void setupGraphicsTab();
116  void updateScaleFactors(uint32 tag);
117 
118  bool loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicType preferredType = MT_AUTO);
119  void saveMusicDeviceSetting(PopUpWidget *popup, Common::String setting);
120 
121  TabWidget *_tabWidget;
122  int _graphicsTabId;
123  int _midiTabId;
124 
125  ScrollContainerWidget *_pathsContainer;
126 
127  PathWidget *_shader;
128  ButtonWidget *_shaderClearButton;
129  ButtonWidget *_updateShadersButton = nullptr;
130 
131 private:
132 
133  //
134  // Control controls
135  //
136  bool _enableControlSettings;
137 
138  CheckboxWidget *_touchpadCheckbox;
139 
140  StaticTextWidget *_kbdMouseSpeedDesc;
141  SliderWidget *_kbdMouseSpeedSlider;
142  StaticTextWidget *_kbdMouseSpeedLabel;
143  StaticTextWidget *_joystickDeadzoneDesc;
144  SliderWidget *_joystickDeadzoneSlider;
145  StaticTextWidget *_joystickDeadzoneLabel;
146 
147  //
148  // KeyMapper controls
149  //
150  Common::RemapWidget *_keymapperWidget;
151 
152  //
153  // Graphics controls
154  //
155  bool _enableGraphicSettings;
156  StaticTextWidget *_gfxPopUpDesc;
157  PopUpWidget *_gfxPopUp;
158  StaticTextWidget *_stretchPopUpDesc;
159  PopUpWidget *_stretchPopUp;
160  StaticTextWidget *_scalerPopUpDesc;
161  PopUpWidget *_scalerPopUp, *_scaleFactorPopUp;
162  ButtonWidget *_shaderButton;
163  CheckboxWidget *_fullscreenCheckbox;
164  CheckboxWidget *_filteringCheckbox;
165  CheckboxWidget *_aspectCheckbox;
166  CheckboxWidget *_vsyncCheckbox;
167  StaticTextWidget *_rendererTypePopUpDesc;
168  PopUpWidget *_rendererTypePopUp;
169  StaticTextWidget *_antiAliasPopUpDesc;
170  PopUpWidget *_antiAliasPopUp;
171  StaticTextWidget *_renderModePopUpDesc;
172  PopUpWidget *_renderModePopUp;
173 
174  //
175  // Audio controls
176  //
177  bool _enableAudioSettings;
178  StaticTextWidget *_midiPopUpDesc;
179  PopUpWidget *_midiPopUp;
180  StaticTextWidget *_oplPopUpDesc;
181  PopUpWidget *_oplPopUp;
182 
183  StaticTextWidget *_mt32DevicePopUpDesc;
184  PopUpWidget *_mt32DevicePopUp;
185  StaticTextWidget *_gmDevicePopUpDesc;
186  PopUpWidget *_gmDevicePopUp;
187 
188  //
189  // MIDI controls
190  //
191  bool _enableMIDISettings;
192  CheckboxWidget *_multiMidiCheckbox;
193  StaticTextWidget *_midiGainDesc;
194  SliderWidget *_midiGainSlider;
195  StaticTextWidget *_midiGainLabel;
196 
197  //
198  // MT-32 controls
199  //
200  bool _enableMT32Settings;
201  CheckboxWidget *_mt32Checkbox;
202  CheckboxWidget *_enableGSCheckbox;
203 
204  //
205  // Subtitle controls
206  //
207  int getSubtitleMode(bool subtitles, bool speech_mute);
208  bool _enableSubtitleSettings;
209  bool _enableSubtitleToggle;
210  StaticTextWidget *_subToggleDesc;
211  RadiobuttonGroup *_subToggleGroup;
212  RadiobuttonWidget *_subToggleSubOnly;
213  RadiobuttonWidget *_subToggleSpeechOnly;
214  RadiobuttonWidget *_subToggleSubBoth;
215  static const char *_subModeDesc[];
216  static const char *_lowresSubModeDesc[];
217  StaticTextWidget *_subSpeedDesc;
218  SliderWidget *_subSpeedSlider;
219  StaticTextWidget *_subSpeedLabel;
220 
221  //
222  // Volume controls
223  //
224  void updateMusicVolume(const int newValue) const;
225  void updateSfxVolume(const int newValue) const;
226  void updateSpeechVolume(const int newValue) const;
227  bool _enableVolumeSettings;
228 
229  StaticTextWidget *_musicVolumeDesc;
230  SliderWidget *_musicVolumeSlider;
231  StaticTextWidget *_musicVolumeLabel;
232 
233  StaticTextWidget *_sfxVolumeDesc;
234  SliderWidget *_sfxVolumeSlider;
235  StaticTextWidget *_sfxVolumeLabel;
236 
237  StaticTextWidget *_speechVolumeDesc;
238  SliderWidget *_speechVolumeSlider;
239  StaticTextWidget *_speechVolumeLabel;
240 
241  CheckboxWidget *_muteCheckbox;
242 
243 protected:
244  //
245  // Game GUI options
246  //
247  Common::String _guioptions;
248  Common::String _guioptionsString;
249 
250  //
251  // Backend controls
252  //
253  OptionsContainerWidget *_backendOptions;
254 };
255 
256 
258 public:
260  ~GlobalOptionsDialog() override;
261 
262  void apply() override;
263  void close() override;
264  void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
265  void handleTickle() override;
266 
267  void reflowLayout() override;
268 
269 protected:
270  void build() override;
271  void clean() override;
272 
273  Common::String _newTheme;
274  LauncherDialog *_launcher;
275 #ifdef USE_FLUIDSYNTH
276  FluidSynthSettingsDialog *_fluidSynthSettingsDialog;
277 #endif
278 
279  void addMIDIControls(GuiObject *boss, const Common::String &prefix);
280 
281  PathWidget *_savePath;
282  ButtonWidget *_savePathClearButton;
283  PathWidget *_themePath;
284  ButtonWidget *_themePathClearButton;
285  PathWidget *_iconPath;
286  ButtonWidget *_iconPathClearButton;
287 #ifdef USE_DLC
288  PathWidget *_dlcPath;
289  ButtonWidget *_dlcPathClearButton;
290 #endif
291  PathWidget *_extraPath;
292  ButtonWidget *_extraPathClearButton;
293 #ifdef DYNAMIC_MODULES
294  PathWidget *_pluginsPath;
295  ButtonWidget *_pluginsPathClearButton;
296 #endif
297  StaticTextWidget *_browserPath;
298  ButtonWidget *_browserPathClearButton;
299  StaticTextWidget *_logPath;
300 
301  void addPathsControls(GuiObject *boss, const Common::String &prefix, bool lowres);
302 
303  //
304  // GUI controls
305  //
306  StaticTextWidget *_curTheme;
307  StaticTextWidget *_guiBasePopUpDesc;
308  PopUpWidget *_guiBasePopUp;
309  StaticTextWidget *_rendererPopUpDesc;
310  PopUpWidget *_rendererPopUp;
311  StaticTextWidget *_guiLanguagePopUpDesc;
312  PopUpWidget *_guiLanguagePopUp;
313  CheckboxWidget *_guiLanguageUseGameLanguageCheckbox;
314  CheckboxWidget *_useSystemDialogsCheckbox;
315  CheckboxWidget *_guiReturnToLauncherAtExit;
316  CheckboxWidget *_guiConfirmExit;
317  CheckboxWidget *_guiDisableBDFScaling;
318 
319  void addGUIControls(GuiObject *boss, const Common::String &prefix, bool lowres);
320 
321  //
322  // Misc controls
323  //
324  StaticTextWidget *_autosavePeriodPopUpDesc;
325  PopUpWidget *_autosavePeriodPopUp;
326  StaticTextWidget *_randomSeedDesc;
327  EditTextWidget *_randomSeed;
328  ButtonWidget *_randomSeedClearButton;
329  PopUpWidget *_debugLevelPopUp;
330 
331 #ifdef USE_UPDATES
332  StaticTextWidget *_updatesPopUpDesc;
333  PopUpWidget *_updatesPopUp;
334 #endif
335 
336  bool updateAutosavePeriod(int newValue);
337  void addMiscControls(GuiObject *boss, const Common::String &prefix, bool lowres);
338 
339 #ifdef USE_CLOUD
340 #ifdef USE_LIBCURL
341  //
342  // Cloud controls
343  //
344  uint32 _selectedStorageIndex;
345  StaticTextWidget *_storagePopUpDesc;
346  PopUpWidget *_storagePopUp;
347  StaticTextWidget *_storageDisabledHint;
348  ButtonWidget *_storageEnableButton;
349  StaticTextWidget *_storageUsernameDesc;
350  StaticTextWidget *_storageUsername;
351  StaticTextWidget *_storageUsedSpaceDesc;
352  StaticTextWidget *_storageUsedSpace;
353  StaticTextWidget *_storageSyncHint;
354  StaticTextWidget *_storageLastSyncDesc;
355  StaticTextWidget *_storageLastSync;
356  ButtonWidget *_storageSyncSavesButton;
357  StaticTextWidget *_storageDownloadHint;
358  ButtonWidget *_storageDownloadButton;
359  StaticTextWidget *_storageDisconnectHint;
360  ButtonWidget *_storageDisconnectButton;
361 
362  bool _connectingStorage;
363  StaticTextWidget *_storageWizardNotConnectedHint;
364  ButtonWidget *_storageWizardConnectButton;
365  bool _redrawCloudTab;
366 
367  void addCloudControls(GuiObject *boss, const Common::String &prefix, bool lowres);
368  void setupCloudTab();
369  void shiftWidget(Widget *widget, const char *widgetName, int32 xOffset, int32 yOffset);
370 
371  void storageSavesSyncedCallback(const Cloud::Storage::BoolResponse &response);
372  void storageErrorCallback(const Networking::ErrorResponse &response);
373 #endif // USE_LIBCURL
374 #endif // USE_CLOUD
375 
376 #ifdef USE_SDL_NET
377  //
378  // LAN controls
379  //
380  ButtonWidget *_runServerButton;
381  StaticTextWidget *_serverInfoLabel;
382  ButtonWidget *_rootPathButton;
383  PathWidget *_rootPath;
384  ButtonWidget *_rootPathClearButton;
385  StaticTextWidget *_serverPortDesc;
386  EditTextWidget *_serverPort;
387  ButtonWidget *_serverPortClearButton;
388  StaticTextWidget *_featureDescriptionLine1;
389  StaticTextWidget *_featureDescriptionLine2;
390  bool _serverWasRunning;
391 
392  void addNetworkControls(GuiObject *boss, const Common::String &prefix, bool lowres);
393  void reflowNetworkTabLayout();
394 #endif // USE_SDL_NET
395 
396  //
397  // Accessibility controls
398  //
399 #ifdef USE_TTS
400  bool _enableTTS;
401  CheckboxWidget *_ttsCheckbox;
402  PopUpWidget *_ttsVoiceSelectionPopUp;
403 
404  void addAccessibilityControls(GuiObject *boss, const Common::String &prefix);
405 #endif
406 #ifdef USE_DISCORD
407  bool _enableDiscordRpc;
408  CheckboxWidget *_discordRpcCheckbox;
409 #endif
410 };
411 
412 } // End of namespace GUI
413 
414 #endif
Definition: fluidsynth-dialog.h:36
Definition: str.h:59
Definition: widget.h:354
Definition: launcher.h:107
Definition: request.h:73
Definition: array.h:52
Definition: edittext.h:32
Definition: scrollcontainer.h:31
MusicType
Definition: mididrv.h:44
Definition: remap-widget.h:44
Definition: widget.h:328
Definition: widget.h:205
Definition: request.h:47
Definition: widget.h:404
Definition: widget.h:377
Definition: system.h:46
Definition: object.h:60
Definition: widget.h:531
Definition: widget.h:462
Definition: options.h:257
Definition: events.h:199
Definition: algorithm.h:29
Definition: dialog.h:49
Definition: widget.h:101
Definition: tab.h:36
Common::String _domain
Definition: options.h:82
Definition: widget.h:232
Definition: popup.h:39
Definition: object.h:40
Definition: options.h:61