diff options
author | Alexander Tkachev | 2016-07-20 16:36:44 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 85f4c69fc981ae1d3807ffb0280b59d627a92ebc (patch) | |
tree | 647eb21ff260d8e3de54b95de505c5fe56397ada /gui | |
parent | 39865e6e6cf67e3b5a3867540dde76969b244246 (diff) | |
download | scummvm-rg350-85f4c69fc981ae1d3807ffb0280b59d627a92ebc.tar.gz scummvm-rg350-85f4c69fc981ae1d3807ffb0280b59d627a92ebc.tar.bz2 scummvm-rg350-85f4c69fc981ae1d3807ffb0280b59d627a92ebc.zip |
CLOUD: Update StorageWizardDialog
It now hides code fields not just when built with SDL_Net, but also when
LocalWebserver's using default port.
So that's why NETWORKING_LOCALWEBSERVER_ENABLE_PORT_OVERRIDE is defined
in localwebserver.h now.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/storagewizarddialog.cpp | 50 | ||||
-rw-r--r-- | gui/storagewizarddialog.h | 3 |
2 files changed, 30 insertions, 23 deletions
diff --git a/gui/storagewizarddialog.cpp b/gui/storagewizarddialog.cpp index a8574ab7d2..299da11812 100644 --- a/gui/storagewizarddialog.cpp +++ b/gui/storagewizarddialog.cpp @@ -61,15 +61,15 @@ StorageWizardDialog::StorageWizardDialog(uint32 storageId): new ButtonWidget(this, "GlobalOptions_Cloud_ConnectionWizard.OpenUrlButton", _("Open URL"), 0, kOpenUrlCmd); _connectWidget = new ButtonWidget(this, "GlobalOptions_Cloud_ConnectionWizard.ConnectButton", _("Connect"), 0, kConnectCmd); -#ifdef USE_SDL_NET - // hide fields and even the button if local webserver is on - returnLine1->setLabel(_s("You would be navigated to ScummVM's page")); - returnLine2->setLabel(_s("when you'd allow it to use your storage.")); - for (uint32 i = 0; i < CODE_FIELDS; ++i) - _codeWidget[i]->setVisible(false); - _messageWidget->setVisible(false); - _connectWidget->setVisible(false); -#endif + if (couldUseLocalServer()) { + // hide fields and even the button if local webserver is on + returnLine1->setLabel(_s("You would be navigated to ScummVM's page")); + returnLine2->setLabel(_s("when you'd allow it to use your storage.")); + for (uint32 i = 0; i < CODE_FIELDS; ++i) + _codeWidget[i]->setVisible(false); + _messageWidget->setVisible(false); + _connectWidget->setVisible(false); + } } void StorageWizardDialog::open() { @@ -97,18 +97,18 @@ void StorageWizardDialog::open() { } } -#ifdef USE_SDL_NET - _stopServerOnClose = !LocalServer.isRunning(); - LocalServer.start(); - LocalServer.indexPageHandler().setTarget(this); -#endif + if (couldUseLocalServer()) { + _stopServerOnClose = !LocalServer.isRunning(); + LocalServer.start(); + LocalServer.indexPageHandler().setTarget(this); + } } void StorageWizardDialog::close() { -#ifdef USE_SDL_NET - if (_stopServerOnClose) LocalServer.stopOnIdle(); - LocalServer.indexPageHandler().setTarget(nullptr); -#endif + if (couldUseLocalServer()) { + if (_stopServerOnClose) LocalServer.stopOnIdle(); + LocalServer.indexPageHandler().setTarget(nullptr); + } Dialog::close(); } @@ -182,12 +182,10 @@ void StorageWizardDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 close(); break; } -#ifdef USE_SDL_NET case kStorageCodePassedCmd: CloudMan.connectStorage(_storageId, LocalServer.indexPageHandler().code()); _close = true; break; -#endif default: Dialog::handleCommand(sender, cmd, data); } @@ -210,12 +208,18 @@ Common::String StorageWizardDialog::getUrl() const { case Cloud::kStorageGoogleDriveId: url += "gd"; break; case Cloud::kStorageBoxId: url += "bx"; break; } -#ifdef USE_SDL_NET - url += "s"; -#endif + + if (couldUseLocalServer()) url += "s"; return url; } +bool StorageWizardDialog::couldUseLocalServer() const { +#ifdef USE_SDL_NET + return Networking::LocalWebserver::getPort() == Networking::LocalWebserver::DEFAULT_SERVER_PORT; +#else + return false; +#endif +} int StorageWizardDialog::decodeHashchar(char c) { const char HASHCHARS[65] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ?!"; diff --git a/gui/storagewizarddialog.h b/gui/storagewizarddialog.h index 6b00d60915..26e8cd42ab 100644 --- a/gui/storagewizarddialog.h +++ b/gui/storagewizarddialog.h @@ -51,6 +51,9 @@ class StorageWizardDialog : public Dialog { /** Return short scummvm.org URL for user to navigate to. */ Common::String getUrl() const; + /** Return whether fields should be used or not. */ + bool couldUseLocalServer() const; + /** * Return the value corresponding to the given character. * |