aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/module.mk1
-rw-r--r--gui/options.cpp54
-rw-r--r--gui/options.h7
-rw-r--r--gui/storagebrowser.cpp96
-rw-r--r--gui/storagebrowser.h51
-rw-r--r--gui/themes/scummmodern/scummmodern_layout.stx13
-rw-r--r--gui/themes/scummmodern/scummmodern_layout_lowres.stx13
7 files changed, 234 insertions, 1 deletions
diff --git a/gui/module.mk b/gui/module.mk
index 2ffea5a2b5..ece360b3cc 100644
--- a/gui/module.mk
+++ b/gui/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS := \
predictivedialog.o \
saveload.o \
saveload-dialog.o \
+ storagebrowser.o \
themebrowser.o \
ThemeEngine.o \
ThemeEval.o \
diff --git a/gui/options.cpp b/gui/options.cpp
index e410971818..df457a89e8 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -43,6 +43,11 @@
#include "audio/mixer.h"
#include "audio/fmopl.h"
+#ifdef USE_CLOUD
+#include "backends/cloud/cloudmanager.h"
+#include "gui/storagebrowser.h"
+#endif
+
namespace GUI {
enum {
@@ -84,6 +89,12 @@ enum {
};
#endif
+#ifdef USE_CLOUD
+enum {
+ kChooseStorageCmd = 'chst'
+};
+#endif
+
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 };
@@ -1251,6 +1262,19 @@ GlobalOptionsDialog::GlobalOptionsDialog()
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"));
+
+ new ButtonWidget(tab, "GlobalOptions_Cloud.StorageButton", _("Storage:"), 0, kChooseStorageCmd);
+ _curStorage = new StaticTextWidget(tab, "GlobalOptions_Cloud.CurStorage", CloudMan.getStorageName());
+#endif
+
// Activate the first tab
tab->setActiveTab(0);
_tabWidget = tab;
@@ -1481,7 +1505,8 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
}
break;
}
- case kChooseThemeCmd: {
+ case kChooseThemeCmd:
+ {
ThemeBrowser browser;
if (browser.runModal() > 0) {
// User made his choice...
@@ -1513,6 +1538,33 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
}
break;
}
+#ifdef USE_CLOUD
+ case kChooseStorageCmd:
+ {
+ StorageBrowser storageBrowser;
+ if (storageBrowser.runModal() > 0) {
+ // User made his choice...
+ uint32 storageIndex = storageBrowser.getSelected();
+ // FIXME: Actually, any changes (including the storage change?) should
+ // only become active *after* the options dialog has closed.
+ if (CloudMan.switchStorage(storageIndex)) {
+ _curStorage->setLabel(CloudMan.getStorageName());
+ //automatically saves in the config if switched successfully
+ } else {
+ bool anotherStorageIsWorking = CloudMan.isWorking();
+ Common::String message = _("Failed to change cloud storage!");
+ if (anotherStorageIsWorking) {
+ message += "\n";
+ message += _("Current cloud storage is working at the moment.");
+ }
+ MessageDialog dialog(message);
+ dialog.runModal();
+ }
+ draw();
+ }
+ break;
+ }
+#endif
#ifdef GUI_ENABLE_KEYSDIALOG
case kChooseKeyMappingCmd:
_keysDialog->runModal();
diff --git a/gui/options.h b/gui/options.h
index 294b41794b..feb77859e8 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -241,6 +241,13 @@ protected:
StaticTextWidget *_updatesPopUpDesc;
PopUpWidget *_updatesPopUp;
#endif
+
+#ifdef USE_CLOUD
+ //
+ // Misc controls
+ //
+ StaticTextWidget *_curStorage;
+#endif
};
} // End of namespace GUI
diff --git a/gui/storagebrowser.cpp b/gui/storagebrowser.cpp
new file mode 100644
index 0000000000..30a0e9e23d
--- /dev/null
+++ b/gui/storagebrowser.cpp
@@ -0,0 +1,96 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "gui/storagebrowser.h"
+#include "gui/widgets/list.h"
+#include "gui/widget.h"
+#include "gui/gui-manager.h"
+
+#include "common/translation.h"
+#ifdef USE_CLOUD
+#include "backends/cloud/cloudmanager.h"
+#endif
+
+namespace GUI {
+
+enum {
+ kChooseCmd = 'Chos'
+};
+
+StorageBrowser::StorageBrowser() : Dialog("Browser") {
+ new StaticTextWidget(this, "Browser.Headline", _("Select a Storage"));
+
+ // Add storages list
+ _storagesList = new ListWidget(this, "Browser.List");
+ _storagesList->setNumberingMode(kListNumberingOff);
+ _storagesList->setEditable(false);
+
+ _backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain;
+
+ // Buttons
+ new ButtonWidget(this, "Browser.Cancel", _("Cancel"), 0, kCloseCmd);
+ new ButtonWidget(this, "Browser.Choose", _("Choose"), 0, kChooseCmd);
+}
+
+void StorageBrowser::open() {
+ // Always refresh storages list
+ updateListing();
+
+ // Call super implementation
+ Dialog::open();
+}
+
+void StorageBrowser::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+ switch (cmd) {
+ case kChooseCmd:
+ case kListItemActivatedCmd:
+ case kListItemDoubleClickedCmd: {
+ int selection = _storagesList->getSelected();
+ if (selection < 0)
+ break;
+ _selectionIndex = selection;
+ setResult(1);
+ close();
+ break;
+ }
+ default:
+ Dialog::handleCommand(sender, cmd, data);
+ }
+}
+
+void StorageBrowser::updateListing() {
+ Common::StringArray list;
+ uint32 currentStorageIndex = 0;
+#ifdef USE_CLOUD
+ list = CloudMan.listStorages();
+ currentStorageIndex = CloudMan.getStorageIndex();
+#endif
+
+ _storagesList->setList(list);
+ _storagesList->scrollTo(0);
+ _storagesList->setSelected(currentStorageIndex);
+
+ // Finally, redraw
+ draw();
+}
+
+} // End of namespace GUI
diff --git a/gui/storagebrowser.h b/gui/storagebrowser.h
new file mode 100644
index 0000000000..b18c30f8c8
--- /dev/null
+++ b/gui/storagebrowser.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GUI_STORAGEBROWSER_H
+#define GUI_STORAGEBROWSER_H
+
+#include "gui/dialog.h"
+#include "common/str.h"
+
+namespace GUI {
+
+class CommandSender;
+class ListWidget;
+
+class StorageBrowser : public Dialog {
+public:
+ StorageBrowser();
+
+ void open();
+ void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
+
+ uint32 getSelected() const { return _selectionIndex; }
+private:
+ ListWidget *_storagesList;
+ uint32 _selectionIndex;
+
+ void updateListing();
+};
+
+} // End of namespace GUI
+
+#endif
diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx
index f14e447535..693be090e8 100644
--- a/gui/themes/scummmodern/scummmodern_layout.stx
+++ b/gui/themes/scummmodern/scummmodern_layout.stx
@@ -538,6 +538,19 @@
</layout>
</dialog>
+ <dialog name = 'GlobalOptions_Cloud' overlays = 'Dialog.GlobalOptions.TabWidget'>
+ <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'>
+ <widget name = 'StorageButton'
+ type = 'Button'
+ />
+ <widget name = 'CurStorage'
+ height = 'Globals.Line.Height'
+ />
+ </layout>
+ </layout>
+ </dialog>
+
<dialog name='KeysDialog' overlays='Dialog.GlobalOptions' shading='dim'>
<layout type='vertical' padding='8,8,8,8' center='true'>
<widget name='Action'
diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx
index 7c2326d5de..105c121a2b 100644
--- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx
+++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx
@@ -527,6 +527,19 @@
</layout>
</dialog>
+ <dialog name = 'GlobalOptions_Cloud' overlays = 'Dialog.GlobalOptions.TabWidget'>
+ <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'>
+ <widget name = 'StorageButton'
+ type = 'Button'
+ />
+ <widget name = 'CurStorage'
+ height = 'Globals.Line.Height'
+ />
+ </layout>
+ </layout>
+ </dialog>
+
<dialog name='KeysDialog' overlays='Dialog.GlobalOptions' shading='dim'>
<layout type='vertical' padding='8,8,8,8' center='true'>
<widget name='Action'