Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI, BACKENDS: Add DLC Downloader #5134

Merged
merged 59 commits into from Sep 14, 2023
Merged

Conversation

ankushdutt
Copy link
Member

This PR will add support to allow downloading freeware games from the ScummVM GUI.

@ankushdutt ankushdutt marked this pull request as draft July 3, 2023 11:11
backends/dlc/dlcmanager.h Outdated Show resolved Hide resolved
@mgerhardy
Copy link
Contributor

maybe the api for mod.io can help to flesh out other store needs: https://github.com/modio/modio-sdk/tree/main

@ankushdutt
Copy link
Member Author

maybe the api for mod.io can help to flesh out other store needs: https://github.com/modio/modio-sdk/tree/main

Thanks, I will take a look.

@ankushdutt ankushdutt force-pushed the gui-download-packages branch 2 times, most recently from ed11ee6 to bd956c2 Compare July 10, 2023 10:14
@lephilousophe lephilousophe added the GSoC Part of a Google Summer of Code project label Jul 11, 2023
backends/dlc/dlcmanager.h Outdated Show resolved Hide resolved
backends/dlc/dlcmanager.h Outdated Show resolved Hide resolved
backends/dlc/dlcmanager.h Outdated Show resolved Hide resolved
gui/download-games-dialog.h Outdated Show resolved Hide resolved
backends/dlc/dlcmanager.h Outdated Show resolved Hide resolved
@ankushdutt ankushdutt force-pushed the gui-download-packages branch 3 times, most recently from 23989d7 to 314ff70 Compare July 21, 2023 08:06
@ankushdutt ankushdutt force-pushed the gui-download-packages branch 2 times, most recently from 7533803 to b976a7b Compare July 27, 2023 17:59
Copy link
Member

@sev- sev- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed it, and there are a few relatively minor notes.

Also, I think you added way too many #ifdefs for the feature, e.g. we will not compile in scummvmdlc, only for debugging purposes, but the interface buttons and dialogs will not be compiled in this case.

backends/dlc/dlcdesc.h Show resolved Hide resolved
Common::String extra;
Common::String engineid;
Common::String guioptions;
uint32 size;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please initialize it, e.g. uint32 size = 0;. And the other two variables below as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

#include "common/singleton.h"

#include "gui/object.h"
#include "gui/launcher.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid these excessive includes in a header file. Use forward declaration, e.g.

namespace GUI {
class LauncherDialog;
}

namespace DLC {
class Store;

....

will be enough since you only refer to those as pointers in the header.

Leave only absolutely necessary includes here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: d701264

// 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add some kind of error checking there. Imagine that the archive is broken or incomplete or there is no space left on the filesystem for extraction. For the latter, you would need to implement error checking in the dumpArchive() method

*
*/

#ifndef BACKENDS_DLC_SCUMMVMCLOUD_SCUMMVMCLOUD_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct one is BACKENDS_DLC_SCUMMVMCLOUD_H

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed

// Set target (Command Receiver) for Command Sender
DLCMan.setTarget(this);

new StaticTextWidget(this, "DownloadGames.Headline", _("Download Freeware Games"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add "and demos"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

gui/dlcsdialog.cpp Show resolved Hide resolved
gui/dlcsdialog.h Show resolved Hide resolved

namespace GUI {

enum {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move it to the .cpp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

gui/launcher.cpp Outdated
@@ -255,6 +264,13 @@ 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens on Android? I think you need to show it when the feature is present, not when scummvmdlc is compiled

if (json == nullptr || !json->isObject()) {
return;
}
// warning("%s", json->stringify(true).c_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps use debug or debugCN from common/debug.h rather than commented out warning

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done

@ankushdutt ankushdutt force-pushed the gui-download-packages branch 2 times, most recently from 9aead60 to 551f1ba Compare August 8, 2023 12:26
Copy link
Member

@sev- sev- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. We are very close to the merge

dataArchive = Common::makeZipArchive(*fs);
// dataArchive is nullptr if zip file is incomplete
if (dataArchive != nullptr) {
dataArchive->dumpArchive(destPath.toString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, since your code is merged, please rebase and add error processing here, e.g. show the user the error messages depending on the returned error.

// 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For brevity, please put DLCMan._queuedDownloadTasks.front() into a local variable and reuse

gui/launcher.cpp Outdated
#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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like this code duplication. You could simplify the thing that when USE_SCUMMVMDLC is defined, g_system->hasFeature(OSystem::kFeatureDLC) is returning true and getDLC() returns ScummVMDLC

@@ -205,6 +205,9 @@
<widget name = 'AddGameButton'
type = 'Button'
/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I am concerned about is that if USE_DLC is not defined, we have a hole between the buttons. Nothing for you to worry about now, I'll see what I can do after testing.

@ankushdutt ankushdutt force-pushed the gui-download-packages branch 3 times, most recently from 2e5a4ee to a794b0c Compare August 9, 2023 21:27
Copy link
Member

@sev- sev- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only one small note/enhancement.

I think, we are close to merge this

}

void ScummVMCloud::startDownloadAsync(const Common::String &id, const Common::String &url) {
Common::String localFile = normalizePath(ConfMan.get("dlcspath") + "/" + id, '/');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to expose dlcpath in the GUI, Options -> Paths

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added it. There is, however, a bit of hole/space when USE_DLC is not defined (possibly due to spacing = 10 in layout element inside .stx). I have added the layout (containing widgets) for dlcpath at the end for consistent spacing between the buttons for different paths. The next widget below will have some space before.

For the record, in the launcher, there is no hole/space for the DLC button if USE_DLC is not defined.

@ankushdutt ankushdutt changed the title [WIP] GUI, BACKENDS: Add DLC Downloader GUI, BACKENDS: Add DLC Downloader Aug 16, 2023
@ankushdutt ankushdutt marked this pull request as ready for review August 16, 2023 03:21
@ankushdutt ankushdutt force-pushed the gui-download-packages branch 2 times, most recently from eced2ec to fe706e9 Compare August 30, 2023 11:51
- 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)
@sev- sev- merged commit 0806d04 into scummvm:master Sep 14, 2023
8 checks passed
@sev-
Copy link
Member

sev- commented Sep 14, 2023

Thank you! Merging, you may continue development in-tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GSoC Part of a Google Summer of Code project
Projects
None yet
5 participants