CLOUD: Fix SaveLoadDialogs to check USE_CLOUD

Linking was failing when disabling curl support.
This commit is contained in:
Alexander Tkachev 2016-07-05 13:30:24 +06:00
parent ad069f442c
commit 81c85b6651
3 changed files with 27 additions and 1 deletions

View file

@ -22,9 +22,11 @@
#include "gui/saveload-dialog.h" #include "gui/saveload-dialog.h"
#ifdef USE_CLOUD
#include "backends/cloud/cloudmanager.h" #include "backends/cloud/cloudmanager.h"
#include "backends/cloud/savessyncrequest.h" #include "backends/cloud/savessyncrequest.h"
#include "backends/networking/curl/connectionmanager.h" #include "backends/networking/curl/connectionmanager.h"
#endif
#include "common/translation.h" #include "common/translation.h"
#include "common/config-manager.h" #include "common/config-manager.h"
@ -39,6 +41,8 @@
namespace GUI { namespace GUI {
#ifdef USE_CLOUD
enum { enum {
kCancelSyncCmd = 'PDCS', kCancelSyncCmd = 'PDCS',
kBackgroundSyncCmd = 'PDBS' kBackgroundSyncCmd = 'PDBS'
@ -93,6 +97,7 @@ void SaveLoadCloudSyncProgressDialog::handleTickle() {
Dialog::handleTickle(); Dialog::handleTickle();
} }
#endif
#ifndef DISABLE_SAVELOADCHOOSER_GRID #ifndef DISABLE_SAVELOADCHOOSER_GRID
SaveLoadChooserType getRequestedSaveLoadDialog(const MetaEngine &metaEngine) { SaveLoadChooserType getRequestedSaveLoadDialog(const MetaEngine &metaEngine) {
@ -152,7 +157,9 @@ SaveLoadChooserDialog::SaveLoadChooserDialog(int x, int y, int w, int h, const b
} }
SaveLoadChooserDialog::~SaveLoadChooserDialog() { SaveLoadChooserDialog::~SaveLoadChooserDialog() {
#ifdef USE_CLOUD
CloudMan.setSyncTarget(nullptr); //not that dialog, at least CloudMan.setSyncTarget(nullptr); //not that dialog, at least
#endif
} }
void SaveLoadChooserDialog::open() { void SaveLoadChooserDialog::open() {
@ -166,7 +173,9 @@ void SaveLoadChooserDialog::open() {
} }
void SaveLoadChooserDialog::close() { void SaveLoadChooserDialog::close() {
#ifdef USE_CLOUD
CloudMan.setSyncTarget(nullptr); //not that dialog, at least CloudMan.setSyncTarget(nullptr); //not that dialog, at least
#endif
Dialog::close(); Dialog::close();
} }
@ -206,14 +215,17 @@ void SaveLoadChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uin
} }
#endif // !DISABLE_SAVELOADCHOOSER_GRID #endif // !DISABLE_SAVELOADCHOOSER_GRID
#ifdef USE_CLOUD
if (cmd == kSavesSyncProgressCmd || cmd == kSavesSyncEndedCmd) { if (cmd == kSavesSyncProgressCmd || cmd == kSavesSyncEndedCmd) {
//this dialog only gets these commands if the progress dialog was shown and user clicked "run in background" //this dialog only gets these commands if the progress dialog was shown and user clicked "run in background"
return updateSaveList(); return updateSaveList();
} }
#endif
return Dialog::handleCommand(sender, cmd, data); return Dialog::handleCommand(sender, cmd, data);
} }
#ifdef USE_CLOUD
void SaveLoadChooserDialog::runSaveSync(bool hasSavepathOverride) { void SaveLoadChooserDialog::runSaveSync(bool hasSavepathOverride) {
if (!CloudMan.isSyncing()) { if (!CloudMan.isSyncing()) {
if (hasSavepathOverride) { if (hasSavepathOverride) {
@ -224,8 +236,10 @@ void SaveLoadChooserDialog::runSaveSync(bool hasSavepathOverride) {
} }
} }
} }
#endif
void SaveLoadChooserDialog::handleTickle() { void SaveLoadChooserDialog::handleTickle() {
#ifdef USE_CLOUD
if (!_dialogWasShown && CloudMan.isSyncing()) { if (!_dialogWasShown && CloudMan.isSyncing()) {
Common::Array<Common::String> files = CloudMan.getSyncingFiles(); Common::Array<Common::String> files = CloudMan.getSyncingFiles();
if (!files.empty()) { if (!files.empty()) {
@ -243,6 +257,7 @@ void SaveLoadChooserDialog::handleTickle() {
updateSaveList(); updateSaveList();
} }
} }
#endif
Dialog::handleTickle(); Dialog::handleTickle();
} }
@ -264,8 +279,10 @@ void SaveLoadChooserDialog::reflowLayout() {
} }
void SaveLoadChooserDialog::updateSaveList() { void SaveLoadChooserDialog::updateSaveList() {
#ifdef USE_CLOUD
Common::Array<Common::String> files = CloudMan.getSyncingFiles(); //returns empty array if not syncing Common::Array<Common::String> files = CloudMan.getSyncingFiles(); //returns empty array if not syncing
g_system->getSavefileManager()->updateSavefilesList(files); g_system->getSavefileManager()->updateSavefilesList(files);
#endif
listSaves(); listSaves();
} }
@ -273,6 +290,8 @@ void SaveLoadChooserDialog::listSaves() {
if (!_metaEngine) return; //very strange if (!_metaEngine) return; //very strange
_saveList = _metaEngine->listSaves(_target.c_str()); _saveList = _metaEngine->listSaves(_target.c_str());
#ifdef USE_CLOUD
//if there is Cloud support, add currently synced files as "locked" saves in the list
if (_metaEngine->simpleSaveNames()) { if (_metaEngine->simpleSaveNames()) {
Common::String pattern = _target + ".###"; Common::String pattern = _target + ".###";
Common::Array<Common::String> files = CloudMan.getSyncingFiles(); //returns empty array if not syncing Common::Array<Common::String> files = CloudMan.getSyncingFiles(); //returns empty array if not syncing
@ -294,6 +313,7 @@ void SaveLoadChooserDialog::listSaves() {
Common::sort(_saveList.begin(), _saveList.end(), SaveStateDescriptorSlotComparator()); Common::sort(_saveList.begin(), _saveList.end(), SaveStateDescriptorSlotComparator());
} }
#endif
} }
#ifndef DISABLE_SAVELOADCHOOSER_GRID #ifndef DISABLE_SAVELOADCHOOSER_GRID

View file

@ -30,6 +30,7 @@
namespace GUI { namespace GUI {
#ifdef USE_CLOUD
enum SaveLoadCloudSyncProgress { enum SaveLoadCloudSyncProgress {
kSavesSyncProgressCmd = 'SSPR', kSavesSyncProgressCmd = 'SSPR',
kSavesSyncEndedCmd = 'SSEN' kSavesSyncEndedCmd = 'SSEN'
@ -46,6 +47,7 @@ public:
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
virtual void handleTickle(); virtual void handleTickle();
}; };
#endif
#define kSwitchSaveLoadDialog -2 #define kSwitchSaveLoadDialog -2
@ -79,7 +81,9 @@ public:
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
#ifdef USE_CLOUD
virtual void runSaveSync(bool hasSavepathOverride); virtual void runSaveSync(bool hasSavepathOverride);
#endif
virtual void handleTickle(); virtual void handleTickle();

View file

@ -87,7 +87,9 @@ int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, con
if (!_impl) if (!_impl)
return -1; return -1;
#ifdef USE_CLOUD
_impl->runSaveSync(ConfMan.hasKey("savepath", target)); _impl->runSaveSync(ConfMan.hasKey("savepath", target));
#endif
// Set up the game domain as newly active domain, so // Set up the game domain as newly active domain, so
// target specific savepath will be checked // target specific savepath will be checked