diff options
-rw-r--r-- | backends/cloud/cloudmanager.cpp | 18 | ||||
-rw-r--r-- | backends/cloud/cloudmanager.h | 26 | ||||
-rw-r--r-- | gui/options.cpp | 35 | ||||
-rw-r--r-- | gui/options.h | 7 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 24 |
5 files changed, 108 insertions, 2 deletions
diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp index a9baac5d02..cb7e6f7cb3 100644 --- a/backends/cloud/cloudmanager.cpp +++ b/backends/cloud/cloudmanager.cpp @@ -132,7 +132,7 @@ Common::StringArray CloudManager::listStorages() const { } bool CloudManager::switchStorage(uint32 index) { - if (index < 0 || index > _storages.size()) { + if (index >= _storages.size()) { warning("CloudManager::switchStorage: invalid index passed"); return false; } @@ -148,6 +148,22 @@ bool CloudManager::switchStorage(uint32 index) { return true; } +Common::String CloudManager::getStorageUsername(uint32 index) { + if (index >= _storages.size()) return ""; + return _storages[index]->name(); //TODO +} + +uint64 CloudManager::getStorageUsedSpace(uint32 index) { + if (index >= _storages.size()) return 0; + return 0; //return _storages[index]->usedSpace(); //TODO +} + +Common::String CloudManager::getStorageLastSync(uint32 index) { + if (index >= _storages.size()) return ""; + if (_storages[index]->isSyncing()) return ""; + return _storages[index]->name(); //->lastSyncDate(); //TODO +} + void CloudManager::printBool(Storage::BoolResponse response) const { debug("bool = %s", (response.value ? "true" : "false")); } diff --git a/backends/cloud/cloudmanager.h b/backends/cloud/cloudmanager.h index 7e8cfd68a3..9956a92824 100644 --- a/backends/cloud/cloudmanager.h +++ b/backends/cloud/cloudmanager.h @@ -104,6 +104,32 @@ public: bool switchStorage(uint32 index); /** + * Return username used by Storage. + * + * @param Storage's index. + * @returns username or "" if index is invalid (no such Storage). + */ + Common::String getStorageUsername(uint32 index); + + /** + * Return space used by Storage. + * + * @param Storage's index. + * @returns used space in bytes or 0 if index is invalid (no such Storage). + */ + uint64 getStorageUsedSpace(uint32 index); + + /** + * Return Storage's last sync date. + * + * @param Storage's index. + * @returns last sync date or "" if index is invalid (no such Storage). + It also returns "" if there never was any sync + or if storage is syncing right now. + */ + Common::String getStorageLastSync(uint32 index); + + /** * Starts saves syncing process in currently active storage if there is any. */ SavesSyncRequest *syncSaves(Cloud::Storage::BoolCallback callback = nullptr, Networking::ErrorCallback errorCallback = nullptr); diff --git a/gui/options.cpp b/gui/options.cpp index df457a89e8..b0a7968b2d 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1273,6 +1273,17 @@ GlobalOptionsDialog::GlobalOptionsDialog() new ButtonWidget(tab, "GlobalOptions_Cloud.StorageButton", _("Storage:"), 0, kChooseStorageCmd); _curStorage = new StaticTextWidget(tab, "GlobalOptions_Cloud.CurStorage", CloudMan.getStorageName()); + + new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageUsernameDesc", _("Username:"), _("Username used by this storage")); + _storageUsername = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageUsernameLabel", "<none>"); + + new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageUsedSpaceDesc", _("Used space:"), _("Space used by ScummVM on this storage")); + _storageUsedSpace = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageUsedSpaceLabel", "0 bytes"); + + new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageLastSyncDesc", _("Last sync time:"), _("When this storage did last saves sync")); + _storageLastSync = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageLastSyncLabel", "<never>"); + + setupCloudTab(); #endif // Activate the first tab @@ -1550,6 +1561,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 if (CloudMan.switchStorage(storageIndex)) { _curStorage->setLabel(CloudMan.getStorageName()); //automatically saves in the config if switched successfully + setupCloudTab(); } else { bool anotherStorageIsWorking = CloudMan.isWorking(); Common::String message = _("Failed to change cloud storage!"); @@ -1621,4 +1633,27 @@ void GlobalOptionsDialog::reflowLayout() { OptionsDialog::reflowLayout(); } +#ifdef USE_CLOUD +void GlobalOptionsDialog::setupCloudTab() { + uint32 index = CloudMan.getStorageIndex(); + if (_storageUsername) { + Common::String username = CloudMan.getStorageUsername(index); + if (username == "") username = _("<none>"); + _storageUsername->setLabel(username); + } + if (_storageUsedSpace) { + uint64 usedSpace = CloudMan.getStorageUsedSpace(index); + _storageUsedSpace->setLabel(Common::String::format(_("%llu bytes"), usedSpace)); + } + if (_storageLastSync) { + Common::String sync = CloudMan.getStorageLastSync(index); + if (sync == "") { + if (CloudMan.isSyncing()) sync = _("<right now>"); + else sync = _("<never>"); + } + _storageLastSync->setLabel(sync); + } +} +#endif + } // End of namespace GUI diff --git a/gui/options.h b/gui/options.h index feb77859e8..228a415b92 100644 --- a/gui/options.h +++ b/gui/options.h @@ -244,9 +244,14 @@ protected: #ifdef USE_CLOUD // - // Misc controls + // Cloud controls // StaticTextWidget *_curStorage; + StaticTextWidget *_storageUsername; + StaticTextWidget *_storageUsedSpace; + StaticTextWidget *_storageLastSync; + + void setupCloudTab(); #endif }; diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 693be090e8..093eeba522 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -548,6 +548,30 @@ height = 'Globals.Line.Height' /> </layout> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'> + <widget name = 'StorageUsernameDesc' + type = 'OptionsLabel' + /> + <widget name = 'StorageUsernameLabel' + height = 'Globals.Line.Height' + /> + </layout> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'> + <widget name = 'StorageUsedSpaceDesc' + type = 'OptionsLabel' + /> + <widget name = 'StorageUsedSpaceLabel' + height = 'Globals.Line.Height' + /> + </layout> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'> + <widget name = 'StorageLastSyncDesc' + type = 'OptionsLabel' + /> + <widget name = 'StorageLastSyncLabel' + height = 'Globals.Line.Height' + /> + </layout> </layout> </dialog> |