diff options
author | Alexander Tkachev | 2016-07-20 16:48:50 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 52503a2713432aab7663f88fd0be07055ee9125d (patch) | |
tree | c2062bfb6a0bcb0cb104b9827c5709a15f69cfaf /gui | |
parent | 85f4c69fc981ae1d3807ffb0280b59d627a92ebc (diff) | |
download | scummvm-rg350-52503a2713432aab7663f88fd0be07055ee9125d.tar.gz scummvm-rg350-52503a2713432aab7663f88fd0be07055ee9125d.tar.bz2 scummvm-rg350-52503a2713432aab7663f88fd0be07055ee9125d.zip |
GUI: Add "Clear port" button in Cloud tab
Diffstat (limited to 'gui')
-rw-r--r-- | gui/options.cpp | 34 | ||||
-rw-r--r-- | gui/options.h | 1 | ||||
-rw-r--r-- | gui/themes/scummclassic/classic_layout.stx | 4 | ||||
-rw-r--r-- | gui/themes/scummclassic/classic_layout_lowres.stx | 4 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 4 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout_lowres.stx | 4 |
6 files changed, 49 insertions, 2 deletions
diff --git a/gui/options.cpp b/gui/options.cpp index cbcb42c69c..abc97aa00e 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -102,7 +102,8 @@ enum { kRefreshStorageCmd = 'rfst', kDownloadStorageCmd = 'dlst', kRunServerCmd = 'rnsv', - kCloudTabContainerReflowCmd = 'ctcr' + kCloudTabContainerReflowCmd = 'ctcr', + kServerPortClearCmd = 'spcl' }; #endif @@ -1321,6 +1322,7 @@ GlobalOptionsDialog::GlobalOptionsDialog(LauncherDialog *launcher) uint32 port = Networking::LocalWebserver::getPort(); _serverPortDesc = new StaticTextWidget(container, "GlobalOptions_Cloud_Container.ServerPortDesc", _("Server's port:"), _("Which port is used by server")); _serverPort = new EditTextWidget(container, "GlobalOptions_Cloud_Container.ServerPortEditText", Common::String::format("%u", port), 0); + _serverPortClearButton = addClearButton(container, "GlobalOptions_Cloud_Container.ServerPortClearButton", kServerPortClearCmd); setupCloudTab(); _redrawCloudTab = false; @@ -1631,6 +1633,16 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 } case kConfigureStorageCmd: { +#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(); +#endif StorageWizardDialog dialog(_selectedStorageIndex); dialog.runModal(); //update container's scrollbar @@ -1677,6 +1689,14 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 else LocalServer.start(); break; } + + case kServerPortClearCmd: { + if (_serverPort) { + _serverPort->setEditString(Common::String::format("%u", Networking::LocalWebserver::DEFAULT_SERVER_PORT)); + } + draw(); + break; + } #endif #ifdef GUI_ENABLE_KEYSDIALOG case kChooseKeyMappingCmd: @@ -1813,7 +1833,7 @@ void GlobalOptionsDialog::setupCloudTab() { //determine original widget's positions int16 x, y; uint16 w, h; - int serverButtonY, serverInfoY, serverPortDescY, serverPortY; + int serverButtonY, serverInfoY, serverPortDescY, serverPortY, serverPortClearButtonY; if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.RunServerButton", x, y, w, h)) warning("GlobalOptions_Cloud_Container.RunServerButton's position is undefined"); serverButtonY = y; @@ -1826,6 +1846,9 @@ void GlobalOptionsDialog::setupCloudTab() { if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.ServerPortEditText", x, y, w, h)) warning("GlobalOptions_Cloud_Container.ServerPortEditText's position is undefined"); serverPortY = y; + if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.ServerPortClearButton", x, y, w, h)) + warning("GlobalOptions_Cloud_Container.ServerPortClearButton's position is undefined"); + serverPortClearButtonY = y; bool serverIsRunning = LocalServer.isRunning(); @@ -1852,15 +1875,22 @@ void GlobalOptionsDialog::setupCloudTab() { _serverPort->setPos(_serverPort->getRelX(), serverLabelPosition + serverPortY - serverInfoY); _serverPort->setEnabled(!serverIsRunning); } + if (_serverPortClearButton) { + _serverPortClearButton->setVisible(true); + _serverPortClearButton->setPos(_serverPortClearButton->getRelX(), serverLabelPosition + serverPortClearButtonY - serverInfoY); + _serverPortClearButton->setEnabled(!serverIsRunning); + } #else 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); #endif } #endif diff --git a/gui/options.h b/gui/options.h index ea8b252db7..42e8ffbbde 100644 --- a/gui/options.h +++ b/gui/options.h @@ -270,6 +270,7 @@ protected: StaticTextWidget *_serverInfoLabel; StaticTextWidget *_serverPortDesc; EditTextWidget *_serverPort; + ButtonWidget *_serverPortClearButton; bool _redrawCloudTab; #ifdef USE_SDL_NET bool _serverWasRunning; diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index 1e3d09d10e..b9c2781fa5 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -591,6 +591,10 @@ width = '70' height = 'Globals.Line.Height' /> + <widget name = 'ServerPortClearButton' + height = 'Globals.Line.Height' + width = 'Globals.Line.Height' + /> </layout> </layout> </dialog> diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index 2ae008a80c..7c062f7776 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -606,6 +606,10 @@ width = '60' height = '16' /> + <widget name = 'ServerPortClearButton' + height = 'Globals.Line.Height' + width = 'Globals.Line.Height' + /> </layout> </layout> </dialog> diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 03fa58acb7..e0ea86893a 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -605,6 +605,10 @@ width = '70' height = 'Globals.Line.Height' /> + <widget name = 'ServerPortClearButton' + height = 'Globals.Line.Height' + width = 'Globals.Line.Height' + /> </layout> </layout> </dialog> diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index b25edcb2b0..ceb43bb717 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -604,6 +604,10 @@ width = '60' height = '16' /> + <widget name = 'ServerPortClearButton' + height = 'Globals.Line.Height' + width = 'Globals.Line.Height' + /> </layout> </layout> </dialog> |