diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/downloaddialog.cpp | 53 | ||||
-rw-r--r-- | gui/downloaddialog.h | 14 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 14 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout_lowres.stx | 14 |
4 files changed, 88 insertions, 7 deletions
diff --git a/gui/downloaddialog.cpp b/gui/downloaddialog.cpp index ac3b3d3c72..28a29fcb64 100644 --- a/gui/downloaddialog.cpp +++ b/gui/downloaddialog.cpp @@ -38,7 +38,7 @@ enum { }; DownloadDialog::DownloadDialog(uint32 storageId): - Dialog("GlobalOptions_Cloud_DownloadDialog"), _close(false) { + Dialog("GlobalOptions_Cloud_DownloadDialog"), _reflow(false) { _backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain; _browser = new BrowserDialog(_("Select directory where to download game data"), true); @@ -46,14 +46,35 @@ DownloadDialog::DownloadDialog(uint32 storageId): _messageText = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.DialogDesc", _("Press the button to download a directory")); _mainButton = new ButtonWidget(this, "GlobalOptions_Cloud_DownloadDialog.MainButton", _("Start download"), 0, kDownloadDialogButtonCmd); + _remoteDirectoryLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.RemoteDirectory", _("From: ")); + _localDirectoryLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.LocalDirectory", _("To: ")); + uint32 progress = (uint32)(100 * CloudMan.getDownloadingProgress()); + _progressBar = new SliderWidget(this, "GlobalOptions_Cloud_DownloadDialog.ProgressBar"); + _progressBar->setMinValue(0); + _progressBar->setMaxValue(100); + _progressBar->setValue(progress); + _progressBar->setEnabled(false); + _percentLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.PercentText", Common::String::format("%u %%", progress)); _closeButton = new ButtonWidget(this, "GlobalOptions_Cloud_DownloadDialog.CloseButton", _("OK"), 0, kCloseCmd); updateButtons(); + + CloudMan.setDownloadTarget(this); +} + +DownloadDialog::~DownloadDialog() { + CloudMan.setDownloadTarget(nullptr); +} + +void DownloadDialog::close() { + CloudMan.setDownloadTarget(nullptr); + Dialog::close(); } void DownloadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case kDownloadDialogButtonCmd: { if (CloudMan.isDownloading()) { + CloudMan.setDownloadTarget(nullptr); CloudMan.cancelDownload(); } else { selectDirectories(); @@ -63,6 +84,14 @@ void DownloadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat draw(); break; } + case kDownloadProgressCmd: + _percentLabel->setLabel(Common::String::format("%u %%", data)); + _progressBar->setValue(data); + _reflow = true; + break; + case kDownloadEndedCmd: + _reflow = true; + break; default: Dialog::handleCommand(sender, cmd, data); } @@ -117,12 +146,14 @@ void DownloadDialog::selectDirectories() { else localPath += '/' + remoteDirectory.name(); CloudMan.startDownload(remoteDirectory.path(), localPath); + CloudMan.setDownloadTarget(this); } void DownloadDialog::handleTickle() { - if (_close) { - setResult(1); - close(); + if (_reflow) { + reflowLayout(); + draw(); + _reflow = false; } Dialog::handleTickle(); @@ -133,14 +164,24 @@ void DownloadDialog::reflowLayout() { updateButtons(); } -void DownloadDialog::updateButtons() { - if (CloudMan.isDownloading()) { +void DownloadDialog::updateButtons() { + bool downloading = CloudMan.isDownloading(); + if (downloading) { _messageText->setLabel(_("Press the button to cancel the download")); _mainButton->setLabel(_("Cancel the download")); + _remoteDirectoryLabel->setLabel(_("From: ") + CloudMan.getDownloadRemoteDirectory()); + _localDirectoryLabel->setLabel(_("To: ") + CloudMan.getDownloadLocalDirectory()); + uint32 progress = (uint32)(100 * CloudMan.getDownloadingProgress()); + _percentLabel->setLabel(Common::String::format("%u %%", progress)); + _progressBar->setValue(progress); } else { _messageText->setLabel(_("Press the button to download a directory")); _mainButton->setLabel(_("Start download")); } + _remoteDirectoryLabel->setVisible(downloading); + _localDirectoryLabel->setVisible(downloading); + _percentLabel->setVisible(downloading); + _progressBar->setVisible(downloading); } } // End of namespace GUI diff --git a/gui/downloaddialog.h b/gui/downloaddialog.h index 508e91adcb..429e20af98 100644 --- a/gui/downloaddialog.h +++ b/gui/downloaddialog.h @@ -33,25 +33,37 @@ class CommandSender; class EditTextWidget; class StaticTextWidget; class ButtonWidget; +class SliderWidget; class BrowserDialog; class RemoteBrowserDialog; +enum DownloadProgress { + kDownloadProgressCmd = 'DLPR', + kDownloadEndedCmd = 'DLEN' +}; + class DownloadDialog : public Dialog { BrowserDialog *_browser; RemoteBrowserDialog *_remoteBrowser; StaticTextWidget *_messageText; ButtonWidget *_mainButton; + StaticTextWidget *_remoteDirectoryLabel; + StaticTextWidget *_localDirectoryLabel; + StaticTextWidget *_percentLabel; + SliderWidget *_progressBar; ButtonWidget *_closeButton; - bool _close; + bool _reflow; void updateButtons(); void selectDirectories(); public: DownloadDialog(uint32 storageId); + virtual ~DownloadDialog(); + virtual void close(); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void handleTickle(); virtual void reflowLayout(); diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index f9ec30b81b..e6493ba160 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -594,6 +594,20 @@ <widget name = 'MainButton' type = 'Button' /> + <widget name = 'RemoteDirectory' + height = 'Globals.Line.Height' + /> + <widget name = 'LocalDirectory' + height = 'Globals.Line.Height' + /> + <widget name = 'ProgressBar' + height = 'Globals.Button.Height' + /> + <space size = '1'/> + <widget name = 'PercentText' + height = 'Globals.Line.Height' + textalign = 'center' + /> <space/> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> <space/> diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index fe15dc2410..ab78d3aee1 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -591,6 +591,20 @@ <widget name = 'MainButton' type = 'Button' /> + <widget name = 'RemoteDirectory' + height = 'Globals.Line.Height' + /> + <widget name = 'LocalDirectory' + height = 'Globals.Line.Height' + /> + <widget name = 'ProgressBar' + height = 'Globals.Button.Height' + /> + <space size = '1'/> + <widget name = 'PercentText' + height = 'Globals.Line.Height' + textalign = 'center' + /> <space/> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6'> <space/> |