mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 20:51:14 +00:00
CLOUD: Make ProgressDialog display downloading progress
This commit is contained in:
parent
3db80154d6
commit
0ce7be17d3
@ -139,6 +139,12 @@ bool CloudManager::isSyncing() {
|
||||
return false;
|
||||
}
|
||||
|
||||
double CloudManager::getSyncDownloadingProgress() {
|
||||
Storage *storage = getCurrentStorage();
|
||||
if (storage) return storage->getSyncDownloadingProgress();
|
||||
return 1;
|
||||
}
|
||||
|
||||
double CloudManager::getSyncProgress() {
|
||||
Storage *storage = getCurrentStorage();
|
||||
if (storage) return storage->getSyncProgress();
|
||||
|
@ -90,6 +90,9 @@ public:
|
||||
/** Returns whether there is a SavesSyncRequest running. */
|
||||
bool isSyncing();
|
||||
|
||||
/** Returns a number in [0, 1] range which represents current sync downloading progress (1 = complete). */
|
||||
double getSyncDownloadingProgress();
|
||||
|
||||
/** Returns a number in [0, 1] range which represents current sync progress (1 = complete). */
|
||||
double getSyncProgress();
|
||||
|
||||
|
@ -208,12 +208,13 @@ void SavesSyncRequest::directoryCreatedErrorCallback(Networking::ErrorResponse e
|
||||
|
||||
void SavesSyncRequest::downloadNextFile() {
|
||||
if (_filesToDownload.empty()) {
|
||||
_currentDownloadingFile = StorageFile("", 0, 0, false); //so getFilesToDownload() would return an empty array
|
||||
sendCommand(kSavesSyncEndedCmd, 0);
|
||||
uploadNextFile();
|
||||
return;
|
||||
}
|
||||
|
||||
sendCommand(kSavesSyncProgressCmd, (int)(getProgress() * 100));
|
||||
sendCommand(kSavesSyncProgressCmd, (int)(getDownloadingProgress() * 100));
|
||||
|
||||
_currentDownloadingFile = _filesToDownload.back();
|
||||
_filesToDownload.pop_back();
|
||||
@ -295,6 +296,19 @@ void SavesSyncRequest::handle() {}
|
||||
|
||||
void SavesSyncRequest::restart() { start(); }
|
||||
|
||||
double SavesSyncRequest::getDownloadingProgress() {
|
||||
if (_totalFilesToHandle == 0) {
|
||||
if (_state == Networking::FINISHED) return 1; //nothing to upload and download => Request ends soon
|
||||
return 0; //directory not listed yet
|
||||
}
|
||||
|
||||
if (_totalFilesToHandle == _filesToUpload.size()) return 1; //nothing to download => download complete
|
||||
|
||||
uint32 totalFilesToDownload = _totalFilesToHandle - _filesToUpload.size();
|
||||
uint32 filesLeftToDownload = _filesToDownload.size() + (_currentDownloadingFile.name() != "" ? 1 : 0);
|
||||
return (double)(totalFilesToDownload - filesLeftToDownload) / (double)(totalFilesToDownload);
|
||||
}
|
||||
|
||||
double SavesSyncRequest::getProgress() {
|
||||
if (_totalFilesToHandle == 0) {
|
||||
if (_state == Networking::FINISHED) return 1; //nothing to upload and download => Request ends soon
|
||||
|
@ -69,6 +69,9 @@ public:
|
||||
virtual void handle();
|
||||
virtual void restart();
|
||||
|
||||
/** Returns a number in range [0, 1], where 1 is "complete". */
|
||||
double getDownloadingProgress();
|
||||
|
||||
/** Returns a number in range [0, 1], where 1 is "complete". */
|
||||
double getProgress();
|
||||
|
||||
|
@ -124,6 +124,15 @@ bool Storage::isSyncing() {
|
||||
return syncing;
|
||||
}
|
||||
|
||||
double Storage::getSyncDownloadingProgress() {
|
||||
double result = 1;
|
||||
_runningRequestsMutex.lock();
|
||||
if (_savesSyncRequest)
|
||||
result = _savesSyncRequest->getDownloadingProgress();
|
||||
_runningRequestsMutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
double Storage::getSyncProgress() {
|
||||
double result = 1;
|
||||
_runningRequestsMutex.lock();
|
||||
|
@ -147,6 +147,9 @@ public:
|
||||
/** Returns whether there is a SavesSyncRequest running. */
|
||||
virtual bool isSyncing();
|
||||
|
||||
/** Returns a number in [0, 1] range which represents current sync progress (1 = complete). */
|
||||
virtual double getSyncDownloadingProgress();
|
||||
|
||||
/** Returns a number in [0, 1] range which represents current sync progress (1 = complete). */
|
||||
virtual double getSyncProgress();
|
||||
|
||||
|
@ -52,7 +52,7 @@ SaveLoadCloudSyncProgressDialog::SaveLoadCloudSyncProgressDialog(): Dialog(10, 1
|
||||
int buttonWidth = 140;
|
||||
int marginBottom = 8;
|
||||
|
||||
uint32 progress = (uint32)(100 * CloudMan.getSyncProgress());
|
||||
uint32 progress = (uint32)(100 * CloudMan.getSyncDownloadingProgress());
|
||||
_label = new StaticTextWidget(this, 10, 10, 300, kLineHeight, Common::String::format("Downloading saves (%u%% complete)...", progress), Graphics::kTextAlignCenter);
|
||||
|
||||
//if (defaultButton)
|
||||
|
Loading…
x
Reference in New Issue
Block a user