aboutsummaryrefslogtreecommitdiff
path: root/gui/options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/options.cpp')
-rw-r--r--gui/options.cpp1249
1 files changed, 943 insertions, 306 deletions
diff --git a/gui/options.cpp b/gui/options.cpp
index ba247e5f15..3f6fc5aa2c 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -28,6 +28,7 @@
#include "gui/widgets/popup.h"
#include "gui/widgets/tab.h"
#include "gui/ThemeEval.h"
+#include "gui/launcher.h"
#include "common/fs.h"
#include "common/config-manager.h"
@@ -36,11 +37,26 @@
#include "common/system.h"
#include "common/textconsole.h"
#include "common/translation.h"
+#include "common/updates.h"
#include "audio/mididrv.h"
#include "audio/musicplugin.h"
#include "audio/mixer.h"
#include "audio/fmopl.h"
+#include "widgets/scrollcontainer.h"
+#include "widgets/edittext.h"
+
+#ifdef USE_CLOUD
+#ifdef USE_LIBCURL
+#include "backends/cloud/cloudmanager.h"
+#include "gui/downloaddialog.h"
+#include "gui/storagewizarddialog.h"
+#endif
+
+#ifdef USE_SDL_NET
+#include "backends/networking/sdl_net/localwebserver.h"
+#endif
+#endif
namespace GUI {
@@ -61,7 +77,8 @@ enum {
kChooseExtraDirCmd = 'chex',
kExtraPathClearCmd = 'clex',
kChoosePluginsDirCmd = 'chpl',
- kChooseThemeCmd = 'chtf'
+ kChooseThemeCmd = 'chtf',
+ kUpdatesCheckCmd = 'updc'
};
enum {
@@ -70,7 +87,7 @@ enum {
kSubtitlesBoth
};
-#ifdef SMALL_SCREEN_DEVICE
+#ifdef GUI_ENABLE_KEYSDIALOG
enum {
kChooseKeyMappingCmd = 'chma'
};
@@ -82,6 +99,23 @@ enum {
};
#endif
+#ifdef USE_CLOUD
+enum {
+ kConfigureStorageCmd = 'cfst',
+ kRefreshStorageCmd = 'rfst',
+ kDownloadStorageCmd = 'dlst',
+ kRunServerCmd = 'rnsv',
+ kCloudTabContainerReflowCmd = 'ctcr',
+ kServerPortClearCmd = 'spcl',
+ kChooseRootDirCmd = 'chrp',
+ kRootPathClearCmd = 'clrp'
+};
+#endif
+
+enum {
+ kApplyCmd = 'appl'
+};
+
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[] = { _s("<default>"), _s("8 kHz"), _s("11 kHz"), _s("22 kHz"), _s("44 kHz"), _s("48 kHz"), 0 };
@@ -93,7 +127,7 @@ OptionsDialog::OptionsDialog(const Common::String &domain, int x, int y, int w,
}
OptionsDialog::OptionsDialog(const Common::String &domain, const Common::String &name)
- : Dialog(name), _domain(domain), _graphicsTabId(-1), _tabWidget(0) {
+ : Dialog(name), _domain(domain), _graphicsTabId(-1), _midiTabId(-1), _pathsTabId(-1), _tabWidget(0) {
init();
}
@@ -108,6 +142,7 @@ void OptionsDialog::init() {
_renderModePopUp = 0;
_renderModePopUpDesc = 0;
_fullscreenCheckbox = 0;
+ _filteringCheckbox = 0;
_aspectCheckbox = 0;
_enableAudioSettings = false;
_midiPopUp = 0;
@@ -142,6 +177,7 @@ void OptionsDialog::init() {
_speechVolumeSlider = 0;
_speechVolumeLabel = 0;
_muteCheckbox = 0;
+ _enableSubtitleSettings = false;
_subToggleDesc = 0;
_subToggleGroup = 0;
_subToggleSubOnly = 0;
@@ -150,7 +186,6 @@ void OptionsDialog::init() {
_subSpeedDesc = 0;
_subSpeedSlider = 0;
_subSpeedLabel = 0;
- _oldTheme = g_gui.theme()->getThemeId();
// Retrieve game GUI options
_guioptions.clear();
@@ -159,13 +194,8 @@ void OptionsDialog::init() {
_guioptions = parseGameGUIOptions(_guioptionsString);
}
}
-
-void OptionsDialog::open() {
- Dialog::open();
-
- // Reset result value
- setResult(0);
-
+
+void OptionsDialog::build() {
// Retrieve game GUI options
_guioptions.clear();
if (ConfMan.hasKey("guioptions", _domain)) {
@@ -204,14 +234,19 @@ void OptionsDialog::open() {
_renderModePopUp->setSelectedTag(sel);
}
-#ifdef SMALL_SCREEN_DEVICE
+#ifdef GUI_ONLY_FULLSCREEN
_fullscreenCheckbox->setState(true);
_fullscreenCheckbox->setEnabled(false);
- _aspectCheckbox->setState(false);
- _aspectCheckbox->setEnabled(false);
-#else // !SMALL_SCREEN_DEVICE
+#else // !GUI_ONLY_FULLSCREEN
// Fullscreen setting
_fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain));
+#endif // GUI_ONLY_FULLSCREEN
+
+ // Filtering setting
+ if (g_system->hasFeature(OSystem::kFeatureFilteringMode))
+ _filteringCheckbox->setState(ConfMan.getBool("filtering", _domain));
+ else
+ _filteringCheckbox->setVisible(false);
// Aspect ratio setting
if (_guioptions.contains(GUIO_NOASPECT)) {
@@ -221,7 +256,6 @@ void OptionsDialog::open() {
_aspectCheckbox->setEnabled(true);
_aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain));
}
-#endif // SMALL_SCREEN_DEVICE
}
@@ -316,199 +350,238 @@ void OptionsDialog::open() {
_subSpeedLabel->setValue(speed);
}
}
+
+void OptionsDialog::clean() {
+ delete _subToggleGroup;
+ while (_firstWidget) {
+ Widget* w = _firstWidget;
+ removeWidget(w);
+ delete w;
+ }
+ init();
+}
+
+void OptionsDialog::rebuild() {
+ int currentTab = _tabWidget->getActiveTab();
+ clean();
+ build();
+ reflowLayout();
+ _tabWidget->setActiveTab(currentTab);
+ setFocusWidget(_firstWidget);
+}
-void OptionsDialog::close() {
- if (getResult()) {
-
- // Graphic options
- bool graphicsModeChanged = false;
- if (_fullscreenCheckbox) {
- if (_enableGraphicSettings) {
- if (ConfMan.getBool("fullscreen", _domain) != _fullscreenCheckbox->getState())
- graphicsModeChanged = true;
- if (ConfMan.getBool("aspect_ratio", _domain) != _aspectCheckbox->getState())
- graphicsModeChanged = true;
-
- ConfMan.setBool("fullscreen", _fullscreenCheckbox->getState(), _domain);
- ConfMan.setBool("aspect_ratio", _aspectCheckbox->getState(), _domain);
-
- bool isSet = false;
-
- if ((int32)_gfxPopUp->getSelectedTag() >= 0) {
- const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
-
- while (gm->name) {
- if (gm->id == (int)_gfxPopUp->getSelectedTag()) {
- if (ConfMan.get("gfx_mode", _domain) != gm->name)
- graphicsModeChanged = true;
- ConfMan.set("gfx_mode", gm->name, _domain);
- isSet = true;
- break;
- }
- gm++;
+void OptionsDialog::open() {
+ build();
+
+ Dialog::open();
+
+ // Reset result value
+ setResult(0);
+}
+
+void OptionsDialog::apply() {
+ // Graphic options
+ bool graphicsModeChanged = false;
+ if (_fullscreenCheckbox) {
+ if (_enableGraphicSettings) {
+ if (ConfMan.getBool("filtering", _domain) != _filteringCheckbox->getState())
+ graphicsModeChanged = true;
+ if (ConfMan.getBool("fullscreen", _domain) != _fullscreenCheckbox->getState())
+ graphicsModeChanged = true;
+ if (ConfMan.getBool("aspect_ratio", _domain) != _aspectCheckbox->getState())
+ graphicsModeChanged = true;
+
+ ConfMan.setBool("filtering", _filteringCheckbox->getState(), _domain);
+ ConfMan.setBool("fullscreen", _fullscreenCheckbox->getState(), _domain);
+ ConfMan.setBool("aspect_ratio", _aspectCheckbox->getState(), _domain);
+
+ bool isSet = false;
+
+ if ((int32)_gfxPopUp->getSelectedTag() >= 0) {
+ const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
+
+ while (gm->name) {
+ if (gm->id == (int)_gfxPopUp->getSelectedTag()) {
+ if (ConfMan.get("gfx_mode", _domain) != gm->name)
+ graphicsModeChanged = true;
+ ConfMan.set("gfx_mode", gm->name, _domain);
+ isSet = true;
+ break;
}
+ gm++;
}
- if (!isSet)
- ConfMan.removeKey("gfx_mode", _domain);
-
- if ((int32)_renderModePopUp->getSelectedTag() >= 0)
- ConfMan.set("render_mode", Common::getRenderModeCode((Common::RenderMode)_renderModePopUp->getSelectedTag()), _domain);
- } else {
- ConfMan.removeKey("fullscreen", _domain);
- ConfMan.removeKey("aspect_ratio", _domain);
- ConfMan.removeKey("gfx_mode", _domain);
- ConfMan.removeKey("render_mode", _domain);
}
+ if (!isSet)
+ ConfMan.removeKey("gfx_mode", _domain);
+
+ if ((int32)_renderModePopUp->getSelectedTag() >= 0)
+ ConfMan.set("render_mode", Common::getRenderModeCode((Common::RenderMode)_renderModePopUp->getSelectedTag()), _domain);
+ } else {
+ ConfMan.removeKey("fullscreen", _domain);
+ ConfMan.removeKey("filtering", _domain);
+ ConfMan.removeKey("aspect_ratio", _domain);
+ ConfMan.removeKey("gfx_mode", _domain);
+ ConfMan.removeKey("render_mode", _domain);
}
-
- // Setup graphics again if needed
- if (_domain == Common::ConfigManager::kApplicationDomain && graphicsModeChanged) {
- g_system->beginGFXTransaction();
- g_system->setGraphicsMode(ConfMan.get("gfx_mode", _domain).c_str());
-
- if (ConfMan.hasKey("aspect_ratio"))
- g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio", _domain));
- if (ConfMan.hasKey("fullscreen"))
- g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen", _domain));
- OSystem::TransactionError gfxError = g_system->endGFXTransaction();
-
- // Since this might change the screen resolution we need to give
- // the GUI a chance to update it's internal state. Otherwise we might
- // get a crash when the GUI tries to grab the overlay.
- //
- // This fixes bug #3303501 "Switching from HQ2x->HQ3x crashes ScummVM"
- //
- // It is important that this is called *before* any of the current
- // dialog's widgets are destroyed (for example before
- // Dialog::close) is called, to prevent crashes caused by invalid
- // widgets being referenced or similar errors.
- g_gui.checkScreenChange();
-
- if (gfxError != OSystem::kTransactionSuccess) {
- // Revert ConfMan to what OSystem is using.
- Common::String message = _("Failed to apply some of the graphic options changes:");
-
- if (gfxError & OSystem::kTransactionModeSwitchFailed) {
- const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
- while (gm->name) {
- if (gm->id == g_system->getGraphicsMode()) {
- ConfMan.set("gfx_mode", gm->name, _domain);
- break;
- }
- gm++;
+ }
+
+ // Setup graphics again if needed
+ if (_domain == Common::ConfigManager::kApplicationDomain && graphicsModeChanged) {
+ g_system->beginGFXTransaction();
+ g_system->setGraphicsMode(ConfMan.get("gfx_mode", _domain).c_str());
+
+ if (ConfMan.hasKey("aspect_ratio"))
+ g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio", _domain));
+ if (ConfMan.hasKey("fullscreen"))
+ g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen", _domain));
+ if (ConfMan.hasKey("filtering"))
+ g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering", _domain));
+
+ OSystem::TransactionError gfxError = g_system->endGFXTransaction();
+
+ // Since this might change the screen resolution we need to give
+ // the GUI a chance to update it's internal state. Otherwise we might
+ // get a crash when the GUI tries to grab the overlay.
+ //
+ // This fixes bug #3303501 "Switching from HQ2x->HQ3x crashes ScummVM"
+ //
+ // It is important that this is called *before* any of the current
+ // dialog's widgets are destroyed (for example before
+ // Dialog::close) is called, to prevent crashes caused by invalid
+ // widgets being referenced or similar errors.
+ g_gui.checkScreenChange();
+
+ if (gfxError != OSystem::kTransactionSuccess) {
+ // Revert ConfMan to what OSystem is using.
+ Common::String message = _("Failed to apply some of the graphic options changes:");
+
+ if (gfxError & OSystem::kTransactionModeSwitchFailed) {
+ const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
+ while (gm->name) {
+ if (gm->id == g_system->getGraphicsMode()) {
+ ConfMan.set("gfx_mode", gm->name, _domain);
+ break;
}
- message += "\n";
- message += _("the video mode could not be changed.");
+ gm++;
}
-
- if (gfxError & OSystem::kTransactionAspectRatioFailed) {
- ConfMan.setBool("aspect_ratio", g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection), _domain);
- message += "\n";
- message += _("the fullscreen setting could not be changed");
- }
-
- if (gfxError & OSystem::kTransactionFullscreenFailed) {
- ConfMan.setBool("fullscreen", g_system->getFeatureState(OSystem::kFeatureFullscreenMode), _domain);
- message += "\n";
- message += _("the aspect ratio setting could not be changed");
- }
-
- // And display the error
- GUI::MessageDialog dialog(message);
- dialog.runModal();
+ message += "\n";
+ message += _("the video mode could not be changed.");
}
- }
-
- // Volume options
- if (_musicVolumeSlider) {
- if (_enableVolumeSettings) {
- ConfMan.setInt("music_volume", _musicVolumeSlider->getValue(), _domain);
- ConfMan.setInt("sfx_volume", _sfxVolumeSlider->getValue(), _domain);
- ConfMan.setInt("speech_volume", _speechVolumeSlider->getValue(), _domain);
- ConfMan.setBool("mute", _muteCheckbox->getState(), _domain);
- } else {
- ConfMan.removeKey("music_volume", _domain);
- ConfMan.removeKey("sfx_volume", _domain);
- ConfMan.removeKey("speech_volume", _domain);
- ConfMan.removeKey("mute", _domain);
+
+ if (gfxError & OSystem::kTransactionAspectRatioFailed) {
+ ConfMan.setBool("aspect_ratio", g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection), _domain);
+ message += "\n";
+ message += _("the aspect ratio setting could not be changed");
}
- }
-
- // Audio options
- if (_midiPopUp) {
- if (_enableAudioSettings) {
- saveMusicDeviceSetting(_midiPopUp, "music_driver");
- } else {
- ConfMan.removeKey("music_driver", _domain);
+
+ if (gfxError & OSystem::kTransactionFullscreenFailed) {
+ ConfMan.setBool("fullscreen", g_system->getFeatureState(OSystem::kFeatureFullscreenMode), _domain);
+ message += "\n";
+ message += _("the fullscreen setting could not be changed");
+ }
+
+ if (gfxError & OSystem::kTransactionFilteringFailed) {
+ ConfMan.setBool("filtering", g_system->getFeatureState(OSystem::kFeatureFilteringMode), _domain);
+ message += "\n";
+ message += _("the filtering setting could not be changed");
}
+
+ // And display the error
+ GUI::MessageDialog dialog(message);
+ dialog.runModal();
}
-
- if (_oplPopUp) {
- if (_enableAudioSettings) {
- const OPL::Config::EmulatorDescription *ed = OPL::Config::findDriver(_oplPopUp->getSelectedTag());
-
- if (ed)
- ConfMan.set("opl_driver", ed->name, _domain);
- else
- ConfMan.removeKey("opl_driver", _domain);
- } else {
+ }
+
+ // Volume options
+ if (_musicVolumeSlider) {
+ if (_enableVolumeSettings) {
+ ConfMan.setInt("music_volume", _musicVolumeSlider->getValue(), _domain);
+ ConfMan.setInt("sfx_volume", _sfxVolumeSlider->getValue(), _domain);
+ ConfMan.setInt("speech_volume", _speechVolumeSlider->getValue(), _domain);
+ ConfMan.setBool("mute", _muteCheckbox->getState(), _domain);
+ } else {
+ ConfMan.removeKey("music_volume", _domain);
+ ConfMan.removeKey("sfx_volume", _domain);
+ ConfMan.removeKey("speech_volume", _domain);
+ ConfMan.removeKey("mute", _domain);
+ }
+ }
+
+ // Audio options
+ if (_midiPopUp) {
+ if (_enableAudioSettings) {
+ saveMusicDeviceSetting(_midiPopUp, "music_driver");
+ } else {
+ ConfMan.removeKey("music_driver", _domain);
+ }
+ }
+
+ if (_oplPopUp) {
+ if (_enableAudioSettings) {
+ const OPL::Config::EmulatorDescription *ed = OPL::Config::findDriver(_oplPopUp->getSelectedTag());
+
+ if (ed)
+ ConfMan.set("opl_driver", ed->name, _domain);
+ else
ConfMan.removeKey("opl_driver", _domain);
- }
+ } else {
+ ConfMan.removeKey("opl_driver", _domain);
}
-
- if (_outputRatePopUp) {
- if (_enableAudioSettings) {
- if (_outputRatePopUp->getSelectedTag() != 0)
- ConfMan.setInt("output_rate", _outputRatePopUp->getSelectedTag(), _domain);
- else
- ConfMan.removeKey("output_rate", _domain);
- } else {
+ }
+
+ if (_outputRatePopUp) {
+ if (_enableAudioSettings) {
+ if (_outputRatePopUp->getSelectedTag() != 0)
+ ConfMan.setInt("output_rate", _outputRatePopUp->getSelectedTag(), _domain);
+ else
ConfMan.removeKey("output_rate", _domain);
- }
+ } else {
+ ConfMan.removeKey("output_rate", _domain);
}
-
- // MIDI options
- if (_multiMidiCheckbox) {
- if (_enableMIDISettings) {
- saveMusicDeviceSetting(_gmDevicePopUp, "gm_device");
-
- ConfMan.setBool("multi_midi", _multiMidiCheckbox->getState(), _domain);
- ConfMan.setInt("midi_gain", _midiGainSlider->getValue(), _domain);
-
- Common::String soundFont(_soundFont->getLabel());
- if (!soundFont.empty() && (soundFont != _c("None", "soundfont")))
- ConfMan.set("soundfont", soundFont, _domain);
- else
- ConfMan.removeKey("soundfont", _domain);
- } else {
- ConfMan.removeKey("gm_device", _domain);
- ConfMan.removeKey("multi_midi", _domain);
- ConfMan.removeKey("midi_gain", _domain);
+ }
+
+ // MIDI options
+ if (_multiMidiCheckbox) {
+ if (_enableMIDISettings) {
+ saveMusicDeviceSetting(_gmDevicePopUp, "gm_device");
+
+ ConfMan.setBool("multi_midi", _multiMidiCheckbox->getState(), _domain);
+ ConfMan.setInt("midi_gain", _midiGainSlider->getValue(), _domain);
+
+ Common::String soundFont(_soundFont->getLabel());
+ if (!soundFont.empty() && (soundFont != _c("None", "soundfont")))
+ ConfMan.set("soundfont", soundFont, _domain);
+ else
ConfMan.removeKey("soundfont", _domain);
- }
+ } else {
+ ConfMan.removeKey("gm_device", _domain);
+ ConfMan.removeKey("multi_midi", _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);
- }
+ }
+
+ // 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 (_subToggleGroup) {
- if (_enableSubtitleSettings) {
- bool subtitles, speech_mute;
- int talkspeed;
- int sliderMaxValue = _subSpeedSlider->getMaxValue();
-
- switch (_subToggleGroup->getValue()) {
+ }
+
+ // Subtitle options
+ if (_subToggleGroup) {
+ if (_enableSubtitleSettings) {
+ bool subtitles, speech_mute;
+ int talkspeed;
+ int sliderMaxValue = _subSpeedSlider->getMaxValue();
+
+ switch (_subToggleGroup->getValue()) {
case kSubtitlesSpeech:
subtitles = speech_mute = false;
break;
@@ -520,26 +593,30 @@ void OptionsDialog::close() {
default:
subtitles = speech_mute = true;
break;
- }
-
- ConfMan.setBool("subtitles", subtitles, _domain);
- ConfMan.setBool("speech_mute", speech_mute, _domain);
-
- // Engines that reuse the subtitle speed widget set their own max value.
- // Scale the config value accordingly (see addSubtitleControls)
- talkspeed = (_subSpeedSlider->getValue() * 255 + sliderMaxValue / 2) / sliderMaxValue;
- ConfMan.setInt("talkspeed", talkspeed, _domain);
-
- } else {
- ConfMan.removeKey("subtitles", _domain);
- ConfMan.removeKey("talkspeed", _domain);
- ConfMan.removeKey("speech_mute", _domain);
}
+
+ ConfMan.setBool("subtitles", subtitles, _domain);
+ ConfMan.setBool("speech_mute", speech_mute, _domain);
+
+ // Engines that reuse the subtitle speed widget set their own max value.
+ // Scale the config value accordingly (see addSubtitleControls)
+ talkspeed = (_subSpeedSlider->getValue() * 255 + sliderMaxValue / 2) / sliderMaxValue;
+ ConfMan.setInt("talkspeed", talkspeed, _domain);
+
+ } else {
+ ConfMan.removeKey("subtitles", _domain);
+ ConfMan.removeKey("talkspeed", _domain);
+ ConfMan.removeKey("speech_mute", _domain);
}
-
- // Save config file
- ConfMan.flushToDisk();
}
+
+ // Save config file
+ ConfMan.flushToDisk();
+}
+
+void OptionsDialog::close() {
+ if (getResult())
+ apply();
Dialog::close();
}
@@ -581,15 +658,14 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
_soundFontClearButton->setEnabled(false);
draw();
break;
+ case kApplyCmd:
+ apply();
+ break;
case kOKCmd:
setResult(1);
close();
break;
case kCloseCmd:
- if (g_gui.theme()->getThemeId() != _oldTheme) {
- g_gui.loadNewTheme(_oldTheme);
- ConfMan.set("gui_theme", _oldTheme);
- }
close();
break;
default:
@@ -604,7 +680,8 @@ void OptionsDialog::setGraphicSettingsState(bool enabled) {
_gfxPopUp->setEnabled(enabled);
_renderModePopUpDesc->setEnabled(enabled);
_renderModePopUp->setEnabled(enabled);
-#ifndef SMALL_SCREEN_DEVICE
+ _filteringCheckbox->setEnabled(enabled);
+#ifndef GUI_ENABLE_KEYSDIALOG
_fullscreenCheckbox->setEnabled(enabled);
if (_guioptions.contains(GUIO_NOASPECT))
_aspectCheckbox->setEnabled(false);
@@ -757,6 +834,9 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr
// Fullscreen checkbox
_fullscreenCheckbox = new CheckboxWidget(boss, prefix + "grFullscreenCheckbox", _("Fullscreen mode"));
+ // Filtering checkbox
+ _filteringCheckbox = new CheckboxWidget(boss, prefix + "grFilteringCheckbox", _("Filter graphics"), _("Use linear filtering when scaling graphics"));
+
// Aspect ratio checkbox
_aspectCheckbox = new CheckboxWidget(boss, prefix + "grAspectCheckbox", _("Aspect ratio correction"), _("Correct aspect ratio for 320x200 games"));
@@ -868,10 +948,6 @@ void OptionsDialog::addMIDIControls(GuiObject *boss, const Common::String &prefi
_midiGainSlider->setMaxValue(1000);
_midiGainLabel = new StaticTextWidget(boss, prefix + "mcMidiGainLabel", "1.00");
-#ifdef USE_FLUIDSYNTH
- new ButtonWidget(boss, prefix + "mcFluidSynthSettings", _("FluidSynth Settings"), 0, kFluidSynthSettingsCmd);
-#endif
-
_enableMIDISettings = true;
}
@@ -1076,9 +1152,77 @@ void OptionsDialog::reflowLayout() {
#pragma mark -
-GlobalOptionsDialog::GlobalOptionsDialog()
- : OptionsDialog(Common::ConfigManager::kApplicationDomain, "GlobalOptions") {
+GlobalOptionsDialog::GlobalOptionsDialog(LauncherDialog *launcher)
+ : OptionsDialog(Common::ConfigManager::kApplicationDomain, "GlobalOptions"), _launcher(launcher) {
+#ifdef GUI_ENABLE_KEYSDIALOG
+ _keysDialog = 0;
+#endif
+#ifdef USE_FLUIDSYNTH
+ _fluidSynthSettingsDialog = 0;
+#endif
+ _savePath = 0;
+ _savePathClearButton = 0;
+ _themePath = 0;
+ _themePathClearButton = 0;
+ _extraPath = 0;
+ _extraPathClearButton = 0;
+#ifdef DYNAMIC_MODULES
+ _pluginsPath = 0;
+#endif
+ _curTheme = 0;
+ _rendererPopUpDesc = 0;
+ _rendererPopUp = 0;
+ _autosavePeriodPopUpDesc = 0;
+ _autosavePeriodPopUp = 0;
+ _guiLanguagePopUpDesc = 0;
+ _guiLanguagePopUp = 0;
+#ifdef USE_UPDATES
+ _updatesPopUpDesc = 0;
+ _updatesPopUp = 0;
+#endif
+#ifdef USE_CLOUD
+#ifdef USE_LIBCURL
+ _selectedStorageIndex = CloudMan.getStorageIndex();
+#else
+ _selectedStorageIndex = 0;
+#endif
+ _storagePopUpDesc = 0;
+ _storagePopUp = 0;
+ _storageUsernameDesc = 0;
+ _storageUsername = 0;
+ _storageUsedSpaceDesc = 0;
+ _storageUsedSpace = 0;
+ _storageLastSyncDesc = 0;
+ _storageLastSync = 0;
+ _storageConnectButton = 0;
+ _storageRefreshButton = 0;
+ _storageDownloadButton = 0;
+ _runServerButton = 0;
+ _serverInfoLabel = 0;
+ _rootPathButton = 0;
+ _rootPath = 0;
+ _rootPathClearButton = 0;
+ _serverPortDesc = 0;
+ _serverPort = 0;
+ _serverPortClearButton = 0;
+ _redrawCloudTab = false;
+#ifdef USE_SDL_NET
+ _serverWasRunning = false;
+#endif
+#endif
+}
+GlobalOptionsDialog::~GlobalOptionsDialog() {
+#ifdef GUI_ENABLE_KEYSDIALOG
+ delete _keysDialog;
+#endif
+
+#ifdef USE_FLUIDSYNTH
+ delete _fluidSynthSettingsDialog;
+#endif
+}
+
+void GlobalOptionsDialog::build() {
// The tab widget
TabWidget *tab = new TabWidget(this, "GlobalOptions.TabWidget");
@@ -1109,6 +1253,10 @@ GlobalOptionsDialog::GlobalOptionsDialog()
_midiTabId = tab->addTab(_("MIDI"));
addMIDIControls(tab, "GlobalOptions_MIDI.");
+#ifdef USE_FLUIDSYNTH
+ new ButtonWidget(tab, "GlobalOptions_MIDI.mcFluidSynthSettings", _("FluidSynth Settings"), 0, kFluidSynthSettingsCmd);
+#endif
+
//
// 4) The MT-32 tab
//
@@ -1194,7 +1342,7 @@ GlobalOptionsDialog::GlobalOptionsDialog()
_autosavePeriodPopUp->appendEntry(_(savePeriodLabels[i]), savePeriodValues[i]);
}
-#ifdef SMALL_SCREEN_DEVICE
+#ifdef GUI_ENABLE_KEYSDIALOG
new ButtonWidget(tab, "GlobalOptions_Misc.KeysButton", _("Keys"), 0, kChooseKeyMappingCmd);
#endif
@@ -1229,35 +1377,100 @@ GlobalOptionsDialog::GlobalOptionsDialog()
#endif // USE_TRANSLATION
+#ifdef USE_UPDATES
+ _updatesPopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Misc.UpdatesPopupDesc", _("Update check:"), _("How often to check ScummVM updates"));
+ _updatesPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.UpdatesPopup");
+
+ const int *vals = Common::UpdateManager::getUpdateIntervals();
+
+ while (*vals != -1) {
+ _updatesPopUp->appendEntry(Common::UpdateManager::updateIntervalToString(*vals), *vals);
+ vals++;
+ }
+
+ _updatesPopUp->setSelectedTag(Common::UpdateManager::normalizeInterval(ConfMan.getInt("updates_check")));
+
+ new ButtonWidget(tab, "GlobalOptions_Misc.UpdatesCheckManuallyButton", _("Check now"), 0, kUpdatesCheckCmd);
+#endif
+
+#ifdef USE_CLOUD
+ //
+ // 7) The cloud tab
+ //
+ if (g_system->getOverlayWidth() > 320)
+ tab->addTab(_("Cloud"));
+ else
+ tab->addTab(_c("Cloud", "lowres"));
+
+ ScrollContainerWidget *container = new ScrollContainerWidget(tab, "GlobalOptions_Cloud.Container", kCloudTabContainerReflowCmd);
+ container->setTarget(this);
+
+ _storagePopUpDesc = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.StoragePopupDesc", _("Storage:"), _("Active cloud storage"));
+ _storagePopUp = new PopUpWidget(container, "GlobalOptions_Cloud_Container.StoragePopup");
+#ifdef USE_LIBCURL
+ Common::StringArray list = CloudMan.listStorages();
+ for (uint32 i = 0; i < list.size(); ++i)
+ _storagePopUp->appendEntry(list[i], i);
+#else
+ _storagePopUp->appendEntry(_("<none>"), 0);
+#endif
+ _storagePopUp->setSelected(_selectedStorageIndex);
+
+ _storageUsernameDesc = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.StorageUsernameDesc", _("Username:"), _("Username used by this storage"));
+ _storageUsername = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.StorageUsernameLabel", "<none>");
+
+ _storageUsedSpaceDesc = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.StorageUsedSpaceDesc", _("Used space:"), _("Space used by ScummVM's saved games on this storage"));
+ _storageUsedSpace = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.StorageUsedSpaceLabel", "0 bytes");
+
+ _storageLastSyncDesc = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.StorageLastSyncDesc", _("Last sync time:"), _("When the last saved games sync for this storage occured"));
+ _storageLastSync = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.StorageLastSyncLabel", "<never>");
+
+ _storageConnectButton = new ButtonWidget(container, "GlobalOptions_Cloud_Container.ConnectButton", _("Connect"), _("Open wizard dialog to connect your cloud storage account"), kConfigureStorageCmd);
+ _storageRefreshButton = new ButtonWidget(container, "GlobalOptions_Cloud_Container.RefreshButton", _("Refresh"), _("Refresh current cloud storage information (username and usage)"), kRefreshStorageCmd);
+ _storageDownloadButton = new ButtonWidget(container, "GlobalOptions_Cloud_Container.DownloadButton", _("Download"), _("Open downloads manager dialog"), kDownloadStorageCmd);
+
+ _runServerButton = new ButtonWidget(container, "GlobalOptions_Cloud_Container.RunServerButton", _("Run server"), _("Run local webserver"), kRunServerCmd);
+ _serverInfoLabel = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.ServerInfoLabel", _("Not running"));
+
+ // Root path
+ if (g_system->getOverlayWidth() > 320)
+ _rootPathButton = new ButtonWidget(container, "GlobalOptions_Cloud_Container.RootPathButton", _("/root/ Path:"), _("Specifies which directory the Files Manager can access"), kChooseRootDirCmd);
+ else
+ _rootPathButton = new ButtonWidget(container, "GlobalOptions_Cloud_Container.RootPathButton", _c("/root/ Path:", "lowres"), _("Specifies which directory the Files Manager can access"), kChooseRootDirCmd);
+ _rootPath = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.RootPath", "/foo/bar", _("Specifies which directory the Files Manager can access"));
+
+ _rootPathClearButton = addClearButton(container, "GlobalOptions_Cloud_Container.RootPathClearButton", kRootPathClearCmd);
+
+#ifdef USE_SDL_NET
+ uint32 port = Networking::LocalWebserver::getPort();
+#else
+ uint32 port = 0; // the following widgets are hidden anyway
+#endif
+ _serverPortDesc = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.ServerPortDesc", _("Server's port:"), _("Which port is used by the server\nAuth with server is not available with non-default port"));
+ _serverPort = new EditTextWidget(container, "GlobalOptions_Cloud_Container.ServerPortEditText", Common::String::format("%u", port), 0);
+ _serverPortClearButton = addClearButton(container, "GlobalOptions_Cloud_Container.ServerPortClearButton", kServerPortClearCmd);
+
+ setupCloudTab();
+#endif // USE_CLOUD
+
// Activate the first tab
tab->setActiveTab(0);
_tabWidget = tab;
// Add OK & Cancel buttons
new ButtonWidget(this, "GlobalOptions.Cancel", _("Cancel"), 0, kCloseCmd);
+ new ButtonWidget(this, "GlobalOptions.Apply", _("Apply"), 0, kApplyCmd);
new ButtonWidget(this, "GlobalOptions.Ok", _("OK"), 0, kOKCmd);
-#ifdef SMALL_SCREEN_DEVICE
+#ifdef GUI_ENABLE_KEYSDIALOG
_keysDialog = new KeysDialog();
#endif
#ifdef USE_FLUIDSYNTH
_fluidSynthSettingsDialog = new FluidSynthSettingsDialog();
#endif
-}
-
-GlobalOptionsDialog::~GlobalOptionsDialog() {
-#ifdef SMALL_SCREEN_DEVICE
- delete _keysDialog;
-#endif
-
-#ifdef USE_FLUIDSYNTH
- delete _fluidSynthSettingsDialog;
-#endif
-}
-void GlobalOptionsDialog::open() {
- OptionsDialog::open();
+ OptionsDialog::build();
#if !( defined(__DC__) || defined(__GP32__) )
// Set _savePath to the current save path
@@ -1305,69 +1518,174 @@ void GlobalOptionsDialog::open() {
if (mode == ThemeEngine::kGfxDisabled)
mode = ThemeEngine::_defaultRendererMode;
_rendererPopUp->setSelectedTag(mode);
+
+#ifdef USE_CLOUD
+ Common::String rootPath(ConfMan.get("rootpath", "cloud"));
+ if (rootPath.empty() || !ConfMan.hasKey("rootpath", "cloud")) {
+ _rootPath->setLabel(_c("None", "path"));
+ } else {
+ _rootPath->setLabel(rootPath);
+ }
+#endif
}
-void GlobalOptionsDialog::close() {
- if (getResult()) {
- Common::String savePath(_savePath->getLabel());
- if (!savePath.empty() && (savePath != _("Default")))
- ConfMan.set("savepath", savePath, _domain);
- else
- ConfMan.removeKey("savepath", _domain);
+void GlobalOptionsDialog::clean() {
+#ifdef GUI_ENABLE_KEYSDIALOG
+ delete _keysDialog;
+ _keysDialog = 0;
+#endif
- Common::String themePath(_themePath->getLabel());
- if (!themePath.empty() && (themePath != _c("None", "path")))
- ConfMan.set("themepath", themePath, _domain);
- else
- ConfMan.removeKey("themepath", _domain);
+#ifdef USE_FLUIDSYNTH
+ delete _fluidSynthSettingsDialog;
+ _fluidSynthSettingsDialog = 0;
+#endif
- Common::String extraPath(_extraPath->getLabel());
- if (!extraPath.empty() && (extraPath != _c("None", "path")))
- ConfMan.set("extrapath", extraPath, _domain);
- else
- ConfMan.removeKey("extrapath", _domain);
+ OptionsDialog::clean();
+}
+
+void GlobalOptionsDialog::apply() {
+ Common::String savePath(_savePath->getLabel());
+ if (!savePath.empty() && (savePath != _("Default")))
+ ConfMan.set("savepath", savePath, _domain);
+ else
+ ConfMan.removeKey("savepath", _domain);
+
+ Common::String themePath(_themePath->getLabel());
+ if (!themePath.empty() && (themePath != _c("None", "path")))
+ ConfMan.set("themepath", themePath, _domain);
+ else
+ ConfMan.removeKey("themepath", _domain);
+
+ Common::String extraPath(_extraPath->getLabel());
+ if (!extraPath.empty() && (extraPath != _c("None", "path")))
+ ConfMan.set("extrapath", extraPath, _domain);
+ else
+ ConfMan.removeKey("extrapath", _domain);
#ifdef DYNAMIC_MODULES
- Common::String pluginsPath(_pluginsPath->getLabel());
- if (!pluginsPath.empty() && (pluginsPath != _c("None", "path")))
- ConfMan.set("pluginspath", pluginsPath, _domain);
- else
- ConfMan.removeKey("pluginspath", _domain);
+ Common::String pluginsPath(_pluginsPath->getLabel());
+ if (!pluginsPath.empty() && (pluginsPath != _c("None", "path")))
+ ConfMan.set("pluginspath", pluginsPath, _domain);
+ else
+ ConfMan.removeKey("pluginspath", _domain);
#endif
- ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain);
+#ifdef USE_CLOUD
+ Common::String rootPath(_rootPath->getLabel());
+ if (!rootPath.empty() && (rootPath != _c("None", "path")))
+ ConfMan.set("rootpath", rootPath, "cloud");
+ else
+ ConfMan.removeKey("rootpath", "cloud");
+#endif
- GUI::ThemeEngine::GraphicsMode selected = (GUI::ThemeEngine::GraphicsMode)_rendererPopUp->getSelectedTag();
- const char *cfg = GUI::ThemeEngine::findModeConfigName(selected);
- if (!ConfMan.get("gui_renderer").equalsIgnoreCase(cfg)) {
- // 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(), selected);
- ConfMan.set("gui_renderer", cfg, _domain);
- }
+ ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain);
+
+ GUI::ThemeEngine::GraphicsMode selected = (GUI::ThemeEngine::GraphicsMode)_rendererPopUp->getSelectedTag();
+ const char *cfg = GUI::ThemeEngine::findModeConfigName(selected);
+ if (!ConfMan.get("gui_renderer").equalsIgnoreCase(cfg)) {
+ // 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(), selected);
+ ConfMan.set("gui_renderer", cfg, _domain);
+ }
#ifdef USE_TRANSLATION
- Common::String oldLang = ConfMan.get("gui_language");
- int selLang = _guiLanguagePopUp->getSelectedTag();
+ Common::String oldLang = ConfMan.get("gui_language");
+ int selLang = _guiLanguagePopUp->getSelectedTag();
- ConfMan.set("gui_language", TransMan.getLangById(selLang));
+ 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);
+ Common::String newLang = ConfMan.get("gui_language").c_str();
+ if (newLang != oldLang) {
+ // 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 before your changes will take effect."));
- error.runModal();
+ // Rebuild the Launcher and Options dialogs
+ g_gui.loadNewTheme(g_gui.theme()->getThemeId(), ThemeEngine::kGfxDisabled, true);
+ rebuild();
+ if (_launcher != 0)
+ _launcher->rebuild();
+ }
+#endif // USE_TRANSLATION
+
+#ifdef USE_UPDATES
+ ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag());
+
+ if (g_system->getUpdateManager()) {
+ if (_updatesPopUp->getSelectedTag() == Common::UpdateManager::kUpdateIntervalNotSupported) {
+ g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled);
+ } else {
+ g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateEnabled);
+ g_system->getUpdateManager()->setUpdateCheckInterval(_updatesPopUp->getSelectedTag());
+ }
+ }
#endif
+
+#ifdef USE_CLOUD
+#ifdef USE_LIBCURL
+ if (CloudMan.getStorageIndex() != _selectedStorageIndex) {
+ if (!CloudMan.switchStorage(_selectedStorageIndex)) {
+ bool anotherStorageIsWorking = CloudMan.isWorking();
+ Common::String message = _("Failed to change cloud storage!");
+ if (anotherStorageIsWorking) {
+ message += "\n";
+ message += _("Another cloud storage is already active.");
+ }
+ MessageDialog dialog(message);
+ dialog.runModal();
}
-#endif // USE_TRANSLATION
+ }
+#endif // USE_LIBCURL
+
+#ifdef USE_SDL_NET
+#ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
+ // save server's port
+ uint32 port = Networking::LocalWebserver::getPort();
+ if (_serverPort) {
+ uint64 contents = _serverPort->getEditString().asUint64();
+ if (contents != 0)
+ port = contents;
+ }
+ ConfMan.setInt("local_server_port", port);
+#endif // NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
+#endif // USE_SDL_NET
+#endif // USE_CLOUD
+
+ if (!_newTheme.empty()) {
+#ifdef USE_TRANSLATION
+ Common::String lang = TransMan.getCurrentLanguage();
+#endif
+ Common::String oldTheme = g_gui.theme()->getThemeId();
+ if (g_gui.loadNewTheme(_newTheme)) {
+#ifdef USE_TRANSLATION
+ // If the charset has changed, it means the font were not found for the
+ // new theme. Since for the moment we do not support change of translation
+ // language without restarting, we let the user know about this.
+ if (lang != TransMan.getCurrentLanguage()) {
+ TransMan.setLanguage(lang.c_str());
+ g_gui.loadNewTheme(oldTheme);
+ _curTheme->setLabel(g_gui.theme()->getThemeName());
+ MessageDialog error(_("The theme you selected does not support your current language. If you want to use this theme you need to switch to another language first."));
+ error.runModal();
+ } else {
+#endif
+ ConfMan.set("gui_theme", _newTheme);
+#ifdef USE_TRANSLATION
+ }
+#endif
+ }
+ draw();
+ _newTheme.clear();
+ }
+
+ OptionsDialog::apply();
+}
+void GlobalOptionsDialog::close() {
+#if defined(USE_CLOUD) && defined(USE_SDL_NET)
+ if (LocalServer.isRunning()) {
+ LocalServer.stop();
}
+#endif
OptionsDialog::close();
}
@@ -1421,6 +1739,21 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
break;
}
#endif
+#ifdef USE_CLOUD
+ case kChooseRootDirCmd: {
+ BrowserDialog browser(_("Select directory for Files Manager /root/"), true);
+ if (browser.runModal() > 0) {
+ // User made his choice...
+ Common::FSNode dir(browser.getResult());
+ Common::String path = dir.getPath();
+ if (path.empty())
+ path = "/"; // absolute root
+ _rootPath->setLabel(path);
+ draw();
+ }
+ break;
+ }
+#endif
case kThemePathClearCmd:
_themePath->setLabel(_c("None", "path"));
break;
@@ -1430,6 +1763,11 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
case kSavePathClearCmd:
_savePath->setLabel(_("Default"));
break;
+#ifdef USE_CLOUD
+ case kRootPathClearCmd:
+ _rootPath->setLabel(_c("None", "path"));
+ break;
+#endif
case kChooseSoundFontCmd: {
BrowserDialog browser(_("Select SoundFont"), false);
if (browser.runModal() > 0) {
@@ -1446,39 +1784,102 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
}
break;
}
- case kChooseThemeCmd: {
+ case kChooseThemeCmd:
+ {
ThemeBrowser browser;
if (browser.runModal() > 0) {
// User made his choice...
- Common::String theme = browser.getSelected();
- // FIXME: Actually, any changes (including the theme change) should
- // only become active *after* the options dialog has closed.
-#ifdef USE_TRANSLATION
- Common::String lang = TransMan.getCurrentLanguage();
-#endif
- if (g_gui.loadNewTheme(theme)) {
-#ifdef USE_TRANSLATION
- // If the charset has changed, it means the font were not found for the
- // new theme. Since for the moment we do not support change of translation
- // language without restarting, we let the user know about this.
- if (lang != TransMan.getCurrentLanguage()) {
- TransMan.setLanguage(lang.c_str());
- g_gui.loadNewTheme(_oldTheme);
- MessageDialog error(_("The theme you selected does not support your current language. If you want to use this theme you need to switch to another language first."));
- error.runModal();
- } else {
-#endif
- _curTheme->setLabel(g_gui.theme()->getThemeName());
- ConfMan.set("gui_theme", theme);
-#ifdef USE_TRANSLATION
- }
-#endif
+ _newTheme = browser.getSelected();
+ _curTheme->setLabel(browser.getSelectedName());
+ }
+ break;
+ }
+#ifdef USE_CLOUD
+ case kCloudTabContainerReflowCmd:
+ setupCloudTab();
+ break;
+#ifdef USE_LIBCURL
+ case kPopUpItemSelectedCmd:
+ {
+ //update container's scrollbar
+ reflowLayout();
+ break;
+ }
+ case kConfigureStorageCmd:
+ {
+#ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
+ // save server's port
+ uint32 port = Networking::LocalWebserver::getPort();
+ if (_serverPort) {
+ uint64 contents = _serverPort->getEditString().asUint64();
+ if (contents != 0)
+ port = contents;
+ }
+ ConfMan.setInt("local_server_port", port);
+ ConfMan.flushToDisk();
+#endif // NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
+ StorageWizardDialog dialog(_selectedStorageIndex);
+ dialog.runModal();
+ //update container's scrollbar
+ reflowLayout();
+ break;
+ }
+ case kRefreshStorageCmd:
+ {
+ CloudMan.info(
+ new Common::Callback<GlobalOptionsDialog, Cloud::Storage::StorageInfoResponse>(this, &GlobalOptionsDialog::storageInfoCallback),
+ new Common::Callback<GlobalOptionsDialog, Networking::ErrorResponse>(this, &GlobalOptionsDialog::storageErrorCallback)
+ );
+ Common::String dir = CloudMan.savesDirectoryPath();
+ if (dir.lastChar() == '/')
+ dir.deleteLastChar();
+ CloudMan.listDirectory(
+ dir,
+ new Common::Callback<GlobalOptionsDialog, Cloud::Storage::ListDirectoryResponse>(this, &GlobalOptionsDialog::storageListDirectoryCallback),
+ new Common::Callback<GlobalOptionsDialog, Networking::ErrorResponse>(this, &GlobalOptionsDialog::storageErrorCallback)
+ );
+ break;
+ }
+ case kDownloadStorageCmd:
+ {
+ DownloadDialog dialog(_selectedStorageIndex, _launcher);
+ dialog.runModal();
+ break;
+ }
+#endif // USE_LIBCURL
+#ifdef USE_SDL_NET
+ case kRunServerCmd:
+ {
+#ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
+ // save server's port
+ uint32 port = Networking::LocalWebserver::getPort();
+ if (_serverPort) {
+ uint64 contents = _serverPort->getEditString().asUint64();
+ if (contents != 0)
+ port = contents;
}
- draw();
+ ConfMan.setInt("local_server_port", port);
+ ConfMan.flushToDisk();
+#endif // NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
+
+ if (LocalServer.isRunning())
+ LocalServer.stopOnIdle();
+ else
+ LocalServer.start();
+
+ break;
+ }
+
+ case kServerPortClearCmd: {
+ if (_serverPort) {
+ _serverPort->setEditString(Common::String::format("%u", Networking::LocalWebserver::DEFAULT_SERVER_PORT));
}
+ draw();
break;
}
-#ifdef SMALL_SCREEN_DEVICE
+#endif // USE_SDL_NET
+#endif // USE_CLOUD
+#ifdef GUI_ENABLE_KEYSDIALOG
case kChooseKeyMappingCmd:
_keysDialog->runModal();
break;
@@ -1488,11 +1889,34 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
_fluidSynthSettingsDialog->runModal();
break;
#endif
+#ifdef USE_UPDATES
+ case kUpdatesCheckCmd:
+ if (g_system->getUpdateManager())
+ g_system->getUpdateManager()->checkForUpdates();
+ break;
+#endif
default:
OptionsDialog::handleCommand(sender, cmd, data);
}
}
+void GlobalOptionsDialog::handleTickle() {
+ OptionsDialog::handleTickle();
+#ifdef USE_CLOUD
+#ifdef USE_SDL_NET
+ if (LocalServer.isRunning() != _serverWasRunning) {
+ _serverWasRunning = !_serverWasRunning;
+ _redrawCloudTab = true;
+ }
+#endif
+ if (_redrawCloudTab) {
+ setupCloudTab();
+ draw();
+ _redrawCloudTab = false;
+ }
+#endif
+}
+
void GlobalOptionsDialog::reflowLayout() {
int activeTab = _tabWidget->getActiveTab();
@@ -1526,6 +1950,219 @@ void GlobalOptionsDialog::reflowLayout() {
_tabWidget->setActiveTab(activeTab);
OptionsDialog::reflowLayout();
+#ifdef USE_CLOUD
+ setupCloudTab();
+#endif
+}
+
+#ifdef USE_CLOUD
+void GlobalOptionsDialog::setupCloudTab() {
+ int serverLabelPosition = -1; //no override
+#ifdef USE_LIBCURL
+ _selectedStorageIndex = _storagePopUp->getSelectedTag();
+
+ if (_storagePopUpDesc) _storagePopUpDesc->setVisible(true);
+ if (_storagePopUp) _storagePopUp->setVisible(true);
+
+ bool shown = (_selectedStorageIndex != Cloud::kStorageNoneId);
+ if (_storageUsernameDesc) _storageUsernameDesc->setVisible(shown);
+ if (_storageUsername) {
+ Common::String username = CloudMan.getStorageUsername(_selectedStorageIndex);
+ if (username == "")
+ username = _("<none>");
+ _storageUsername->setLabel(username);
+ _storageUsername->setVisible(shown);
+ }
+ if (_storageUsedSpaceDesc) _storageUsedSpaceDesc->setVisible(shown);
+ if (_storageUsedSpace) {
+ uint64 usedSpace = CloudMan.getStorageUsedSpace(_selectedStorageIndex);
+ _storageUsedSpace->setLabel(Common::String::format(_("%llu bytes"), usedSpace));
+ _storageUsedSpace->setVisible(shown);
+ }
+ if (_storageLastSyncDesc) _storageLastSyncDesc->setVisible(shown);
+ if (_storageLastSync) {
+ Common::String sync = CloudMan.getStorageLastSync(_selectedStorageIndex);
+ if (sync == "") {
+ if (_selectedStorageIndex == CloudMan.getStorageIndex() && CloudMan.isSyncing())
+ sync = _("<right now>");
+ else
+ sync = _("<never>");
+ }
+ _storageLastSync->setLabel(sync);
+ _storageLastSync->setVisible(shown);
+ }
+ if (_storageConnectButton)
+ _storageConnectButton->setVisible(shown);
+ if (_storageRefreshButton)
+ _storageRefreshButton->setVisible(shown && _selectedStorageIndex == CloudMan.getStorageIndex());
+ if (_storageDownloadButton)
+ _storageDownloadButton->setVisible(shown && _selectedStorageIndex == CloudMan.getStorageIndex());
+ if (!shown)
+ serverLabelPosition = (_storageUsernameDesc ? _storageUsernameDesc->getRelY() : 0);
+#else // USE_LIBCURL
+ _selectedStorageIndex = 0;
+
+ if (_storagePopUpDesc)
+ _storagePopUpDesc->setVisible(false);
+ if (_storagePopUp)
+ _storagePopUp->setVisible(false);
+ if (_storageUsernameDesc)
+ _storageUsernameDesc->setVisible(false);
+ if (_storageUsernameDesc)
+ _storageUsernameDesc->setVisible(false);
+ if (_storageUsername)
+ _storageUsername->setVisible(false);
+ if (_storageUsedSpaceDesc)
+ _storageUsedSpaceDesc->setVisible(false);
+ if (_storageUsedSpace)
+ _storageUsedSpace->setVisible(false);
+ if (_storageLastSyncDesc)
+ _storageLastSyncDesc->setVisible(false);
+ if (_storageLastSync)
+ _storageLastSync->setVisible(false);
+ if (_storageConnectButton)
+ _storageConnectButton->setVisible(false);
+ if (_storageRefreshButton)
+ _storageRefreshButton->setVisible(false);
+ if (_storageDownloadButton)
+ _storageDownloadButton->setVisible(false);
+
+ serverLabelPosition = (_storagePopUpDesc ? _storagePopUpDesc->getRelY() : 0);
+#endif // USE_LIBCURL
+#ifdef USE_SDL_NET
+ //determine original widget's positions
+ int16 x, y;
+ uint16 w, h;
+ int serverButtonY, serverInfoY;
+ int serverRootButtonY, serverRootY, serverRootClearButtonY;
+ int serverPortDescY, serverPortY, serverPortClearButtonY;
+ if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.RunServerButton", x, y, w, h))
+ warning("GlobalOptions_Cloud_Container.RunServerButton's position is undefined");
+ serverButtonY = y;
+ if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.ServerInfoLabel", x, y, w, h))
+ warning("GlobalOptions_Cloud_Container.ServerInfoLabel's position is undefined");
+ serverInfoY = y;
+
+ if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.RootPathButton", x, y, w, h))
+ warning("GlobalOptions_Cloud_Container.RootPathButton's position is undefined");
+ serverRootButtonY = y;
+ if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.RootPath", x, y, w, h))
+ warning("GlobalOptions_Cloud_Container.RootPath's position is undefined");
+ serverRootY = y;
+ if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.RootPathClearButton", x, y, w, h))
+ warning("GlobalOptions_Cloud_Container.RootPathClearButton's position is undefined");
+ serverRootClearButtonY = y;
+
+ if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.ServerPortDesc", x, y, w, h))
+ warning("GlobalOptions_Cloud_Container.ServerPortDesc's position is undefined");
+ serverPortDescY = y;
+ if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.ServerPortEditText", x, y, w, h))
+ warning("GlobalOptions_Cloud_Container.ServerPortEditText's position is undefined");
+ serverPortY = y;
+ if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.ServerPortClearButton", x, y, w, h))
+ warning("GlobalOptions_Cloud_Container.ServerPortClearButton's position is undefined");
+ serverPortClearButtonY = y;
+
+ bool serverIsRunning = LocalServer.isRunning();
+
+ if (serverLabelPosition < 0)
+ serverLabelPosition = serverInfoY;
+ if (_runServerButton) {
+ _runServerButton->setVisible(true);
+ _runServerButton->setPos(_runServerButton->getRelX(), serverLabelPosition + serverButtonY - serverInfoY);
+ _runServerButton->setLabel(_(serverIsRunning ? "Stop server" : "Run server"));
+ _runServerButton->setTooltip(_(serverIsRunning ? "Stop local webserver" : "Run local webserver"));
+ }
+ if (_serverInfoLabel) {
+ _serverInfoLabel->setVisible(true);
+ _serverInfoLabel->setPos(_serverInfoLabel->getRelX(), serverLabelPosition);
+ if (serverIsRunning)
+ _serverInfoLabel->setLabel(LocalServer.getAddress());
+ else
+ _serverInfoLabel->setLabel(_("Not running"));
+ }
+ if (_rootPathButton) {
+ _rootPathButton->setVisible(true);
+ _rootPathButton->setPos(_rootPathButton->getRelX(), serverLabelPosition + serverRootButtonY - serverInfoY);
+ }
+ if (_rootPath) {
+ _rootPath->setVisible(true);
+ _rootPath->setPos(_rootPath->getRelX(), serverLabelPosition + serverRootY - serverInfoY);
+ }
+ if (_rootPathClearButton) {
+ _rootPathClearButton->setVisible(true);
+ _rootPathClearButton->setPos(_rootPathClearButton->getRelX(), serverLabelPosition + serverRootClearButtonY - serverInfoY);
+ }
+#ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
+ if (_serverPortDesc) {
+ _serverPortDesc->setVisible(true);
+ _serverPortDesc->setPos(_serverPortDesc->getRelX(), serverLabelPosition + serverPortDescY - serverInfoY);
+ _serverPortDesc->setEnabled(!serverIsRunning);
+ }
+ if (_serverPort) {
+ _serverPort->setVisible(true);
+ _serverPort->setPos(_serverPort->getRelX(), serverLabelPosition + serverPortY - serverInfoY);
+ _serverPort->setEnabled(!serverIsRunning);
+ }
+ if (_serverPortClearButton) {
+ _serverPortClearButton->setVisible(true);
+ _serverPortClearButton->setPos(_serverPortClearButton->getRelX(), serverLabelPosition + serverPortClearButtonY - serverInfoY);
+ _serverPortClearButton->setEnabled(!serverIsRunning);
+ }
+#else // NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
+ if (_serverPortDesc)
+ _serverPortDesc->setVisible(false);
+ if (_serverPort)
+ _serverPort->setVisible(false);
+ if (_serverPortClearButton)
+ _serverPortClearButton->setVisible(false);
+#endif // NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
+#else // USE_SDL_NET
+ if (_runServerButton)
+ _runServerButton->setVisible(false);
+ if (_serverInfoLabel)
+ _serverInfoLabel->setVisible(false);
+ if (_rootPathButton)
+ _rootPathButton->setVisible(false);
+ if (_rootPath)
+ _rootPath->setVisible(false);
+ if (_rootPathClearButton)
+ _rootPathClearButton->setVisible(false);
+ if (_serverPortDesc)
+ _serverPortDesc->setVisible(false);
+ if (_serverPort)
+ _serverPort->setVisible(false);
+ if (_serverPortClearButton)
+ _serverPortClearButton->setVisible(false);
+#endif // USE_SDL_NET
+}
+
+#ifdef USE_LIBCURL
+void GlobalOptionsDialog::storageInfoCallback(Cloud::Storage::StorageInfoResponse response) {
+ //we could've used response.value.email()
+ //but Storage already notified CloudMan
+ //so we just set the flag to redraw our cloud tab
+ _redrawCloudTab = true;
+}
+
+void GlobalOptionsDialog::storageListDirectoryCallback(Cloud::Storage::ListDirectoryResponse response) {
+ Common::Array<Cloud::StorageFile> &files = response.value;
+ uint64 totalSize = 0;
+ for (uint32 i = 0; i < files.size(); ++i)
+ if (!files[i].isDirectory())
+ totalSize += files[i].size();
+ CloudMan.setStorageUsedSpace(CloudMan.getStorageIndex(), totalSize);
+ _redrawCloudTab = true;
+}
+
+void GlobalOptionsDialog::storageErrorCallback(Networking::ErrorResponse response) {
+ debug(9, "GlobalOptionsDialog: error response (%s, %ld):", (response.failed ? "failed" : "interrupted"), response.httpResponseCode);
+ debug(9, "%s", response.response.c_str());
+
+ if (!response.interrupted)
+ g_system->displayMessageOnOSD(_("Request failed.\nCheck your Internet connection."));
}
+#endif // USE_LIBCURL
+#endif // USE_CLOUD
} // End of namespace GUI