mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-21 01:05:59 +00:00
BACKENDS: Implement auto addition of DLC entry in ScummVM config after download
This commit is contained in:
parent
c0800f5eda
commit
a344e7e43f
@ -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]);
|
||||
|
@ -55,6 +55,8 @@ public:
|
||||
|
||||
void refreshDLCList();
|
||||
|
||||
void refreshLauncherGameList();
|
||||
|
||||
// Add download task to queue, runs on click download button,
|
||||
void addDownload(uint32 idx);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user