diff options
| -rw-r--r-- | backends/cloud/savessyncrequest.cpp | 4 | ||||
| -rw-r--r-- | backends/saves/default/default-saves.cpp | 20 | ||||
| -rw-r--r-- | backends/saves/default/default-saves.h | 7 | ||||
| -rw-r--r-- | common/savefile.h | 7 | ||||
| -rw-r--r-- | gui/saveload-dialog.cpp | 23 | ||||
| -rw-r--r-- | gui/saveload-dialog.h | 7 | 
6 files changed, 56 insertions, 12 deletions
diff --git a/backends/cloud/savessyncrequest.cpp b/backends/cloud/savessyncrequest.cpp index 072685773e..d983a0fcae 100644 --- a/backends/cloud/savessyncrequest.cpp +++ b/backends/cloud/savessyncrequest.cpp @@ -214,11 +214,11 @@ void SavesSyncRequest::downloadNextFile() {  		return;  	} -	sendCommand(kSavesSyncProgressCmd, (int)(getDownloadingProgress() * 100)); -  	_currentDownloadingFile = _filesToDownload.back();  	_filesToDownload.pop_back(); +	sendCommand(kSavesSyncProgressCmd, (int)(getDownloadingProgress() * 100)); +  	///////  	debug("downloading %s (%d %%)", _currentDownloadingFile.name().c_str(), (int)(getProgress() * 100));  	/////// diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp index 75ba50a081..a11d687c16 100644 --- a/backends/saves/default/default-saves.cpp +++ b/backends/saves/default/default-saves.cpp @@ -59,19 +59,33 @@ void DefaultSaveFileManager::checkPath(const Common::FSNode &dir) {  	}  } +void DefaultSaveFileManager::updateSavefilesList(Common::StringArray &lockedFiles) { +	//make it refresh the cache next time it lists the saves +	_cachedDirectory = ""; + +	//remember the locked files list because some of these files don't exist yet +	_lockedFiles = lockedFiles; +} +  Common::StringArray DefaultSaveFileManager::listSavefiles(const Common::String &pattern) {  	// Assure the savefile name cache is up-to-date.  	assureCached(getSavePath());  	if (getError().getCode() != Common::kNoError)  		return Common::StringArray(); +	Common::HashMap<Common::String, bool> locked; +	for (Common::StringArray::const_iterator i = _lockedFiles.begin(), end = _lockedFiles.end(); i != end; ++i) { +		if (i->matchString(pattern, true)) { +			locked[*i] = true; +		} +	} +  	Common::StringArray results; -	for (SaveFileCache::const_iterator file = _saveFileCache.begin(), end = _saveFileCache.end(); file != end; ++file) { -		if (file->_key.matchString(pattern, true)) { +	for (SaveFileCache::const_iterator file = _saveFileCache.begin(), end = _saveFileCache.end(); file != end; ++file) {		 +		if (!locked.contains(file->_key) && file->_key.matchString(pattern, true)) {  			results.push_back(file->_key);  		}  	} -  	return results;  } diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h index 166e7004ed..af30cf45e9 100644 --- a/backends/saves/default/default-saves.h +++ b/backends/saves/default/default-saves.h @@ -37,6 +37,7 @@ public:  	DefaultSaveFileManager();  	DefaultSaveFileManager(const Common::String &defaultSavepath); +	virtual void updateSavefilesList(Common::StringArray &lockedFiles);  	virtual Common::StringArray listSavefiles(const Common::String &pattern);  	virtual Common::InSaveFile *openRawFile(const Common::String &filename);  	virtual Common::InSaveFile *openForLoading(const Common::String &filename); @@ -75,6 +76,12 @@ protected:  	 */  	SaveFileCache _saveFileCache; +	/** +	 * List of "locked" files. These cannot be used for saving/loading +	 * because CloudManager is downloading those. +	 */ +	Common::StringArray _lockedFiles; +  private:  	/**  	 * The currently cached directory. diff --git a/common/savefile.h b/common/savefile.h index d9c5512b7e..38b21c9ddd 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -183,6 +183,13 @@ public:  	 * @see Common::matchString()  	 */  	virtual StringArray listSavefiles(const String &pattern) = 0; + +	/** +	 * Refreshes the save files list (because some new files could've been added) +	 * and remembers the "locked" files list. These files could not be used +	 * for saving or loading because they are being synced by CloudManager. +	 */ +	virtual void updateSavefilesList(StringArray &lockedFiles) = 0;  };  } // End of namespace Common diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 6d343c88ed..2f10182006 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -35,6 +35,7 @@  #include "gui/widgets/edittext.h"  #include "graphics/scaler.h" +#include <common/savefile.h>  namespace GUI { @@ -201,12 +202,9 @@ void SaveLoadChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uin  		//this dialog only gets these commands if the progress dialog was shown and user clicked "run in background"  		switch (cmd) { -		case kSavesSyncProgressCmd:			 -			//TODO: unlock that save which was downloaded -			break; - +		case kSavesSyncProgressCmd:  		case kSavesSyncEndedCmd: -			//TODO: ? +			updateSaveList();  			break;  		}  	} @@ -237,6 +235,7 @@ void SaveLoadChooserDialog::handleTickle() {  			}  			CloudMan.setSyncTarget(this);  			_dialogWasShown = true; +			updateSaveList();  		}  	}  	Dialog::handleTickle(); @@ -259,6 +258,11 @@ void SaveLoadChooserDialog::reflowLayout() {  	Dialog::reflowLayout();  } +void SaveLoadChooserDialog::updateSaveList() {	 +	Common::Array<Common::String> files = CloudMan.getSyncingFiles(); //returns empty array if not syncing	 +	g_system->getSavefileManager()->updateSavefilesList(files); +} +  #ifndef DISABLE_SAVELOADCHOOSER_GRID  void SaveLoadChooserDialog::addChooserButtons() {  	if (_listButton) { @@ -570,6 +574,7 @@ void SaveLoadChooserSimple::close() {  }  void SaveLoadChooserSimple::updateSaveList() { +	SaveLoadChooserDialog::updateSaveList();  	_saveList = _metaEngine->listSaves(_target.c_str());  	int curSlot = 0; @@ -631,6 +636,7 @@ void SaveLoadChooserSimple::updateSaveList() {  	}  	_list->setList(saveNames, &colors); +	draw();  }  // SaveLoadChooserGrid implementation @@ -726,6 +732,13 @@ void SaveLoadChooserGrid::handleMouseWheel(int x, int y, int direction) {  	}  } +void SaveLoadChooserGrid::updateSaveList() { +	SaveLoadChooserDialog::updateSaveList(); +	_saveList = _metaEngine->listSaves(_target.c_str()); +	updateSaves(); +	draw(); +} +  void SaveLoadChooserGrid::open() {  	SaveLoadChooserDialog::open(); diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index e8f0c37228..a767fb8a23 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -84,6 +84,7 @@ public:  protected:  	virtual int runIntern() = 0; +	virtual void updateSaveList();  	const bool				_saveMode;  	const MetaEngine		*_metaEngine; @@ -122,6 +123,8 @@ public:  	virtual void open();  	virtual void close(); +protected: +	virtual void updateSaveList();  private:  	virtual int runIntern(); @@ -136,8 +139,7 @@ private:  	SaveStateList			_saveList;  	String					_resultString; - -	void updateSaveList(); +	  	void updateSelection(bool redraw);  }; @@ -180,6 +182,7 @@ public:  protected:  	virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);  	virtual void handleMouseWheel(int x, int y, int direction); +	virtual void updateSaveList();  private:  	virtual int runIntern();  | 
