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
Conversation
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. |
ed11ee6
to
bd956c2
Compare
23989d7
to
314ff70
Compare
7533803
to
b976a7b
Compare
There was a problem hiding this 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
Outdated
Common::String extra; | ||
Common::String engineid; | ||
Common::String guioptions; | ||
uint32 size; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
backends/dlc/dlcmanager.h
Outdated
#include "common/singleton.h" | ||
|
||
#include "gui/object.h" | ||
#include "gui/launcher.h" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: d701264
backends/dlc/scummvmcloud.cpp
Outdated
// 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); |
There was a problem hiding this comment.
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
backends/dlc/scummvmcloud.h
Outdated
* | ||
*/ | ||
|
||
#ifndef BACKENDS_DLC_SCUMMVMCLOUD_SCUMMVMCLOUD_H |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed
gui/dlcsdialog.cpp
Outdated
// Set target (Command Receiver) for Command Sender | ||
DLCMan.setTarget(this); | ||
|
||
new StaticTextWidget(this, "DownloadGames.Headline", _("Download Freeware Games")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add "and demos"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
gui/downloaddlcsdialog.h
Outdated
|
||
namespace GUI { | ||
|
||
enum { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
186a525
to
e20917f
Compare
backends/dlc/scummvmcloud.cpp
Outdated
if (json == nullptr || !json->isObject()) { | ||
return; | ||
} | ||
// warning("%s", json->stringify(true).c_str()); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done
9aead60
to
551f1ba
Compare
There was a problem hiding this 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
backends/dlc/scummvmcloud.cpp
Outdated
dataArchive = Common::makeZipArchive(*fs); | ||
// dataArchive is nullptr if zip file is incomplete | ||
if (dataArchive != nullptr) { | ||
dataArchive->dumpArchive(destPath.toString()); |
There was a problem hiding this comment.
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.
backends/dlc/scummvmcloud.cpp
Outdated
// 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); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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' | |||
/> |
There was a problem hiding this comment.
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.
2e5a4ee
to
a794b0c
Compare
There was a problem hiding this 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, '/'); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
eced2ec
to
fe706e9
Compare
…pending DLC downloads
- 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)
fe706e9
to
b986b40
Compare
Thank you! Merging, you may continue development in-tree |
This PR will add support to allow downloading freeware games from the ScummVM GUI.