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  StaticTextWidget *_rotationModePopUpDesc;
174  PopUpWidget *_rotationModePopUp;
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 
260 public:
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  PathWidget *_savePath;
284  ButtonWidget *_savePathClearButton;
285  PathWidget *_themePath;
286  ButtonWidget *_themePathClearButton;
287  PathWidget *_iconPath;
288  ButtonWidget *_iconPathClearButton;
289 #ifdef USE_DLC
290  PathWidget *_dlcPath;
291  ButtonWidget *_dlcPathClearButton;
292 #endif
293  PathWidget *_extraPath;
294  ButtonWidget *_extraPathClearButton;
295 #ifdef DYNAMIC_MODULES
296  PathWidget *_pluginsPath;
297  ButtonWidget *_pluginsPathClearButton;
298 #endif
299  StaticTextWidget *_browserPath;
300  ButtonWidget *_browserPathClearButton;
301  StaticTextWidget *_logPath;
302 
303  void addPathsControls(GuiObject *boss, const Common::String &prefix, bool lowres);
304 
305  //
306  // GUI controls
307  //
308  StaticTextWidget *_curTheme;
309  StaticTextWidget *_guiBasePopUpDesc;
310  PopUpWidget *_guiBasePopUp;
311  StaticTextWidget *_rendererPopUpDesc;
312  PopUpWidget *_rendererPopUp;
313  StaticTextWidget *_guiLanguagePopUpDesc;
314  PopUpWidget *_guiLanguagePopUp;
315  CheckboxWidget *_guiLanguageUseGameLanguageCheckbox;
316  CheckboxWidget *_useSystemDialogsCheckbox;
317  CheckboxWidget *_guiReturnToLauncherAtExit;
318  CheckboxWidget *_guiConfirmExit;
319  CheckboxWidget *_guiDisableBDFScaling;
320 
321  void addGUIControls(GuiObject *boss, const Common::String &prefix, bool lowres);
322 
323  //
324  // Misc controls
325  //
326  StaticTextWidget *_autosavePeriodPopUpDesc;
327  PopUpWidget *_autosavePeriodPopUp;
328  StaticTextWidget *_randomSeedDesc;
329  EditTextWidget *_randomSeed;
330  ButtonWidget *_randomSeedClearButton;
331  PopUpWidget *_debugLevelPopUp;
332 
333 #ifdef USE_UPDATES
334  StaticTextWidget *_updatesPopUpDesc;
335  PopUpWidget *_updatesPopUp;
336 #endif
337 
338  bool updateAutosavePeriod(int newValue);
339  void addMiscControls(GuiObject *boss, const Common::String &prefix, bool lowres);
340 
341 #ifdef USE_CLOUD
342 #ifdef USE_LIBCURL
343  //
344  // Cloud controls
345  //
346  uint32 _selectedStorageIndex;
347  StaticTextWidget *_storagePopUpDesc;
348  PopUpWidget *_storagePopUp;
349  StaticTextWidget *_storageDisabledHint;
350  ButtonWidget *_storageEnableButton;
351  StaticTextWidget *_storageUsernameDesc;
352  StaticTextWidget *_storageUsername;
353  StaticTextWidget *_storageUsedSpaceDesc;
354  StaticTextWidget *_storageUsedSpace;
355  StaticTextWidget *_storageSyncHint;
356  StaticTextWidget *_storageLastSyncDesc;
357  StaticTextWidget *_storageLastSync;
358  ButtonWidget *_storageSyncSavesButton;
359  StaticTextWidget *_storageDownloadHint;
360  ButtonWidget *_storageDownloadButton;
361  StaticTextWidget *_storageDisconnectHint;
362  ButtonWidget *_storageDisconnectButton;
363 
364  bool _connectingStorage;
365  StaticTextWidget *_storageWizardNotConnectedHint;
366  ButtonWidget *_storageWizardConnectButton;
367  bool _redrawCloudTab;
368 
369  void addCloudControls(GuiObject *boss, const Common::String &prefix, bool lowres);
370  void setupCloudTab();
371  void shiftWidget(Widget *widget, const char *widgetName, int32 xOffset, int32 yOffset);
372 
373  void storageSavesSyncedCallback(const Cloud::Storage::BoolResponse &response);
374  void storageErrorCallback(const Networking::ErrorResponse &response);
375 #endif // USE_LIBCURL
376 #endif // USE_CLOUD
377 
378 #ifdef USE_SDL_NET
379  //
380  // LAN controls
381  //
382  ButtonWidget *_runServerButton;
383  StaticTextWidget *_serverInfoLabel;
384  ButtonWidget *_rootPathButton;
385  PathWidget *_rootPath;
386  ButtonWidget *_rootPathClearButton;
387  StaticTextWidget *_serverPortDesc;
388  EditTextWidget *_serverPort;
389  ButtonWidget *_serverPortClearButton;
390  StaticTextWidget *_featureDescriptionLine1;
391  StaticTextWidget *_featureDescriptionLine2;
392  bool _serverWasRunning;
393 
394  void addNetworkControls(GuiObject *boss, const Common::String &prefix, bool lowres);
395  void reflowNetworkTabLayout();
396 #endif // USE_SDL_NET
397 
398  //
399  // Accessibility controls
400  //
401 #ifdef USE_TTS
402  bool _enableTTS;
403  CheckboxWidget *_ttsCheckbox;
404  PopUpWidget *_ttsVoiceSelectionPopUp;
405 
406  void addAccessibilityControls(GuiObject *boss, const Common::String &prefix);
407 #endif
408 #ifdef USE_DISCORD
409  bool _enableDiscordRpc;
410  CheckboxWidget *_discordRpcCheckbox;
411 #endif
412 };
413 
414 } // End of namespace GUI
415 
416 #endif
Definition: fluidsynth-dialog.h:36
Definition: str.h:59
Definition: widget.h:355
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:329
Definition: widget.h:205
Definition: request.h:47
Definition: widget.h:405
Definition: widget.h:378
Definition: system.h:46
Definition: object.h:60
Definition: widget.h:532
Definition: widget.h:463
Definition: options.h:259
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:233
Definition: popup.h:39
Definition: object.h:40
Definition: options.h:61