diff options
author | Alexander Tkachev | 2016-07-05 16:31:52 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | e601c39802adbb64dce4b449c617e1786ef584ed (patch) | |
tree | 47967b710c44a15524b7170885080aaefdceb949 /gui | |
parent | 3da38ca60b65d3f1bd67b049f3c4b2a90a4d6a19 (diff) | |
download | scummvm-rg350-e601c39802adbb64dce4b449c617e1786ef584ed.tar.gz scummvm-rg350-e601c39802adbb64dce4b449c617e1786ef584ed.tar.bz2 scummvm-rg350-e601c39802adbb64dce4b449c617e1786ef584ed.zip |
CLOUD: Make "Run server" button active
It should show the real server's IP over there, but that doesn't work
yet.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/options.cpp | 33 | ||||
-rw-r--r-- | gui/options.h | 3 | ||||
-rw-r--r-- | gui/storagewizarddialog.cpp | 5 | ||||
-rw-r--r-- | gui/storagewizarddialog.h | 1 |
4 files changed, 34 insertions, 8 deletions
diff --git a/gui/options.cpp b/gui/options.cpp index 9d9833496f..bb9bf4d123 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -49,6 +49,10 @@ #include "gui/storagewizarddialog.h" #endif +#ifdef USE_SDL_NET +#include "backends/networking/sdl_net/localwebserver.h" +#endif + namespace GUI { enum { @@ -1306,10 +1310,13 @@ GlobalOptionsDialog::GlobalOptionsDialog() _storageDownloadButton = new ButtonWidget(tab, "GlobalOptions_Cloud.DownloadButton", _("Downloads"), _("Open downloads manager dialog"), kDownloadStorageCmd); _runServerButton = new ButtonWidget(tab, "GlobalOptions_Cloud.RunServerButton", _("Run server"), _("Run local webserver"), kRunServerCmd); - _serverInfoLabel = new StaticTextWidget(tab, "GlobalOptions_Cloud.ServerInfoLabel", "Not running"); + _serverInfoLabel = new StaticTextWidget(tab, "GlobalOptions_Cloud.ServerInfoLabel", _("Not running")); setupCloudTab(); _redrawCloudTab = false; +#ifdef USE_SDL_NET + _serverWasRunning = false; +#endif #endif // Activate the first tab @@ -1623,9 +1630,8 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 #ifdef USE_SDL_NET case kRunServerCmd: { - //TODO - //DownloadDialog dialog(_selectedStorageIndex); - //dialog.runModal(); + if (LocalServer.isRunning()) LocalServer.stopOnIdle(); + else LocalServer.start(); break; } #endif @@ -1653,6 +1659,12 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 void GlobalOptionsDialog::handleTickle() { OptionsDialog::handleTickle(); #ifdef USE_CLOUD +#ifdef USE_SDL_NET + if (LocalServer.isRunning() != _serverWasRunning) { + _serverWasRunning = !_serverWasRunning; + _redrawCloudTab = true; + } +#endif if (_redrawCloudTab) { setupCloudTab(); draw(); @@ -1762,10 +1774,19 @@ void GlobalOptionsDialog::setupCloudTab() { if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud.ServerInfoLabel", x, y, w, h)) warning("GlobalOptions_Cloud.ServerInfoLabel's position is undefined"); serverInfoY = y; + + bool serverIsRunning = LocalServer.isRunning(); if (serverLabelPosition < 0) serverLabelPosition = serverInfoY; - if (_runServerButton) _runServerButton->setPos(_runServerButton->getRelX(), serverLabelPosition + serverButtonY - serverInfoY); - if (_serverInfoLabel) _serverInfoLabel->setPos(_serverInfoLabel->getRelX(), serverLabelPosition); + if (_runServerButton) { + _runServerButton->setPos(_runServerButton->getRelX(), serverLabelPosition + serverButtonY - serverInfoY); + _runServerButton->setLabel(_(serverIsRunning ? "Stop server" : "Run server")); + } + if (_serverInfoLabel) { + _serverInfoLabel->setPos(_serverInfoLabel->getRelX(), serverLabelPosition); + if (serverIsRunning) _serverInfoLabel->setLabel(LocalServer.getAddress()); + else _serverInfoLabel->setLabel(_("Not running")); + } #else if (_runServerButton) _runServerButton->setVisible(false); if (_serverInfoLabel) _serverInfoLabel->setVisible(false); diff --git a/gui/options.h b/gui/options.h index c4c70aa369..1d7f9ffd49 100644 --- a/gui/options.h +++ b/gui/options.h @@ -266,6 +266,9 @@ protected: ButtonWidget *_runServerButton; StaticTextWidget *_serverInfoLabel; bool _redrawCloudTab; +#ifdef USE_SDL_NET + bool _serverWasRunning; +#endif void setupCloudTab(); #endif diff --git a/gui/storagewizarddialog.cpp b/gui/storagewizarddialog.cpp index 6734d1c97e..7871017f5d 100644 --- a/gui/storagewizarddialog.cpp +++ b/gui/storagewizarddialog.cpp @@ -39,7 +39,7 @@ enum { }; StorageWizardDialog::StorageWizardDialog(uint32 storageId): - Dialog("GlobalOptions_Cloud_ConnectionWizard"), _storageId(storageId), _close(false) { + Dialog("GlobalOptions_Cloud_ConnectionWizard"), _storageId(storageId), _close(false), _stopServerOnClose(false) { _backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain; Common::String headline = Common::String::format(_("%s Storage Connection Wizard"), CloudMan.listStorages()[_storageId].c_str()); @@ -83,6 +83,7 @@ StorageWizardDialog::StorageWizardDialog(uint32 storageId): void StorageWizardDialog::open() { Dialog::open(); #ifdef USE_SDL_NET + _stopServerOnClose = !LocalServer.isRunning(); LocalServer.start(); LocalServer.indexPageHandler().setTarget(this); #endif @@ -90,7 +91,7 @@ void StorageWizardDialog::open() { void StorageWizardDialog::close() { #ifdef USE_SDL_NET - LocalServer.stopOnIdle(); + if (_stopServerOnClose) LocalServer.stopOnIdle(); LocalServer.indexPageHandler().setTarget(nullptr); #endif Dialog::close(); diff --git a/gui/storagewizarddialog.h b/gui/storagewizarddialog.h index 93df56d300..ade3c57b47 100644 --- a/gui/storagewizarddialog.h +++ b/gui/storagewizarddialog.h @@ -46,6 +46,7 @@ class StorageWizardDialog : public Dialog { StaticTextWidget *_messageWidget; ButtonWidget *_connectWidget; bool _close; + bool _stopServerOnClose; /** * Return the value corresponding to the given character. |