aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-05 13:11:29 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commitad069f442ce1a042361620f30d5b313668df23c4 (patch)
tree888d68c9959f7d520c52795a7f067675d577387b
parent2284333b1c9348638ce0255668f4c0abb85aeb84 (diff)
downloadscummvm-rg350-ad069f442ce1a042361620f30d5b313668df23c4.tar.gz
scummvm-rg350-ad069f442ce1a042361620f30d5b313668df23c4.tar.bz2
scummvm-rg350-ad069f442ce1a042361620f30d5b313668df23c4.zip
GUI: Add "Run server" button in Cloud tab
-rw-r--r--gui/object.h2
-rw-r--r--gui/options.cpp72
-rw-r--r--gui/options.h6
-rw-r--r--gui/themes/scummmodern/scummmodern_layout.stx8
-rw-r--r--gui/themes/scummmodern/scummmodern_layout_lowres.stx8
5 files changed, 90 insertions, 6 deletions
diff --git a/gui/object.h b/gui/object.h
index 776c941356..1541c35aa8 100644
--- a/gui/object.h
+++ b/gui/object.h
@@ -76,6 +76,8 @@ public:
virtual void setTextDrawableArea(const Common::Rect &r) { _textDrawableArea = r; }
+ virtual int16 getRelX() const { return _x; }
+ virtual int16 getRelY() const { return _y; }
virtual int16 getAbsX() const { return _x; }
virtual int16 getAbsY() const { return _y; }
virtual int16 getChildX() const { return getAbsX(); }
diff --git a/gui/options.cpp b/gui/options.cpp
index 1ea64cab3d..433278460c 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -90,11 +90,12 @@ enum {
};
#endif
-#ifdef USE_CLOUD
+#if defined USE_CLOUD || defined USE_SDL_NET
enum {
kConfigureStorageCmd = 'cfst',
kRefreshStorageCmd = 'rfst',
- kDownloadStorageCmd = 'dlst'
+ kDownloadStorageCmd = 'dlst',
+ kRunServerCmd = 'rnsv'
};
#endif
@@ -1265,7 +1266,7 @@ GlobalOptionsDialog::GlobalOptionsDialog()
new ButtonWidget(tab, "GlobalOptions_Misc.UpdatesCheckManuallyButton", _("Check now"), 0, kUpdatesCheckCmd);
#endif
-#ifdef USE_CLOUD
+#if defined USE_CLOUD || defined USE_SDL_NET
//
// 7) The cloud tab
//
@@ -1274,13 +1275,21 @@ GlobalOptionsDialog::GlobalOptionsDialog()
else
tab->addTab(_c("Cloud", "lowres"));
+#ifdef USE_CLOUD
_selectedStorageIndex = CloudMan.getStorageIndex();
+#else
+ _selectedStorageIndex = 0;
+#endif
_storagePopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Cloud.StoragePopupDesc", _("Storage:"), _("Active cloud storage"));
_storagePopUp = new PopUpWidget(tab, "GlobalOptions_Cloud.StoragePopup");
+#ifdef USE_CLOUD
Common::StringArray list = CloudMan.listStorages();
for (uint32 i = 0; i < list.size(); ++i)
_storagePopUp->appendEntry(list[i], i);
+#else
+ _storagePopUp->appendEntry(_("<none>"), 0);
+#endif
_storagePopUp->setSelected(_selectedStorageIndex);
_storageUsernameDesc = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageUsernameDesc", _("Username:"), _("Username used by this storage"));
@@ -1296,6 +1305,9 @@ GlobalOptionsDialog::GlobalOptionsDialog()
_storageRefreshButton = new ButtonWidget(tab, "GlobalOptions_Cloud.RefreshButton", _("Refresh"), _("Refresh current cloud storage information (username and usage)"), kRefreshStorageCmd);
_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");
+
setupCloudTab();
_redrawCloudTab = false;
#endif
@@ -1608,6 +1620,15 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
break;
}
#endif
+#ifdef USE_SDL_NET
+ case kRunServerCmd:
+ {
+ //TODO
+ //DownloadDialog dialog(_selectedStorageIndex);
+ //dialog.runModal();
+ break;
+ }
+#endif
#ifdef GUI_ENABLE_KEYSDIALOG
case kChooseKeyMappingCmd:
_keysDialog->runModal();
@@ -1675,8 +1696,10 @@ void GlobalOptionsDialog::reflowLayout() {
OptionsDialog::reflowLayout();
}
-#ifdef USE_CLOUD
+#if defined USE_CLOUD || defined USE_SDL_NET
void GlobalOptionsDialog::setupCloudTab() {
+ int serverLabelPosition = -1; //no override
+#ifdef USE_CLOUD
_selectedStorageIndex = _storagePopUp->getSelectedTag();
bool shown = (_selectedStorageIndex != Cloud::kStorageNoneId);
@@ -1706,8 +1729,47 @@ void GlobalOptionsDialog::setupCloudTab() {
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);
+
+ serverButtonPosition = (_storagePopUpDesc ? _storagePopUpDesc->getRelY() : 0);
+#endif
+#ifdef USE_SDL_NET
+ //determine original widget's positions
+ int16 x, y;
+ uint16 w, h;
+ int serverButtonY, serverInfoY;
+ if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud.RunServerButton", x, y, w, h))
+ warning("GlobalOptions_Cloud.RunServerButton's position is undefined");
+ serverButtonY = y;
+ if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud.ServerInfoLabel", x, y, w, h))
+ warning("GlobalOptions_Cloud.ServerInfoLabel's position is undefined");
+ serverInfoY = y;
+
+ if (serverLabelPosition < 0) serverLabelPosition = serverInfoY;
+ if (_runServerButton) _runServerButton->setPos(_runServerButton->getRelX(), serverLabelPosition + serverButtonY - serverInfoY);
+ if (_serverInfoLabel) _serverInfoLabel->setPos(_serverInfoLabel->getRelX(), serverLabelPosition);
+#else
+ if (_runServerButton) _runServerButton->setVisible(false);
+ if (_serverInfoLabel) _serverInfoLabel->setVisible(false);
+#endif
}
-
+#endif
+#ifdef USE_CLOUD
void GlobalOptionsDialog::storageInfoCallback(Cloud::Storage::StorageInfoResponse response) {
//we could've used response.value.email()
//but Storage already notified CloudMan
diff --git a/gui/options.h b/gui/options.h
index fa7a1d28b9..77470aef57 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -247,7 +247,7 @@ protected:
PopUpWidget *_updatesPopUp;
#endif
-#ifdef USE_CLOUD
+#if defined USE_CLOUD || defined USE_SDL_NET
//
// Cloud controls
//
@@ -263,9 +263,13 @@ protected:
ButtonWidget *_storageConnectButton;
ButtonWidget *_storageRefreshButton;
ButtonWidget *_storageDownloadButton;
+ ButtonWidget *_runServerButton;
+ StaticTextWidget *_serverInfoLabel;
bool _redrawCloudTab;
void setupCloudTab();
+#endif
+#ifdef USE_CLOUD
void storageInfoCallback(Cloud::Storage::StorageInfoResponse response);
void storageListDirectoryCallback(Cloud::Storage::ListDirectoryResponse response);
#endif
diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx
index d2e60d7456..9e79ac29b7 100644
--- a/gui/themes/scummmodern/scummmodern_layout.stx
+++ b/gui/themes/scummmodern/scummmodern_layout.stx
@@ -583,6 +583,14 @@
type = 'Button'
/>
</layout>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'>
+ <widget name = 'RunServerButton'
+ type = 'Button'
+ />
+ <widget name = 'ServerInfoLabel'
+ height = '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 1ff2e9f524..9f00d2ee95 100644
--- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx
+++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx
@@ -580,6 +580,14 @@
type = 'Button'
/>
</layout>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'>
+ <widget name = 'RunServerButton'
+ type = 'Button'
+ />
+ <widget name = 'ServerInfoLabel'
+ height = 'Globals.Line.Height'
+ />
+ </layout>
</layout>
</dialog>