[Scummvm-git-logs] scummvm master -> 0806d04dfd16b893e9f53a919073ab7e37eaaa2b
sev-
noreply at scummvm.org
Thu Sep 14 06:23:29 UTC 2023
This automated email contains information about 59 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ec3fe97b14 GUI: Add Download Games button in Launcher
4af698b7cd GUI: Setup new dialog for Download Games
4a73a002ca GUI: Add ListWidget for download games dialog
3b8c7f0d72 GUI: Create download button command for downlad games dialog
0fa82ea4ae GUI: Gray out already downloaded games
6e8bdee909 BACKENDS: Add initial code for DLC Manager
a2046a71c0 JANITORIAL: Update playstore.h licence to GPL v3+
99af2be9c0 BACKENDS: Initial implementation of Android PlayStore DLC Manager
045a99e50c BACKENDS: Remove platform-specific defines and enforce factory design pattern for creating DLC store
3f8ddc117e BACKENDS: Add DLC download queue and implement some DLCManager functions
478d3f2ab9 COMMON: Fix incomplete type warning for dlc store
c0f91421cc BACKENDS: Initial code for downloading DLCs using CURL
f380eaf9cc BACKENDS: Generalize startDownloadAsync() for downloading DLCs
5ac2efcf5c BACKENDS: Populate dlc list using getAllDLCs() response
c3fcfd0b00 BACKENDS: Implement extract downloaded DLCs and remove cache in ScummVMCloud
1a8c5383a4 BACKENDS: Delete request when DLC is downloaded
7dc5facd71 BACKENDS: Extend preprocessor directives to support Windows in SummVMCloud::removeCacheFile
2c987fbba5 GUI: Fix graying out DLCs to use String for id
6a269c6b06 BACKENDS: Implement get DLC list on request and redraw dialog once DLCs are fetched
86f01bcd45 BACKENDS: Improve ScummVMCloud::extractZip()
c0800f5eda BACKENDS: Add more members in DLCDesc
a344e7e43f BACKENDS: Implement auto addition of DLC entry in ScummVM config after download
b4438f744a BACKENDS: Create dlcspath for storing DLCs
750a196c05 GUI: Remove CommandSender's target when DLC dialog is destructed
f976ecded4 GUI: Initial code to show DLC download progress
5059b3072e JANITORIAL: Rename download-games-dialog to dlcsdialog
13dc800e96 BACKENDS: Implement interrupt/cancel pending DLC downloads
3633392b6d BACKENDS: Fix launcher does not refresh after DLC download if DLC dialog is closed
dd87960fe8 BACKENDS: Restrict adding DLC in download queue if it's already in queue
a4329e21b9 GUI: Disable download button when no item is selected in DLC browsing dialog
2f6b87f0d4 GUI: Improve DLC download request indication
3bba45bd5c GUI: Add error label in downloaddlcsdialog
22f912d7e0 DLC: Wrap ScummVM DLC in configure enabled feature, disabled by default
8774429891 JANITORIAL: Fix defines and code formatting
6f5587fcd0 GUI: Fix crash if a game is downloaded when last item is selected in pending DLC downloads
3d841a59e0 DLC: Use const, uint32 and reference where appropriate
b9e5694f39 BACKENDS: DLC: Refresh DLC list after download is cancelled
24a7e4cf73 BACKENDS: Change DLC::DLCDesc to struct, deallocate DLCMan._dlcs
9292288626 JANITORIAL: Move enum to cpp of downloaddlcsdialog.h
896793eb2c JANITORIAL: Change StaticTextWidget's text of dlcsdialog
f1a5ebfe94 I18N: Add gui/dlcsdialog and gui/downloaddlcsdialog to POTFILES
d932cb8179 JANITORIAL: Fix formatting and define in scummvmcloud.h
2756f6ae71 JANITORIAL: Remove unneeded includes from store.h
ee2e8afd30 JANITORIAL: Fix indentation in scummvmcloud
708432c163 BACKENDS: Change return type of getDefaultDLCsPath() to Common::Path
097b049aea DLC: Use forward declaration where appropriate
e24ad8fc20 JANITORIAL: Use debug instead of commented warning in scummvmcloud.cpp
97aa1d602a JANITORIAL: Remove DLCMan.init() and its destroy call since it's not required
4ae119d63f DLC: Add USE_DLC in configure for general DLC integration
0c7f65e5b7 JANITORIAL: Remove unneeded includes from dlcmanager.cpp
6890e3097b BACKENDS: DLC: Improve code readability in scummvmcloud.cpp
2a60a4d213 DLC: Set kFeatureDLC and _dlcStore for ScummVMCloud, Playstore in backend
9a68de2f52 BACKENDS: DLC: Handle errors in ScummVMCloud::extractZip()
a4888cf24c JANITORIAL: Improve code readability in scummvmcloud.cpp
24392d4838 DLC: Add lowres_layout.stx and generated theme files
f03d59620b JANITORIAL: Remove unneeded functions from dlcmanager.h
a26d00a2b7 DLC: Remove Playstore code
c1d1e4e411 DLC: Add dlcpath in Global Options
0806d04dfd DLC: Add generated theme files
Commit: ec3fe97b14771675c5211c9276cf04fcd9c12fd7
https://github.com/scummvm/scummvm/commit/ec3fe97b14771675c5211c9276cf04fcd9c12fd7
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Add Download Games button in Launcher
Changed paths:
gui/launcher.cpp
gui/themes/common/highres_layout.stx
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 4c85215d05b..2c9f0cbab25 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -66,6 +66,7 @@ enum {
kOptionsCmd = 'OPTN',
kAddGameCmd = 'ADDG',
kMassAddGameCmd = 'MADD',
+ kDownloadGameCmd = 'DWNG',
kEditGameCmd = 'EDTG',
kRemoveGameCmd = 'REMG',
kLoadGameCmd = 'LOAD',
@@ -254,6 +255,8 @@ void LauncherDialog::build() {
new ButtonWidget(this, _title + ".AboutButton", _("A~b~out"), _("About ScummVM"), kAboutCmd);
// I18N: Button caption. O is the shortcut, Ctrl+O, put it in parens for non-latin (~O~)
new ButtonWidget(this, _title + ".OptionsButton", _("Global ~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd, 0, _c("Global ~O~pts...", "lowres"));
+ // I18N: Button download games button.
+ new ButtonWidget(this, _title + ".DownloadGameButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
// Above the lowest button rows: two more buttons (directly below the list box)
DropdownButtonWidget *addButton =
@@ -727,6 +730,11 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
case kMassAddGameCmd:
massAddGame();
break;
+ case kDownloadGameCmd: {
+ MessageDialog downloader("Download Freeware Games");
+ downloader.runModal();
+ }
+ break;
case kRemoveGameCmd:
if (item < 0) return;
removeGame(item);
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index a0536572b42..f878bc169a3 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -204,6 +204,9 @@
<widget name = 'AddGameButton'
type = 'Button'
/>
+ <widget name = 'DownloadGameButton'
+ type = 'Button'
+ />
<widget name = 'EditGameButton'
type = 'Button'
/>
Commit: 4af698b7cdcdde18c77849d970e322384fde6bdb
https://github.com/scummvm/scummvm/commit/4af698b7cdcdde18c77849d970e322384fde6bdb
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Setup new dialog for Download Games
Changed paths:
A gui/download-games-dialog.cpp
A gui/download-games-dialog.h
gui/launcher.cpp
gui/module.mk
gui/themes/common/highres_layout.stx
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
new file mode 100644
index 00000000000..1ec6555e8aa
--- /dev/null
+++ b/gui/download-games-dialog.cpp
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "gui/download-games-dialog.h"
+#include "gui/widget.h"
+
+#include "common/translation.h"
+
+namespace GUI {
+
+DownloadGamesDialog::DownloadGamesDialog()
+ : Dialog("DownloadGames") {
+
+ new StaticTextWidget(this, "DownloadGames.Headline", _("Download Freeware Games"));
+}
+
+} // End of namespace GUI
diff --git a/gui/download-games-dialog.h b/gui/download-games-dialog.h
new file mode 100644
index 00000000000..c4a8bcb8083
--- /dev/null
+++ b/gui/download-games-dialog.h
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DOWNLOAD_GAMES_DIALOG_H
+#define DOWNLOAD_GAMES_DIALOG_H
+
+#include "gui/dialog.h"
+
+namespace GUI {
+
+class DownloadGamesDialog : public Dialog {
+public:
+ DownloadGamesDialog();
+};
+
+} // End of namespace GUI
+
+#endif
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 2c9f0cbab25..6fc6222aab0 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -32,6 +32,7 @@
#include "gui/about.h"
#include "gui/browser.h"
#include "gui/chooser.h"
+#include "gui/download-games-dialog.h"
#include "gui/editgamedialog.h"
#include "gui/launcher.h"
#include "gui/massadd.h"
@@ -256,7 +257,7 @@ void LauncherDialog::build() {
// I18N: Button caption. O is the shortcut, Ctrl+O, put it in parens for non-latin (~O~)
new ButtonWidget(this, _title + ".OptionsButton", _("Global ~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd, 0, _c("Global ~O~pts...", "lowres"));
// I18N: Button download games button.
- new ButtonWidget(this, _title + ".DownloadGameButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
+ new ButtonWidget(this, _title + ".DownloadGamesButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
// Above the lowest button rows: two more buttons (directly below the list box)
DropdownButtonWidget *addButton =
@@ -731,7 +732,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
massAddGame();
break;
case kDownloadGameCmd: {
- MessageDialog downloader("Download Freeware Games");
+ DownloadGamesDialog downloader;
downloader.runModal();
}
break;
diff --git a/gui/module.mk b/gui/module.mk
index 562a11829d7..01cf562d1cd 100644
--- a/gui/module.mk
+++ b/gui/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
console.o \
debugger.o \
dialog.o \
+ download-games-dialog.o \
dump-all-dialogs.o \
editgamedialog.o \
error.o \
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index f878bc169a3..25438a4a659 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -204,7 +204,7 @@
<widget name = 'AddGameButton'
type = 'Button'
/>
- <widget name = 'DownloadGameButton'
+ <widget name = 'DownloadGamesButton'
type = 'Button'
/>
<widget name = 'EditGameButton'
@@ -291,6 +291,9 @@
<widget name = 'AddGameButton'
height = 'Globals.Button.Height'
/>
+ <widget name = 'DownloadGamesButton'
+ height = 'Globals.Button.Height'
+ />
<widget name = 'EditGameButton'
height = 'Globals.Button.Height'
/>
@@ -371,6 +374,9 @@
<widget name = 'AddGameButton'
height = 'Globals.Button.Height'
/>
+ <widget name = 'DownloadGamesButton'
+ height = 'Globals.Button.Height'
+ />
<widget name = 'RemoveGameButton'
height = 'Globals.Button.Height'
/>
@@ -507,6 +513,14 @@
</layout>
</dialog>
+ <dialog name = 'DownloadGames' overlays = 'screen' inset = '32' shading = 'dim'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8'>
+ <widget name = 'Headline'
+ height = 'Globals.Line.Height'
+ />
+ </layout>
+ </dialog>
+
<dialog name = 'GlobalOptions' overlays = 'screen' inset = '32' shading = 'dim' resolution='x<800'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'TabWidget' type = 'TabWidget'/>
Commit: 4a73a002ca2c0663cde1420143966850474bfe4c
https://github.com/scummvm/scummvm/commit/4a73a002ca2c0663cde1420143966850474bfe4c
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Add ListWidget for download games dialog
Changed paths:
gui/download-games-dialog.cpp
gui/download-games-dialog.h
gui/themes/common/highres_layout.stx
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
index 1ec6555e8aa..9ee00e4d256 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/download-games-dialog.cpp
@@ -21,15 +21,42 @@
#include "gui/download-games-dialog.h"
#include "gui/widget.h"
-
+#include "gui/widgets/list.h"
#include "common/translation.h"
namespace GUI {
+enum {
+ kDownloadSelectedCmd = 'DWNS',
+};
+
DownloadGamesDialog::DownloadGamesDialog()
: Dialog("DownloadGames") {
new StaticTextWidget(this, "DownloadGames.Headline", _("Download Freeware Games"));
+
+ // Add list with downloadable game titles
+ _gamesList = new ListWidget(this, "DownloadGames.List");
+ _gamesList->setNumberingMode(kListNumberingOff);
+ _gamesList->setEditable(false);
+
+ // Populate the ListWidget
+ Common::U32StringArray games = {
+ _("Beneath a Steel Sky - Freeware CD Version"),
+ _("Beneath a Steel Sky - Freeware Floppy Version"),
+ _("Broken Sword 2.5: The Return of the Templars - Freeware Version"),
+ _("Broken Sword 2.5: The Return of the Templars - Hebrew translation AddOn"),
+ _("Dráscula: The Vampire Strikes Back - Freeware Version (English)"),
+ _("Dráscula: The Vampire Strikes Back - Freeware Version (Music AddOn, MP3 format)"),
+ _("Dráscula: The Vampire Strikes Back - Freeware Version (Music AddOn, FLAC format)"),
+ _("Dráscula: The Vampire Strikes Back - Freeware Version (Music AddOn, OGG format)"),
+ _("Dráscula: The Vampire Strikes Back - Freeware Version (Spanish, German, French and Italian AddOn)"),
+ _("Dráscula: The Vampire Strikes Back - Freeware Version (Updated Spanish, German, French and Italian AddOn) - requires ScummVM 1.3.0 or more"),
+ };
+ _gamesList->setList(games);
+
+ new ButtonWidget(this, "DownloadGames.Back", _("Back"), Common::U32String(), kCloseCmd);
+ new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
}
} // End of namespace GUI
diff --git a/gui/download-games-dialog.h b/gui/download-games-dialog.h
index c4a8bcb8083..6df642ad4de 100644
--- a/gui/download-games-dialog.h
+++ b/gui/download-games-dialog.h
@@ -23,12 +23,16 @@
#define DOWNLOAD_GAMES_DIALOG_H
#include "gui/dialog.h"
+#include "gui/widgets/list.h"
namespace GUI {
-
+
class DownloadGamesDialog : public Dialog {
public:
DownloadGamesDialog();
+
+private:
+ ListWidget *_gamesList;
};
} // End of namespace GUI
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index 25438a4a659..15c68c76873 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -518,6 +518,16 @@
<widget name = 'Headline'
height = 'Globals.Line.Height'
/>
+ <widget name = 'List'/>
+ <layout type = 'horizontal' padding = '16, 16, 16, 16'>
+ <widget name = 'Back'
+ type = 'Button'
+ />
+ <space/>
+ <widget name = 'Download'
+ type = 'Button'
+ />
+ </layout>
</layout>
</dialog>
Commit: 3b8c7f0d72bc28d3a26eb3e7ef8b759584ae004d
https://github.com/scummvm/scummvm/commit/3b8c7f0d72bc28d3a26eb3e7ef8b759584ae004d
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Create download button command for downlad games dialog
Changed paths:
gui/download-games-dialog.cpp
gui/download-games-dialog.h
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
index 9ee00e4d256..f8158d650b3 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/download-games-dialog.cpp
@@ -20,6 +20,7 @@
*/
#include "gui/download-games-dialog.h"
+#include "gui/message.h"
#include "gui/widget.h"
#include "gui/widgets/list.h"
#include "common/translation.h"
@@ -59,4 +60,17 @@ DownloadGamesDialog::DownloadGamesDialog()
new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
}
+void DownloadGamesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+ switch (cmd) {
+ //Search for typed-in directory
+ case kDownloadSelectedCmd: {
+ MessageDialog dialog("Downloading: " + _gamesList->getSelectedString());
+ dialog.runModal();
+ }
+ break;
+ default:
+ Dialog::handleCommand(sender, cmd, data);
+ }
+}
+
} // End of namespace GUI
diff --git a/gui/download-games-dialog.h b/gui/download-games-dialog.h
index 6df642ad4de..2a556bfcc07 100644
--- a/gui/download-games-dialog.h
+++ b/gui/download-games-dialog.h
@@ -31,6 +31,8 @@ class DownloadGamesDialog : public Dialog {
public:
DownloadGamesDialog();
+ void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
+
private:
ListWidget *_gamesList;
};
Commit: 0fa82ea4ae69d94e1cecf723ccdba7ad68605cc6
https://github.com/scummvm/scummvm/commit/0fa82ea4ae69d94e1cecf723ccdba7ad68605cc6
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Gray out already downloaded games
This change makes the downloadable games entries grayed out for
already downloaded games. For graying out we are scaning game
entries in scummvm.ini for unique "download" keys.
Changed paths:
gui/download-games-dialog.cpp
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
index f8158d650b3..96cd84a3c96 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/download-games-dialog.cpp
@@ -54,6 +54,18 @@ DownloadGamesDialog::DownloadGamesDialog()
_("Dráscula: The Vampire Strikes Back - Freeware Version (Spanish, German, French and Italian AddOn)"),
_("Dráscula: The Vampire Strikes Back - Freeware Version (Updated Spanish, German, French and Italian AddOn) - requires ScummVM 1.3.0 or more"),
};
+
+ // Gray out already downloaded packages
+ for (Common::ConfigManager::DomainMap::iterator domain = ConfMan.beginGameDomains(); domain != ConfMan.endGameDomains(); ++domain) {
+ if (domain->_value.contains("download")) {
+ Common::String val(domain->_value.getVal("download"));
+ uint64 id = val.asUint64();
+ if (id < games.size()) {
+ games[id] = "\001C{alternate}" + games[id];
+ }
+ }
+ }
+
_gamesList->setList(games);
new ButtonWidget(this, "DownloadGames.Back", _("Back"), Common::U32String(), kCloseCmd);
Commit: 6e8bdee909c50bef7132454e28a97ef52a1834aa
https://github.com/scummvm/scummvm/commit/6e8bdee909c50bef7132454e28a97ef52a1834aa
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Add initial code for DLC Manager
Changed paths:
A backends/dlc/android/playstore.h
A backends/dlc/dlcmanager.cpp
A backends/dlc/dlcmanager.h
A backends/dlc/store.h
backends/module.mk
backends/platform/android/android.cpp
base/main.cpp
common/system.h
gui/launcher.cpp
diff --git a/backends/dlc/android/playstore.h b/backends/dlc/android/playstore.h
new file mode 100644
index 00000000000..7137f61e2b1
--- /dev/null
+++ b/backends/dlc/android/playstore.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#ifndef BACKENDS_DLC_PLAYSTORE_PLAYSTORE_H
+#define BACKENDS_DLC_PLAYSTORE_PLAYSTORE_H
+
+#include "backends/dlc/store.h"
+#include "common/callback.h"
+
+namespace DLC {
+namespace PlayStore {
+
+class PlayStore: public DLC::Store {
+
+public:
+ PlayStore() {}
+ virtual ~PlayStore() {}
+
+ virtual void init() override {}
+
+ virtual void requestInfo() override {}
+
+ virtual void getDownloadState() override {}
+
+ virtual void requestDownload() override {}
+
+ virtual void getBytesDownloaded() override {}
+
+ virtual void cancelDownload() override {}
+};
+
+} // End of namespace PlayStore
+} // End of namespace DLC
+
+#endif
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
new file mode 100644
index 00000000000..ab662845c26
--- /dev/null
+++ b/backends/dlc/dlcmanager.cpp
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#include "backends/dlc/dlcmanager.h"
+#include "backends/dlc/android/playstore.h"
+
+namespace Common {
+
+DECLARE_SINGLETON(DLC::DLCManager);
+
+}
+
+namespace DLC {
+
+DLCManager::DLCManager() {
+ // if --playstore flag
+ _store = new DLC::PlayStore::PlayStore();
+}
+
+void DLCManager::init() {
+
+}
+
+void DLCManager::initDownload() {
+ _store->requestDownload();
+ // handle errors
+}
+
+bool DLCManager::getFeatureState(DLC::Feature f) {
+ return false;
+}
+
+} // End of namespace DLC
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
new file mode 100644
index 00000000000..8bc760a5790
--- /dev/null
+++ b/backends/dlc/dlcmanager.h
@@ -0,0 +1,71 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DLC_DLCMANAGER_H
+#define DLC_DLCMANAGER_H
+
+#include "common/str.h"
+#include "common/singleton.h"
+#include "backends/dlc/store.h"
+
+namespace DLC {
+
+enum Feature {
+ kInProgress
+};
+
+class DLCManager : public Common::Singleton<DLCManager> {
+
+ struct DLCDesc {
+ Common::String name;
+ Common::String description;
+ uint32 size;
+ uint32 game_id;
+ };
+
+ Store* _store;
+
+public:
+ DLCManager();
+ virtual ~DLCManager() {}
+
+ void init();
+
+ DLCDesc getDLCList();
+
+ void initDownload();
+
+ void cancelDownload();
+
+ bool getFeatureState(DLC::Feature f);
+ void setFeatureState(DLC::Feature f, bool enable);
+
+ void getPercentDownloaded();
+
+ uint32 getInProgressGame();
+};
+
+#define DLCMan DLC::DLCManager::instance()
+
+} // End of namespace DLC
+
+
+#endif
diff --git a/backends/dlc/store.h b/backends/dlc/store.h
new file mode 100644
index 00000000000..186e68189fe
--- /dev/null
+++ b/backends/dlc/store.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DLC_STORE_H
+#define DLC_STORE_H
+
+namespace DLC {
+
+class Store {
+
+public:
+ Store() {}
+ virtual ~Store() {}
+
+ virtual void init() = 0;
+
+ virtual void requestInfo() = 0;
+
+ virtual void getDownloadState() = 0;
+
+ virtual void requestDownload() = 0;
+
+ virtual void getBytesDownloaded() = 0;
+
+ virtual void cancelDownload() = 0;
+};
+
+} // End of namespace DLC
+
+
+#endif
diff --git a/backends/module.mk b/backends/module.mk
index 4473de46ebd..fbe00cb1295 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
modular-backend.o \
audiocd/audiocd-stream.o \
audiocd/default/default-audiocd.o \
+ dlc/dlcmanager.o \
events/default/default-events.o \
fs/abstract-fs.o \
fs/stdiostream.o \
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index e89dd8f84d4..694985af579 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -637,6 +637,7 @@ bool OSystem_Android::hasFeature(Feature f) {
f == kFeatureTouchscreen) {
return true;
}
+ if (f == kFeatureDLC) return true;
/* Even if we are using the 2D graphics manager,
* we are at one initGraphics3d call of supporting GLES2 */
if (f == kFeatureOpenGLForGame) return true;
diff --git a/base/main.cpp b/base/main.cpp
index 44098d82e02..6f3afde422d 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -71,6 +71,7 @@
#include "backends/keymapper/action.h"
#include "backends/keymapper/keymap.h"
#include "backends/keymapper/keymapper.h"
+#include "backends/dlc/dlcmanager.h"
#ifdef USE_CLOUD
#ifdef USE_LIBCURL
@@ -699,6 +700,8 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
CloudMan.syncSaves();
#endif
+ DLCMan.init();
+
// Unless a game was specified, show the launcher dialog
if (nullptr == ConfMan.getActiveDomain())
launcherDialog();
@@ -848,6 +851,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
Cloud::CloudManager::destroy();
#endif
#endif
+ DLC::DLCManager::destroy();
PluginManager::instance().unloadDetectionPlugin();
PluginManager::instance().unloadAllPlugins();
PluginManager::destroy();
diff --git a/common/system.h b/common/system.h
index 84384a2679e..4f5543c604d 100644
--- a/common/system.h
+++ b/common/system.h
@@ -569,6 +569,11 @@ public:
*/
kFeatureShaders,
+ /**
+ * Support for downloading DLC packages.
+ */
+ kFeatureDLC,
+
/**
* Support for using the native system file browser dialog
* through the DialogManager.
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 6fc6222aab0..3aac8b46ca4 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -256,8 +256,11 @@ void LauncherDialog::build() {
new ButtonWidget(this, _title + ".AboutButton", _("A~b~out"), _("About ScummVM"), kAboutCmd);
// I18N: Button caption. O is the shortcut, Ctrl+O, put it in parens for non-latin (~O~)
new ButtonWidget(this, _title + ".OptionsButton", _("Global ~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd, 0, _c("Global ~O~pts...", "lowres"));
- // I18N: Button download games button.
- new ButtonWidget(this, _title + ".DownloadGamesButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
+
+ if (g_system->hasFeature(OSystem::kFeatureDLC)) {
+ // I18N: Button browse downloadable games (DLC)
+ new ButtonWidget(this, _title + ".DownloadGamesButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
+ }
// Above the lowest button rows: two more buttons (directly below the list box)
DropdownButtonWidget *addButton =
Commit: a2046a71c00dd4092bd9a352d49fe585770b4608
https://github.com/scummvm/scummvm/commit/a2046a71c00dd4092bd9a352d49fe585770b4608
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Update playstore.h licence to GPL v3+
Changed paths:
backends/dlc/android/playstore.h
diff --git a/backends/dlc/android/playstore.h b/backends/dlc/android/playstore.h
index 7137f61e2b1..c74a7cbcd08 100644
--- a/backends/dlc/android/playstore.h
+++ b/backends/dlc/android/playstore.h
@@ -1,24 +1,23 @@
/* ScummVM - Graphic Adventure Engine
-*
-* ScummVM is the legal property of its developers, whose names
-* are too numerous to list here. Please refer to the COPYRIGHT
-* file distributed with this source distribution.
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-*/
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
#ifndef BACKENDS_DLC_PLAYSTORE_PLAYSTORE_H
#define BACKENDS_DLC_PLAYSTORE_PLAYSTORE_H
Commit: 99af2be9c0b5abcb17a676ca3edc2728ba1ef1b8
https://github.com/scummvm/scummvm/commit/99af2be9c0b5abcb17a676ca3edc2728ba1ef1b8
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Initial implementation of Android PlayStore DLC Manager
Changed paths:
A backends/dlc/android/playstore.cpp
backends/dlc/android/playstore.h
backends/dlc/dlcmanager.cpp
backends/module.mk
backends/platform/android/jni-android.cpp
backends/platform/android/jni-android.h
backends/platform/android/org/scummvm/scummvm/ScummVM.java
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
dists/android/build.gradle
diff --git a/backends/dlc/android/playstore.cpp b/backends/dlc/android/playstore.cpp
new file mode 100644
index 00000000000..8a4cd7644b0
--- /dev/null
+++ b/backends/dlc/android/playstore.cpp
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#if defined(__ANDROID__)
+
+#include "backends/dlc/android/playstore.h"
+
+namespace DLC {
+namespace PlayStore {
+
+PlayStore::PlayStore() {
+ _playStoreObject = JNI::getPlayStoreDLCManager();
+}
+
+void PlayStore::init() {
+
+}
+
+void PlayStore::requestInfo() {
+ JNIEnv *env = JNI::getEnv();
+ jclass playStoreClass = env->GetObjectClass(_playStoreObject);
+
+ jmethodID getPackLocationMethod = env->GetMethodID(playStoreClass, "getPackLocation", "(Ljava/lang/String;)Lcom/google/android/play/core/assetpacks/AssetPackLocation;");
+
+ jstring packName = env->NewStringUTF("beneath_a_steel_sky");
+ jobject packLocationObject = env->CallObjectMethod(_playStoreObject, getPackLocationMethod, packName);
+
+ env->DeleteLocalRef(packName);
+ env->DeleteLocalRef(packLocationObject);
+
+ // TODO: return a string/struct for the location and add a function parameter i.e. packName
+}
+
+} // End of namespace PlayStore
+} // End of namespace DLC
+
+#endif
diff --git a/backends/dlc/android/playstore.h b/backends/dlc/android/playstore.h
index c74a7cbcd08..a800a3450f1 100644
--- a/backends/dlc/android/playstore.h
+++ b/backends/dlc/android/playstore.h
@@ -19,11 +19,13 @@
*
*/
+#if defined(__ANDROID__)
+
#ifndef BACKENDS_DLC_PLAYSTORE_PLAYSTORE_H
#define BACKENDS_DLC_PLAYSTORE_PLAYSTORE_H
#include "backends/dlc/store.h"
-#include "common/callback.h"
+#include "backends/platform/android/jni-android.h"
namespace DLC {
namespace PlayStore {
@@ -31,12 +33,12 @@ namespace PlayStore {
class PlayStore: public DLC::Store {
public:
- PlayStore() {}
+ PlayStore();
virtual ~PlayStore() {}
- virtual void init() override {}
+ virtual void init() override;
- virtual void requestInfo() override {}
+ virtual void requestInfo() override;
virtual void getDownloadState() override {}
@@ -45,9 +47,14 @@ public:
virtual void getBytesDownloaded() override {}
virtual void cancelDownload() override {}
+
+private:
+ jobject _playStoreObject;
+
};
} // End of namespace PlayStore
} // End of namespace DLC
#endif
+#endif
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index ab662845c26..0068a0beeac 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -20,8 +20,8 @@
*/
-#include "backends/dlc/dlcmanager.h"
#include "backends/dlc/android/playstore.h"
+#include "backends/dlc/dlcmanager.h"
namespace Common {
@@ -32,8 +32,10 @@ DECLARE_SINGLETON(DLC::DLCManager);
namespace DLC {
DLCManager::DLCManager() {
- // if --playstore flag
+ // TODO: Implement Factory Design Pattern
+ #if defined(__ANDROID__)
_store = new DLC::PlayStore::PlayStore();
+ #endif
}
void DLCManager::init() {
@@ -41,7 +43,7 @@ void DLCManager::init() {
}
void DLCManager::initDownload() {
- _store->requestDownload();
+ // _store->requestDownload();
// handle errors
}
diff --git a/backends/module.mk b/backends/module.mk
index fbe00cb1295..1583acb0929 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -289,6 +289,7 @@ endif
ifeq ($(BACKEND),android)
MODULE_OBJS += \
+ dlc/android/playstore.o \
fs/android/android-fs-factory.o \
fs/android/android-posix-fs.o \
fs/android/android-saf-fs.o \
diff --git a/backends/platform/android/jni-android.cpp b/backends/platform/android/jni-android.cpp
index 7b8120d7a37..1778ca5db2a 100644
--- a/backends/platform/android/jni-android.cpp
+++ b/backends/platform/android/jni-android.cpp
@@ -107,6 +107,8 @@ jmethodID JNI::_MID_getNewSAFTree = 0;
jmethodID JNI::_MID_getSAFTrees = 0;
jmethodID JNI::_MID_findSAFTree = 0;
+jmethodID JNI::_MID_getPlayStoreDLCManager = 0;
+
jmethodID JNI::_MID_EGL10_eglSwapBuffers = 0;
jmethodID JNI::_MID_AudioTrack_flush = 0;
@@ -800,6 +802,8 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
FIND_METHOD(, getSAFTrees, "()[Lorg/scummvm/scummvm/SAFFSTree;");
FIND_METHOD(, findSAFTree, "(Ljava/lang/String;)Lorg/scummvm/scummvm/SAFFSTree;");
+ FIND_METHOD(, getPlayStoreDLCManager, "()Lcom/google/android/play/core/assetpacks/AssetPackManager;");
+
_jobj_egl = env->NewGlobalRef(egl);
_jobj_egl_display = env->NewGlobalRef(egl_display);
_egl_version = 0;
@@ -1149,4 +1153,21 @@ jobject JNI::findSAFTree(const Common::String &name) {
return tree;
}
+jobject JNI::getPlayStoreDLCManager() {
+ JNIEnv *env = JNI::getEnv();
+
+ jobject store = env->CallObjectMethod(_jobj, _MID_getPlayStoreDLCManager);
+
+ if (env->ExceptionCheck()) {
+ LOGE("getPlayStoreDLCManager: error");
+
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+
+ return nullptr;
+ }
+
+ return store;
+}
+
#endif
diff --git a/backends/platform/android/jni-android.h b/backends/platform/android/jni-android.h
index 3f21dbeba7a..6127990be55 100644
--- a/backends/platform/android/jni-android.h
+++ b/backends/platform/android/jni-android.h
@@ -119,6 +119,7 @@ public:
static jobject getNewSAFTree(bool folder, bool writable, const Common::String &initURI, const Common::String &prompt);
static Common::Array<jobject> getSAFTrees();
static jobject findSAFTree(const Common::String &name);
+ static jobject getPlayStoreDLCManager();
private:
static pthread_key_t _env_tls;
@@ -164,6 +165,8 @@ private:
static jmethodID _MID_getSAFTrees;
static jmethodID _MID_findSAFTree;
+ static jmethodID _MID_getPlayStoreDLCManager;
+
static jmethodID _MID_EGL10_eglSwapBuffers;
static jmethodID _MID_AudioTrack_flush;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index 7e29a1a55d4..37a3e0d091d 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -12,6 +12,8 @@ import android.os.Build;
import android.util.Log;
import android.view.SurfaceHolder;
+import com.google.android.play.core.assetpacks.AssetPackManager;
+
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Scanner;
@@ -90,6 +92,7 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
abstract protected SAFFSTree getNewSAFTree(boolean folder, boolean write, String initialURI, String prompt);
abstract protected SAFFSTree[] getSAFTrees();
abstract protected SAFFSTree findSAFTree(String name);
+ abstract protected AssetPackManager getPlayStoreDLCManager();
public ScummVM(AssetManager asset_manager, SurfaceHolder holder, final MyScummVMDestroyedCallback scummVMDestroyedCallback) {
_asset_manager = asset_manager;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 85d56a421dd..1e74c24c694 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -48,6 +48,9 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
+import com.google.android.play.core.assetpacks.AssetPackManager;
+import com.google.android.play.core.assetpacks.AssetPackManagerFactory;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -877,6 +880,11 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
protected SAFFSTree findSAFTree(String name) {
return SAFFSTree.findTree(ScummVMActivity.this, name);
}
+
+ @Override
+ protected AssetPackManager getPlayStoreDLCManager() {
+ return AssetPackManagerFactory.getInstance(getApplicationContext());
+ }
}
private MyScummVM _scummvm;
diff --git a/dists/android/build.gradle b/dists/android/build.gradle
index 23000480287..daef8e9b70a 100644
--- a/dists/android/build.gradle
+++ b/dists/android/build.gradle
@@ -108,4 +108,5 @@ android {
dependencies {
implementation "androidx.annotation:annotation:1.5.0"
implementation "androidx.appcompat:appcompat:1.6.1"
+ implementation "com.google.android.play:asset-delivery:2.1.0"
}
Commit: 045a99e50c09937bbc6c10c1688fadce110f9af0
https://github.com/scummvm/scummvm/commit/045a99e50c09937bbc6c10c1688fadce110f9af0
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Remove platform-specific defines and enforce factory design pattern for creating DLC store
Changed paths:
backends/dlc/dlcmanager.cpp
backends/platform/android/android.cpp
common/system.cpp
common/system.h
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 0068a0beeac..741dd03ebc5 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -22,6 +22,7 @@
#include "backends/dlc/android/playstore.h"
#include "backends/dlc/dlcmanager.h"
+#include "common/system.h"
namespace Common {
@@ -32,10 +33,7 @@ DECLARE_SINGLETON(DLC::DLCManager);
namespace DLC {
DLCManager::DLCManager() {
- // TODO: Implement Factory Design Pattern
- #if defined(__ANDROID__)
- _store = new DLC::PlayStore::PlayStore();
- #endif
+ _store = g_system->getDLCStore();
}
void DLCManager::init() {
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 694985af579..dc510668f3a 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -76,6 +76,8 @@
#include "backends/keymapper/keymapper-defaults.h"
#include "backends/keymapper/standard-actions.h"
+#include "backends/dlc/android/playstore.h"
+
#include "common/util.h"
#include "common/textconsole.h"
#include "common/rect.h"
@@ -221,6 +223,10 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
fsFactory.initSAF();
}
_fsFactory = &fsFactory;
+
+ // TODO: Create a new factory for Android, to assign it according to the Android's distribution store
+ // E.g. to handle the cases for: playstore, no store (apk on ScummVM website), amazon app store, etc.
+ _dlcStore = new DLC::PlayStore::PlayStore();
}
OSystem_Android::~OSystem_Android() {
@@ -255,6 +261,9 @@ OSystem_Android::~OSystem_Android() {
delete _logger;
_logger = nullptr;
+
+ delete _dlcStore;
+ _dlcStore = nullptr;
}
void *OSystem_Android::timerThreadFunc(void *arg) {
diff --git a/common/system.cpp b/common/system.cpp
index 07854eab6ed..d7f7ea79e91 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -56,6 +56,7 @@ OSystem::OSystem() {
_dialogManager = nullptr;
#endif
_fsFactory = nullptr;
+ _dlcStore = nullptr;
_backendInitialized = false;
}
@@ -92,6 +93,9 @@ OSystem::~OSystem() {
delete _fsFactory;
_fsFactory = nullptr;
+
+ delete _dlcStore;
+ _dlcStore = nullptr;
}
void OSystem::initBackend() {
diff --git a/common/system.h b/common/system.h
index 4f5543c604d..4d0cc2460c4 100644
--- a/common/system.h
+++ b/common/system.h
@@ -46,6 +46,10 @@ class GuiObject;
class OptionsContainerWidget;
}
+namespace DLC {
+class Store;
+}
+
namespace Common {
class EventManager;
class MutexInternal;
@@ -263,6 +267,11 @@ protected:
*/
FilesystemFactory *_fsFactory;
+ /**
+ * Used by the DLC Manager implementation
+ */
+ DLC::Store *_dlcStore;
+
/**
* Used by the default clipboard implementation, for backends that don't
* implement clipboard support.
@@ -1730,6 +1739,15 @@ public:
}
#endif
+ /**
+ * Return the DLC Store, used to implement DLC manager functions.
+ *
+ * @return The Store for the current distribution platform.
+ */
+ virtual DLC::Store *getDLCStore() {
+ return _dlcStore;
+ }
+
/**
* Return the FilesystemFactory object, depending on the current architecture.
*
Commit: 3f8ddc117e748dbee408c13ebff6c3d2201cf497
https://github.com/scummvm/scummvm/commit/3f8ddc117e748dbee408c13ebff6c3d2201cf497
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Add DLC download queue and implement some DLCManager functions
Changed paths:
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 741dd03ebc5..04ce6e76fce 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -37,16 +37,58 @@ DLCManager::DLCManager() {
}
void DLCManager::init() {
+ getAllDLCs(_dlcs);
+}
+
+void DLCManager::getAllDLCs(Common::Array<DLC*>& dlcs) {
+ // if distribution store's API available call it else hardcode
+}
+
+void DLCManager::addDownload(uint32 idx) {
+ _dlcs[idx]->state = kInProgress;
+ _queuedDownloadTasks.push(_dlcs[idx]);
+ if (!_isDLCDownloading) {
+ DLCManager::processDownload();
+ }
+}
+
+void DLCManager::processDownload() {
+ if (!_queuedDownloadTasks.empty()) {
+ if (_dlcs[_queuedDownloadTasks.front()->idx]->state == kInProgress) {
+ _isDLCDownloading = true;
+ _currentDownloadingDLC = _queuedDownloadTasks.front()->id;
+ DLCManager::startDownloadAsync(_queuedDownloadTasks.front()->id, &DLCManager::cb);
+ } else {
+ // state is already cancelled/downloaded -> skip download
+ _queuedDownloadTasks.pop();
+ // process next download in the queue
+ processDownload();
+ }
+ } else {
+ _isDLCDownloading = false;
+ }
+}
+void DLCManager::cb() {
+ // if finished successfully
+ _dlcs[_queuedDownloadTasks.front()->idx]->state = kDownloaded;
+ _queuedDownloadTasks.pop();
+ // process next download in the queue
+ DLCManager::processDownload();
}
-void DLCManager::initDownload() {
- // _store->requestDownload();
- // handle errors
+bool DLCManager::cancelDownload(uint32 idx) {
+ if (_currentDownloadingDLC == _dlcs[idx]->id) {
+ // if already downloading, interrupt startDownloadAsync
+ } else {
+ // if not started, skip it in processDownload()
+ _dlcs[idx]->state = kCancelled;
+ }
+ return true;
}
-bool DLCManager::getFeatureState(DLC::Feature f) {
- return false;
+Common::String DLCManager::getCurrentDownloadingDLC() {
+ return _currentDownloadingDLC;
}
} // End of namespace DLC
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 8bc760a5790..7dfe41359f4 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -23,44 +23,67 @@
#define DLC_DLCMANAGER_H
#include "common/str.h"
+#include "common/str-array.h"
+#include "common/queue.h"
#include "common/singleton.h"
#include "backends/dlc/store.h"
namespace DLC {
-enum Feature {
- kInProgress
+enum State {
+ kAvailable,
+ kInProgress,
+ kDownloaded,
+ kCancelled
+};
+
+struct DLC {
+ Common::String name;
+ Common::String id;
+ uint32 size;
+ uint32 idx;
+ State state;
};
class DLCManager : public Common::Singleton<DLCManager> {
- struct DLCDesc {
- Common::String name;
- Common::String description;
- uint32 size;
- uint32 game_id;
- };
+ Common::Array<DLC*> _dlcs;
+ Common::Queue<DLC*> _queuedDownloadTasks;
Store* _store;
+ bool _isDLCDownloading = false;
+ Common::String _currentDownloadingDLC;
+
public:
DLCManager();
virtual ~DLCManager() {}
void init();
- DLCDesc getDLCList();
+ // Runs only once in init()
+ void getAllDLCs(Common::Array<DLC*>& dlcs);
+
+ // Requested by GUI to show all available DLCs in simple list view
+ Common::U32StringArray getDLCList();
+
+ // Add download task to queue, runs on click download button,
+ void addDownload(uint32 idx);
+
+ bool cancelDownload(uint32 idx);
+
+ void processDownload();
- void initDownload();
+ // Returns the % download progress of current downloading game
+ uint32 downloadProgress();
- void cancelDownload();
+ Common::String getCurrentDownloadingDLC();
- bool getFeatureState(DLC::Feature f);
- void setFeatureState(DLC::Feature f, bool enable);
+ // Callback function for startDownloadAsync
+ void cb();
- void getPercentDownloaded();
+ void startDownloadAsync(Common::String id, void(DLCManager::*callback)()) {}
- uint32 getInProgressGame();
};
#define DLCMan DLC::DLCManager::instance()
Commit: 478d3f2ab9620a4927896192cc8f5a4863ee4206
https://github.com/scummvm/scummvm/commit/478d3f2ab9620a4927896192cc8f5a4863ee4206
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
COMMON: Fix incomplete type warning for dlc store
Changed paths:
common/system.cpp
diff --git a/common/system.cpp b/common/system.cpp
index d7f7ea79e91..d202be13340 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -37,6 +37,7 @@
#include "backends/audiocd/default/default-audiocd.h"
#include "backends/fs/fs-factory.h"
#include "backends/timer/default/default-timer.h"
+#include "backends/dlc/store.h"
OSystem *g_system = nullptr;
Commit: c0f91421cc69106d72fce6d211eea9396062268e
https://github.com/scummvm/scummvm/commit/c0f91421cc69106d72fce6d211eea9396062268e
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Initial code for downloading DLCs using CURL
Changed paths:
A backends/dlc/dlcdesc.h
A backends/dlc/scummvmcloud.cpp
A backends/dlc/scummvmcloud.h
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
backends/dlc/store.h
backends/module.mk
gui/download-games-dialog.cpp
diff --git a/backends/dlc/dlcdesc.h b/backends/dlc/dlcdesc.h
new file mode 100644
index 00000000000..779ff1ad385
--- /dev/null
+++ b/backends/dlc/dlcdesc.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DLC_DLCT_H
+#define DLC_DLCT_H
+
+#include "common/str.h"
+
+namespace DLC {
+
+class DLCDesc {
+
+public:
+ enum State {
+ kAvailable,
+ kInProgress,
+ kDownloaded,
+ kCancelled,
+ kErrorDownloading
+ };
+ Common::String name;
+ Common::String id;
+ uint32 size;
+ uint32 idx;
+ State state;
+};
+
+
+} // End of namespace DLC
+
+#endif
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 04ce6e76fce..f8476226046 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -22,6 +22,8 @@
#include "backends/dlc/android/playstore.h"
#include "backends/dlc/dlcmanager.h"
+#include "backends/dlc/scummvmcloud.h"
+#include "backends/dlc/android/playstore.h"
#include "common/system.h"
namespace Common {
@@ -33,48 +35,49 @@ DECLARE_SINGLETON(DLC::DLCManager);
namespace DLC {
DLCManager::DLCManager() {
- _store = g_system->getDLCStore();
+ // _store = g_system->getDLCStore();
+ // TODO: Handle creation through getDLCStore()
+ _store = new DLC::ScummVMCloud::ScummVMCloud();
}
void DLCManager::init() {
- getAllDLCs(_dlcs);
+ DLCManager::getAllDLCs(_dlcs);
}
-void DLCManager::getAllDLCs(Common::Array<DLC*>& dlcs) {
- // if distribution store's API available call it else hardcode
+void DLCManager::getAllDLCs(Common::Array<DLCDesc*> &dlcs) {
+ _store->getAllDLCs(dlcs);
}
void DLCManager::addDownload(uint32 idx) {
- _dlcs[idx]->state = kInProgress;
+ _dlcs[idx]->state = DLCDesc::kInProgress;
_queuedDownloadTasks.push(_dlcs[idx]);
if (!_isDLCDownloading) {
- DLCManager::processDownload();
+ // if queue is not already processing
+ DLCManager::processDownloadQueue();
}
}
-void DLCManager::processDownload() {
+void DLCManager::processDownloadQueue() {
+ _isDLCDownloading = true;
if (!_queuedDownloadTasks.empty()) {
- if (_dlcs[_queuedDownloadTasks.front()->idx]->state == kInProgress) {
- _isDLCDownloading = true;
+ if (_queuedDownloadTasks.front()->state == DLCDesc::kInProgress) {
_currentDownloadingDLC = _queuedDownloadTasks.front()->id;
- DLCManager::startDownloadAsync(_queuedDownloadTasks.front()->id, &DLCManager::cb);
+ DLCManager::startDownloadAsync(_queuedDownloadTasks.front()->id);
} else {
// state is already cancelled/downloaded -> skip download
_queuedDownloadTasks.pop();
// process next download in the queue
- processDownload();
+ processDownloadQueue();
}
} else {
+ // no more download in queue
_isDLCDownloading = false;
+ _currentDownloadingDLC = "";
}
}
-void DLCManager::cb() {
- // if finished successfully
- _dlcs[_queuedDownloadTasks.front()->idx]->state = kDownloaded;
- _queuedDownloadTasks.pop();
- // process next download in the queue
- DLCManager::processDownload();
+void DLCManager::startDownloadAsync(Common::String &id) {
+ _store->startDownloadAsync(id);
}
bool DLCManager::cancelDownload(uint32 idx) {
@@ -82,7 +85,7 @@ bool DLCManager::cancelDownload(uint32 idx) {
// if already downloading, interrupt startDownloadAsync
} else {
// if not started, skip it in processDownload()
- _dlcs[idx]->state = kCancelled;
+ _dlcs[idx]->state = DLCDesc::kCancelled;
}
return true;
}
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 7dfe41359f4..6afe19fc573 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -27,42 +27,30 @@
#include "common/queue.h"
#include "common/singleton.h"
#include "backends/dlc/store.h"
+#include "backends/dlc/dlcdesc.h"
+#include "backends/networking/curl/request.h"
namespace DLC {
-enum State {
- kAvailable,
- kInProgress,
- kDownloaded,
- kCancelled
-};
-
-struct DLC {
- Common::String name;
- Common::String id;
- uint32 size;
- uint32 idx;
- State state;
-};
-
class DLCManager : public Common::Singleton<DLCManager> {
- Common::Array<DLC*> _dlcs;
- Common::Queue<DLC*> _queuedDownloadTasks;
+ Common::Array<DLCDesc*> _dlcs;
- Store* _store;
+ Store *_store;
bool _isDLCDownloading = false;
Common::String _currentDownloadingDLC;
public:
+ Common::Queue<DLCDesc*> _queuedDownloadTasks;
+
DLCManager();
virtual ~DLCManager() {}
void init();
// Runs only once in init()
- void getAllDLCs(Common::Array<DLC*>& dlcs);
+ void getAllDLCs(Common::Array<DLCDesc*> &dlcs);
// Requested by GUI to show all available DLCs in simple list view
Common::U32StringArray getDLCList();
@@ -72,18 +60,18 @@ public:
bool cancelDownload(uint32 idx);
- void processDownload();
+ void processDownloadQueue();
// Returns the % download progress of current downloading game
uint32 downloadProgress();
Common::String getCurrentDownloadingDLC();
- // Callback function for startDownloadAsync
- void cb();
+ void startDownloadAsync(Common::String &id);
- void startDownloadAsync(Common::String id, void(DLCManager::*callback)()) {}
+ void errorCallback(Networking::ErrorResponse error);
+ void downloadFileCallback(Networking::DataResponse r);
};
#define DLCMan DLC::DLCManager::instance()
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
new file mode 100644
index 00000000000..c420b9cdae3
--- /dev/null
+++ b/backends/dlc/scummvmcloud.cpp
@@ -0,0 +1,63 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "backends/dlc/scummvmcloud.h"
+#include "backends/dlc/dlcmanager.h"
+#include "common/config-manager.h"
+
+namespace DLC {
+namespace ScummVMCloud {
+
+void ScummVMCloud::getAllDLCs(Common::Array<DLCDesc*> &dlcs) {
+ dlcs.push_back(new DLCDesc{"Beneath a Steel Sky - Freeware CD Version", "bass_cd", 100, 0, DLCDesc::kAvailable});
+ dlcs.push_back(new DLCDesc{"Beneath a Steel Sky - Freeware Floppy Version", "bass_floppy", 230, 1, DLCDesc::kAvailable});
+}
+
+void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
+ Networking::SessionFileResponse *response = static_cast<Networking::SessionFileResponse *>(r.value);
+ if (response->eos) {
+ warning("downloaded");
+ DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kDownloaded;
+ DLCMan._queuedDownloadTasks.pop();
+ DLCMan.processDownloadQueue();
+ }
+}
+
+void ScummVMCloud::errorCallback(Networking::ErrorResponse error) {
+ // error downloading - start next download in queue
+ DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kErrorDownloading;
+ DLCMan._queuedDownloadTasks.pop();
+ DLCMan.processDownloadQueue();
+}
+
+void ScummVMCloud::startDownloadAsync(Common::String &id) {
+ Common::String url = Common::String::format("https://downloads.scummvm.org/frs/extras/Beneath%%20a%%20Steel%%20Sky/bass-cd-1.2.zip");
+ Common::String localFile = "";
+
+ Networking::SessionRequest *rq = session.get(url, localFile,
+ new Common::Callback<ScummVMCloud, Networking::DataResponse>(this, &ScummVMCloud::downloadFileCallback),
+ new Common::Callback<ScummVMCloud, Networking::ErrorResponse>(this, &ScummVMCloud::errorCallback));
+
+ rq->start();
+}
+
+} // End of namespace ScummVMCloud
+} // End of namespace DLC
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
new file mode 100644
index 00000000000..4d7e5122850
--- /dev/null
+++ b/backends/dlc/scummvmcloud.h
@@ -0,0 +1,66 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef BACKENDS_DLC_ScummVMCloud_ScummVMCloud_H
+#define BACKENDS_DLC_ScummVMCloud_ScummVMCloud_H
+
+#include "backends/dlc/store.h"
+#include "backends/dlc/dlcdesc.h"
+#include "backends/networking/curl/session.h"
+#include "backends/networking/curl/request.h"
+#include "common/queue.h"
+
+namespace DLC {
+namespace ScummVMCloud {
+
+class ScummVMCloud: public DLC::Store {
+
+Networking::Session session;
+
+public:
+ ScummVMCloud() {}
+ virtual ~ScummVMCloud() {}
+
+ virtual void init() override {}
+
+ virtual void requestInfo() override {}
+
+ virtual void getDownloadState() override {}
+
+ virtual void requestDownload() override {}
+
+ virtual void getBytesDownloaded() override {}
+
+ virtual void cancelDownload() override {}
+
+ virtual void getAllDLCs(Common::Array<DLCDesc*> &dlcs) override;
+
+ virtual void startDownloadAsync(Common::String &id) override;
+
+ void downloadFileCallback(Networking::DataResponse response);
+
+ void errorCallback(Networking::ErrorResponse error);
+};
+
+} // End of namespace ScummVMCloud
+} // End of namespace DLC
+
+#endif
diff --git a/backends/dlc/store.h b/backends/dlc/store.h
index 186e68189fe..899dd3388cd 100644
--- a/backends/dlc/store.h
+++ b/backends/dlc/store.h
@@ -22,6 +22,11 @@
#ifndef DLC_STORE_H
#define DLC_STORE_H
+#include "common/str.h"
+#include "common/array.h"
+#include "common/queue.h"
+#include "backends/dlc/dlcdesc.h"
+
namespace DLC {
class Store {
@@ -41,6 +46,11 @@ public:
virtual void getBytesDownloaded() = 0;
virtual void cancelDownload() = 0;
+
+ virtual void getAllDLCs(Common::Array<DLCDesc*> &dlcs) = 0;
+
+ virtual void startDownloadAsync(Common::String &id) = 0;
+
};
} // End of namespace DLC
diff --git a/backends/module.mk b/backends/module.mk
index 1583acb0929..9ddce1c40d3 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -79,7 +79,8 @@ MODULE_OBJS += \
networking/curl/session.o \
networking/curl/sessionrequest.o \
networking/curl/socket.o \
- networking/curl/url.o
+ networking/curl/url.o \
+ dlc/scummvmcloud.o
endif
ifdef USE_SDL_NET
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
index 96cd84a3c96..2cb2172bd54 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/download-games-dialog.cpp
@@ -24,6 +24,7 @@
#include "gui/widget.h"
#include "gui/widgets/list.h"
#include "common/translation.h"
+#include "backends/dlc/dlcmanager.h"
namespace GUI {
@@ -78,6 +79,7 @@ void DownloadGamesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
case kDownloadSelectedCmd: {
MessageDialog dialog("Downloading: " + _gamesList->getSelectedString());
dialog.runModal();
+ DLCMan.addDownload(1);
}
break;
default:
Commit: f380eaf9cc79564dd7baa61e02ffeda7d29bcee7
https://github.com/scummvm/scummvm/commit/f380eaf9cc79564dd7baa61e02ffeda7d29bcee7
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Generalize startDownloadAsync() for downloading DLCs
Changed paths:
backends/dlc/dlcdesc.h
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
backends/dlc/store.h
diff --git a/backends/dlc/dlcdesc.h b/backends/dlc/dlcdesc.h
index 779ff1ad385..1ff183235ba 100644
--- a/backends/dlc/dlcdesc.h
+++ b/backends/dlc/dlcdesc.h
@@ -38,6 +38,7 @@ public:
};
Common::String name;
Common::String id;
+ Common::String url;
uint32 size;
uint32 idx;
State state;
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index f8476226046..53369cdfb4f 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -62,7 +62,7 @@ void DLCManager::processDownloadQueue() {
if (!_queuedDownloadTasks.empty()) {
if (_queuedDownloadTasks.front()->state == DLCDesc::kInProgress) {
_currentDownloadingDLC = _queuedDownloadTasks.front()->id;
- DLCManager::startDownloadAsync(_queuedDownloadTasks.front()->id);
+ DLCManager::startDownloadAsync(_queuedDownloadTasks.front()->id, _queuedDownloadTasks.front()->url);
} else {
// state is already cancelled/downloaded -> skip download
_queuedDownloadTasks.pop();
@@ -76,8 +76,8 @@ void DLCManager::processDownloadQueue() {
}
}
-void DLCManager::startDownloadAsync(Common::String &id) {
- _store->startDownloadAsync(id);
+void DLCManager::startDownloadAsync(const Common::String &id, const Common::String &url) {
+ _store->startDownloadAsync(id, url);
}
bool DLCManager::cancelDownload(uint32 idx) {
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 6afe19fc573..9cc2752e890 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -67,7 +67,7 @@ public:
Common::String getCurrentDownloadingDLC();
- void startDownloadAsync(Common::String &id);
+ void startDownloadAsync(const Common::String &id, const Common::String &url);
void errorCallback(Networking::ErrorResponse error);
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index c420b9cdae3..abb1c464909 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -27,8 +27,8 @@ namespace DLC {
namespace ScummVMCloud {
void ScummVMCloud::getAllDLCs(Common::Array<DLCDesc*> &dlcs) {
- dlcs.push_back(new DLCDesc{"Beneath a Steel Sky - Freeware CD Version", "bass_cd", 100, 0, DLCDesc::kAvailable});
- dlcs.push_back(new DLCDesc{"Beneath a Steel Sky - Freeware Floppy Version", "bass_floppy", 230, 1, DLCDesc::kAvailable});
+ dlcs.push_back(new DLCDesc{"Beneath a Steel Sky - Freeware CD Version", "bass_cd", "https://downloads.scummvm.org/frs/extras/Beneath%20a%20Steel%20Sky/bass-cd-1.2.zip", 100, 0, DLCDesc::kAvailable});
+ dlcs.push_back(new DLCDesc{"Beneath a Steel Sky - Freeware Floppy Version", "bass_floppy", "https://downloads.scummvm.org/frs/extras/Beneath%20a%20Steel%20Sky/BASS-Floppy-1.3.zip", 230, 1, DLCDesc::kAvailable});
}
void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
@@ -48,9 +48,9 @@ void ScummVMCloud::errorCallback(Networking::ErrorResponse error) {
DLCMan.processDownloadQueue();
}
-void ScummVMCloud::startDownloadAsync(Common::String &id) {
- Common::String url = Common::String::format("https://downloads.scummvm.org/frs/extras/Beneath%%20a%%20Steel%%20Sky/bass-cd-1.2.zip");
- Common::String localFile = "";
+void ScummVMCloud::startDownloadAsync(const Common::String &id, const Common::String &url) {
+ // TODO: Change it to dlcpath
+ Common::String localFile = normalizePath(ConfMan.get("iconspath") + "/" + id, '/');
Networking::SessionRequest *rq = session.get(url, localFile,
new Common::Callback<ScummVMCloud, Networking::DataResponse>(this, &ScummVMCloud::downloadFileCallback),
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index 4d7e5122850..264cd389ec6 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -53,7 +53,7 @@ public:
virtual void getAllDLCs(Common::Array<DLCDesc*> &dlcs) override;
- virtual void startDownloadAsync(Common::String &id) override;
+ virtual void startDownloadAsync(const Common::String &id, const Common::String &url) override;
void downloadFileCallback(Networking::DataResponse response);
diff --git a/backends/dlc/store.h b/backends/dlc/store.h
index 899dd3388cd..def0b03ae7a 100644
--- a/backends/dlc/store.h
+++ b/backends/dlc/store.h
@@ -49,7 +49,7 @@ public:
virtual void getAllDLCs(Common::Array<DLCDesc*> &dlcs) = 0;
- virtual void startDownloadAsync(Common::String &id) = 0;
+ virtual void startDownloadAsync(const Common::String &id, const Common::String &url) = 0;
};
Commit: 5ac2efcf5cdc3e19fb06958df969714bff3d37f9
https://github.com/scummvm/scummvm/commit/5ac2efcf5cdc3e19fb06958df969714bff3d37f9
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Populate dlc list using getAllDLCs() response
Changed paths:
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
gui/download-games-dialog.cpp
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 9cc2752e890..1b3f1c80331 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -34,14 +34,13 @@ namespace DLC {
class DLCManager : public Common::Singleton<DLCManager> {
- Common::Array<DLCDesc*> _dlcs;
-
Store *_store;
bool _isDLCDownloading = false;
Common::String _currentDownloadingDLC;
public:
+ Common::Array<DLCDesc*> _dlcs;
Common::Queue<DLCDesc*> _queuedDownloadTasks;
DLCManager();
@@ -52,9 +51,6 @@ public:
// Runs only once in init()
void getAllDLCs(Common::Array<DLCDesc*> &dlcs);
- // Requested by GUI to show all available DLCs in simple list view
- Common::U32StringArray getDLCList();
-
// Add download task to queue, runs on click download button,
void addDownload(uint32 idx);
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index abb1c464909..a74760cb223 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -22,13 +22,49 @@
#include "backends/dlc/scummvmcloud.h"
#include "backends/dlc/dlcmanager.h"
#include "common/config-manager.h"
+#include "common/formats/json.h"
namespace DLC {
namespace ScummVMCloud {
+void ScummVMCloud::jsonCallbackGetAllDLCs(Networking::JsonResponse response) {
+ Common::JSONValue *json = (Common::JSONValue *)response.value;
+ if (json == nullptr || !json->isObject()) {
+ return;
+ }
+ // warning("%s", json->stringify(true).c_str());
+ Common::JSONObject result = json->asObject();
+ if (result.contains("entries")) {
+ Common::JSONArray items = result.getVal("entries")->asArray();
+ for (uint32 i = 0; i < items.size(); ++i) {
+ if (!Networking::CurlJsonRequest::jsonIsObject(items[i], "ScummVMCloud")) continue;
+ Common::JSONObject item = items[i]->asObject();
+ Common::String id = item.getVal("id")->asString();
+ Common::String name = item.getVal("name")->asString();
+ Common::String url = item.getVal("url")->asString();
+ uint32 size;
+ if (item.getVal("size")->isString()) {
+ size = item.getVal("size")->asString().asUint64();
+ } else {
+ size = item.getVal("size")->asIntegerNumber();
+ }
+ DLCMan._dlcs.push_back(new DLCDesc{name, id, url, size, i, DLCDesc::kAvailable});
+ }
+ }
+}
+
+void ScummVMCloud::errorCallbackGetAllDLCs(Networking::ErrorResponse error) {
+ warning("JsonRequest Error - getAllDLCs");
+}
+
void ScummVMCloud::getAllDLCs(Common::Array<DLCDesc*> &dlcs) {
- dlcs.push_back(new DLCDesc{"Beneath a Steel Sky - Freeware CD Version", "bass_cd", "https://downloads.scummvm.org/frs/extras/Beneath%20a%20Steel%20Sky/bass-cd-1.2.zip", 100, 0, DLCDesc::kAvailable});
- dlcs.push_back(new DLCDesc{"Beneath a Steel Sky - Freeware Floppy Version", "bass_floppy", "https://downloads.scummvm.org/frs/extras/Beneath%20a%20Steel%20Sky/BASS-Floppy-1.3.zip", 230, 1, DLCDesc::kAvailable});
+ Common::String url("https://mocki.io/v1/0d86064d-1c04-41c8-a7b0-7e7e044b9b58"); // temporary mock api
+ Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(
+ new Common::Callback<ScummVMCloud, Networking::JsonResponse>(this, &ScummVMCloud::jsonCallbackGetAllDLCs),
+ new Common::Callback<ScummVMCloud, Networking::ErrorResponse>(this, &ScummVMCloud::errorCallbackGetAllDLCs),
+ url);
+
+ request->execute();
}
void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index 264cd389ec6..7cf6b33b42d 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -26,6 +26,7 @@
#include "backends/dlc/dlcdesc.h"
#include "backends/networking/curl/session.h"
#include "backends/networking/curl/request.h"
+#include "backends/networking/curl/curljsonrequest.h"
#include "common/queue.h"
namespace DLC {
@@ -55,6 +56,11 @@ public:
virtual void startDownloadAsync(const Common::String &id, const Common::String &url) override;
+ // callback functions
+ void jsonCallbackGetAllDLCs(Networking::JsonResponse response);
+
+ void errorCallbackGetAllDLCs(Networking::ErrorResponse error);
+
void downloadFileCallback(Networking::DataResponse response);
void errorCallback(Networking::ErrorResponse error);
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
index 2cb2172bd54..15fe96e7b4f 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/download-games-dialog.cpp
@@ -43,18 +43,10 @@ DownloadGamesDialog::DownloadGamesDialog()
_gamesList->setEditable(false);
// Populate the ListWidget
- Common::U32StringArray games = {
- _("Beneath a Steel Sky - Freeware CD Version"),
- _("Beneath a Steel Sky - Freeware Floppy Version"),
- _("Broken Sword 2.5: The Return of the Templars - Freeware Version"),
- _("Broken Sword 2.5: The Return of the Templars - Hebrew translation AddOn"),
- _("Dráscula: The Vampire Strikes Back - Freeware Version (English)"),
- _("Dráscula: The Vampire Strikes Back - Freeware Version (Music AddOn, MP3 format)"),
- _("Dráscula: The Vampire Strikes Back - Freeware Version (Music AddOn, FLAC format)"),
- _("Dráscula: The Vampire Strikes Back - Freeware Version (Music AddOn, OGG format)"),
- _("Dráscula: The Vampire Strikes Back - Freeware Version (Spanish, German, French and Italian AddOn)"),
- _("Dráscula: The Vampire Strikes Back - Freeware Version (Updated Spanish, German, French and Italian AddOn) - requires ScummVM 1.3.0 or more"),
- };
+ Common::U32StringArray games;
+ for (int i = 0; i < DLCMan._dlcs.size(); ++i) {
+ games.push_back(DLCMan._dlcs[i]->name);
+ }
// Gray out already downloaded packages
for (Common::ConfigManager::DomainMap::iterator domain = ConfMan.beginGameDomains(); domain != ConfMan.endGameDomains(); ++domain) {
@@ -79,7 +71,7 @@ void DownloadGamesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
case kDownloadSelectedCmd: {
MessageDialog dialog("Downloading: " + _gamesList->getSelectedString());
dialog.runModal();
- DLCMan.addDownload(1);
+ DLCMan.addDownload(_gamesList->getSelected());
}
break;
default:
Commit: c3fcfd0b0070a03b656b4996b63f29ab4d329567
https://github.com/scummvm/scummvm/commit/c3fcfd0b0070a03b656b4996b63f29ab4d329567
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Implement extract downloaded DLCs and remove cache in ScummVMCloud
Changed paths:
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
backends/dlc/store.h
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index a74760cb223..f46f4dad73d 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -19,6 +19,15 @@
*
*/
+#if defined(POSIX)
+#define FORBIDDEN_SYMBOL_EXCEPTION_unlink
+
+#include <unistd.h>
+#endif
+
+#include "common/archive.h"
+#include "common/compression/unzip.h"
+#include "common/file.h"
#include "backends/dlc/scummvmcloud.h"
#include "backends/dlc/dlcmanager.h"
#include "common/config-manager.h"
@@ -71,6 +80,12 @@ void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
Networking::SessionFileResponse *response = static_cast<Networking::SessionFileResponse *>(r.value);
if (response->eos) {
warning("downloaded");
+ Common::Path relativeFilePath = Common::Path(DLCMan._queuedDownloadTasks.front()->id);
+ // extract the downloaded zip
+ extractZip(relativeFilePath);
+ // remove cache (the downloaded .zip)
+ removeCacheFile(relativeFilePath);
+ // handle next download
DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kDownloaded;
DLCMan._queuedDownloadTasks.pop();
DLCMan.processDownloadQueue();
@@ -95,5 +110,28 @@ void ScummVMCloud::startDownloadAsync(const Common::String &id, const Common::St
rq->start();
}
+void ScummVMCloud::extractZip(Common::Path file) {
+ Common::Archive *dataArchive = nullptr;
+ Common::Path dlcPath = Common::Path(ConfMan.get("iconspath"));
+ Common::FSNode *fs = new Common::FSNode(dlcPath.join(file));
+ if (fs->exists()) {
+ dataArchive = Common::makeZipArchive(*fs);
+ // dataArchive is nullptr if zip file is incomplete
+ if (dataArchive != nullptr) {
+ dataArchive->dumpArchive(dlcPath.toString());
+ }
+ }
+ delete fs;
+ delete dataArchive;
+}
+
+void ScummVMCloud::removeCacheFile(Common::Path file) {
+ Common::Path dlcPath = Common::Path(ConfMan.get("iconspath"));
+ Common::Path fileToDelete = dlcPath.join(file);
+ #if defined(POSIX)
+ unlink(fileToDelete.toString().c_str());
+ #endif
+}
+
} // End of namespace ScummVMCloud
} // End of namespace DLC
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index 7cf6b33b42d..d248671d6ed 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -56,6 +56,10 @@ public:
virtual void startDownloadAsync(const Common::String &id, const Common::String &url) override;
+ virtual void removeCacheFile(Common::Path file) override;
+
+ void extractZip(Common::Path file);
+
// callback functions
void jsonCallbackGetAllDLCs(Networking::JsonResponse response);
diff --git a/backends/dlc/store.h b/backends/dlc/store.h
index def0b03ae7a..d0d35ae3b0d 100644
--- a/backends/dlc/store.h
+++ b/backends/dlc/store.h
@@ -25,6 +25,7 @@
#include "common/str.h"
#include "common/array.h"
#include "common/queue.h"
+#include "common/path.h"
#include "backends/dlc/dlcdesc.h"
namespace DLC {
@@ -51,6 +52,7 @@ public:
virtual void startDownloadAsync(const Common::String &id, const Common::String &url) = 0;
+ virtual void removeCacheFile(Common::Path file) = 0;
};
} // End of namespace DLC
Commit: 1a8c5383a460683496c172f698d62bc7abe63642
https://github.com/scummvm/scummvm/commit/1a8c5383a460683496c172f698d62bc7abe63642
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Delete request when DLC is downloaded
Changed paths:
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index f46f4dad73d..fa8877f755b 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -80,6 +80,7 @@ void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
Networking::SessionFileResponse *response = static_cast<Networking::SessionFileResponse *>(r.value);
if (response->eos) {
warning("downloaded");
+ _rq->close(); // delete request
Common::Path relativeFilePath = Common::Path(DLCMan._queuedDownloadTasks.front()->id);
// extract the downloaded zip
extractZip(relativeFilePath);
@@ -103,11 +104,11 @@ void ScummVMCloud::startDownloadAsync(const Common::String &id, const Common::St
// TODO: Change it to dlcpath
Common::String localFile = normalizePath(ConfMan.get("iconspath") + "/" + id, '/');
- Networking::SessionRequest *rq = session.get(url, localFile,
+ _rq = new Networking::SessionRequest(url, localFile,
new Common::Callback<ScummVMCloud, Networking::DataResponse>(this, &ScummVMCloud::downloadFileCallback),
new Common::Callback<ScummVMCloud, Networking::ErrorResponse>(this, &ScummVMCloud::errorCallback));
- rq->start();
+ _rq->start();
}
void ScummVMCloud::extractZip(Common::Path file) {
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index d248671d6ed..e6aebab2a3e 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -34,7 +34,7 @@ namespace ScummVMCloud {
class ScummVMCloud: public DLC::Store {
-Networking::Session session;
+Networking::SessionRequest *_rq;
public:
ScummVMCloud() {}
Commit: 7dc5facd719c021890d9074837997f2acd190e1b
https://github.com/scummvm/scummvm/commit/7dc5facd719c021890d9074837997f2acd190e1b
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Extend preprocessor directives to support Windows in SummVMCloud::removeCacheFile
Changed paths:
backends/dlc/scummvmcloud.cpp
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index fa8877f755b..62d05630e3f 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -129,9 +129,13 @@ void ScummVMCloud::extractZip(Common::Path file) {
void ScummVMCloud::removeCacheFile(Common::Path file) {
Common::Path dlcPath = Common::Path(ConfMan.get("iconspath"));
Common::Path fileToDelete = dlcPath.join(file);
- #if defined(POSIX)
+#if defined(POSIX)
unlink(fileToDelete.toString().c_str());
- #endif
+#elif defined(WIN32)
+ _unlink(fileToDelete.toString().c_str());
+#else
+ warning("ScummVMCloud::removeCacheFile(): Removing is unimplemented");
+#endif
}
} // End of namespace ScummVMCloud
Commit: 2c987fbba54324fbcfd3c1494988e6dafae14c2c
https://github.com/scummvm/scummvm/commit/2c987fbba54324fbcfd3c1494988e6dafae14c2c
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Fix graying out DLCs to use String for id
Changed paths:
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
gui/download-games-dialog.cpp
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 53369cdfb4f..370f1b3a102 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -94,4 +94,11 @@ Common::String DLCManager::getCurrentDownloadingDLC() {
return _currentDownloadingDLC;
}
+int DLCManager::getDLCIdxFromId(const Common::String &id) {
+ for (int i = 0; i < _dlcs.size(); ++i) {
+ if (_dlcs[i]->id == id) return i;
+ }
+ return -1;
+}
+
} // End of namespace DLC
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 1b3f1c80331..a3428a80a60 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -63,6 +63,8 @@ public:
Common::String getCurrentDownloadingDLC();
+ int getDLCIdxFromId(const Common::String &id);
+
void startDownloadAsync(const Common::String &id, const Common::String &url);
void errorCallback(Networking::ErrorResponse error);
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
index 15fe96e7b4f..1107d8bf8b7 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/download-games-dialog.cpp
@@ -51,10 +51,10 @@ DownloadGamesDialog::DownloadGamesDialog()
// Gray out already downloaded packages
for (Common::ConfigManager::DomainMap::iterator domain = ConfMan.beginGameDomains(); domain != ConfMan.endGameDomains(); ++domain) {
if (domain->_value.contains("download")) {
- Common::String val(domain->_value.getVal("download"));
- uint64 id = val.asUint64();
- if (id < games.size()) {
- games[id] = "\001C{alternate}" + games[id];
+ Common::String id = domain->_value.getVal("download");
+ int idx = DLCMan.getDLCIdxFromId(id);
+ if (idx != -1 && idx < games.size()) {
+ games[idx] = "\001C{alternate}" + games[idx];
}
}
}
Commit: 6a269c6b062ce0c680c1597ad97e1dc0e38ab0ac
https://github.com/scummvm/scummvm/commit/6a269c6b062ce0c680c1597ad97e1dc0e38ab0ac
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Implement get DLC list on request and redraw dialog once DLCs are fetched
This commit will add functionality to only fetch the DLCs from the server
on clicking the button for browsing DLCs. Before, we were fetching the DLCs on start.
The dialog will redraw once the DLCs are fetched. The fetched DLCs are cached.
Changed paths:
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
backends/dlc/store.h
gui/download-games-dialog.cpp
gui/download-games-dialog.h
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 370f1b3a102..c6fd57cd1f9 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -25,6 +25,7 @@
#include "backends/dlc/scummvmcloud.h"
#include "backends/dlc/android/playstore.h"
#include "common/system.h"
+#include "gui/download-games-dialog.h"
namespace Common {
@@ -34,18 +35,20 @@ DECLARE_SINGLETON(DLC::DLCManager);
namespace DLC {
-DLCManager::DLCManager() {
+DLCManager::DLCManager(): CommandSender(nullptr) {
// _store = g_system->getDLCStore();
// TODO: Handle creation through getDLCStore()
_store = new DLC::ScummVMCloud::ScummVMCloud();
}
-void DLCManager::init() {
- DLCManager::getAllDLCs(_dlcs);
+void DLCManager::init() {}
+
+void DLCManager::getAllDLCs() {
+ _store->getAllDLCs();
}
-void DLCManager::getAllDLCs(Common::Array<DLCDesc*> &dlcs) {
- _store->getAllDLCs(dlcs);
+void DLCManager::refreshDLCList() {
+ sendCommand(GUI::kRefreshDLCList, 0);
}
void DLCManager::addDownload(uint32 idx) {
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index a3428a80a60..16a8274ac33 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -29,10 +29,11 @@
#include "backends/dlc/store.h"
#include "backends/dlc/dlcdesc.h"
#include "backends/networking/curl/request.h"
+#include "gui/object.h"
namespace DLC {
-class DLCManager : public Common::Singleton<DLCManager> {
+class DLCManager : public Common::Singleton<DLCManager>, public GUI::CommandSender {
Store *_store;
@@ -40,6 +41,7 @@ class DLCManager : public Common::Singleton<DLCManager> {
Common::String _currentDownloadingDLC;
public:
+ bool _fetchDLCs = false;
Common::Array<DLCDesc*> _dlcs;
Common::Queue<DLCDesc*> _queuedDownloadTasks;
@@ -48,8 +50,10 @@ public:
void init();
- // Runs only once in init()
- void getAllDLCs(Common::Array<DLCDesc*> &dlcs);
+ // Runs only once
+ void getAllDLCs();
+
+ void refreshDLCList();
// Add download task to queue, runs on click download button,
void addDownload(uint32 idx);
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index 62d05630e3f..c50c332965a 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -60,13 +60,15 @@ void ScummVMCloud::jsonCallbackGetAllDLCs(Networking::JsonResponse response) {
DLCMan._dlcs.push_back(new DLCDesc{name, id, url, size, i, DLCDesc::kAvailable});
}
}
+ // send refresh DLC list command to GUI
+ DLCMan.refreshDLCList();
}
void ScummVMCloud::errorCallbackGetAllDLCs(Networking::ErrorResponse error) {
warning("JsonRequest Error - getAllDLCs");
}
-void ScummVMCloud::getAllDLCs(Common::Array<DLCDesc*> &dlcs) {
+void ScummVMCloud::getAllDLCs() {
Common::String url("https://mocki.io/v1/0d86064d-1c04-41c8-a7b0-7e7e044b9b58"); // temporary mock api
Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(
new Common::Callback<ScummVMCloud, Networking::JsonResponse>(this, &ScummVMCloud::jsonCallbackGetAllDLCs),
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index e6aebab2a3e..6d8fa977204 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -52,7 +52,7 @@ public:
virtual void cancelDownload() override {}
- virtual void getAllDLCs(Common::Array<DLCDesc*> &dlcs) override;
+ virtual void getAllDLCs() override;
virtual void startDownloadAsync(const Common::String &id, const Common::String &url) override;
diff --git a/backends/dlc/store.h b/backends/dlc/store.h
index d0d35ae3b0d..6e7f4319f45 100644
--- a/backends/dlc/store.h
+++ b/backends/dlc/store.h
@@ -48,7 +48,7 @@ public:
virtual void cancelDownload() = 0;
- virtual void getAllDLCs(Common::Array<DLCDesc*> &dlcs) = 0;
+ virtual void getAllDLCs() = 0;
virtual void startDownloadAsync(const Common::String &id, const Common::String &url) = 0;
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
index 1107d8bf8b7..6cade6de66a 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/download-games-dialog.cpp
@@ -23,17 +23,17 @@
#include "gui/message.h"
#include "gui/widget.h"
#include "gui/widgets/list.h"
+#include "gui/gui-manager.h"
#include "common/translation.h"
#include "backends/dlc/dlcmanager.h"
namespace GUI {
-enum {
- kDownloadSelectedCmd = 'DWNS',
-};
-
DownloadGamesDialog::DownloadGamesDialog()
: Dialog("DownloadGames") {
+
+ // Set target (Command Receiver) for Command Sender
+ DLCMan.setTarget(this);
new StaticTextWidget(this, "DownloadGames.Headline", _("Download Freeware Games"));
@@ -42,6 +42,22 @@ DownloadGamesDialog::DownloadGamesDialog()
_gamesList->setNumberingMode(kListNumberingOff);
_gamesList->setEditable(false);
+ if (!DLCMan._fetchDLCs) {
+ DLCMan.getAllDLCs();
+ DLCMan._fetchDLCs = true;
+ Common::U32StringArray fetchingText = {
+ _("Fetching DLCs..."),
+ };
+ _gamesList->setList(fetchingText);
+ } else {
+ refreshDLCList();
+ }
+
+ new ButtonWidget(this, "DownloadGames.Back", _("Back"), Common::U32String(), kCloseCmd);
+ new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
+}
+
+void DownloadGamesDialog::refreshDLCList() {
// Populate the ListWidget
Common::U32StringArray games;
for (int i = 0; i < DLCMan._dlcs.size(); ++i) {
@@ -60,20 +76,21 @@ DownloadGamesDialog::DownloadGamesDialog()
}
_gamesList->setList(games);
-
- new ButtonWidget(this, "DownloadGames.Back", _("Back"), Common::U32String(), kCloseCmd);
- new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
+ g_gui.scheduleTopDialogRedraw();
}
void DownloadGamesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
- //Search for typed-in directory
case kDownloadSelectedCmd: {
MessageDialog dialog("Downloading: " + _gamesList->getSelectedString());
dialog.runModal();
DLCMan.addDownload(_gamesList->getSelected());
}
break;
+ case kRefreshDLCList: {
+ refreshDLCList();
+ }
+ break;
default:
Dialog::handleCommand(sender, cmd, data);
}
diff --git a/gui/download-games-dialog.h b/gui/download-games-dialog.h
index 2a556bfcc07..3afd4113ba3 100644
--- a/gui/download-games-dialog.h
+++ b/gui/download-games-dialog.h
@@ -27,14 +27,21 @@
namespace GUI {
+enum {
+ kDownloadSelectedCmd = 'DWNS',
+ kRefreshDLCList = 'RDLC',
+};
+
class DownloadGamesDialog : public Dialog {
public:
DownloadGamesDialog();
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
+ void refreshDLCList();
+
private:
- ListWidget *_gamesList;
+ ListWidget *_gamesList;
};
} // End of namespace GUI
Commit: 86f01bcd45748bfe58d8e2a10d1da1aa298f19ee
https://github.com/scummvm/scummvm/commit/86f01bcd45748bfe58d8e2a10d1da1aa298f19ee
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Improve ScummVMCloud::extractZip()
- Extract each game in it's own directory based on it's name
- Add extra parameter to pass the destination path
Changed paths:
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index c50c332965a..81f3ee30692 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -28,6 +28,7 @@
#include "common/archive.h"
#include "common/compression/unzip.h"
#include "common/file.h"
+#include "common/punycode.h"
#include "backends/dlc/scummvmcloud.h"
#include "backends/dlc/dlcmanager.h"
#include "common/config-manager.h"
@@ -85,7 +86,9 @@ void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
_rq->close(); // delete request
Common::Path relativeFilePath = Common::Path(DLCMan._queuedDownloadTasks.front()->id);
// extract the downloaded zip
- extractZip(relativeFilePath);
+ Common::String gameDir = Common::punycode_encodefilename(DLCMan._queuedDownloadTasks.front()->name);
+ Common::Path destPath = Common::Path(ConfMan.get("iconspath")).appendComponent(gameDir);
+ extractZip(relativeFilePath, destPath);
// remove cache (the downloaded .zip)
removeCacheFile(relativeFilePath);
// handle next download
@@ -113,7 +116,7 @@ void ScummVMCloud::startDownloadAsync(const Common::String &id, const Common::St
_rq->start();
}
-void ScummVMCloud::extractZip(Common::Path file) {
+void ScummVMCloud::extractZip(const Common::Path &file, const Common::Path &destPath) {
Common::Archive *dataArchive = nullptr;
Common::Path dlcPath = Common::Path(ConfMan.get("iconspath"));
Common::FSNode *fs = new Common::FSNode(dlcPath.join(file));
@@ -121,7 +124,7 @@ void ScummVMCloud::extractZip(Common::Path file) {
dataArchive = Common::makeZipArchive(*fs);
// dataArchive is nullptr if zip file is incomplete
if (dataArchive != nullptr) {
- dataArchive->dumpArchive(dlcPath.toString());
+ dataArchive->dumpArchive(destPath.toString());
}
}
delete fs;
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index 6d8fa977204..37e63687bc2 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -58,7 +58,8 @@ public:
virtual void removeCacheFile(Common::Path file) override;
- void extractZip(Common::Path file);
+ // extracts the provided zip in the provided destination path
+ void extractZip(const Common::Path &file, const Common::Path &destPath);
// callback functions
void jsonCallbackGetAllDLCs(Networking::JsonResponse response);
Commit: c0800f5eda7d19900fc82387b146006bb8d5a70d
https://github.com/scummvm/scummvm/commit/c0800f5eda7d19900fc82387b146006bb8d5a70d
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Add more members in DLCDesc
Changed paths:
backends/dlc/dlcdesc.h
backends/dlc/scummvmcloud.cpp
diff --git a/backends/dlc/dlcdesc.h b/backends/dlc/dlcdesc.h
index 1ff183235ba..b25cc4949e4 100644
--- a/backends/dlc/dlcdesc.h
+++ b/backends/dlc/dlcdesc.h
@@ -39,6 +39,13 @@ public:
Common::String name;
Common::String id;
Common::String url;
+ Common::String platform;
+ Common::String gameid;
+ Common::String description;
+ Common::String language;
+ Common::String extra;
+ Common::String engineid;
+ Common::String guioptions;
uint32 size;
uint32 idx;
State state;
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index 81f3ee30692..4da64a94313 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -52,13 +52,20 @@ void ScummVMCloud::jsonCallbackGetAllDLCs(Networking::JsonResponse response) {
Common::String id = item.getVal("id")->asString();
Common::String name = item.getVal("name")->asString();
Common::String url = item.getVal("url")->asString();
+ Common::String platform = item.getVal("platform")->asString();
+ Common::String gameid = item.getVal("gameid")->asString();
+ Common::String description = item.getVal("description")->asString();
+ Common::String language = item.getVal("language")->asString();
+ Common::String extra = item.getVal("extra")->asString();
+ Common::String engineid = item.getVal("engineid")->asString();
+ Common::String guioptions = item.getVal("guioptions")->asString();
uint32 size;
if (item.getVal("size")->isString()) {
size = item.getVal("size")->asString().asUint64();
} else {
size = item.getVal("size")->asIntegerNumber();
}
- DLCMan._dlcs.push_back(new DLCDesc{name, id, url, size, i, DLCDesc::kAvailable});
+ DLCMan._dlcs.push_back(new DLCDesc{name, id, url, platform, gameid, description, language, extra, engineid, guioptions, size, i, DLCDesc::kAvailable});
}
}
// send refresh DLC list command to GUI
@@ -70,7 +77,7 @@ void ScummVMCloud::errorCallbackGetAllDLCs(Networking::ErrorResponse error) {
}
void ScummVMCloud::getAllDLCs() {
- Common::String url("https://mocki.io/v1/0d86064d-1c04-41c8-a7b0-7e7e044b9b58"); // temporary mock api
+ Common::String url("https://scummvm-dlcs-default-rtdb.firebaseio.com/dlcs.json"); // temporary mock api
Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(
new Common::Callback<ScummVMCloud, Networking::JsonResponse>(this, &ScummVMCloud::jsonCallbackGetAllDLCs),
new Common::Callback<ScummVMCloud, Networking::ErrorResponse>(this, &ScummVMCloud::errorCallbackGetAllDLCs),
Commit: a344e7e43fbd07966555018d97d4a83a585d23b6
https://github.com/scummvm/scummvm/commit/a344e7e43fbd07966555018d97d4a83a585d23b6
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Implement auto addition of DLC entry in ScummVM config after download
Changed paths:
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
gui/download-games-dialog.cpp
gui/download-games-dialog.h
gui/launcher.cpp
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index c6fd57cd1f9..d7d180c3397 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -51,6 +51,10 @@ void DLCManager::refreshDLCList() {
sendCommand(GUI::kRefreshDLCList, 0);
}
+void DLCManager::refreshLauncherGameList() {
+ sendCommand(GUI::kRefreshLauncher, 0);
+}
+
void DLCManager::addDownload(uint32 idx) {
_dlcs[idx]->state = DLCDesc::kInProgress;
_queuedDownloadTasks.push(_dlcs[idx]);
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 16a8274ac33..78aed85b7ae 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -55,6 +55,8 @@ public:
void refreshDLCList();
+ void refreshLauncherGameList();
+
// Add download task to queue, runs on click download button,
void addDownload(uint32 idx);
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index 4da64a94313..dcd6c6c0a2e 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -33,6 +33,8 @@
#include "backends/dlc/dlcmanager.h"
#include "common/config-manager.h"
#include "common/formats/json.h"
+#include "engines/metaengine.h"
+#include "gui/gui-manager.h"
namespace DLC {
namespace ScummVMCloud {
@@ -98,6 +100,8 @@ void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
extractZip(relativeFilePath, destPath);
// remove cache (the downloaded .zip)
removeCacheFile(relativeFilePath);
+ // add downloaded game entry in scummvm configuration file
+ addEntryToConfig(destPath);
// handle next download
DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kDownloaded;
DLCMan._queuedDownloadTasks.pop();
@@ -150,5 +154,33 @@ void ScummVMCloud::removeCacheFile(Common::Path file) {
#endif
}
+void ScummVMCloud::addEntryToConfig(Common::Path gamePath) {
+ Common::FSNode dir(gamePath);
+ Common::FSList fsnodes;
+ if (!dir.getChildren(fsnodes, Common::FSNode::kListAll)) {
+ warning("ScummVMCloud::addEntryToConfig(): Game directory does not exists");
+ return;
+ }
+ if (fsnodes.size() == 1 && fsnodes[0].isDirectory()) {
+ // if extraction process created a new folder inside gamePath, set gamePath to that directory
+ gamePath = gamePath.appendComponent(fsnodes[0].getFileName());
+ }
+ // add a new entry in scummvm config file
+ Common::String domain = EngineMan.generateUniqueDomain(DLCMan._queuedDownloadTasks.front()->gameid);
+ ConfMan.addGameDomain(domain);
+ ConfMan.set("engineid", DLCMan._queuedDownloadTasks.front()->engineid, domain);
+ ConfMan.set("gameid", DLCMan._queuedDownloadTasks.front()->gameid, domain);
+ ConfMan.set("description", DLCMan._queuedDownloadTasks.front()->description, domain);
+ ConfMan.set("language", DLCMan._queuedDownloadTasks.front()->language, domain);
+ ConfMan.set("platform", DLCMan._queuedDownloadTasks.front()->platform, domain);
+ ConfMan.set("path", gamePath.toString(), domain);
+ ConfMan.set("extra", DLCMan._queuedDownloadTasks.front()->extra, domain);
+ ConfMan.set("guioptions", DLCMan._queuedDownloadTasks.front()->guioptions, domain);
+ ConfMan.set("download", DLCMan._queuedDownloadTasks.front()->id, domain);
+
+ // send refresh launcher command to GUI
+ DLCMan.refreshLauncherGameList();
+}
+
} // End of namespace ScummVMCloud
} // End of namespace DLC
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index 37e63687bc2..d5509855f26 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -61,6 +61,8 @@ public:
// extracts the provided zip in the provided destination path
void extractZip(const Common::Path &file, const Common::Path &destPath);
+ void addEntryToConfig(Common::Path gamePath);
+
// callback functions
void jsonCallbackGetAllDLCs(Networking::JsonResponse response);
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
index 6cade6de66a..2625cdc0063 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/download-games-dialog.cpp
@@ -29,8 +29,8 @@
namespace GUI {
-DownloadGamesDialog::DownloadGamesDialog()
- : Dialog("DownloadGames") {
+DownloadGamesDialog::DownloadGamesDialog(LauncherDialog *launcher)
+ : Dialog("DownloadGames"), _launcher(launcher) {
// Set target (Command Receiver) for Command Sender
DLCMan.setTarget(this);
@@ -91,6 +91,10 @@ void DownloadGamesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
refreshDLCList();
}
break;
+ case kRefreshLauncher: {
+ _launcher->rebuild();
+ }
+ break;
default:
Dialog::handleCommand(sender, cmd, data);
}
diff --git a/gui/download-games-dialog.h b/gui/download-games-dialog.h
index 3afd4113ba3..68640e8d1e4 100644
--- a/gui/download-games-dialog.h
+++ b/gui/download-games-dialog.h
@@ -24,17 +24,19 @@
#include "gui/dialog.h"
#include "gui/widgets/list.h"
+#include "gui/launcher.h"
namespace GUI {
enum {
kDownloadSelectedCmd = 'DWNS',
kRefreshDLCList = 'RDLC',
+ kRefreshLauncher = 'RFLR'
};
class DownloadGamesDialog : public Dialog {
public:
- DownloadGamesDialog();
+ DownloadGamesDialog(LauncherDialog *launcher);
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
@@ -42,6 +44,7 @@ public:
private:
ListWidget *_gamesList;
+ LauncherDialog *_launcher;
};
} // End of namespace GUI
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 3aac8b46ca4..cb4ac01c05c 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -735,7 +735,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
massAddGame();
break;
case kDownloadGameCmd: {
- DownloadGamesDialog downloader;
+ DownloadGamesDialog downloader(this);
downloader.runModal();
}
break;
Commit: b4438f744ad992cdd301e514762ccf1445e17990
https://github.com/scummvm/scummvm/commit/b4438f744ad992cdd301e514762ccf1445e17990
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Create dlcspath for storing DLCs
Changed paths:
backends/dlc/scummvmcloud.cpp
backends/platform/sdl/macosx/macosx.cpp
backends/platform/sdl/macosx/macosx.h
backends/platform/sdl/posix/posix.cpp
backends/platform/sdl/posix/posix.h
backends/platform/sdl/sdl.cpp
backends/platform/sdl/sdl.h
backends/platform/sdl/win32/win32.cpp
backends/platform/sdl/win32/win32.h
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index dcd6c6c0a2e..eb90478a55e 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -96,7 +96,7 @@ void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
Common::Path relativeFilePath = Common::Path(DLCMan._queuedDownloadTasks.front()->id);
// extract the downloaded zip
Common::String gameDir = Common::punycode_encodefilename(DLCMan._queuedDownloadTasks.front()->name);
- Common::Path destPath = Common::Path(ConfMan.get("iconspath")).appendComponent(gameDir);
+ Common::Path destPath = Common::Path(ConfMan.get("dlcspath")).appendComponent(gameDir);
extractZip(relativeFilePath, destPath);
// remove cache (the downloaded .zip)
removeCacheFile(relativeFilePath);
@@ -117,8 +117,7 @@ void ScummVMCloud::errorCallback(Networking::ErrorResponse error) {
}
void ScummVMCloud::startDownloadAsync(const Common::String &id, const Common::String &url) {
- // TODO: Change it to dlcpath
- Common::String localFile = normalizePath(ConfMan.get("iconspath") + "/" + id, '/');
+ Common::String localFile = normalizePath(ConfMan.get("dlcspath") + "/" + id, '/');
_rq = new Networking::SessionRequest(url, localFile,
new Common::Callback<ScummVMCloud, Networking::DataResponse>(this, &ScummVMCloud::downloadFileCallback),
@@ -129,7 +128,7 @@ void ScummVMCloud::startDownloadAsync(const Common::String &id, const Common::St
void ScummVMCloud::extractZip(const Common::Path &file, const Common::Path &destPath) {
Common::Archive *dataArchive = nullptr;
- Common::Path dlcPath = Common::Path(ConfMan.get("iconspath"));
+ Common::Path dlcPath = Common::Path(ConfMan.get("dlcspath"));
Common::FSNode *fs = new Common::FSNode(dlcPath.join(file));
if (fs->exists()) {
dataArchive = Common::makeZipArchive(*fs);
@@ -143,7 +142,7 @@ void ScummVMCloud::extractZip(const Common::Path &file, const Common::Path &dest
}
void ScummVMCloud::removeCacheFile(Common::Path file) {
- Common::Path dlcPath = Common::Path(ConfMan.get("iconspath"));
+ Common::Path dlcPath = Common::Path(ConfMan.get("dlcspath"));
Common::Path fileToDelete = dlcPath.join(file);
#if defined(POSIX)
unlink(fileToDelete.toString().c_str());
diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index 165efc2db20..f821b558274 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -261,6 +261,16 @@ Common::String OSystem_MacOSX::getDefaultIconsPath() {
return defaultIconsPath;
}
+Common::String OSystem_MacOSX::getDefaultDLCsPath() {
+ const Common::String defaultDLCsPath = getAppSupportPathMacOSX() + "/DLCs";
+
+ if (!Posix::assureDirectoryExists(defaultDLCsPath)) {
+ return Common::String();
+ }
+
+ return defaultDLCsPath;
+}
+
Common::String OSystem_MacOSX::getScreenshotsPath() {
// If the user has configured a screenshots path, use it
const Common::String path = OSystem_SDL::getScreenshotsPath();
diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h
index 40235b87d21..41bf8723eb8 100644
--- a/backends/platform/sdl/macosx/macosx.h
+++ b/backends/platform/sdl/macosx/macosx.h
@@ -51,6 +51,7 @@ public:
// Default paths
Common::String getDefaultIconsPath() override;
+ Common::String getDefaultDLCsPath() override;
Common::String getScreenshotsPath() override;
protected:
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
index b5fe6ad237d..e33b5ee9657 100644
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -260,6 +260,31 @@ Common::String OSystem_POSIX::getDefaultIconsPath() {
return Common::String::format("%s/%s", prefix, iconsPath.c_str());
}
+Common::String OSystem_POSIX::getDefaultDLCsPath() {
+ Common::String dlcsPath;
+
+ // On POSIX systems we follow the XDG Base Directory Specification for
+ // where to store files. The version we based our code upon can be found
+ // over here: https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.8.html
+ const char *prefix = getenv("XDG_CACHE_HOME");
+ if (prefix == nullptr || !*prefix) {
+ prefix = getenv("HOME");
+ if (prefix == nullptr) {
+ return Common::String();
+ }
+
+ dlcsPath = ".cache/";
+ }
+
+ dlcsPath += "scummvm/dlcs";
+
+ if (!Posix::assureDirectoryExists(dlcsPath, prefix)) {
+ return Common::String();
+ }
+
+ return Common::String::format("%s/%s", prefix, dlcsPath.c_str());
+}
+
Common::String OSystem_POSIX::getScreenshotsPath() {
// If the user has configured a screenshots path, use it
const Common::String path = OSystem_SDL::getScreenshotsPath();
diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h
index 5623a8c84d6..f260762eec3 100644
--- a/backends/platform/sdl/posix/posix.h
+++ b/backends/platform/sdl/posix/posix.h
@@ -37,6 +37,7 @@ public:
// Default paths
Common::String getDefaultIconsPath() override;
+ Common::String getDefaultDLCsPath() override;
Common::String getScreenshotsPath() override;
protected:
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 35a02a1e01f..9425464f917 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -314,6 +314,7 @@ void OSystem_SDL::initBackend() {
#endif
ConfMan.registerDefault("iconspath", this->getDefaultIconsPath());
+ ConfMan.registerDefault("dlcspath", this->getDefaultDLCsPath());
_inited = true;
@@ -788,6 +789,14 @@ Common::String OSystem_SDL::getDefaultIconsPath() {
return path;
}
+// Not specified in base class
+Common::String OSystem_SDL::getDefaultDLCsPath() {
+ Common::String path = ConfMan.get("dlcspath");
+ if (!path.empty() && !path.hasSuffix("/"))
+ path += "/";
+ return path;
+}
+
//Not specified in base class
Common::String OSystem_SDL::getScreenshotsPath() {
Common::String path = ConfMan.get("screenshotpath");
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 450a6f28d98..c756a8dc054 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -93,6 +93,7 @@ public:
// Default paths
virtual Common::String getDefaultIconsPath();
+ virtual Common::String getDefaultDLCsPath();
virtual Common::String getScreenshotsPath();
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index 088f65c1fb8..bc2a3b0a98b 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -274,6 +274,24 @@ Common::String OSystem_Win32::getDefaultIconsPath() {
return Win32::tcharToString(iconsPath);
}
+Common::String OSystem_Win32::getDefaultDLCsPath() {
+ TCHAR dlcsPath[MAX_PATH];
+
+ if (_isPortable) {
+ Win32::getProcessDirectory(dlcsPath, MAX_PATH);
+ _tcscat(dlcsPath, TEXT("\\DLCs\\"));
+ } else {
+ // Use the Application Data directory of the user profile
+ if (!Win32::getApplicationDataDirectory(dlcsPath)) {
+ return Common::String();
+ }
+ _tcscat(dlcsPath, TEXT("\\DLCs\\"));
+ CreateDirectory(dlcsPath, nullptr);
+ }
+
+ return Win32::tcharToString(dlcsPath);
+}
+
Common::String OSystem_Win32::getScreenshotsPath() {
// If the user has configured a screenshots path, use it
Common::String screenshotsPath = ConfMan.get("screenshotpath");
diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h
index dd8a4cc0689..e80cdcefeb4 100644
--- a/backends/platform/sdl/win32/win32.h
+++ b/backends/platform/sdl/win32/win32.h
@@ -50,6 +50,7 @@ public:
// Default paths
Common::String getDefaultIconsPath() override;
+ Common::String getDefaultDLCsPath() override;
Common::String getScreenshotsPath() override;
protected:
Commit: 750a196c059be2fd531efc5d1aa1b3852ae83361
https://github.com/scummvm/scummvm/commit/750a196c059be2fd531efc5d1aa1b3852ae83361
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Remove CommandSender's target when DLC dialog is destructed
- This will prevent segmentation fault when a command is sent after
the dialog is closed
Changed paths:
gui/download-games-dialog.cpp
gui/download-games-dialog.h
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
index 2625cdc0063..4ed294491ac 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/download-games-dialog.cpp
@@ -57,6 +57,10 @@ DownloadGamesDialog::DownloadGamesDialog(LauncherDialog *launcher)
new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
}
+DownloadGamesDialog::~DownloadGamesDialog() {
+ DLCMan.setTarget(nullptr);
+}
+
void DownloadGamesDialog::refreshDLCList() {
// Populate the ListWidget
Common::U32StringArray games;
diff --git a/gui/download-games-dialog.h b/gui/download-games-dialog.h
index 68640e8d1e4..81e6d7a302d 100644
--- a/gui/download-games-dialog.h
+++ b/gui/download-games-dialog.h
@@ -37,6 +37,7 @@ enum {
class DownloadGamesDialog : public Dialog {
public:
DownloadGamesDialog(LauncherDialog *launcher);
+ ~DownloadGamesDialog() override;
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
Commit: f976ecded4f8c52841769bb1e71d84ce8254993c
https://github.com/scummvm/scummvm/commit/f976ecded4f8c52841769bb1e71d84ce8254993c
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Initial code to show DLC download progress
Changed paths:
A gui/downloaddlcsdialog.cpp
A gui/downloaddlcsdialog.h
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
gui/download-games-dialog.cpp
gui/download-games-dialog.h
gui/module.mk
gui/themes/common/highres_layout.stx
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index d7d180c3397..e642ac8253e 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -65,6 +65,7 @@ void DLCManager::addDownload(uint32 idx) {
}
void DLCManager::processDownloadQueue() {
+ _currentDownloadedSize = 0;
_isDLCDownloading = true;
if (!_queuedDownloadTasks.empty()) {
if (_queuedDownloadTasks.front()->state == DLCDesc::kInProgress) {
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 78aed85b7ae..b5448b49214 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -42,6 +42,7 @@ class DLCManager : public Common::Singleton<DLCManager>, public GUI::CommandSend
public:
bool _fetchDLCs = false;
+ uint32 _currentDownloadedSize;
Common::Array<DLCDesc*> _dlcs;
Common::Queue<DLCDesc*> _queuedDownloadTasks;
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index eb90478a55e..1df9d3ad204 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -90,6 +90,7 @@ void ScummVMCloud::getAllDLCs() {
void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
Networking::SessionFileResponse *response = static_cast<Networking::SessionFileResponse *>(r.value);
+ DLCMan._currentDownloadedSize += response->len;
if (response->eos) {
warning("downloaded");
_rq->close(); // delete request
diff --git a/gui/download-games-dialog.cpp b/gui/download-games-dialog.cpp
index 4ed294491ac..665626be2e9 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/download-games-dialog.cpp
@@ -24,6 +24,7 @@
#include "gui/widget.h"
#include "gui/widgets/list.h"
#include "gui/gui-manager.h"
+#include "gui/downloaddlcsdialog.h"
#include "common/translation.h"
#include "backends/dlc/dlcmanager.h"
@@ -54,6 +55,7 @@ DownloadGamesDialog::DownloadGamesDialog(LauncherDialog *launcher)
}
new ButtonWidget(this, "DownloadGames.Back", _("Back"), Common::U32String(), kCloseCmd);
+ new ButtonWidget(this, "DownloadGames.AllDownloads", _("All Downloads"), Common::U32String(), kAllDownloadsCmd);
new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
}
@@ -85,6 +87,11 @@ void DownloadGamesDialog::refreshDLCList() {
void DownloadGamesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
+ case kAllDownloadsCmd: {
+ DownloadDLCsDialog dialog;
+ dialog.runModal();
+ }
+ break;
case kDownloadSelectedCmd: {
MessageDialog dialog("Downloading: " + _gamesList->getSelectedString());
dialog.runModal();
diff --git a/gui/download-games-dialog.h b/gui/download-games-dialog.h
index 81e6d7a302d..8083589e13a 100644
--- a/gui/download-games-dialog.h
+++ b/gui/download-games-dialog.h
@@ -31,7 +31,8 @@ namespace GUI {
enum {
kDownloadSelectedCmd = 'DWNS',
kRefreshDLCList = 'RDLC',
- kRefreshLauncher = 'RFLR'
+ kRefreshLauncher = 'RFLR',
+ kAllDownloadsCmd = 'ALLD'
};
class DownloadGamesDialog : public Dialog {
diff --git a/gui/downloaddlcsdialog.cpp b/gui/downloaddlcsdialog.cpp
new file mode 100644
index 00000000000..0c980980f4b
--- /dev/null
+++ b/gui/downloaddlcsdialog.cpp
@@ -0,0 +1,138 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/translation.h"
+
+#include "gui/downloaddlcsdialog.h"
+#include "gui/widget.h"
+#include "gui/gui-manager.h"
+
+#include "backends/dlc/dlcmanager.h"
+#include "backends/dlc/dlcdesc.h"
+
+namespace GUI {
+
+DownloadDLCsDialog::DownloadDLCsDialog()
+ : Dialog("DLCDownloads") {
+
+ new StaticTextWidget(this, "DLCDownloads.Headline", _("Currently Downloading Games"));
+
+ _currentDownloadLabel = new StaticTextWidget(this, "DLCDownloads.CurrentDownload", Common::U32String());
+
+ _progressBar = new SliderWidget(this, "DLCDownloads.ProgressBar");
+ _progressBar->setMinValue(0);
+ _progressBar->setMaxValue(100);
+ _progressBar->setValue(0);
+ _progressBar->setEnabled(false);
+
+ _percentLabel = new StaticTextWidget(this, "DLCDownloads.PercentText", Common::String());
+ _downloadedSizeLabel = new StaticTextWidget(this, "DLCDownloads.DownloadedSize", Common::U32String());
+
+ new StaticTextWidget(this, "DLCDownloads.Pending", _("Pending Downloads"));
+ _pendingDownloadsList = new ListWidget(this, "DLCDownloads.List");
+ _pendingDownloadsList->setNumberingMode(kListNumberingOff);
+ _pendingDownloadsList->setEditable(false);
+
+ new ButtonWidget(this, "DLCDownloads.Back", _("Back"), Common::U32String(), kCloseCmd);
+ _cancelButton = new ButtonWidget(this, "DLCDownloads.Cancel", _("Cancel"), Common::U32String(), kCancelSelectedCmd);
+
+ refreshWidgets();
+}
+
+Common::U32String DownloadDLCsDialog::getSizeLabelText() {
+ const char *downloadedUnits, *totalUnits;
+ Common::String downloaded = Common::getHumanReadableBytes(DLCMan._currentDownloadedSize, downloadedUnits);
+ Common::String total = Common::getHumanReadableBytes(DLCMan._queuedDownloadTasks.front()->size, totalUnits);
+ return Common::U32String::format(_("Downloaded %s %S / %s %S"), downloaded.c_str(), _(downloadedUnits).c_str(), total.c_str(), _(totalUnits).c_str());
+}
+
+uint32 DownloadDLCsDialog::getDownloadingProgress() {
+ if (DLCMan._queuedDownloadTasks.empty()) {
+ // no DLC is currently downloading
+ return 0;
+ }
+ uint32 progress = (uint32)(100 * ((double)DLCMan._currentDownloadedSize / (double)DLCMan._queuedDownloadTasks.front()->size));
+ return progress;
+}
+
+void DownloadDLCsDialog::refreshWidgets() {
+ Common::U32StringArray pendingList;
+ if (DLCMan._queuedDownloadTasks.empty()) {
+ // no DLC is currently downloading
+ _currentDownloadLabel->setLabel(Common::U32String("No downloads in progress"));
+ _downloadedSizeLabel->setLabel(Common::U32String());
+ _pendingDownloadsList->setList(pendingList);
+ } else {
+ _currentDownloadLabel->setLabel(DLCMan._queuedDownloadTasks.front()->name);
+ _downloadedSizeLabel->setLabel(getSizeLabelText());
+
+ for (auto it : DLCMan._dlcs) {
+ if (it->state == DLC::DLCDesc::kInProgress) {
+ pendingList.push_back(it->name);
+ }
+ }
+ _pendingDownloadsList->setList(pendingList);
+ _pendingDownloadsList->setSelected(_selectedIdx);
+ }
+
+ uint32 progress = getDownloadingProgress();
+ _percentLabel->setLabel(Common::String::format("%u %%", progress));
+ _progressBar->setValue(progress);
+
+ g_gui.scheduleTopDialogRedraw();
+}
+
+void DownloadDLCsDialog::handleTickle() {
+ int32 progress = getDownloadingProgress();
+
+ if (_progressBar->getValue() != progress) {
+ _selectedIdx = _pendingDownloadsList->getSelected();
+ refreshWidgets();
+ }
+
+ // enable cancel button only when a list item is selected
+ if (_pendingDownloadsList->getSelected() == -1) {
+ if (_cancelButton->isEnabled()) {
+ _cancelButton->setEnabled(false);
+ g_gui.scheduleTopDialogRedraw();
+ }
+ } else {
+ if (!_cancelButton->isEnabled()) {
+ _cancelButton->setEnabled(true);
+ g_gui.scheduleTopDialogRedraw();
+ }
+ }
+
+ Dialog::handleTickle();
+}
+
+void DownloadDLCsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+ switch (cmd) {
+ case kCancelSelectedCmd: {
+ // set state of selected DLC to kCancelled
+ }
+ break;
+ default:
+ Dialog::handleCommand(sender, cmd, data);
+ }
+}
+
+} // End of namespace GUI
diff --git a/gui/downloaddlcsdialog.h b/gui/downloaddlcsdialog.h
new file mode 100644
index 00000000000..3a8e02965d9
--- /dev/null
+++ b/gui/downloaddlcsdialog.h
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DOWNLOAD_DLCS_DIALOG_H
+#define DOWNLOAD_DLCS_DIALOG_H
+
+#include "gui/dialog.h"
+#include "gui/widgets/list.h"
+
+namespace GUI {
+
+enum {
+ kCancelSelectedCmd = 'CANS',
+};
+
+class DownloadDLCsDialog : public Dialog {
+public:
+ DownloadDLCsDialog();
+
+ void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
+ void handleTickle() override;
+ uint32 getDownloadingProgress();
+
+private:
+ StaticTextWidget *_currentDownloadLabel;
+ StaticTextWidget *_downloadedSizeLabel;
+ StaticTextWidget *_percentLabel;
+ SliderWidget *_progressBar;
+ ListWidget *_pendingDownloadsList;
+ ButtonWidget *_cancelButton;
+
+ int _selectedIdx = -1;
+
+ Common::U32String getSizeLabelText();
+
+ void refreshWidgets();
+};
+
+} // End of namespace GUI
+
+#endif
diff --git a/gui/module.mk b/gui/module.mk
index 01cf562d1cd..7684134c9d9 100644
--- a/gui/module.mk
+++ b/gui/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS := \
debugger.o \
dialog.o \
download-games-dialog.o \
+ downloaddlcsdialog.o \
dump-all-dialogs.o \
editgamedialog.o \
error.o \
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index 15c68c76873..be60b8c0748 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -523,6 +523,9 @@
<widget name = 'Back'
type = 'Button'
/>
+ <widget name = 'AllDownloads'
+ type = 'Button'
+ />
<space/>
<widget name = 'Download'
type = 'Button'
@@ -531,6 +534,44 @@
</layout>
</dialog>
+ <dialog name = 'DLCDownloads' overlays = 'screen' inset = '32' shading = 'dim'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8'>
+ <widget name = 'Headline'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'CurrentDownload'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'ProgressBar'
+ height = 'Globals.Button.Height'
+ />
+ <space size = '1'/>
+ <widget name = 'PercentText'
+ height = 'Globals.Line.Height'
+ textalign = 'center'
+ />
+ <widget name = 'DownloadedSize'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'DownloadSpeed'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'Pending'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'List'/>
+ <layout type = 'horizontal' padding = '16, 16, 16, 16'>
+ <widget name = 'Back'
+ type = 'Button'
+ />
+ <space/>
+ <widget name = 'Cancel'
+ type = 'Button'
+ />
+ </layout>
+ </layout>
+ </dialog>
+
<dialog name = 'GlobalOptions' overlays = 'screen' inset = '32' shading = 'dim' resolution='x<800'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'TabWidget' type = 'TabWidget'/>
Commit: 5059b3072e761d8cf9973e78b64393a36484dd5f
https://github.com/scummvm/scummvm/commit/5059b3072e761d8cf9973e78b64393a36484dd5f
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Rename download-games-dialog to dlcsdialog
Changed paths:
A gui/dlcsdialog.cpp
A gui/dlcsdialog.h
R gui/download-games-dialog.cpp
R gui/download-games-dialog.h
backends/dlc/dlcmanager.cpp
gui/launcher.cpp
gui/module.mk
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index e642ac8253e..8f09298cf8a 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -25,7 +25,7 @@
#include "backends/dlc/scummvmcloud.h"
#include "backends/dlc/android/playstore.h"
#include "common/system.h"
-#include "gui/download-games-dialog.h"
+#include "gui/dlcsdialog.h"
namespace Common {
diff --git a/gui/download-games-dialog.cpp b/gui/dlcsdialog.cpp
similarity index 91%
rename from gui/download-games-dialog.cpp
rename to gui/dlcsdialog.cpp
index 665626be2e9..ba37b96fa69 100644
--- a/gui/download-games-dialog.cpp
+++ b/gui/dlcsdialog.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "gui/download-games-dialog.h"
+#include "gui/dlcsdialog.h"
#include "gui/message.h"
#include "gui/widget.h"
#include "gui/widgets/list.h"
@@ -30,7 +30,7 @@
namespace GUI {
-DownloadGamesDialog::DownloadGamesDialog(LauncherDialog *launcher)
+DLCsDialog::DLCsDialog(LauncherDialog *launcher)
: Dialog("DownloadGames"), _launcher(launcher) {
// Set target (Command Receiver) for Command Sender
@@ -59,11 +59,11 @@ DownloadGamesDialog::DownloadGamesDialog(LauncherDialog *launcher)
new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
}
-DownloadGamesDialog::~DownloadGamesDialog() {
+DLCsDialog::~DLCsDialog() {
DLCMan.setTarget(nullptr);
}
-void DownloadGamesDialog::refreshDLCList() {
+void DLCsDialog::refreshDLCList() {
// Populate the ListWidget
Common::U32StringArray games;
for (int i = 0; i < DLCMan._dlcs.size(); ++i) {
@@ -85,7 +85,7 @@ void DownloadGamesDialog::refreshDLCList() {
g_gui.scheduleTopDialogRedraw();
}
-void DownloadGamesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+void DLCsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kAllDownloadsCmd: {
DownloadDLCsDialog dialog;
diff --git a/gui/download-games-dialog.h b/gui/dlcsdialog.h
similarity index 87%
rename from gui/download-games-dialog.h
rename to gui/dlcsdialog.h
index 8083589e13a..66830a0d7f0 100644
--- a/gui/download-games-dialog.h
+++ b/gui/dlcsdialog.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef DOWNLOAD_GAMES_DIALOG_H
-#define DOWNLOAD_GAMES_DIALOG_H
+#ifndef DLCS_DIALOG_H
+#define DLCS_DIALOG_H
#include "gui/dialog.h"
#include "gui/widgets/list.h"
@@ -35,10 +35,10 @@ enum {
kAllDownloadsCmd = 'ALLD'
};
-class DownloadGamesDialog : public Dialog {
+class DLCsDialog : public Dialog {
public:
- DownloadGamesDialog(LauncherDialog *launcher);
- ~DownloadGamesDialog() override;
+ DLCsDialog(LauncherDialog *launcher);
+ ~DLCsDialog() override;
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index cb4ac01c05c..9a43e07f86c 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -32,7 +32,7 @@
#include "gui/about.h"
#include "gui/browser.h"
#include "gui/chooser.h"
-#include "gui/download-games-dialog.h"
+#include "gui/dlcsdialog.h"
#include "gui/editgamedialog.h"
#include "gui/launcher.h"
#include "gui/massadd.h"
@@ -735,7 +735,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
massAddGame();
break;
case kDownloadGameCmd: {
- DownloadGamesDialog downloader(this);
+ DLCsDialog downloader(this);
downloader.runModal();
}
break;
diff --git a/gui/module.mk b/gui/module.mk
index 7684134c9d9..7d574cff167 100644
--- a/gui/module.mk
+++ b/gui/module.mk
@@ -7,7 +7,7 @@ MODULE_OBJS := \
console.o \
debugger.o \
dialog.o \
- download-games-dialog.o \
+ dlcsdialog.o \
downloaddlcsdialog.o \
dump-all-dialogs.o \
editgamedialog.o \
Commit: 13dc800e964567dbe87501574a2cb61c4db0f15c
https://github.com/scummvm/scummvm/commit/13dc800e964567dbe87501574a2cb61c4db0f15c
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Implement interrupt/cancel pending DLC downloads
Changed paths:
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
gui/downloaddlcsdialog.cpp
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 8f09298cf8a..a331a5dc891 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -58,6 +58,7 @@ void DLCManager::refreshLauncherGameList() {
void DLCManager::addDownload(uint32 idx) {
_dlcs[idx]->state = DLCDesc::kInProgress;
_queuedDownloadTasks.push(_dlcs[idx]);
+ _dlcsInProgress.push_back(_dlcs[idx]);
if (!_isDLCDownloading) {
// if queue is not already processing
DLCManager::processDownloadQueue();
@@ -74,6 +75,7 @@ void DLCManager::processDownloadQueue() {
} else {
// state is already cancelled/downloaded -> skip download
_queuedDownloadTasks.pop();
+ _dlcsInProgress.remove_at(0);
// process next download in the queue
processDownloadQueue();
}
@@ -89,8 +91,9 @@ void DLCManager::startDownloadAsync(const Common::String &id, const Common::Stri
}
bool DLCManager::cancelDownload(uint32 idx) {
- if (_currentDownloadingDLC == _dlcs[idx]->id) {
+ if (_queuedDownloadTasks.front()->idx == idx) {
// if already downloading, interrupt startDownloadAsync
+ _interruptCurrentDownload = true;
} else {
// if not started, skip it in processDownload()
_dlcs[idx]->state = DLCDesc::kCancelled;
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index b5448b49214..20493cfc590 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -42,8 +42,10 @@ class DLCManager : public Common::Singleton<DLCManager>, public GUI::CommandSend
public:
bool _fetchDLCs = false;
+ bool _interruptCurrentDownload = false;
uint32 _currentDownloadedSize;
Common::Array<DLCDesc*> _dlcs;
+ Common::Array<DLCDesc*> _dlcsInProgress;
Common::Queue<DLCDesc*> _queuedDownloadTasks;
DLCManager();
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index 1df9d3ad204..77da3d71347 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -91,6 +91,18 @@ void ScummVMCloud::getAllDLCs() {
void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
Networking::SessionFileResponse *response = static_cast<Networking::SessionFileResponse *>(r.value);
DLCMan._currentDownloadedSize += response->len;
+ if (DLCMan._interruptCurrentDownload) {
+ _rq->close();
+ DLCMan._interruptCurrentDownload = false;
+ // delete the download cache (the incomplete .zip)
+ Common::Path relativeFilePath = Common::Path(DLCMan._queuedDownloadTasks.front()->id);
+ removeCacheFile(relativeFilePath);
+ // handle next download
+ DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kDownloaded;
+ DLCMan._queuedDownloadTasks.pop();
+ DLCMan._dlcsInProgress.remove_at(0);
+ DLCMan.processDownloadQueue();
+ }
if (response->eos) {
warning("downloaded");
_rq->close(); // delete request
@@ -106,6 +118,7 @@ void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
// handle next download
DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kDownloaded;
DLCMan._queuedDownloadTasks.pop();
+ DLCMan._dlcsInProgress.remove_at(0);
DLCMan.processDownloadQueue();
}
}
@@ -114,6 +127,7 @@ void ScummVMCloud::errorCallback(Networking::ErrorResponse error) {
// error downloading - start next download in queue
DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kErrorDownloading;
DLCMan._queuedDownloadTasks.pop();
+ DLCMan._dlcsInProgress.remove_at(0);
DLCMan.processDownloadQueue();
}
diff --git a/gui/downloaddlcsdialog.cpp b/gui/downloaddlcsdialog.cpp
index 0c980980f4b..51f34e8d0b2 100644
--- a/gui/downloaddlcsdialog.cpp
+++ b/gui/downloaddlcsdialog.cpp
@@ -84,9 +84,11 @@ void DownloadDLCsDialog::refreshWidgets() {
_currentDownloadLabel->setLabel(DLCMan._queuedDownloadTasks.front()->name);
_downloadedSizeLabel->setLabel(getSizeLabelText());
- for (auto it : DLCMan._dlcs) {
+ for (auto it : DLCMan._dlcsInProgress) {
if (it->state == DLC::DLCDesc::kInProgress) {
pendingList.push_back(it->name);
+ } else {
+ pendingList.push_back("[Cancelled] " + it->name);
}
}
_pendingDownloadsList->setList(pendingList);
@@ -127,7 +129,8 @@ void DownloadDLCsDialog::handleTickle() {
void DownloadDLCsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kCancelSelectedCmd: {
- // set state of selected DLC to kCancelled
+ uint32 idx = DLCMan._dlcsInProgress[_pendingDownloadsList->getSelected()]->idx;
+ DLCMan.cancelDownload(idx);
}
break;
default:
Commit: 3633392b6d879c2a4c452cb8c8077fbe8e8a545c
https://github.com/scummvm/scummvm/commit/3633392b6d879c2a4c452cb8c8077fbe8e8a545c
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Fix launcher does not refresh after DLC download if DLC dialog is closed
Changed paths:
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
gui/dlcsdialog.cpp
gui/dlcsdialog.h
gui/launcher.cpp
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index a331a5dc891..24e113e6a61 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -52,7 +52,13 @@ void DLCManager::refreshDLCList() {
}
void DLCManager::refreshLauncherGameList() {
- sendCommand(GUI::kRefreshLauncher, 0);
+ if (_launcher) {
+ _launcher->rebuild();
+ }
+}
+
+void DLCManager::setLauncher(GUI::LauncherDialog *launcher) {
+ _launcher = launcher;
}
void DLCManager::addDownload(uint32 idx) {
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 20493cfc590..ba9d6a1f92a 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -30,12 +30,14 @@
#include "backends/dlc/dlcdesc.h"
#include "backends/networking/curl/request.h"
#include "gui/object.h"
+#include "gui/launcher.h"
namespace DLC {
class DLCManager : public Common::Singleton<DLCManager>, public GUI::CommandSender {
Store *_store;
+ GUI::LauncherDialog *_launcher;
bool _isDLCDownloading = false;
Common::String _currentDownloadingDLC;
@@ -60,6 +62,8 @@ public:
void refreshLauncherGameList();
+ void setLauncher(GUI::LauncherDialog *launcher);
+
// Add download task to queue, runs on click download button,
void addDownload(uint32 idx);
diff --git a/gui/dlcsdialog.cpp b/gui/dlcsdialog.cpp
index ba37b96fa69..fc3ebe33810 100644
--- a/gui/dlcsdialog.cpp
+++ b/gui/dlcsdialog.cpp
@@ -30,9 +30,7 @@
namespace GUI {
-DLCsDialog::DLCsDialog(LauncherDialog *launcher)
- : Dialog("DownloadGames"), _launcher(launcher) {
-
+DLCsDialog::DLCsDialog() : Dialog("DownloadGames") {
// Set target (Command Receiver) for Command Sender
DLCMan.setTarget(this);
@@ -102,10 +100,6 @@ void DLCsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
refreshDLCList();
}
break;
- case kRefreshLauncher: {
- _launcher->rebuild();
- }
- break;
default:
Dialog::handleCommand(sender, cmd, data);
}
diff --git a/gui/dlcsdialog.h b/gui/dlcsdialog.h
index 66830a0d7f0..961477a43e3 100644
--- a/gui/dlcsdialog.h
+++ b/gui/dlcsdialog.h
@@ -31,13 +31,12 @@ namespace GUI {
enum {
kDownloadSelectedCmd = 'DWNS',
kRefreshDLCList = 'RDLC',
- kRefreshLauncher = 'RFLR',
kAllDownloadsCmd = 'ALLD'
};
class DLCsDialog : public Dialog {
public:
- DLCsDialog(LauncherDialog *launcher);
+ DLCsDialog();
~DLCsDialog() override;
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
@@ -46,7 +45,6 @@ public:
private:
ListWidget *_gamesList;
- LauncherDialog *_launcher;
};
} // End of namespace GUI
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 9a43e07f86c..60693ae2b7d 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -58,6 +58,7 @@
#if defined(USE_CLOUD) && defined(USE_LIBCURL)
#include "backends/cloud/cloudmanager.h"
#endif
+#include "backends/dlc/dlcmanager.h"
namespace GUI {
@@ -203,6 +204,8 @@ LauncherDialog::LauncherDialog(const Common::String &dialogName)
_metadataParser.close();
}
g_gui.unlockIconsSet();
+
+ DLCMan.setLauncher(this);
}
LauncherDialog::~LauncherDialog() {
@@ -735,7 +738,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
massAddGame();
break;
case kDownloadGameCmd: {
- DLCsDialog downloader(this);
+ DLCsDialog downloader;
downloader.runModal();
}
break;
Commit: dd87960fe8b2920f0b83919cf2b8ab42b5a718fb
https://github.com/scummvm/scummvm/commit/dd87960fe8b2920f0b83919cf2b8ab42b5a718fb
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Restrict adding DLC in download queue if it's already in queue
Changed paths:
backends/dlc/dlcmanager.cpp
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 24e113e6a61..6d1641eb2f9 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -62,6 +62,10 @@ void DLCManager::setLauncher(GUI::LauncherDialog *launcher) {
}
void DLCManager::addDownload(uint32 idx) {
+ if (_dlcs[idx]->state == DLCDesc::kInProgress) {
+ // if DLC is already in queue, don't add again
+ return;
+ }
_dlcs[idx]->state = DLCDesc::kInProgress;
_queuedDownloadTasks.push(_dlcs[idx]);
_dlcsInProgress.push_back(_dlcs[idx]);
Commit: a4329e21b97db7e821f54599abca0edfbeaecac0
https://github.com/scummvm/scummvm/commit/a4329e21b97db7e821f54599abca0edfbeaecac0
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Disable download button when no item is selected in DLC browsing dialog
Changed paths:
gui/dlcsdialog.cpp
gui/dlcsdialog.h
diff --git a/gui/dlcsdialog.cpp b/gui/dlcsdialog.cpp
index fc3ebe33810..c9394bf1294 100644
--- a/gui/dlcsdialog.cpp
+++ b/gui/dlcsdialog.cpp
@@ -54,7 +54,7 @@ DLCsDialog::DLCsDialog() : Dialog("DownloadGames") {
new ButtonWidget(this, "DownloadGames.Back", _("Back"), Common::U32String(), kCloseCmd);
new ButtonWidget(this, "DownloadGames.AllDownloads", _("All Downloads"), Common::U32String(), kAllDownloadsCmd);
- new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
+ _downloadButton = new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
}
DLCsDialog::~DLCsDialog() {
@@ -83,6 +83,23 @@ void DLCsDialog::refreshDLCList() {
g_gui.scheduleTopDialogRedraw();
}
+void DLCsDialog::handleTickle() {
+ // enable download button only when a list item is selected
+ if (_gamesList->getSelected() == -1) {
+ if (_downloadButton->isEnabled()) {
+ _downloadButton->setEnabled(false);
+ g_gui.scheduleTopDialogRedraw();
+ }
+ } else {
+ if (!_downloadButton->isEnabled()) {
+ _downloadButton->setEnabled(true);
+ g_gui.scheduleTopDialogRedraw();
+ }
+ }
+
+ Dialog::handleTickle();
+}
+
void DLCsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kAllDownloadsCmd: {
diff --git a/gui/dlcsdialog.h b/gui/dlcsdialog.h
index 961477a43e3..04ef3f60499 100644
--- a/gui/dlcsdialog.h
+++ b/gui/dlcsdialog.h
@@ -39,12 +39,14 @@ public:
DLCsDialog();
~DLCsDialog() override;
+ void handleTickle() override;
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
void refreshDLCList();
private:
ListWidget *_gamesList;
+ ButtonWidget *_downloadButton;
};
} // End of namespace GUI
Commit: 2f6b87f0d4ac5156e34734bc6599e929aba49b3b
https://github.com/scummvm/scummvm/commit/2f6b87f0d4ac5156e34734bc6599e929aba49b3b
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Improve DLC download request indication
Changed paths:
backends/dlc/scummvmcloud.cpp
gui/dlcsdialog.cpp
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index 77da3d71347..56fbb202d86 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -117,6 +117,7 @@ void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
addEntryToConfig(destPath);
// handle next download
DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kDownloaded;
+ DLCMan.refreshDLCList();
DLCMan._queuedDownloadTasks.pop();
DLCMan._dlcsInProgress.remove_at(0);
DLCMan.processDownloadQueue();
diff --git a/gui/dlcsdialog.cpp b/gui/dlcsdialog.cpp
index c9394bf1294..59e951e968f 100644
--- a/gui/dlcsdialog.cpp
+++ b/gui/dlcsdialog.cpp
@@ -65,7 +65,11 @@ void DLCsDialog::refreshDLCList() {
// Populate the ListWidget
Common::U32StringArray games;
for (int i = 0; i < DLCMan._dlcs.size(); ++i) {
- games.push_back(DLCMan._dlcs[i]->name);
+ if (DLCMan._dlcs[i]->state == DLC::DLCDesc::kInProgress) {
+ games.push_back("[Downloading] " + DLCMan._dlcs[i]->name);
+ } else {
+ games.push_back(DLCMan._dlcs[i]->name);
+ }
}
// Gray out already downloaded packages
@@ -108,9 +112,8 @@ void DLCsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
}
break;
case kDownloadSelectedCmd: {
- MessageDialog dialog("Downloading: " + _gamesList->getSelectedString());
- dialog.runModal();
DLCMan.addDownload(_gamesList->getSelected());
+ refreshDLCList();
}
break;
case kRefreshDLCList: {
Commit: 3bba45bd5ccd5907e971789d6a1a1fe339326c15
https://github.com/scummvm/scummvm/commit/3bba45bd5ccd5907e971789d6a1a1fe339326c15
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Add error label in downloaddlcsdialog
Changed paths:
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
gui/downloaddlcsdialog.cpp
gui/downloaddlcsdialog.h
gui/themes/common/highres_layout.stx
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index ba9d6a1f92a..a497388586c 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -46,6 +46,7 @@ public:
bool _fetchDLCs = false;
bool _interruptCurrentDownload = false;
uint32 _currentDownloadedSize;
+ Common::String _errorText;
Common::Array<DLCDesc*> _dlcs;
Common::Array<DLCDesc*> _dlcsInProgress;
Common::Queue<DLCDesc*> _queuedDownloadTasks;
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index 56fbb202d86..eb6c09dfbf9 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -151,6 +151,9 @@ void ScummVMCloud::extractZip(const Common::Path &file, const Common::Path &dest
// dataArchive is nullptr if zip file is incomplete
if (dataArchive != nullptr) {
dataArchive->dumpArchive(destPath.toString());
+ DLCMan._errorText = "";
+ } else {
+ DLCMan._errorText = "ERROR: " + DLCMan._queuedDownloadTasks.front()->name + ": Archive is broken, please re-download!";
}
}
delete fs;
diff --git a/gui/downloaddlcsdialog.cpp b/gui/downloaddlcsdialog.cpp
index 51f34e8d0b2..104e4dbbe05 100644
--- a/gui/downloaddlcsdialog.cpp
+++ b/gui/downloaddlcsdialog.cpp
@@ -36,6 +36,7 @@ DownloadDLCsDialog::DownloadDLCsDialog()
new StaticTextWidget(this, "DLCDownloads.Headline", _("Currently Downloading Games"));
_currentDownloadLabel = new StaticTextWidget(this, "DLCDownloads.CurrentDownload", Common::U32String());
+ _errorLabel = new StaticTextWidget(this, "DLCDownloads.ErrorText", Common::U32String(DLCMan._errorText));
_progressBar = new SliderWidget(this, "DLCDownloads.ProgressBar");
_progressBar->setMinValue(0);
@@ -123,6 +124,11 @@ void DownloadDLCsDialog::handleTickle() {
}
}
+ if (_errorLabel->getLabel() != DLCMan._errorText) {
+ _errorLabel->setLabel(DLCMan._errorText);
+ g_gui.scheduleTopDialogRedraw();
+ }
+
Dialog::handleTickle();
}
diff --git a/gui/downloaddlcsdialog.h b/gui/downloaddlcsdialog.h
index 3a8e02965d9..b8e323bb6f2 100644
--- a/gui/downloaddlcsdialog.h
+++ b/gui/downloaddlcsdialog.h
@@ -41,6 +41,7 @@ public:
private:
StaticTextWidget *_currentDownloadLabel;
+ StaticTextWidget *_errorLabel;
StaticTextWidget *_downloadedSizeLabel;
StaticTextWidget *_percentLabel;
SliderWidget *_progressBar;
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index be60b8c0748..bed6f17961a 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -542,6 +542,9 @@
<widget name = 'CurrentDownload'
height = 'Globals.Line.Height'
/>
+ <widget name = 'ErrorText'
+ height = 'Globals.Line.Height'
+ />
<widget name = 'ProgressBar'
height = 'Globals.Button.Height'
/>
Commit: 22f912d7e073f8ffdf9f76c6a07d25c594e40596
https://github.com/scummvm/scummvm/commit/22f912d7e073f8ffdf9f76c6a07d25c594e40596
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
DLC: Wrap ScummVM DLC in configure enabled feature, disabled by default
Changed paths:
backends/module.mk
base/main.cpp
configure
gui/launcher.cpp
gui/module.mk
diff --git a/backends/module.mk b/backends/module.mk
index 9ddce1c40d3..bcb6ea41cba 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -5,7 +5,6 @@ MODULE_OBJS := \
modular-backend.o \
audiocd/audiocd-stream.o \
audiocd/default/default-audiocd.o \
- dlc/dlcmanager.o \
events/default/default-events.o \
fs/abstract-fs.o \
fs/stdiostream.o \
@@ -68,6 +67,14 @@ MODULE_OBJS += \
endif
endif
+ifdef USE_SCUMMVMDLC
+ifdef USE_LIBCURL
+MODULE_OBJS += \
+ dlc/dlcmanager.o \
+ dlc/scummvmcloud.o
+endif
+endif
+
ifdef USE_LIBCURL
MODULE_OBJS += \
networking/curl/connectionmanager.o \
@@ -79,8 +86,7 @@ MODULE_OBJS += \
networking/curl/session.o \
networking/curl/sessionrequest.o \
networking/curl/socket.o \
- networking/curl/url.o \
- dlc/scummvmcloud.o
+ networking/curl/url.o
endif
ifdef USE_SDL_NET
diff --git a/base/main.cpp b/base/main.cpp
index 6f3afde422d..57bb5800617 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -71,7 +71,12 @@
#include "backends/keymapper/action.h"
#include "backends/keymapper/keymap.h"
#include "backends/keymapper/keymapper.h"
+
+#ifdef USE_SCUMMVMDLC
+#ifdef USE_LIBCURL
#include "backends/dlc/dlcmanager.h"
+#endif
+#endif
#ifdef USE_CLOUD
#ifdef USE_LIBCURL
@@ -700,7 +705,9 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
CloudMan.syncSaves();
#endif
+#if defined(USE_SCUMMVM) && defined(USE_LIBCURL)
DLCMan.init();
+#endif
// Unless a game was specified, show the launcher dialog
if (nullptr == ConfMan.getActiveDomain())
@@ -851,7 +858,11 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
Cloud::CloudManager::destroy();
#endif
#endif
+#ifdef USE_SCUMMVMDLC
+#ifdef USE_LIBCURL
DLC::DLCManager::destroy();
+#endif
+#endif
PluginManager::instance().unloadDetectionPlugin();
PluginManager::instance().unloadAllPlugins();
PluginManager::destroy();
diff --git a/configure b/configure
index 3a2f8996240..101ab5506c0 100755
--- a/configure
+++ b/configure
@@ -197,6 +197,7 @@ _enable_tsan=no
_enable_ubsan=no
_bink=yes
_cloud=auto
+_scummvmdlc=no
_pandoc=no
_curl=yes
_lld=no
@@ -958,6 +959,7 @@ Optional Features:
--disable-cloud don't build cloud support
--disable-system-dialogs don't build support for system dialogs
--enable-vkeybd build virtual keyboard support
+ --enable-scummvmdlc build scummvm dlc downloading support
--enable-eventrecorder enable event recording functionality
--disable-eventrecorder disable event recording functionality
--enable-updates build support for updates
@@ -1252,6 +1254,8 @@ for ac_option in $@; do
--disable-enet) _enet=no ;;
--enable-cloud) _cloud=yes ;;
--disable-cloud) _cloud=no ;;
+ --enable-scummvmdlc) _scummvmdlc=yes ;;
+ --disable-scummvmdlc) _scummvmdlc=no ;;
--enable-lld) _lld=yes ;;
--disable-lld) _lld=no ;;
--enable-mold) _mold=yes ;;
@@ -5832,6 +5836,8 @@ else
fi
define_in_config_if_yes $_cloud 'USE_CLOUD'
+define_in_config_if_yes $_scummvmdlc 'USE_SCUMMVMDLC'
+
#
# Check is NSDockTilePlugIn protocol is supported
#
@@ -7030,6 +7036,11 @@ fi
if test "$_cloud" = yes ; then
echo_n ", cloud"
fi
+
+if test "$_scummvmdlc" = yes ; then
+ echo_n ", scummvmdlc"
+fi
+
if test "$_enet" = yes ; then
echo ", ENet"
else
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 60693ae2b7d..3631270904c 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -58,7 +58,9 @@
#if defined(USE_CLOUD) && defined(USE_LIBCURL)
#include "backends/cloud/cloudmanager.h"
#endif
+#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
#include "backends/dlc/dlcmanager.h"
+#endif
namespace GUI {
@@ -205,7 +207,9 @@ LauncherDialog::LauncherDialog(const Common::String &dialogName)
}
g_gui.unlockIconsSet();
+#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
DLCMan.setLauncher(this);
+#endif
}
LauncherDialog::~LauncherDialog() {
@@ -261,8 +265,10 @@ void LauncherDialog::build() {
new ButtonWidget(this, _title + ".OptionsButton", _("Global ~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd, 0, _c("Global ~O~pts...", "lowres"));
if (g_system->hasFeature(OSystem::kFeatureDLC)) {
- // I18N: Button browse downloadable games (DLC)
+#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
+ // I18N: Button browse downloadable games (DLC)
new ButtonWidget(this, _title + ".DownloadGamesButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
+#endif
}
// Above the lowest button rows: two more buttons (directly below the list box)
@@ -737,11 +743,13 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
case kMassAddGameCmd:
massAddGame();
break;
+#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
case kDownloadGameCmd: {
DLCsDialog downloader;
downloader.runModal();
}
break;
+#endif
case kRemoveGameCmd:
if (item < 0) return;
removeGame(item);
diff --git a/gui/module.mk b/gui/module.mk
index 7d574cff167..8209e434a60 100644
--- a/gui/module.mk
+++ b/gui/module.mk
@@ -7,8 +7,6 @@ MODULE_OBJS := \
console.o \
debugger.o \
dialog.o \
- dlcsdialog.o \
- downloaddlcsdialog.o \
dump-all-dialogs.o \
editgamedialog.o \
error.o \
@@ -58,6 +56,14 @@ MODULE_OBJS += \
endif
endif
+ifdef USE_SCUMMVMDLC
+ifdef USE_LIBCURL
+MODULE_OBJS += \
+ dlcsdialog.o \
+ downloaddlcsdialog.o
+endif
+endif
+
ifdef ENABLE_EVENTRECORDER
MODULE_OBJS += \
editrecorddialog.o \
Commit: 877442989197858e4bb4d68487a1fbfcfac6d14c
https://github.com/scummvm/scummvm/commit/877442989197858e4bb4d68487a1fbfcfac6d14c
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Fix defines and code formatting
Changed paths:
backends/dlc/dlcdesc.h
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
backends/dlc/store.h
gui/dlcsdialog.cpp
gui/dlcsdialog.h
gui/downloaddlcsdialog.h
diff --git a/backends/dlc/dlcdesc.h b/backends/dlc/dlcdesc.h
index b25cc4949e4..4cd88a0b0a4 100644
--- a/backends/dlc/dlcdesc.h
+++ b/backends/dlc/dlcdesc.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef DLC_DLCT_H
-#define DLC_DLCT_H
+#ifndef BACKENDS_DLC_DLCDESC_H
+#define BACKENDS_DLC_DLCDESC_H
#include "common/str.h"
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 6d1641eb2f9..8ab17d1368e 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -19,12 +19,13 @@
*
*/
+#include "common/system.h"
#include "backends/dlc/android/playstore.h"
#include "backends/dlc/dlcmanager.h"
#include "backends/dlc/scummvmcloud.h"
#include "backends/dlc/android/playstore.h"
-#include "common/system.h"
+
#include "gui/dlcsdialog.h"
namespace Common {
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index a497388586c..2bcbc37ba64 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -19,18 +19,20 @@
*
*/
-#ifndef DLC_DLCMANAGER_H
-#define DLC_DLCMANAGER_H
+#ifndef BACKENDS_DLC_DLCMANAGER_H
+#define BACKENDS_DLC_DLCMANAGER_H
#include "common/str.h"
#include "common/str-array.h"
#include "common/queue.h"
#include "common/singleton.h"
+
+#include "gui/object.h"
+#include "gui/launcher.h"
+
#include "backends/dlc/store.h"
#include "backends/dlc/dlcdesc.h"
#include "backends/networking/curl/request.h"
-#include "gui/object.h"
-#include "gui/launcher.h"
namespace DLC {
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index eb6c09dfbf9..de41417d0fb 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -29,13 +29,16 @@
#include "common/compression/unzip.h"
#include "common/file.h"
#include "common/punycode.h"
-#include "backends/dlc/scummvmcloud.h"
-#include "backends/dlc/dlcmanager.h"
#include "common/config-manager.h"
#include "common/formats/json.h"
-#include "engines/metaengine.h"
+
#include "gui/gui-manager.h"
+#include "backends/dlc/scummvmcloud.h"
+#include "backends/dlc/dlcmanager.h"
+
+#include "engines/metaengine.h"
+
namespace DLC {
namespace ScummVMCloud {
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index d5509855f26..9a026168e36 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -19,15 +19,16 @@
*
*/
-#ifndef BACKENDS_DLC_ScummVMCloud_ScummVMCloud_H
-#define BACKENDS_DLC_ScummVMCloud_ScummVMCloud_H
+#ifndef BACKENDS_DLC_SCUMMVMCLOUD_SCUMMVMCLOUD_H
+#define BACKENDS_DLC_SCUMMVMCLOUD_SCUMMVMCLOUD_H
+
+#include "common/queue.h"
#include "backends/dlc/store.h"
#include "backends/dlc/dlcdesc.h"
#include "backends/networking/curl/session.h"
#include "backends/networking/curl/request.h"
#include "backends/networking/curl/curljsonrequest.h"
-#include "common/queue.h"
namespace DLC {
namespace ScummVMCloud {
diff --git a/backends/dlc/store.h b/backends/dlc/store.h
index 6e7f4319f45..6038a6c596c 100644
--- a/backends/dlc/store.h
+++ b/backends/dlc/store.h
@@ -19,13 +19,14 @@
*
*/
-#ifndef DLC_STORE_H
-#define DLC_STORE_H
+#ifndef BACKENDS_DLC_STORE_H
+#define BACKENDS_DLC_STORE_H
#include "common/str.h"
#include "common/array.h"
#include "common/queue.h"
#include "common/path.h"
+
#include "backends/dlc/dlcdesc.h"
namespace DLC {
diff --git a/gui/dlcsdialog.cpp b/gui/dlcsdialog.cpp
index 59e951e968f..67579dd493c 100644
--- a/gui/dlcsdialog.cpp
+++ b/gui/dlcsdialog.cpp
@@ -19,13 +19,15 @@
*
*/
+#include "common/translation.h"
+
#include "gui/dlcsdialog.h"
#include "gui/message.h"
#include "gui/widget.h"
#include "gui/widgets/list.h"
#include "gui/gui-manager.h"
#include "gui/downloaddlcsdialog.h"
-#include "common/translation.h"
+
#include "backends/dlc/dlcmanager.h"
namespace GUI {
diff --git a/gui/dlcsdialog.h b/gui/dlcsdialog.h
index 04ef3f60499..b8b6d269d0d 100644
--- a/gui/dlcsdialog.h
+++ b/gui/dlcsdialog.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef DLCS_DIALOG_H
-#define DLCS_DIALOG_H
+#ifndef GUI_DLCSDIALOG_H
+#define GUI_DLCSDIALOG_H
#include "gui/dialog.h"
#include "gui/widgets/list.h"
diff --git a/gui/downloaddlcsdialog.h b/gui/downloaddlcsdialog.h
index b8e323bb6f2..d3684fbc751 100644
--- a/gui/downloaddlcsdialog.h
+++ b/gui/downloaddlcsdialog.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef DOWNLOAD_DLCS_DIALOG_H
-#define DOWNLOAD_DLCS_DIALOG_H
+#ifndef GUI_DOWNLOADDLCSDIALOG_H
+#define GUI_DOWNLOADDLCSDIALOG_H
#include "gui/dialog.h"
#include "gui/widgets/list.h"
Commit: 6f5587fcd03de9c1f3550ab426887d41df827ed2
https://github.com/scummvm/scummvm/commit/6f5587fcd03de9c1f3550ab426887d41df827ed2
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
GUI: Fix crash if a game is downloaded when last item is selected in pending DLC downloads
Changed paths:
gui/downloaddlcsdialog.cpp
diff --git a/gui/downloaddlcsdialog.cpp b/gui/downloaddlcsdialog.cpp
index 104e4dbbe05..27138c94239 100644
--- a/gui/downloaddlcsdialog.cpp
+++ b/gui/downloaddlcsdialog.cpp
@@ -93,6 +93,10 @@ void DownloadDLCsDialog::refreshWidgets() {
}
}
_pendingDownloadsList->setList(pendingList);
+ if (_progressBar->getValue() >= 100) {
+ // if a game is downloaded i.e. the first item is removed from _dlcsInProgress
+ _selectedIdx--;
+ }
_pendingDownloadsList->setSelected(_selectedIdx);
}
Commit: 3d841a59e057047bf72a7022671503735d6bb329
https://github.com/scummvm/scummvm/commit/3d841a59e057047bf72a7022671503735d6bb329
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
DLC: Use const, uint32 and reference where appropriate
Changed paths:
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
backends/dlc/store.h
gui/dlcsdialog.cpp
gui/downloaddlcsdialog.cpp
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 8ab17d1368e..3269da6203c 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -112,12 +112,12 @@ bool DLCManager::cancelDownload(uint32 idx) {
return true;
}
-Common::String DLCManager::getCurrentDownloadingDLC() {
+Common::String DLCManager::getCurrentDownloadingDLC() const {
return _currentDownloadingDLC;
}
-int DLCManager::getDLCIdxFromId(const Common::String &id) {
- for (int i = 0; i < _dlcs.size(); ++i) {
+int DLCManager::getDLCIdxFromId(const Common::String &id) const {
+ for (uint32 i = 0; i < _dlcs.size(); ++i) {
if (_dlcs[i]->id == id) return i;
}
return -1;
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 2bcbc37ba64..d75a56732a0 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -75,11 +75,11 @@ public:
void processDownloadQueue();
// Returns the % download progress of current downloading game
- uint32 downloadProgress();
+ uint32 downloadProgress() const;
- Common::String getCurrentDownloadingDLC();
+ Common::String getCurrentDownloadingDLC() const;
- int getDLCIdxFromId(const Common::String &id);
+ int getDLCIdxFromId(const Common::String &id) const;
void startDownloadAsync(const Common::String &id, const Common::String &url);
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index de41417d0fb..4c89962ded0 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -163,7 +163,7 @@ void ScummVMCloud::extractZip(const Common::Path &file, const Common::Path &dest
delete dataArchive;
}
-void ScummVMCloud::removeCacheFile(Common::Path file) {
+void ScummVMCloud::removeCacheFile(const Common::Path &file) {
Common::Path dlcPath = Common::Path(ConfMan.get("dlcspath"));
Common::Path fileToDelete = dlcPath.join(file);
#if defined(POSIX)
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index 9a026168e36..8eeaf20d367 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -57,7 +57,7 @@ public:
virtual void startDownloadAsync(const Common::String &id, const Common::String &url) override;
- virtual void removeCacheFile(Common::Path file) override;
+ virtual void removeCacheFile(const Common::Path &file) override;
// extracts the provided zip in the provided destination path
void extractZip(const Common::Path &file, const Common::Path &destPath);
diff --git a/backends/dlc/store.h b/backends/dlc/store.h
index 6038a6c596c..30c8d31a604 100644
--- a/backends/dlc/store.h
+++ b/backends/dlc/store.h
@@ -53,7 +53,7 @@ public:
virtual void startDownloadAsync(const Common::String &id, const Common::String &url) = 0;
- virtual void removeCacheFile(Common::Path file) = 0;
+ virtual void removeCacheFile(const Common::Path &file) = 0;
};
} // End of namespace DLC
diff --git a/gui/dlcsdialog.cpp b/gui/dlcsdialog.cpp
index 67579dd493c..607b2111a50 100644
--- a/gui/dlcsdialog.cpp
+++ b/gui/dlcsdialog.cpp
@@ -66,7 +66,7 @@ DLCsDialog::~DLCsDialog() {
void DLCsDialog::refreshDLCList() {
// Populate the ListWidget
Common::U32StringArray games;
- for (int i = 0; i < DLCMan._dlcs.size(); ++i) {
+ for (uint32 i = 0; i < DLCMan._dlcs.size(); ++i) {
if (DLCMan._dlcs[i]->state == DLC::DLCDesc::kInProgress) {
games.push_back("[Downloading] " + DLCMan._dlcs[i]->name);
} else {
diff --git a/gui/downloaddlcsdialog.cpp b/gui/downloaddlcsdialog.cpp
index 27138c94239..52c10338f6a 100644
--- a/gui/downloaddlcsdialog.cpp
+++ b/gui/downloaddlcsdialog.cpp
@@ -85,7 +85,7 @@ void DownloadDLCsDialog::refreshWidgets() {
_currentDownloadLabel->setLabel(DLCMan._queuedDownloadTasks.front()->name);
_downloadedSizeLabel->setLabel(getSizeLabelText());
- for (auto it : DLCMan._dlcsInProgress) {
+ for (const auto &it : DLCMan._dlcsInProgress) {
if (it->state == DLC::DLCDesc::kInProgress) {
pendingList.push_back(it->name);
} else {
@@ -108,7 +108,7 @@ void DownloadDLCsDialog::refreshWidgets() {
}
void DownloadDLCsDialog::handleTickle() {
- int32 progress = getDownloadingProgress();
+ uint32 progress = getDownloadingProgress();
if (_progressBar->getValue() != progress) {
_selectedIdx = _pendingDownloadsList->getSelected();
Commit: b9e5694f39979e430f502c3d217decba2cbd8699
https://github.com/scummvm/scummvm/commit/b9e5694f39979e430f502c3d217decba2cbd8699
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: DLC: Refresh DLC list after download is cancelled
Changed paths:
backends/dlc/dlcmanager.cpp
backends/dlc/scummvmcloud.cpp
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 3269da6203c..ac21573ff8a 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -108,6 +108,7 @@ bool DLCManager::cancelDownload(uint32 idx) {
} else {
// if not started, skip it in processDownload()
_dlcs[idx]->state = DLCDesc::kCancelled;
+ DLCMan.refreshDLCList();
}
return true;
}
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index 4c89962ded0..f70e9590708 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -100,8 +100,11 @@ void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
// delete the download cache (the incomplete .zip)
Common::Path relativeFilePath = Common::Path(DLCMan._queuedDownloadTasks.front()->id);
removeCacheFile(relativeFilePath);
+
+ DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kCancelled;
+ DLCMan.refreshDLCList();
+
// handle next download
- DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kDownloaded;
DLCMan._queuedDownloadTasks.pop();
DLCMan._dlcsInProgress.remove_at(0);
DLCMan.processDownloadQueue();
Commit: 24a7e4cf73d2d9987bb916a0463a11ecfbe18213
https://github.com/scummvm/scummvm/commit/24a7e4cf73d2d9987bb916a0463a11ecfbe18213
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Change DLC::DLCDesc to struct, deallocate DLCMan._dlcs
Changed paths:
backends/dlc/dlcdesc.h
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
diff --git a/backends/dlc/dlcdesc.h b/backends/dlc/dlcdesc.h
index 4cd88a0b0a4..16b443690ef 100644
--- a/backends/dlc/dlcdesc.h
+++ b/backends/dlc/dlcdesc.h
@@ -26,7 +26,7 @@
namespace DLC {
-class DLCDesc {
+struct DLCDesc {
public:
enum State {
@@ -46,9 +46,9 @@ public:
Common::String extra;
Common::String engineid;
Common::String guioptions;
- uint32 size;
- uint32 idx;
- State state;
+ uint32 size = 0;
+ uint32 idx = 0;
+ State state = State::kAvailable;
};
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index ac21573ff8a..ef5b40a03ff 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -42,6 +42,12 @@ DLCManager::DLCManager(): CommandSender(nullptr) {
_store = new DLC::ScummVMCloud::ScummVMCloud();
}
+DLCManager::~DLCManager() {
+ for (uint32 i = 0; i < _dlcs.size(); ++i) {
+ delete _dlcs[i];
+ }
+}
+
void DLCManager::init() {}
void DLCManager::getAllDLCs() {
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index d75a56732a0..7b4fde5bf93 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -54,7 +54,7 @@ public:
Common::Queue<DLCDesc*> _queuedDownloadTasks;
DLCManager();
- virtual ~DLCManager() {}
+ virtual ~DLCManager();
void init();
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index f70e9590708..ca50c197bed 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -54,23 +54,25 @@ void ScummVMCloud::jsonCallbackGetAllDLCs(Networking::JsonResponse response) {
for (uint32 i = 0; i < items.size(); ++i) {
if (!Networking::CurlJsonRequest::jsonIsObject(items[i], "ScummVMCloud")) continue;
Common::JSONObject item = items[i]->asObject();
- Common::String id = item.getVal("id")->asString();
- Common::String name = item.getVal("name")->asString();
- Common::String url = item.getVal("url")->asString();
- Common::String platform = item.getVal("platform")->asString();
- Common::String gameid = item.getVal("gameid")->asString();
- Common::String description = item.getVal("description")->asString();
- Common::String language = item.getVal("language")->asString();
- Common::String extra = item.getVal("extra")->asString();
- Common::String engineid = item.getVal("engineid")->asString();
- Common::String guioptions = item.getVal("guioptions")->asString();
- uint32 size;
+
+ DLC::DLCDesc *dlc = new DLC::DLCDesc();
+ dlc->id = item.getVal("id")->asString();
+ dlc->name = item.getVal("name")->asString();
+ dlc->url = item.getVal("url")->asString();
+ dlc->platform = item.getVal("platform")->asString();
+ dlc->gameid = item.getVal("gameid")->asString();
+ dlc->description = item.getVal("description")->asString();
+ dlc->language = item.getVal("language")->asString();
+ dlc->extra = item.getVal("extra")->asString();
+ dlc->engineid = item.getVal("engineid")->asString();
+ dlc->guioptions = item.getVal("guioptions")->asString();
if (item.getVal("size")->isString()) {
- size = item.getVal("size")->asString().asUint64();
+ dlc->size = item.getVal("size")->asString().asUint64();
} else {
- size = item.getVal("size")->asIntegerNumber();
+ dlc->size = item.getVal("size")->asIntegerNumber();
}
- DLCMan._dlcs.push_back(new DLCDesc{name, id, url, platform, gameid, description, language, extra, engineid, guioptions, size, i, DLCDesc::kAvailable});
+ dlc->idx = i;
+ DLCMan._dlcs.push_back(dlc);
}
}
// send refresh DLC list command to GUI
Commit: 92922886262185afb7e7c3d979a3dfa4fbfeb754
https://github.com/scummvm/scummvm/commit/92922886262185afb7e7c3d979a3dfa4fbfeb754
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Move enum to cpp of downloaddlcsdialog.h
Changed paths:
gui/downloaddlcsdialog.cpp
gui/downloaddlcsdialog.h
diff --git a/gui/downloaddlcsdialog.cpp b/gui/downloaddlcsdialog.cpp
index 52c10338f6a..75e3d0c1dd2 100644
--- a/gui/downloaddlcsdialog.cpp
+++ b/gui/downloaddlcsdialog.cpp
@@ -28,6 +28,10 @@
#include "backends/dlc/dlcmanager.h"
#include "backends/dlc/dlcdesc.h"
+enum {
+ kCancelSelectedCmd = 'CANS',
+};
+
namespace GUI {
DownloadDLCsDialog::DownloadDLCsDialog()
diff --git a/gui/downloaddlcsdialog.h b/gui/downloaddlcsdialog.h
index d3684fbc751..a1585503d69 100644
--- a/gui/downloaddlcsdialog.h
+++ b/gui/downloaddlcsdialog.h
@@ -27,10 +27,6 @@
namespace GUI {
-enum {
- kCancelSelectedCmd = 'CANS',
-};
-
class DownloadDLCsDialog : public Dialog {
public:
DownloadDLCsDialog();
Commit: 896793eb2c7516a6a65ee996ce1b85577542a109
https://github.com/scummvm/scummvm/commit/896793eb2c7516a6a65ee996ce1b85577542a109
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Change StaticTextWidget's text of dlcsdialog
Changed paths:
gui/dlcsdialog.cpp
diff --git a/gui/dlcsdialog.cpp b/gui/dlcsdialog.cpp
index 607b2111a50..c171083ceb0 100644
--- a/gui/dlcsdialog.cpp
+++ b/gui/dlcsdialog.cpp
@@ -36,7 +36,7 @@ DLCsDialog::DLCsDialog() : Dialog("DownloadGames") {
// Set target (Command Receiver) for Command Sender
DLCMan.setTarget(this);
- new StaticTextWidget(this, "DownloadGames.Headline", _("Download Freeware Games"));
+ new StaticTextWidget(this, "DownloadGames.Headline", _("Download Freeware Games and Demos"));
// Add list with downloadable game titles
_gamesList = new ListWidget(this, "DownloadGames.List");
Commit: f1a5ebfe9432df36c1c8d23c42399aed5c14c656
https://github.com/scummvm/scummvm/commit/f1a5ebfe9432df36c1c8d23c42399aed5c14c656
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
I18N: Add gui/dlcsdialog and gui/downloaddlcsdialog to POTFILES
Changed paths:
po/POTFILES
diff --git a/po/POTFILES b/po/POTFILES
index ba86acdb24b..cb7f58096d4 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -2,7 +2,9 @@ gui/about.cpp
gui/browser.cpp
gui/chooser.cpp
gui/cloudconnectionwizard.cpp
+gui/dlcsdialog.h
gui/downloaddialog.cpp
+gui/downloaddlcsdialog.h
gui/downloadpacksdialog.cpp
gui/editgamedialog.cpp
gui/editrecorddialog.cpp
Commit: d932cb817914847795ebabd7d1e96966c748b4be
https://github.com/scummvm/scummvm/commit/d932cb817914847795ebabd7d1e96966c748b4be
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Fix formatting and define in scummvmcloud.h
Changed paths:
backends/dlc/scummvmcloud.h
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index 8eeaf20d367..9f5949f93cd 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef BACKENDS_DLC_SCUMMVMCLOUD_SCUMMVMCLOUD_H
-#define BACKENDS_DLC_SCUMMVMCLOUD_SCUMMVMCLOUD_H
+#ifndef BACKENDS_DLC_SCUMMVMCLOUD_H
+#define BACKENDS_DLC_SCUMMVMCLOUD_H
#include "common/queue.h"
@@ -33,7 +33,7 @@
namespace DLC {
namespace ScummVMCloud {
-class ScummVMCloud: public DLC::Store {
+class ScummVMCloud : public DLC::Store {
Networking::SessionRequest *_rq;
Commit: 2756f6ae718309117419e6f31683375884aaac40
https://github.com/scummvm/scummvm/commit/2756f6ae718309117419e6f31683375884aaac40
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Remove unneeded includes from store.h
Changed paths:
backends/dlc/store.h
diff --git a/backends/dlc/store.h b/backends/dlc/store.h
index 30c8d31a604..610db92b944 100644
--- a/backends/dlc/store.h
+++ b/backends/dlc/store.h
@@ -23,8 +23,6 @@
#define BACKENDS_DLC_STORE_H
#include "common/str.h"
-#include "common/array.h"
-#include "common/queue.h"
#include "common/path.h"
#include "backends/dlc/dlcdesc.h"
Commit: ee2e8afd30216ae1dcb84d47e5d4a46e2ba4b83f
https://github.com/scummvm/scummvm/commit/ee2e8afd30216ae1dcb84d47e5d4a46e2ba4b83f
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Fix indentation in scummvmcloud
Changed paths:
backends/dlc/scummvmcloud.h
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index 9f5949f93cd..a38f7e0a25f 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -35,7 +35,7 @@ namespace ScummVMCloud {
class ScummVMCloud : public DLC::Store {
-Networking::SessionRequest *_rq;
+ Networking::SessionRequest *_rq;
public:
ScummVMCloud() {}
Commit: 708432c163c4aa8f69ffa11aa1686f6920f49736
https://github.com/scummvm/scummvm/commit/708432c163c4aa8f69ffa11aa1686f6920f49736
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: Change return type of getDefaultDLCsPath() to Common::Path
Changed paths:
backends/platform/sdl/macosx/macosx.cpp
backends/platform/sdl/macosx/macosx.h
backends/platform/sdl/posix/posix.cpp
backends/platform/sdl/posix/posix.h
backends/platform/sdl/sdl.cpp
backends/platform/sdl/sdl.h
backends/platform/sdl/win32/win32.cpp
backends/platform/sdl/win32/win32.h
diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index f821b558274..d309d41a681 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -261,11 +261,11 @@ Common::String OSystem_MacOSX::getDefaultIconsPath() {
return defaultIconsPath;
}
-Common::String OSystem_MacOSX::getDefaultDLCsPath() {
- const Common::String defaultDLCsPath = getAppSupportPathMacOSX() + "/DLCs";
+Common::Path OSystem_MacOSX::getDefaultDLCsPath() {
+ const Common::Path defaultDLCsPath(getAppSupportPathMacOSX() + "/DLCs");
- if (!Posix::assureDirectoryExists(defaultDLCsPath)) {
- return Common::String();
+ if (!Posix::assureDirectoryExists(defaultDLCsPath.toString())) {
+ return Common::Path();
}
return defaultDLCsPath;
diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h
index 41bf8723eb8..e244b36d0b5 100644
--- a/backends/platform/sdl/macosx/macosx.h
+++ b/backends/platform/sdl/macosx/macosx.h
@@ -51,7 +51,7 @@ public:
// Default paths
Common::String getDefaultIconsPath() override;
- Common::String getDefaultDLCsPath() override;
+ Common::Path getDefaultDLCsPath() override;
Common::String getScreenshotsPath() override;
protected:
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
index e33b5ee9657..7ade2bfd9dc 100644
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -260,8 +260,8 @@ Common::String OSystem_POSIX::getDefaultIconsPath() {
return Common::String::format("%s/%s", prefix, iconsPath.c_str());
}
-Common::String OSystem_POSIX::getDefaultDLCsPath() {
- Common::String dlcsPath;
+Common::Path OSystem_POSIX::getDefaultDLCsPath() {
+ Common::Path dlcsPath;
// On POSIX systems we follow the XDG Base Directory Specification for
// where to store files. The version we based our code upon can be found
@@ -275,14 +275,12 @@ Common::String OSystem_POSIX::getDefaultDLCsPath() {
dlcsPath = ".cache/";
}
-
- dlcsPath += "scummvm/dlcs";
-
- if (!Posix::assureDirectoryExists(dlcsPath, prefix)) {
- return Common::String();
+ dlcsPath = dlcsPath.join(Common::Path("scummvm/dlcs"));
+ if (!Posix::assureDirectoryExists(dlcsPath.toString(), prefix)) {
+ return Common::Path();
}
- return Common::String::format("%s/%s", prefix, dlcsPath.c_str());
+ return dlcsPath;
}
Common::String OSystem_POSIX::getScreenshotsPath() {
diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h
index f260762eec3..248419f6988 100644
--- a/backends/platform/sdl/posix/posix.h
+++ b/backends/platform/sdl/posix/posix.h
@@ -37,7 +37,7 @@ public:
// Default paths
Common::String getDefaultIconsPath() override;
- Common::String getDefaultDLCsPath() override;
+ Common::Path getDefaultDLCsPath() override;
Common::String getScreenshotsPath() override;
protected:
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 9425464f917..a91a46464b7 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -314,7 +314,7 @@ void OSystem_SDL::initBackend() {
#endif
ConfMan.registerDefault("iconspath", this->getDefaultIconsPath());
- ConfMan.registerDefault("dlcspath", this->getDefaultDLCsPath());
+ ConfMan.registerDefault("dlcspath", this->getDefaultDLCsPath().toString());
_inited = true;
@@ -790,10 +790,8 @@ Common::String OSystem_SDL::getDefaultIconsPath() {
}
// Not specified in base class
-Common::String OSystem_SDL::getDefaultDLCsPath() {
- Common::String path = ConfMan.get("dlcspath");
- if (!path.empty() && !path.hasSuffix("/"))
- path += "/";
+Common::Path OSystem_SDL::getDefaultDLCsPath() {
+ Common::Path path(ConfMan.get("dlcspath"));
return path;
}
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index c756a8dc054..ca74a05dd81 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -93,7 +93,7 @@ public:
// Default paths
virtual Common::String getDefaultIconsPath();
- virtual Common::String getDefaultDLCsPath();
+ virtual Common::Path getDefaultDLCsPath();
virtual Common::String getScreenshotsPath();
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index bc2a3b0a98b..91118cf5824 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -274,7 +274,7 @@ Common::String OSystem_Win32::getDefaultIconsPath() {
return Win32::tcharToString(iconsPath);
}
-Common::String OSystem_Win32::getDefaultDLCsPath() {
+Common::Path OSystem_Win32::getDefaultDLCsPath() {
TCHAR dlcsPath[MAX_PATH];
if (_isPortable) {
@@ -283,13 +283,13 @@ Common::String OSystem_Win32::getDefaultDLCsPath() {
} else {
// Use the Application Data directory of the user profile
if (!Win32::getApplicationDataDirectory(dlcsPath)) {
- return Common::String();
+ return Common::Path();
}
_tcscat(dlcsPath, TEXT("\\DLCs\\"));
CreateDirectory(dlcsPath, nullptr);
}
- return Win32::tcharToString(dlcsPath);
+ return Common::Path(Win32::tcharToString(dlcsPath));
}
Common::String OSystem_Win32::getScreenshotsPath() {
diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h
index e80cdcefeb4..ff418d59965 100644
--- a/backends/platform/sdl/win32/win32.h
+++ b/backends/platform/sdl/win32/win32.h
@@ -50,7 +50,7 @@ public:
// Default paths
Common::String getDefaultIconsPath() override;
- Common::String getDefaultDLCsPath() override;
+ Common::Path getDefaultDLCsPath() override;
Common::String getScreenshotsPath() override;
protected:
Commit: 097b049aeadef79a68f8d95df564dc709b7e8e3e
https://github.com/scummvm/scummvm/commit/097b049aeadef79a68f8d95df564dc709b7e8e3e
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
DLC: Use forward declaration where appropriate
Changed paths:
backends/dlc/dlcmanager.cpp
backends/dlc/dlcmanager.h
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
gui/dlcsdialog.cpp
gui/dlcsdialog.h
gui/downloaddlcsdialog.cpp
gui/downloaddlcsdialog.h
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index ef5b40a03ff..0d9566132ac 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -21,12 +21,14 @@
#include "common/system.h"
-#include "backends/dlc/android/playstore.h"
#include "backends/dlc/dlcmanager.h"
+#include "backends/dlc/dlcdesc.h"
+#include "backends/dlc/android/playstore.h"
#include "backends/dlc/scummvmcloud.h"
#include "backends/dlc/android/playstore.h"
#include "gui/dlcsdialog.h"
+#include "gui/launcher.h"
namespace Common {
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 7b4fde5bf93..2633fe3d37b 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -28,12 +28,18 @@
#include "common/singleton.h"
#include "gui/object.h"
-#include "gui/launcher.h"
-#include "backends/dlc/store.h"
-#include "backends/dlc/dlcdesc.h"
#include "backends/networking/curl/request.h"
+namespace GUI {
+class LauncherDialog;
+}
+
+namespace DLC {
+class Store;
+struct DLCDesc;
+}
+
namespace DLC {
class DLCManager : public Common::Singleton<DLCManager>, public GUI::CommandSender {
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index ca50c197bed..d01da75a4a6 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -34,6 +34,7 @@
#include "gui/gui-manager.h"
+#include "backends/networking/curl/sessionrequest.h"
#include "backends/dlc/scummvmcloud.h"
#include "backends/dlc/dlcmanager.h"
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index a38f7e0a25f..80dd997b44e 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -26,10 +26,13 @@
#include "backends/dlc/store.h"
#include "backends/dlc/dlcdesc.h"
-#include "backends/networking/curl/session.h"
#include "backends/networking/curl/request.h"
#include "backends/networking/curl/curljsonrequest.h"
+namespace Networking {
+class SessionRequest;
+}
+
namespace DLC {
namespace ScummVMCloud {
diff --git a/gui/dlcsdialog.cpp b/gui/dlcsdialog.cpp
index c171083ceb0..bbd30e7aebb 100644
--- a/gui/dlcsdialog.cpp
+++ b/gui/dlcsdialog.cpp
@@ -26,9 +26,11 @@
#include "gui/widget.h"
#include "gui/widgets/list.h"
#include "gui/gui-manager.h"
+#include "gui/launcher.h"
#include "gui/downloaddlcsdialog.h"
#include "backends/dlc/dlcmanager.h"
+#include "backends/dlc/dlcdesc.h"
namespace GUI {
diff --git a/gui/dlcsdialog.h b/gui/dlcsdialog.h
index b8b6d269d0d..ee6ab52839a 100644
--- a/gui/dlcsdialog.h
+++ b/gui/dlcsdialog.h
@@ -23,8 +23,6 @@
#define GUI_DLCSDIALOG_H
#include "gui/dialog.h"
-#include "gui/widgets/list.h"
-#include "gui/launcher.h"
namespace GUI {
@@ -34,6 +32,10 @@ enum {
kAllDownloadsCmd = 'ALLD'
};
+class CommandSender;
+class ListWidget;
+class ButtonWidget;
+
class DLCsDialog : public Dialog {
public:
DLCsDialog();
diff --git a/gui/downloaddlcsdialog.cpp b/gui/downloaddlcsdialog.cpp
index 75e3d0c1dd2..d7ee14025a7 100644
--- a/gui/downloaddlcsdialog.cpp
+++ b/gui/downloaddlcsdialog.cpp
@@ -24,6 +24,7 @@
#include "gui/downloaddlcsdialog.h"
#include "gui/widget.h"
#include "gui/gui-manager.h"
+#include "gui/widgets/list.h"
#include "backends/dlc/dlcmanager.h"
#include "backends/dlc/dlcdesc.h"
diff --git a/gui/downloaddlcsdialog.h b/gui/downloaddlcsdialog.h
index a1585503d69..dfe95aabe3c 100644
--- a/gui/downloaddlcsdialog.h
+++ b/gui/downloaddlcsdialog.h
@@ -23,10 +23,15 @@
#define GUI_DOWNLOADDLCSDIALOG_H
#include "gui/dialog.h"
-#include "gui/widgets/list.h"
namespace GUI {
+class CommandSender;
+class StaticTextWidget;
+class SliderWidget;
+class ListWidget;
+class ButtonWidget;
+
class DownloadDLCsDialog : public Dialog {
public:
DownloadDLCsDialog();
Commit: e24ad8fc20253a40700def54495e5f5df29a609d
https://github.com/scummvm/scummvm/commit/e24ad8fc20253a40700def54495e5f5df29a609d
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Use debug instead of commented warning in scummvmcloud.cpp
Changed paths:
backends/dlc/scummvmcloud.cpp
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index d01da75a4a6..591ecc45e1e 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -48,7 +48,7 @@ void ScummVMCloud::jsonCallbackGetAllDLCs(Networking::JsonResponse response) {
if (json == nullptr || !json->isObject()) {
return;
}
- // warning("%s", json->stringify(true).c_str());
+ debug(1, "DLC list JSON response: %s", json->stringify(true).c_str());
Common::JSONObject result = json->asObject();
if (result.contains("entries")) {
Common::JSONArray items = result.getVal("entries")->asArray();
Commit: 97aa1d602aca4f92d5b55eb967feb9c6c7c92dcb
https://github.com/scummvm/scummvm/commit/97aa1d602aca4f92d5b55eb967feb9c6c7c92dcb
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Remove DLCMan.init() and its destroy call since it's not required
Changed paths:
base/main.cpp
diff --git a/base/main.cpp b/base/main.cpp
index 57bb5800617..44098d82e02 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -72,12 +72,6 @@
#include "backends/keymapper/keymap.h"
#include "backends/keymapper/keymapper.h"
-#ifdef USE_SCUMMVMDLC
-#ifdef USE_LIBCURL
-#include "backends/dlc/dlcmanager.h"
-#endif
-#endif
-
#ifdef USE_CLOUD
#ifdef USE_LIBCURL
#include "backends/cloud/cloudmanager.h"
@@ -705,10 +699,6 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
CloudMan.syncSaves();
#endif
-#if defined(USE_SCUMMVM) && defined(USE_LIBCURL)
- DLCMan.init();
-#endif
-
// Unless a game was specified, show the launcher dialog
if (nullptr == ConfMan.getActiveDomain())
launcherDialog();
@@ -857,11 +847,6 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
//I think it's important to destroy it after ConnectionManager
Cloud::CloudManager::destroy();
#endif
-#endif
-#ifdef USE_SCUMMVMDLC
-#ifdef USE_LIBCURL
- DLC::DLCManager::destroy();
-#endif
#endif
PluginManager::instance().unloadDetectionPlugin();
PluginManager::instance().unloadAllPlugins();
Commit: 4ae119d63fccab2b260864233fdd2243524295cb
https://github.com/scummvm/scummvm/commit/4ae119d63fccab2b260864233fdd2243524295cb
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
DLC: Add USE_DLC in configure for general DLC integration
- Developers will need to use --enable-dlc with configure if they want to integrate
the DLC downloader. The kFeatureDLC will determine if the target platform is supported
- USE_SCUMMVMDLC will be used specifically to compile curl based ScummVMCloud (USE_DLC
will be automatically enabled if ScummVMCloud is supported)
Changed paths:
backends/dlc/dlcmanager.cpp
backends/module.mk
configure
gui/launcher.cpp
gui/module.mk
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 0d9566132ac..70c7db7a885 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -39,9 +39,11 @@ DECLARE_SINGLETON(DLC::DLCManager);
namespace DLC {
DLCManager::DLCManager(): CommandSender(nullptr) {
- // _store = g_system->getDLCStore();
- // TODO: Handle creation through getDLCStore()
+#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
_store = new DLC::ScummVMCloud::ScummVMCloud();
+#else
+ _store = g_system->getDLCStore();
+#endif
}
DLCManager::~DLCManager() {
diff --git a/backends/module.mk b/backends/module.mk
index bcb6ea41cba..cc3b202865c 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -70,11 +70,19 @@ endif
ifdef USE_SCUMMVMDLC
ifdef USE_LIBCURL
MODULE_OBJS += \
- dlc/dlcmanager.o \
dlc/scummvmcloud.o
endif
endif
+ifdef USE_DLC
+MODULE_OBJS += \
+ dlc/dlcmanager.o
+ifeq ($(BACKEND),android)
+MODULE_OBJS += \
+ dlc/android/playstore.o
+endif
+endif
+
ifdef USE_LIBCURL
MODULE_OBJS += \
networking/curl/connectionmanager.o \
@@ -296,7 +304,6 @@ endif
ifeq ($(BACKEND),android)
MODULE_OBJS += \
- dlc/android/playstore.o \
fs/android/android-fs-factory.o \
fs/android/android-posix-fs.o \
fs/android/android-saf-fs.o \
diff --git a/configure b/configure
index 101ab5506c0..0b675e95d72 100755
--- a/configure
+++ b/configure
@@ -197,6 +197,7 @@ _enable_tsan=no
_enable_ubsan=no
_bink=yes
_cloud=auto
+_dlc=no
_scummvmdlc=no
_pandoc=no
_curl=yes
@@ -959,7 +960,8 @@ Optional Features:
--disable-cloud don't build cloud support
--disable-system-dialogs don't build support for system dialogs
--enable-vkeybd build virtual keyboard support
- --enable-scummvmdlc build scummvm dlc downloading support
+ --enable-dlc build scummvm dlc downloading support
+ --enable-scummvmdlc build scummvm dlc downloading support using ScummVM Cloud
--enable-eventrecorder enable event recording functionality
--disable-eventrecorder disable event recording functionality
--enable-updates build support for updates
@@ -1254,6 +1256,8 @@ for ac_option in $@; do
--disable-enet) _enet=no ;;
--enable-cloud) _cloud=yes ;;
--disable-cloud) _cloud=no ;;
+ --enable-dlc) _dlc=yes ;;
+ --disable-dlc) _dlc=no ;;
--enable-scummvmdlc) _scummvmdlc=yes ;;
--disable-scummvmdlc) _scummvmdlc=no ;;
--enable-lld) _lld=yes ;;
@@ -5836,6 +5840,13 @@ else
fi
define_in_config_if_yes $_cloud 'USE_CLOUD'
+if test "$_scummvmdlc" = "yes"; then
+ if test "$_libcurl" = "yes"; then
+ _dlc=yes
+ fi
+fi
+
+define_in_config_if_yes $_dlc 'USE_DLC'
define_in_config_if_yes $_scummvmdlc 'USE_SCUMMVMDLC'
#
@@ -7037,6 +7048,10 @@ if test "$_cloud" = yes ; then
echo_n ", cloud"
fi
+if test "$_dlc" = yes ; then
+ echo_n ", dlc"
+fi
+
if test "$_scummvmdlc" = yes ; then
echo_n ", scummvmdlc"
fi
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 3631270904c..98be575acf7 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -58,7 +58,7 @@
#if defined(USE_CLOUD) && defined(USE_LIBCURL)
#include "backends/cloud/cloudmanager.h"
#endif
-#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
+#if defined(USE_DLC)
#include "backends/dlc/dlcmanager.h"
#endif
@@ -209,6 +209,10 @@ LauncherDialog::LauncherDialog(const Common::String &dialogName)
#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
DLCMan.setLauncher(this);
+#elif defined(USE_DLC)
+ if (g_system->hasFeature(OSystem::kFeatureDLC)) {
+ DLCMan.setLauncher(this);
+ }
#endif
}
@@ -264,12 +268,14 @@ void LauncherDialog::build() {
// I18N: Button caption. O is the shortcut, Ctrl+O, put it in parens for non-latin (~O~)
new ButtonWidget(this, _title + ".OptionsButton", _("Global ~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd, 0, _c("Global ~O~pts...", "lowres"));
- if (g_system->hasFeature(OSystem::kFeatureDLC)) {
#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
- // I18N: Button browse downloadable games (DLC)
+ // I18N: Button browse downloadable games (DLC)
+ new ButtonWidget(this, _title + ".DownloadGamesButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
+#elif defined(USE_DLC)
+ if (g_system->hasFeature(OSystem::kFeatureDLC)) {
new ButtonWidget(this, _title + ".DownloadGamesButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
-#endif
}
+#endif
// Above the lowest button rows: two more buttons (directly below the list box)
DropdownButtonWidget *addButton =
@@ -743,7 +749,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
case kMassAddGameCmd:
massAddGame();
break;
-#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
+#if defined(USE_DLC)
case kDownloadGameCmd: {
DLCsDialog downloader;
downloader.runModal();
diff --git a/gui/module.mk b/gui/module.mk
index 8209e434a60..5f93f397526 100644
--- a/gui/module.mk
+++ b/gui/module.mk
@@ -56,13 +56,11 @@ MODULE_OBJS += \
endif
endif
-ifdef USE_SCUMMVMDLC
-ifdef USE_LIBCURL
+ifdef USE_DLC
MODULE_OBJS += \
dlcsdialog.o \
downloaddlcsdialog.o
endif
-endif
ifdef ENABLE_EVENTRECORDER
MODULE_OBJS += \
Commit: 0c7f65e5b7b2fef2f59882fe6d51afdb673d123f
https://github.com/scummvm/scummvm/commit/0c7f65e5b7b2fef2f59882fe6d51afdb673d123f
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Remove unneeded includes from dlcmanager.cpp
Changed paths:
backends/dlc/dlcmanager.cpp
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index 70c7db7a885..c0aea1bd683 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -23,9 +23,7 @@
#include "backends/dlc/dlcmanager.h"
#include "backends/dlc/dlcdesc.h"
-#include "backends/dlc/android/playstore.h"
#include "backends/dlc/scummvmcloud.h"
-#include "backends/dlc/android/playstore.h"
#include "gui/dlcsdialog.h"
#include "gui/launcher.h"
Commit: 6890e3097b8506a23f4fc31c011fe4d06c3eac91
https://github.com/scummvm/scummvm/commit/6890e3097b8506a23f4fc31c011fe4d06c3eac91
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: DLC: Improve code readability in scummvmcloud.cpp
Changed paths:
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index 591ecc45e1e..3a79b8ef493 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -37,6 +37,7 @@
#include "backends/networking/curl/sessionrequest.h"
#include "backends/dlc/scummvmcloud.h"
#include "backends/dlc/dlcmanager.h"
+#include "backends/dlc/dlcdesc.h"
#include "engines/metaengine.h"
@@ -193,17 +194,18 @@ void ScummVMCloud::addEntryToConfig(Common::Path gamePath) {
gamePath = gamePath.appendComponent(fsnodes[0].getFileName());
}
// add a new entry in scummvm config file
- Common::String domain = EngineMan.generateUniqueDomain(DLCMan._queuedDownloadTasks.front()->gameid);
+ DLC::DLCDesc *dlc = DLCMan._queuedDownloadTasks.front();
+ Common::String domain = EngineMan.generateUniqueDomain(dlc->gameid);
ConfMan.addGameDomain(domain);
- ConfMan.set("engineid", DLCMan._queuedDownloadTasks.front()->engineid, domain);
- ConfMan.set("gameid", DLCMan._queuedDownloadTasks.front()->gameid, domain);
- ConfMan.set("description", DLCMan._queuedDownloadTasks.front()->description, domain);
- ConfMan.set("language", DLCMan._queuedDownloadTasks.front()->language, domain);
- ConfMan.set("platform", DLCMan._queuedDownloadTasks.front()->platform, domain);
+ ConfMan.set("engineid", dlc->engineid, domain);
+ ConfMan.set("gameid", dlc->gameid, domain);
+ ConfMan.set("description", dlc->description, domain);
+ ConfMan.set("language", dlc->language, domain);
+ ConfMan.set("platform", dlc->platform, domain);
ConfMan.set("path", gamePath.toString(), domain);
- ConfMan.set("extra", DLCMan._queuedDownloadTasks.front()->extra, domain);
- ConfMan.set("guioptions", DLCMan._queuedDownloadTasks.front()->guioptions, domain);
- ConfMan.set("download", DLCMan._queuedDownloadTasks.front()->id, domain);
+ ConfMan.set("extra", dlc->extra, domain);
+ ConfMan.set("guioptions", dlc->guioptions, domain);
+ ConfMan.set("download", dlc->id, domain);
// send refresh launcher command to GUI
DLCMan.refreshLauncherGameList();
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index 80dd997b44e..f4553cf1881 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -25,7 +25,6 @@
#include "common/queue.h"
#include "backends/dlc/store.h"
-#include "backends/dlc/dlcdesc.h"
#include "backends/networking/curl/request.h"
#include "backends/networking/curl/curljsonrequest.h"
Commit: 2a60a4d21324f6c5893d1c7a9f5715fb4fd24e63
https://github.com/scummvm/scummvm/commit/2a60a4d21324f6c5893d1c7a9f5715fb4fd24e63
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
DLC: Set kFeatureDLC and _dlcStore for ScummVMCloud, Playstore in backend
Changed paths:
backends/dlc/dlcmanager.cpp
backends/platform/android/android.cpp
backends/platform/sdl/sdl.cpp
common/system.h
gui/launcher.cpp
diff --git a/backends/dlc/dlcmanager.cpp b/backends/dlc/dlcmanager.cpp
index c0aea1bd683..e48d60c5603 100644
--- a/backends/dlc/dlcmanager.cpp
+++ b/backends/dlc/dlcmanager.cpp
@@ -36,12 +36,8 @@ DECLARE_SINGLETON(DLC::DLCManager);
namespace DLC {
-DLCManager::DLCManager(): CommandSender(nullptr) {
-#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
- _store = new DLC::ScummVMCloud::ScummVMCloud();
-#else
+DLCManager::DLCManager() : CommandSender(nullptr) {
_store = g_system->getDLCStore();
-#endif
}
DLCManager::~DLCManager() {
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index dc510668f3a..0383d54a9ba 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -224,9 +224,9 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
}
_fsFactory = &fsFactory;
- // TODO: Create a new factory for Android, to assign it according to the Android's distribution store
- // E.g. to handle the cases for: playstore, no store (apk on ScummVM website), amazon app store, etc.
+#if defined(USE_DLC)
_dlcStore = new DLC::PlayStore::PlayStore();
+#endif
}
OSystem_Android::~OSystem_Android() {
@@ -646,7 +646,9 @@ bool OSystem_Android::hasFeature(Feature f) {
f == kFeatureTouchscreen) {
return true;
}
+#if defined(USE_DLC)
if (f == kFeatureDLC) return true;
+#endif
/* Even if we are using the 2D graphics manager,
* we are at one initGraphics3d call of supporting GLES2 */
if (f == kFeatureOpenGLForGame) return true;
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index a91a46464b7..4aecdeda34b 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -54,6 +54,9 @@
#include "backends/graphics3d/openglsdl/openglsdl-graphics3d.h"
#include "graphics/opengl/context.h"
#endif
+#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
+#include "backends/dlc/scummvmcloud.h"
+#endif
#include "graphics/renderer.h"
#include <time.h> // for getTimeAndDate()
@@ -90,6 +93,9 @@ OSystem_SDL::OSystem_SDL()
_eventSource(nullptr),
_eventSourceWrapper(nullptr),
_window(nullptr) {
+#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
+ _dlcStore = new DLC::ScummVMCloud::ScummVMCloud();
+#endif
}
OSystem_SDL::~OSystem_SDL() {
@@ -198,6 +204,9 @@ bool OSystem_SDL::hasFeature(Feature f) {
* we are at one initGraphics3d call of supporting OpenGL */
if (f == kFeatureOpenGLForGame) return true;
if (f == kFeatureShadersForGame) return _supportsShaders;
+#endif
+#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
+ if (f == kFeatureDLC) return true;
#endif
return ModularGraphicsBackend::hasFeature(f);
}
diff --git a/common/system.h b/common/system.h
index 4d0cc2460c4..72c71621cc2 100644
--- a/common/system.h
+++ b/common/system.h
@@ -1742,7 +1742,7 @@ public:
/**
* Return the DLC Store, used to implement DLC manager functions.
*
- * @return The Store for the current distribution platform.
+ * @return The Store for the current architecture/distribution platform.
*/
virtual DLC::Store *getDLCStore() {
return _dlcStore;
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 98be575acf7..4e373c9bab5 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -207,9 +207,7 @@ LauncherDialog::LauncherDialog(const Common::String &dialogName)
}
g_gui.unlockIconsSet();
-#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
- DLCMan.setLauncher(this);
-#elif defined(USE_DLC)
+#if defined(USE_DLC)
if (g_system->hasFeature(OSystem::kFeatureDLC)) {
DLCMan.setLauncher(this);
}
@@ -268,10 +266,7 @@ void LauncherDialog::build() {
// I18N: Button caption. O is the shortcut, Ctrl+O, put it in parens for non-latin (~O~)
new ButtonWidget(this, _title + ".OptionsButton", _("Global ~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd, 0, _c("Global ~O~pts...", "lowres"));
-#if defined(USE_SCUMMVMDLC) && defined(USE_LIBCURL)
- // I18N: Button browse downloadable games (DLC)
- new ButtonWidget(this, _title + ".DownloadGamesButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
-#elif defined(USE_DLC)
+#if defined(USE_DLC)
if (g_system->hasFeature(OSystem::kFeatureDLC)) {
new ButtonWidget(this, _title + ".DownloadGamesButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
}
Commit: 9a68de2f52d059ecc5c18a6c02b0b75848fdbfd2
https://github.com/scummvm/scummvm/commit/9a68de2f52d059ecc5c18a6c02b0b75848fdbfd2
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
BACKENDS: DLC: Handle errors in ScummVMCloud::extractZip()
Changed paths:
backends/dlc/scummvmcloud.cpp
backends/dlc/scummvmcloud.h
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index 3a79b8ef493..41de19a2090 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -120,14 +120,22 @@ void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
// extract the downloaded zip
Common::String gameDir = Common::punycode_encodefilename(DLCMan._queuedDownloadTasks.front()->name);
Common::Path destPath = Common::Path(ConfMan.get("dlcspath")).appendComponent(gameDir);
- extractZip(relativeFilePath, destPath);
+ Common::Error error = extractZip(relativeFilePath, destPath);
// remove cache (the downloaded .zip)
removeCacheFile(relativeFilePath);
- // add downloaded game entry in scummvm configuration file
- addEntryToConfig(destPath);
- // handle next download
- DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kDownloaded;
+ if (error.getCode() == Common::kNoError) {
+ // add downloaded game entry in scummvm configuration file
+ addEntryToConfig(destPath);
+ DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kDownloaded;
+ DLCMan._errorText = "";
+ } else {
+ // if there is any error in extraction
+ DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kErrorDownloading;
+ DLCMan._errorText = error.getDesc();
+ }
DLCMan.refreshDLCList();
+
+ // handle next download
DLCMan._queuedDownloadTasks.pop();
DLCMan._dlcsInProgress.remove_at(0);
DLCMan.processDownloadQueue();
@@ -152,22 +160,24 @@ void ScummVMCloud::startDownloadAsync(const Common::String &id, const Common::St
_rq->start();
}
-void ScummVMCloud::extractZip(const Common::Path &file, const Common::Path &destPath) {
+Common::Error ScummVMCloud::extractZip(const Common::Path &file, const Common::Path &destPath) {
Common::Archive *dataArchive = nullptr;
Common::Path dlcPath = Common::Path(ConfMan.get("dlcspath"));
Common::FSNode *fs = new Common::FSNode(dlcPath.join(file));
+ Common::Error error = Common::kNoError;
if (fs->exists()) {
dataArchive = Common::makeZipArchive(*fs);
// dataArchive is nullptr if zip file is incomplete
if (dataArchive != nullptr) {
- dataArchive->dumpArchive(destPath.toString());
- DLCMan._errorText = "";
+ error = dataArchive->dumpArchive(destPath.toString());
} else {
- DLCMan._errorText = "ERROR: " + DLCMan._queuedDownloadTasks.front()->name + ": Archive is broken, please re-download!";
+ error = Common::Error(Common::kCreatingFileFailed, DLCMan._queuedDownloadTasks.front()->name + "Archive is broken, please re-download");
}
}
delete fs;
delete dataArchive;
+
+ return error;
}
void ScummVMCloud::removeCacheFile(const Common::Path &file) {
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index f4553cf1881..f15da9dd663 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -62,7 +62,7 @@ public:
virtual void removeCacheFile(const Common::Path &file) override;
// extracts the provided zip in the provided destination path
- void extractZip(const Common::Path &file, const Common::Path &destPath);
+ Common::Error extractZip(const Common::Path &file, const Common::Path &destPath);
void addEntryToConfig(Common::Path gamePath);
Commit: a4888cf24c9d9767287d8e087d89230bbcaf0fcd
https://github.com/scummvm/scummvm/commit/a4888cf24c9d9767287d8e087d89230bbcaf0fcd
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Improve code readability in scummvmcloud.cpp
Changed paths:
backends/dlc/scummvmcloud.cpp
diff --git a/backends/dlc/scummvmcloud.cpp b/backends/dlc/scummvmcloud.cpp
index 41de19a2090..69fd4d34fd4 100644
--- a/backends/dlc/scummvmcloud.cpp
+++ b/backends/dlc/scummvmcloud.cpp
@@ -114,25 +114,32 @@ void ScummVMCloud::downloadFileCallback(Networking::DataResponse r) {
DLCMan.processDownloadQueue();
}
if (response->eos) {
- warning("downloaded");
+ DLC::DLCDesc *dlc = DLCMan._queuedDownloadTasks.front();
+ debug(1, "Downloaded: %s", dlc->name.c_str());
+
_rq->close(); // delete request
- Common::Path relativeFilePath = Common::Path(DLCMan._queuedDownloadTasks.front()->id);
+
+ Common::Path relativeFilePath = Common::Path(dlc->id);
+
// extract the downloaded zip
- Common::String gameDir = Common::punycode_encodefilename(DLCMan._queuedDownloadTasks.front()->name);
+ Common::String gameDir = Common::punycode_encodefilename(dlc->name);
Common::Path destPath = Common::Path(ConfMan.get("dlcspath")).appendComponent(gameDir);
Common::Error error = extractZip(relativeFilePath, destPath);
+
// remove cache (the downloaded .zip)
removeCacheFile(relativeFilePath);
+
if (error.getCode() == Common::kNoError) {
// add downloaded game entry in scummvm configuration file
addEntryToConfig(destPath);
- DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kDownloaded;
+ dlc->state = DLCDesc::kDownloaded;
DLCMan._errorText = "";
} else {
// if there is any error in extraction
- DLCMan._queuedDownloadTasks.front()->state = DLCDesc::kErrorDownloading;
+ dlc->state = DLCDesc::kErrorDownloading;
DLCMan._errorText = error.getDesc();
}
+
DLCMan.refreshDLCList();
// handle next download
Commit: 24392d4838ace09a2e4b5ec91e03a2cffc746f30
https://github.com/scummvm/scummvm/commit/24392d4838ace09a2e4b5ec91e03a2cffc746f30
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
DLC: Add lowres_layout.stx and generated theme files
Changed paths:
gui/themes/common/lowres_layout.stx
diff --git a/gui/themes/common/lowres_layout.stx b/gui/themes/common/lowres_layout.stx
index 9a3637d3da0..a7cab1c5366 100644
--- a/gui/themes/common/lowres_layout.stx
+++ b/gui/themes/common/lowres_layout.stx
@@ -186,6 +186,9 @@
<widget name = 'AddGameButton'
height = 'Globals.Button.Height'
/>
+ <widget name = 'DownloadGamesButton'
+ height = 'Globals.Button.Height'
+ />
<widget name = 'EditGameButton'
height = 'Globals.Button.Height'
/>
@@ -263,6 +266,9 @@
<widget name = 'AddGameButton'
height = 'Globals.Button.Height'
/>
+ <widget name = 'DownloadGamesButton'
+ height = 'Globals.Button.Height'
+ />
<widget name = 'RemoveGameButton'
height = 'Globals.Button.Height'
/>
@@ -375,6 +381,68 @@
</layout>
</dialog>
+ <dialog name = 'DownloadGames' overlays = 'screen' inset = '16' shading = 'dim'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8'>
+ <widget name = 'Headline'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'List'/>
+ <layout type = 'horizontal' padding = '8, 8, 8, 8'>
+ <widget name = 'Back'
+ type = 'Button'
+ />
+ <widget name = 'AllDownloads'
+ type = 'Button'
+ />
+ <space/>
+ <widget name = 'Download'
+ type = 'Button'
+ />
+ </layout>
+ </layout>
+ </dialog>
+
+ <dialog name = 'DLCDownloads' overlays = 'screen' inset = '16' shading = 'dim'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8'>
+ <widget name = 'Headline'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'CurrentDownload'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'ErrorText'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'ProgressBar'
+ height = 'Globals.Button.Height'
+ />
+ <space size = '1'/>
+ <widget name = 'PercentText'
+ height = 'Globals.Line.Height'
+ textalign = 'center'
+ />
+ <widget name = 'DownloadedSize'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'DownloadSpeed'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'Pending'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'List'/>
+ <layout type = 'horizontal' padding = '8, 8, 8, 8'>
+ <widget name = 'Back'
+ type = 'Button'
+ />
+ <space/>
+ <widget name = 'Cancel'
+ type = 'Button'
+ />
+ </layout>
+ </layout>
+ </dialog>
+
<dialog name = 'GlobalOptions' overlays = 'screen' inset = '16' shading = 'dim'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'TabWidget' type = 'TabWidget'/>
Commit: f03d59620b6546e1657b8793663bcd9ef62084e9
https://github.com/scummvm/scummvm/commit/f03d59620b6546e1657b8793663bcd9ef62084e9
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
JANITORIAL: Remove unneeded functions from dlcmanager.h
Changed paths:
backends/dlc/dlcmanager.h
diff --git a/backends/dlc/dlcmanager.h b/backends/dlc/dlcmanager.h
index 2633fe3d37b..8cb2b4f2621 100644
--- a/backends/dlc/dlcmanager.h
+++ b/backends/dlc/dlcmanager.h
@@ -80,18 +80,11 @@ public:
void processDownloadQueue();
- // Returns the % download progress of current downloading game
- uint32 downloadProgress() const;
-
Common::String getCurrentDownloadingDLC() const;
int getDLCIdxFromId(const Common::String &id) const;
void startDownloadAsync(const Common::String &id, const Common::String &url);
-
- void errorCallback(Networking::ErrorResponse error);
-
- void downloadFileCallback(Networking::DataResponse r);
};
#define DLCMan DLC::DLCManager::instance()
Commit: a26d00a2b73480461d320a74203ba15a042b6337
https://github.com/scummvm/scummvm/commit/a26d00a2b73480461d320a74203ba15a042b6337
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
DLC: Remove Playstore code
Changed paths:
R backends/dlc/android/playstore.cpp
R backends/dlc/android/playstore.h
backends/dlc/scummvmcloud.h
backends/dlc/store.h
backends/module.mk
backends/platform/android/android.cpp
backends/platform/android/jni-android.cpp
backends/platform/android/jni-android.h
backends/platform/android/org/scummvm/scummvm/ScummVM.java
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
dists/android/build.gradle
diff --git a/backends/dlc/android/playstore.cpp b/backends/dlc/android/playstore.cpp
deleted file mode 100644
index 8a4cd7644b0..00000000000
--- a/backends/dlc/android/playstore.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#if defined(__ANDROID__)
-
-#include "backends/dlc/android/playstore.h"
-
-namespace DLC {
-namespace PlayStore {
-
-PlayStore::PlayStore() {
- _playStoreObject = JNI::getPlayStoreDLCManager();
-}
-
-void PlayStore::init() {
-
-}
-
-void PlayStore::requestInfo() {
- JNIEnv *env = JNI::getEnv();
- jclass playStoreClass = env->GetObjectClass(_playStoreObject);
-
- jmethodID getPackLocationMethod = env->GetMethodID(playStoreClass, "getPackLocation", "(Ljava/lang/String;)Lcom/google/android/play/core/assetpacks/AssetPackLocation;");
-
- jstring packName = env->NewStringUTF("beneath_a_steel_sky");
- jobject packLocationObject = env->CallObjectMethod(_playStoreObject, getPackLocationMethod, packName);
-
- env->DeleteLocalRef(packName);
- env->DeleteLocalRef(packLocationObject);
-
- // TODO: return a string/struct for the location and add a function parameter i.e. packName
-}
-
-} // End of namespace PlayStore
-} // End of namespace DLC
-
-#endif
diff --git a/backends/dlc/android/playstore.h b/backends/dlc/android/playstore.h
deleted file mode 100644
index a800a3450f1..00000000000
--- a/backends/dlc/android/playstore.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#if defined(__ANDROID__)
-
-#ifndef BACKENDS_DLC_PLAYSTORE_PLAYSTORE_H
-#define BACKENDS_DLC_PLAYSTORE_PLAYSTORE_H
-
-#include "backends/dlc/store.h"
-#include "backends/platform/android/jni-android.h"
-
-namespace DLC {
-namespace PlayStore {
-
-class PlayStore: public DLC::Store {
-
-public:
- PlayStore();
- virtual ~PlayStore() {}
-
- virtual void init() override;
-
- virtual void requestInfo() override;
-
- virtual void getDownloadState() override {}
-
- virtual void requestDownload() override {}
-
- virtual void getBytesDownloaded() override {}
-
- virtual void cancelDownload() override {}
-
-private:
- jobject _playStoreObject;
-
-};
-
-} // End of namespace PlayStore
-} // End of namespace DLC
-
-#endif
-#endif
diff --git a/backends/dlc/scummvmcloud.h b/backends/dlc/scummvmcloud.h
index f15da9dd663..f7dd28c1e10 100644
--- a/backends/dlc/scummvmcloud.h
+++ b/backends/dlc/scummvmcloud.h
@@ -43,18 +43,6 @@ public:
ScummVMCloud() {}
virtual ~ScummVMCloud() {}
- virtual void init() override {}
-
- virtual void requestInfo() override {}
-
- virtual void getDownloadState() override {}
-
- virtual void requestDownload() override {}
-
- virtual void getBytesDownloaded() override {}
-
- virtual void cancelDownload() override {}
-
virtual void getAllDLCs() override;
virtual void startDownloadAsync(const Common::String &id, const Common::String &url) override;
diff --git a/backends/dlc/store.h b/backends/dlc/store.h
index 610db92b944..a12b360a4e9 100644
--- a/backends/dlc/store.h
+++ b/backends/dlc/store.h
@@ -35,18 +35,6 @@ public:
Store() {}
virtual ~Store() {}
- virtual void init() = 0;
-
- virtual void requestInfo() = 0;
-
- virtual void getDownloadState() = 0;
-
- virtual void requestDownload() = 0;
-
- virtual void getBytesDownloaded() = 0;
-
- virtual void cancelDownload() = 0;
-
virtual void getAllDLCs() = 0;
virtual void startDownloadAsync(const Common::String &id, const Common::String &url) = 0;
diff --git a/backends/module.mk b/backends/module.mk
index cc3b202865c..6b2367e4a66 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -77,10 +77,6 @@ endif
ifdef USE_DLC
MODULE_OBJS += \
dlc/dlcmanager.o
-ifeq ($(BACKEND),android)
-MODULE_OBJS += \
- dlc/android/playstore.o
-endif
endif
ifdef USE_LIBCURL
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 0383d54a9ba..e89dd8f84d4 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -76,8 +76,6 @@
#include "backends/keymapper/keymapper-defaults.h"
#include "backends/keymapper/standard-actions.h"
-#include "backends/dlc/android/playstore.h"
-
#include "common/util.h"
#include "common/textconsole.h"
#include "common/rect.h"
@@ -223,10 +221,6 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
fsFactory.initSAF();
}
_fsFactory = &fsFactory;
-
-#if defined(USE_DLC)
- _dlcStore = new DLC::PlayStore::PlayStore();
-#endif
}
OSystem_Android::~OSystem_Android() {
@@ -261,9 +255,6 @@ OSystem_Android::~OSystem_Android() {
delete _logger;
_logger = nullptr;
-
- delete _dlcStore;
- _dlcStore = nullptr;
}
void *OSystem_Android::timerThreadFunc(void *arg) {
@@ -646,9 +637,6 @@ bool OSystem_Android::hasFeature(Feature f) {
f == kFeatureTouchscreen) {
return true;
}
-#if defined(USE_DLC)
- if (f == kFeatureDLC) return true;
-#endif
/* Even if we are using the 2D graphics manager,
* we are at one initGraphics3d call of supporting GLES2 */
if (f == kFeatureOpenGLForGame) return true;
diff --git a/backends/platform/android/jni-android.cpp b/backends/platform/android/jni-android.cpp
index 1778ca5db2a..7b8120d7a37 100644
--- a/backends/platform/android/jni-android.cpp
+++ b/backends/platform/android/jni-android.cpp
@@ -107,8 +107,6 @@ jmethodID JNI::_MID_getNewSAFTree = 0;
jmethodID JNI::_MID_getSAFTrees = 0;
jmethodID JNI::_MID_findSAFTree = 0;
-jmethodID JNI::_MID_getPlayStoreDLCManager = 0;
-
jmethodID JNI::_MID_EGL10_eglSwapBuffers = 0;
jmethodID JNI::_MID_AudioTrack_flush = 0;
@@ -802,8 +800,6 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
FIND_METHOD(, getSAFTrees, "()[Lorg/scummvm/scummvm/SAFFSTree;");
FIND_METHOD(, findSAFTree, "(Ljava/lang/String;)Lorg/scummvm/scummvm/SAFFSTree;");
- FIND_METHOD(, getPlayStoreDLCManager, "()Lcom/google/android/play/core/assetpacks/AssetPackManager;");
-
_jobj_egl = env->NewGlobalRef(egl);
_jobj_egl_display = env->NewGlobalRef(egl_display);
_egl_version = 0;
@@ -1153,21 +1149,4 @@ jobject JNI::findSAFTree(const Common::String &name) {
return tree;
}
-jobject JNI::getPlayStoreDLCManager() {
- JNIEnv *env = JNI::getEnv();
-
- jobject store = env->CallObjectMethod(_jobj, _MID_getPlayStoreDLCManager);
-
- if (env->ExceptionCheck()) {
- LOGE("getPlayStoreDLCManager: error");
-
- env->ExceptionDescribe();
- env->ExceptionClear();
-
- return nullptr;
- }
-
- return store;
-}
-
#endif
diff --git a/backends/platform/android/jni-android.h b/backends/platform/android/jni-android.h
index 6127990be55..3f21dbeba7a 100644
--- a/backends/platform/android/jni-android.h
+++ b/backends/platform/android/jni-android.h
@@ -119,7 +119,6 @@ public:
static jobject getNewSAFTree(bool folder, bool writable, const Common::String &initURI, const Common::String &prompt);
static Common::Array<jobject> getSAFTrees();
static jobject findSAFTree(const Common::String &name);
- static jobject getPlayStoreDLCManager();
private:
static pthread_key_t _env_tls;
@@ -165,8 +164,6 @@ private:
static jmethodID _MID_getSAFTrees;
static jmethodID _MID_findSAFTree;
- static jmethodID _MID_getPlayStoreDLCManager;
-
static jmethodID _MID_EGL10_eglSwapBuffers;
static jmethodID _MID_AudioTrack_flush;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index 37a3e0d091d..7e29a1a55d4 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -12,8 +12,6 @@ import android.os.Build;
import android.util.Log;
import android.view.SurfaceHolder;
-import com.google.android.play.core.assetpacks.AssetPackManager;
-
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Scanner;
@@ -92,7 +90,6 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
abstract protected SAFFSTree getNewSAFTree(boolean folder, boolean write, String initialURI, String prompt);
abstract protected SAFFSTree[] getSAFTrees();
abstract protected SAFFSTree findSAFTree(String name);
- abstract protected AssetPackManager getPlayStoreDLCManager();
public ScummVM(AssetManager asset_manager, SurfaceHolder holder, final MyScummVMDestroyedCallback scummVMDestroyedCallback) {
_asset_manager = asset_manager;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 1e74c24c694..85d56a421dd 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -48,9 +48,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
-import com.google.android.play.core.assetpacks.AssetPackManager;
-import com.google.android.play.core.assetpacks.AssetPackManagerFactory;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -880,11 +877,6 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
protected SAFFSTree findSAFTree(String name) {
return SAFFSTree.findTree(ScummVMActivity.this, name);
}
-
- @Override
- protected AssetPackManager getPlayStoreDLCManager() {
- return AssetPackManagerFactory.getInstance(getApplicationContext());
- }
}
private MyScummVM _scummvm;
diff --git a/dists/android/build.gradle b/dists/android/build.gradle
index daef8e9b70a..23000480287 100644
--- a/dists/android/build.gradle
+++ b/dists/android/build.gradle
@@ -108,5 +108,4 @@ android {
dependencies {
implementation "androidx.annotation:annotation:1.5.0"
implementation "androidx.appcompat:appcompat:1.6.1"
- implementation "com.google.android.play:asset-delivery:2.1.0"
}
Commit: c1d1e4e4116c6f12ac7d08c888b2c928e8f705fa
https://github.com/scummvm/scummvm/commit/c1d1e4e4116c6f12ac7d08c888b2c928e8f705fa
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
DLC: Add dlcpath in Global Options
Changed paths:
gui/options.cpp
gui/options.h
gui/themes/common/highres_layout.stx
gui/themes/common/lowres_layout.stx
diff --git a/gui/options.cpp b/gui/options.cpp
index 61b52618f2f..89eed23bc4c 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -89,9 +89,11 @@ enum {
kSavePathClearCmd = 'clsp',
kChooseThemeDirCmd = 'chth',
kChooseIconDirCmd = 'chic',
+ kChooseDLCDirCmd = 'chdc',
kThemePathClearCmd = 'clth',
kBrowserPathClearCmd = 'clbr',
kIconPathClearCmd = 'clic',
+ kDLCPathClearCmd = 'cldc',
kChooseExtraDirCmd = 'chex',
kExtraPathClearCmd = 'clex',
kChoosePluginsDirCmd = 'chpl',
@@ -2091,6 +2093,10 @@ GlobalOptionsDialog::GlobalOptionsDialog(LauncherDialog *launcher)
_themePathClearButton = nullptr;
_iconPath = nullptr;
_iconPathClearButton = nullptr;
+#ifdef USE_DLC
+ _dlcPath = nullptr;
+ _dlcPathClearButton = nullptr;
+#endif
_extraPath = nullptr;
_extraPathClearButton = nullptr;
#ifdef DYNAMIC_MODULES
@@ -2357,6 +2363,9 @@ void GlobalOptionsDialog::build() {
setPath(_savePath, "savepath", _("Default"));
setPath(_themePath, "themepath", _c("None", "path"));
setPath(_iconPath, "iconspath", _("Default"));
+#ifdef USE_DLC
+ setPath(_dlcPath, "dlcspath", _("Default"));
+#endif
setPath(_extraPath, "extrapath", _c("None", "path"));
#ifdef DYNAMIC_MODULES
@@ -2450,6 +2459,18 @@ void GlobalOptionsDialog::addPathsControls(GuiObject *boss, const Common::String
_iconPathClearButton = addClearButton(boss, prefix + "IconPathClearButton", kIconPathClearCmd);
+#if defined(USE_DLC)
+ if (g_system->hasFeature(OSystem::kFeatureDLC)) {
+ if (!lowres)
+ new ButtonWidget(boss, prefix + "DLCButton", _("DLC Path:"), Common::U32String(), kChooseDLCDirCmd);
+ else
+ new ButtonWidget(boss, prefix + "DLCButton", _c("DLC Path:", "lowres"), Common::U32String(), kChooseDLCDirCmd);
+ _dlcPath = new StaticTextWidget(boss, prefix + "DLCPath", _c("Default", "path"));
+
+ _dlcPathClearButton = addClearButton(boss, prefix + "DLCPathClearButton", kDLCPathClearCmd);
+ }
+#endif
+
if (!lowres)
new ButtonWidget(boss, prefix + "ExtraButton", _("Extra Path:"), _("Specifies path to additional data used by all games or ScummVM"), kChooseExtraDirCmd);
else
@@ -2894,6 +2915,9 @@ void GlobalOptionsDialog::apply() {
changePath(_savePath, "savepath", _("Default"));
changePath(_themePath, "themepath", _c("None", "path"));
changePath(_iconPath, "iconspath", _("Default"));
+#ifdef USE_DLC
+ changePath(_dlcPath, "dlcspath", _("Default"));
+#endif
changePath(_extraPath, "extrapath", _c("None", "path"));
#ifdef DYNAMIC_MODULES
@@ -3166,6 +3190,18 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
}
break;
}
+#ifdef USE_DLC
+ case kChooseDLCDirCmd: {
+ BrowserDialog browser(_("Select directory for DLC downloads"), true);
+ if (browser.runModal() > 0) {
+ // User made his choice...
+ Common::FSNode dir(browser.getResult());
+ _dlcPath->setLabel(dir.getPath());
+ g_gui.scheduleTopDialogRedraw();
+ }
+ break;
+ }
+#endif
case kChooseExtraDirCmd: {
BrowserDialog browser(_("Select directory for extra files"), true);
if (browser.runModal() > 0) {
@@ -3231,6 +3267,11 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
case kIconPathClearCmd:
_iconPath->setLabel(_("Default"));
break;
+#ifdef USE_DLC
+ case kDLCPathClearCmd:
+ _dlcPath->setLabel(_("Default"));
+ break;
+#endif
case kExtraPathClearCmd:
_extraPath->setLabel(_c("None", "path"));
break;
@@ -3491,6 +3532,13 @@ void GlobalOptionsDialog::reflowLayout() {
delete _iconPathClearButton;
_iconPathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.IconPathClearButton", kIconPathClearCmd);
+#ifdef USE_DLC
+ _tabWidget->removeWidget(_dlcPathClearButton);
+ _dlcPathClearButton->setNext(nullptr);
+ delete _dlcPathClearButton;
+ _dlcPathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.DLCPathClearButton", kDLCPathClearCmd);
+#endif
+
_tabWidget->removeWidget(_extraPathClearButton);
_extraPathClearButton->setNext(nullptr);
delete _extraPathClearButton;
diff --git a/gui/options.h b/gui/options.h
index 6077415b7d0..6e690e762b7 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -278,6 +278,10 @@ protected:
ButtonWidget *_themePathClearButton;
StaticTextWidget *_iconPath;
ButtonWidget *_iconPathClearButton;
+#ifdef USE_DLC
+ StaticTextWidget *_dlcPath;
+ ButtonWidget *_dlcPathClearButton;
+#endif
StaticTextWidget *_extraPath;
ButtonWidget *_extraPathClearButton;
#ifdef DYNAMIC_MODULES
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index bed6f17961a..fa866fc0c46 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -957,6 +957,18 @@
width = 'Globals.Line.Height'
/>
</layout>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
+ <widget name = 'DLCButton'
+ type = 'Button'
+ />
+ <widget name = 'DLCPath'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'DLCPathClearButton'
+ height = 'Globals.Line.Height'
+ width = 'Globals.Line.Height'
+ />
+ </layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
<widget name = 'PluginsButton'
type = 'Button'
diff --git a/gui/themes/common/lowres_layout.stx b/gui/themes/common/lowres_layout.stx
index a7cab1c5366..6fe4cb2c712 100644
--- a/gui/themes/common/lowres_layout.stx
+++ b/gui/themes/common/lowres_layout.stx
@@ -803,6 +803,18 @@
width = 'Globals.Line.Height'
/>
</layout>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '16' align = 'center'>
+ <widget name = 'DLCButton'
+ type = 'Button'
+ />
+ <widget name = 'DLCPath'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'DLCPathClearButton'
+ height = 'Globals.Line.Height'
+ width = 'Globals.Line.Height'
+ />
+ </layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '16' align = 'center'>
<widget name = 'PluginsButton'
type = 'Button'
Commit: 0806d04dfd16b893e9f53a919073ab7e37eaaa2b
https://github.com/scummvm/scummvm/commit/0806d04dfd16b893e9f53a919073ab7e37eaaa2b
Author: Ankush Dutt (ankushd100 at gmail.com)
Date: 2023-09-14T08:22:56+02:00
Commit Message:
DLC: Add generated theme files
Changed paths:
gui/themes/residualvm.zip
gui/themes/scummclassic.zip
gui/themes/scummmodern.zip
gui/themes/scummremastered.zip
diff --git a/gui/themes/residualvm.zip b/gui/themes/residualvm.zip
index 51fe4ecd43d..044ef231380 100644
Binary files a/gui/themes/residualvm.zip and b/gui/themes/residualvm.zip differ
diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip
index e418a8f2a03..761009e102a 100644
Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ
diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip
index 09ca539828c..5b5500c2b27 100644
Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ
diff --git a/gui/themes/scummremastered.zip b/gui/themes/scummremastered.zip
index 37b6735e427..625a65bcf93 100644
Binary files a/gui/themes/scummremastered.zip and b/gui/themes/scummremastered.zip differ
More information about the Scummvm-git-logs
mailing list