aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/downloaddialog.cpp42
-rw-r--r--gui/options.cpp139
-rw-r--r--gui/remotebrowser.cpp18
-rw-r--r--gui/saveload-dialog.cpp15
-rw-r--r--gui/storagewizarddialog.cpp50
5 files changed, 170 insertions, 94 deletions
diff --git a/gui/downloaddialog.cpp b/gui/downloaddialog.cpp
index 495e9c13f0..ea7ace2f2a 100644
--- a/gui/downloaddialog.cpp
+++ b/gui/downloaddialog.cpp
@@ -92,12 +92,12 @@ void DownloadDialog::close() {
void DownloadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kDownloadDialogButtonCmd:
- {
- CloudMan.setDownloadTarget(nullptr);
- CloudMan.cancelDownload();
- close();
- break;
- }
+ {
+ CloudMan.setDownloadTarget(nullptr);
+ CloudMan.cancelDownload();
+ close();
+ break;
+ }
case kDownloadProgressCmd:
if (!_close) {
refreshWidgets();
@@ -116,16 +116,19 @@ bool DownloadDialog::selectDirectories() {
if (Networking::Connection::isLimited()) {
MessageDialog alert(_("It looks like your connection is limited. "
"Do you really want to download files with it?"), _("Yes"), _("No"));
- if (alert.runModal() != GUI::kMessageOK) return false;
+ if (alert.runModal() != GUI::kMessageOK)
+ return false;
}
//first user should select remote directory to download
- if (_remoteBrowser->runModal() <= 0) return false;
+ if (_remoteBrowser->runModal() <= 0)
+ return false;
Cloud::StorageFile remoteDirectory = _remoteBrowser->getResult();
//now user should select local directory to download into
- if (_browser->runModal() <= 0) return false;
+ if (_browser->runModal() <= 0)
+ return false;
Common::FSNode dir(_browser->getResult());
Common::FSList files;
@@ -149,7 +152,8 @@ bool DownloadDialog::selectDirectories() {
_("Yes"),
_("No")
);
- if (alert.runModal() != GUI::kMessageOK) return false;
+ if (alert.runModal() != GUI::kMessageOK)
+ return false;
break;
}
}
@@ -161,12 +165,18 @@ bool DownloadDialog::selectDirectories() {
if (localPath.size() && localPath.lastChar() != '/' && localPath.lastChar() != '\\') {
int backslashes = 0;
for (uint32 i = 0; i < localPath.size(); ++i)
- if (localPath[i] == '/') --backslashes;
- else if (localPath[i] == '\\') ++backslashes;
-
- if (backslashes > 0) localPath += '\\' + remoteDirectory.name();
- else localPath += '/' + remoteDirectory.name();
- } else localPath += remoteDirectory.name();
+ if (localPath[i] == '/')
+ --backslashes;
+ else if (localPath[i] == '\\')
+ ++backslashes;
+
+ if (backslashes > 0)
+ localPath += '\\' + remoteDirectory.name();
+ else
+ localPath += '/' + remoteDirectory.name();
+ } else {
+ localPath += remoteDirectory.name();
+ }
CloudMan.startDownload(remoteDirectory.path(), localPath);
CloudMan.setDownloadTarget(this);
diff --git a/gui/options.cpp b/gui/options.cpp
index 34044b7acb..603fc23eea 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -1502,7 +1502,8 @@ void GlobalOptionsDialog::close() {
uint32 port = Networking::LocalWebserver::getPort();
if (_serverPort) {
uint64 contents = _serverPort->getEditString().asUint64();
- if (contents != 0) port = contents;
+ if (contents != 0)
+ port = contents;
}
ConfMan.setInt("local_server_port", port);
#endif
@@ -1638,7 +1639,8 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
uint32 port = Networking::LocalWebserver::getPort();
if (_serverPort) {
uint64 contents = _serverPort->getEditString().asUint64();
- if (contents != 0) port = contents;
+ if (contents != 0)
+ port = contents;
}
ConfMan.setInt("local_server_port", port);
ConfMan.flushToDisk();
@@ -1656,7 +1658,8 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
new Common::Callback<GlobalOptionsDialog, Networking::ErrorResponse>(this, &GlobalOptionsDialog::storageErrorCallback)
);
Common::String dir = CloudMan.savesDirectoryPath();
- if (dir.lastChar() == '/') dir.deleteLastChar();
+ if (dir.lastChar() == '/')
+ dir.deleteLastChar();
CloudMan.listDirectory(
dir,
new Common::Callback<GlobalOptionsDialog, Cloud::Storage::ListDirectoryResponse>(this, &GlobalOptionsDialog::storageListDirectoryCallback),
@@ -1665,30 +1668,34 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
break;
}
case kDownloadStorageCmd:
- {
- DownloadDialog dialog(_selectedStorageIndex, _launcher);
- dialog.runModal();
- break;
- }
+ {
+ DownloadDialog dialog(_selectedStorageIndex, _launcher);
+ dialog.runModal();
+ break;
+ }
#endif
#ifdef USE_SDL_NET
case kRunServerCmd:
- {
+ {
#ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
- // save server's port
- uint32 port = Networking::LocalWebserver::getPort();
- if (_serverPort) {
- uint64 contents = _serverPort->getEditString().asUint64();
- if (contents != 0) port = contents;
- }
- ConfMan.setInt("local_server_port", port);
- ConfMan.flushToDisk();
+ // save server's port
+ uint32 port = Networking::LocalWebserver::getPort();
+ if (_serverPort) {
+ uint64 contents = _serverPort->getEditString().asUint64();
+ if (contents != 0)
+ port = contents;
+ }
+ ConfMan.setInt("local_server_port", port);
+ ConfMan.flushToDisk();
#endif
- if (LocalServer.isRunning()) LocalServer.stopOnIdle();
- else LocalServer.start();
- break;
- }
+ if (LocalServer.isRunning())
+ LocalServer.stopOnIdle();
+ else
+ LocalServer.start();
+
+ break;
+ }
case kServerPortClearCmd: {
if (_serverPort) {
@@ -1787,7 +1794,8 @@ void GlobalOptionsDialog::setupCloudTab() {
if (_storageUsernameDesc) _storageUsernameDesc->setVisible(shown);
if (_storageUsername) {
Common::String username = CloudMan.getStorageUsername(_selectedStorageIndex);
- if (username == "") username = _("<none>");
+ if (username == "")
+ username = _("<none>");
_storageUsername->setLabel(username);
_storageUsername->setVisible(shown);
}
@@ -1801,31 +1809,49 @@ void GlobalOptionsDialog::setupCloudTab() {
if (_storageLastSync) {
Common::String sync = CloudMan.getStorageLastSync(_selectedStorageIndex);
if (sync == "") {
- if (_selectedStorageIndex == CloudMan.getStorageIndex() && CloudMan.isSyncing()) sync = _("<right now>");
- else sync = _("<never>");
+ if (_selectedStorageIndex == CloudMan.getStorageIndex() && CloudMan.isSyncing())
+ sync = _("<right now>");
+ else
+ sync = _("<never>");
}
_storageLastSync->setLabel(sync);
_storageLastSync->setVisible(shown);
}
- if (_storageConnectButton) _storageConnectButton->setVisible(shown);
- if (_storageRefreshButton) _storageRefreshButton->setVisible(shown && _selectedStorageIndex == CloudMan.getStorageIndex());
- if (_storageDownloadButton) _storageDownloadButton->setVisible(shown && _selectedStorageIndex == CloudMan.getStorageIndex());
- if (!shown) serverLabelPosition = (_storageUsernameDesc ? _storageUsernameDesc->getRelY() : 0);
+ if (_storageConnectButton)
+ _storageConnectButton->setVisible(shown);
+ if (_storageRefreshButton)
+ _storageRefreshButton->setVisible(shown && _selectedStorageIndex == CloudMan.getStorageIndex());
+ if (_storageDownloadButton)
+ _storageDownloadButton->setVisible(shown && _selectedStorageIndex == CloudMan.getStorageIndex());
+ if (!shown)
+ serverLabelPosition = (_storageUsernameDesc ? _storageUsernameDesc->getRelY() : 0);
#else
_selectedStorageIndex = 0;
- if (_storagePopUpDesc) _storagePopUpDesc->setVisible(false);
- if (_storagePopUp) _storagePopUp->setVisible(false);
- if (_storageUsernameDesc) _storageUsernameDesc->setVisible(false);
- if (_storageUsernameDesc) _storageUsernameDesc->setVisible(false);
- if (_storageUsername) _storageUsername->setVisible(false);
- if (_storageUsedSpaceDesc) _storageUsedSpaceDesc->setVisible(false);
- if (_storageUsedSpace) _storageUsedSpace->setVisible(false);
- if (_storageLastSyncDesc) _storageLastSyncDesc->setVisible(false);
- if (_storageLastSync) _storageLastSync->setVisible(false);
- if (_storageConnectButton) _storageConnectButton->setVisible(false);
- if (_storageRefreshButton) _storageRefreshButton->setVisible(false);
- if (_storageDownloadButton) _storageDownloadButton->setVisible(false);
+ if (_storagePopUpDesc)
+ _storagePopUpDesc->setVisible(false);
+ if (_storagePopUp)
+ _storagePopUp->setVisible(false);
+ if (_storageUsernameDesc)
+ _storageUsernameDesc->setVisible(false);
+ if (_storageUsernameDesc)
+ _storageUsernameDesc->setVisible(false);
+ if (_storageUsername)
+ _storageUsername->setVisible(false);
+ if (_storageUsedSpaceDesc)
+ _storageUsedSpaceDesc->setVisible(false);
+ if (_storageUsedSpace)
+ _storageUsedSpace->setVisible(false);
+ if (_storageLastSyncDesc)
+ _storageLastSyncDesc->setVisible(false);
+ if (_storageLastSync)
+ _storageLastSync->setVisible(false);
+ if (_storageConnectButton)
+ _storageConnectButton->setVisible(false);
+ if (_storageRefreshButton)
+ _storageRefreshButton->setVisible(false);
+ if (_storageDownloadButton)
+ _storageDownloadButton->setVisible(false);
serverLabelPosition = (_storagePopUpDesc ? _storagePopUpDesc->getRelY() : 0);
#endif
@@ -1852,7 +1878,8 @@ void GlobalOptionsDialog::setupCloudTab() {
bool serverIsRunning = LocalServer.isRunning();
- if (serverLabelPosition < 0) serverLabelPosition = serverInfoY;
+ if (serverLabelPosition < 0)
+ serverLabelPosition = serverInfoY;
if (_runServerButton) {
_runServerButton->setVisible(true);
_runServerButton->setPos(_runServerButton->getRelX(), serverLabelPosition + serverButtonY - serverInfoY);
@@ -1861,8 +1888,10 @@ void GlobalOptionsDialog::setupCloudTab() {
if (_serverInfoLabel) {
_serverInfoLabel->setVisible(true);
_serverInfoLabel->setPos(_serverInfoLabel->getRelX(), serverLabelPosition);
- if (serverIsRunning) _serverInfoLabel->setLabel(LocalServer.getAddress());
- else _serverInfoLabel->setLabel(_("Not running"));
+ if (serverIsRunning)
+ _serverInfoLabel->setLabel(LocalServer.getAddress());
+ else
+ _serverInfoLabel->setLabel(_("Not running"));
}
#ifdef NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE
if (_serverPortDesc) {
@@ -1881,16 +1910,24 @@ void GlobalOptionsDialog::setupCloudTab() {
_serverPortClearButton->setEnabled(!serverIsRunning);
}
#else
- if (_serverPortDesc) _serverPortDesc->setVisible(false);
- if (_serverPort) _serverPort->setVisible(false);
- if (_serverPortClearButton) _serverPortClearButton->setVisible(false);
+ if (_serverPortDesc)
+ _serverPortDesc->setVisible(false);
+ if (_serverPort)
+ _serverPort->setVisible(false);
+ if (_serverPortClearButton)
+ _serverPortClearButton->setVisible(false);
#endif
#else
- if (_runServerButton) _runServerButton->setVisible(false);
- if (_serverInfoLabel) _serverInfoLabel->setVisible(false);
- if (_serverPortDesc) _serverPortDesc->setVisible(false);
- if (_serverPort) _serverPort->setVisible(false);
- if (_serverPortClearButton) _serverPortClearButton->setVisible(false);
+ if (_runServerButton)
+ _runServerButton->setVisible(false);
+ if (_serverInfoLabel)
+ _serverInfoLabel->setVisible(false);
+ if (_serverPortDesc)
+ _serverPortDesc->setVisible(false);
+ if (_serverPort)
+ _serverPort->setVisible(false);
+ if (_serverPortClearButton)
+ _serverPortClearButton->setVisible(false);
#endif
}
#endif
diff --git a/gui/remotebrowser.cpp b/gui/remotebrowser.cpp
index 49f35edc16..b87fc60f7e 100644
--- a/gui/remotebrowser.cpp
+++ b/gui/remotebrowser.cpp
@@ -135,8 +135,10 @@ void RemoteBrowserDialog::handleTickle() {
void RemoteBrowserDialog::updateListing() {
// Update the path display
Common::String path = _node.path();
- if (path.empty()) path = "/"; //root
- if (_navigationLocked) path = "Loading... " + path;
+ if (path.empty())
+ path = "/"; //root
+ if (_navigationLocked)
+ path = "Loading... " + path;
_currentPath->setLabel(path);
if (!_navigationLocked) {
@@ -168,7 +170,8 @@ void RemoteBrowserDialog::goUp() {
_rememberedNodeContents.erase(_node.path());
Common::String path = _node.path();
- if (path.size() && (path.lastChar() == '/' || path.lastChar() == '\\')) path.deleteLastChar();
+ if (path.size() && (path.lastChar() == '/' || path.lastChar() == '\\'))
+ path.deleteLastChar();
if (path.empty()) {
_rememberedNodeContents.erase("");
} else {
@@ -183,7 +186,8 @@ void RemoteBrowserDialog::goUp() {
}
void RemoteBrowserDialog::listDirectory(Cloud::StorageFile node) {
- if (_navigationLocked || _workingRequest) return;
+ if (_navigationLocked || _workingRequest)
+ return;
if (_rememberedNodeContents.contains(node.path())) {
_nodeContent = _rememberedNodeContents[node.path()];
@@ -205,7 +209,8 @@ void RemoteBrowserDialog::listDirectory(Cloud::StorageFile node) {
void RemoteBrowserDialog::directoryListedCallback(Cloud::Storage::ListDirectoryResponse response) {
_workingRequest = nullptr;
- if (_ignoreCallback) return;
+ if (_ignoreCallback)
+ return;
_navigationLocked = false;
_nodeContent = response.value;
@@ -215,7 +220,8 @@ void RemoteBrowserDialog::directoryListedCallback(Cloud::Storage::ListDirectoryR
void RemoteBrowserDialog::directoryListedErrorCallback(Networking::ErrorResponse error) {
_workingRequest = nullptr;
- if (_ignoreCallback) return;
+ if (_ignoreCallback)
+ return;
_navigationLocked = false;
_node = _backupNode;
diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index 0a39f59cd6..0bed5f4d5b 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -111,9 +111,9 @@ SaveLoadChooserType getRequestedSaveLoadDialog(const MetaEngine &metaEngine) {
g_gui.checkScreenChange();
if (g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400
- && metaEngine.hasFeature(MetaEngine::kSavesSupportMetaInfo)
- && metaEngine.hasFeature(MetaEngine::kSavesSupportThumbnail)
- && userConfig.equalsIgnoreCase("grid")) {
+ && metaEngine.hasFeature(MetaEngine::kSavesSupportMetaInfo)
+ && metaEngine.hasFeature(MetaEngine::kSavesSupportThumbnail)
+ && userConfig.equalsIgnoreCase("grid")) {
// In case we are 640x400 or higher, this dialog is not in save mode,
// the user requested the grid dialog and the engines supports it we
// try to set it up.
@@ -232,7 +232,8 @@ void SaveLoadChooserDialog::runSaveSync(bool hasSavepathOverride) {
ConnMan.showCloudDisabledIcon();
} else {
Cloud::SavesSyncRequest *request = CloudMan.syncSaves();
- if (request) request->setTarget(this);
+ if (request)
+ request->setTarget(this);
}
}
}
@@ -296,13 +297,15 @@ void SaveLoadChooserDialog::listSaves() {
Common::String pattern = _target + ".###";
Common::Array<Common::String> files = CloudMan.getSyncingFiles(); //returns empty array if not syncing
for (uint32 i = 0; i < files.size(); ++i) {
- if (!files[i].matchString(pattern, true)) continue;
+ if (!files[i].matchString(pattern, true))
+ continue;
//make up some slot number
int slotNum = 0;
for (uint32 j = (files[i].size() > 3 ? files[i].size() - 3 : 0); j < files[i].size(); ++j) { //3 last chars
char c = files[i][j];
- if (c < '0' || c > '9') continue;
+ if (c < '0' || c > '9')
+ continue;
slotNum = slotNum * 10 + (c - '0');
}
diff --git a/gui/storagewizarddialog.cpp b/gui/storagewizarddialog.cpp
index 5838dd1f11..e3bac98175 100644
--- a/gui/storagewizarddialog.cpp
+++ b/gui/storagewizarddialog.cpp
@@ -80,15 +80,18 @@ void StorageWizardDialog::open() {
MessageDialog alert(_("The other Storage is working. Do you want to interrupt it?"), _("Yes"), _("No"));
if (alert.runModal() == GUI::kMessageOK) {
- if (CloudMan.isDownloading()) CloudMan.cancelDownload();
- if (CloudMan.isSyncing()) CloudMan.cancelSync();
+ if (CloudMan.isDownloading())
+ CloudMan.cancelDownload();
+ if (CloudMan.isSyncing())
+ CloudMan.cancelSync();
// I believe it still would return `true` here, but just in case
if (CloudMan.isWorking()) {
MessageDialog alert2(_("Wait until current Storage finishes up and try again."));
alert2.runModal();
- } else
+ } else {
doClose = false;
+ }
}
if (doClose) {
@@ -106,7 +109,8 @@ void StorageWizardDialog::open() {
void StorageWizardDialog::close() {
if (Cloud::CloudManager::couldUseLocalServer()) {
- if (_stopServerOnClose) LocalServer.stopOnIdle();
+ if (_stopServerOnClose)
+ LocalServer.stopOnIdle();
LocalServer.indexPageHandler().setTarget(nullptr);
}
Dialog::close();
@@ -139,8 +143,10 @@ void StorageWizardDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
if (message.size() > 0) {
Common::String messageTemplate;
- if (CODE_FIELDS - correctFields == 1) messageTemplate = _("Field %s has a mistake in it.");
- else messageTemplate = _("Fields %s have mistakes in them.");
+ if (CODE_FIELDS - correctFields == 1)
+ messageTemplate = _("Field %s has a mistake in it.");
+ else
+ messageTemplate = _("Fields %s have mistakes in them.");
message = Common::String::format(messageTemplate.c_str(), message.c_str());
}
@@ -154,8 +160,10 @@ void StorageWizardDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
uint32 crc = crc16(code);
ok = (crc == gotcrc);
}
- if (ok) message = _("All OK!");
- else message = _("Invalid code");
+ if (ok)
+ message = _("All OK!");
+ else
+ message = _("Invalid code");
}
_connectWidget->setEnabled(ok);
_messageWidget->setLabel(message);
@@ -172,7 +180,8 @@ void StorageWizardDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
Common::String code;
for (uint32 i = 0; i < CODE_FIELDS; ++i) {
Common::String subcode = _codeWidget[i]->getEditString();
- if (subcode.size() == 0) continue;
+ if (subcode.size() == 0)
+ continue;
code += subcode;
code.deleteLastChar();
}
@@ -203,13 +212,23 @@ void StorageWizardDialog::handleTickle() {
Common::String StorageWizardDialog::getUrl() const {
Common::String url = "https://www.scummvm.org/c/";
switch (_storageId) {
- case Cloud::kStorageDropboxId: url += "db"; break;
- case Cloud::kStorageOneDriveId: url += "od"; break;
- case Cloud::kStorageGoogleDriveId: url += "gd"; break;
- case Cloud::kStorageBoxId: url += "bx"; break;
+ case Cloud::kStorageDropboxId:
+ url += "db";
+ break;
+ case Cloud::kStorageOneDriveId:
+ url += "od";
+ break;
+ case Cloud::kStorageGoogleDriveId:
+ url += "gd";
+ break;
+ case Cloud::kStorageBoxId:
+ url += "bx";
+ break;
}
- if (Cloud::CloudManager::couldUseLocalServer()) url += "s";
+ if (Cloud::CloudManager::couldUseLocalServer())
+ url += "s";
+
return url;
}
@@ -222,7 +241,8 @@ int StorageWizardDialog::decodeHashchar(char c) {
}
bool StorageWizardDialog::correctChecksum(Common::String s) {
- if (s.size() == 0) return false; //no last char
+ if (s.size() == 0)
+ return false; //no last char
int providedChecksum = decodeHashchar(s.lastChar());
int calculatedChecksum = 0x2A; //any initial value would do, but it must equal to the one used on the page where these checksums were generated
for (uint32 i = 0; i < s.size()-1; ++i) {