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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
fac8eae
GUI: Add Download Games button in Launcher
ankushdutt Jun 12, 2023
ba4a5a6
GUI: Setup new dialog for Download Games
ankushdutt Jun 13, 2023
9bf3b8c
GUI: Add ListWidget for download games dialog
ankushdutt Jun 13, 2023
cb37f3d
GUI: Create download button command for downlad games dialog
ankushdutt Jun 13, 2023
e13fbf3
GUI: Gray out already downloaded games
ankushdutt Jun 15, 2023
a099747
BACKENDS: Add initial code for DLC Manager
ankushdutt Jun 26, 2023
9181b33
JANITORIAL: Update playstore.h licence to GPL v3+
ankushdutt Jul 1, 2023
44a85ef
BACKENDS: Initial implementation of Android PlayStore DLC Manager
ankushdutt Jul 1, 2023
43ebacb
BACKENDS: Remove platform-specific defines and enforce factory design…
ankushdutt Jul 1, 2023
8577d91
BACKENDS: Add DLC download queue and implement some DLCManager functions
ankushdutt Jul 8, 2023
a2a1abb
COMMON: Fix incomplete type warning for dlc store
ankushdutt Jul 8, 2023
5ac9635
BACKENDS: Initial code for downloading DLCs using CURL
ankushdutt Jul 13, 2023
348147c
BACKENDS: Generalize startDownloadAsync() for downloading DLCs
ankushdutt Jul 14, 2023
18afc90
BACKENDS: Populate dlc list using getAllDLCs() response
ankushdutt Jul 14, 2023
a310216
BACKENDS: Implement extract downloaded DLCs and remove cache in Scumm…
ankushdutt Jul 21, 2023
c7f7991
BACKENDS: Delete request when DLC is downloaded
ankushdutt Jul 21, 2023
5e20f60
BACKENDS: Extend preprocessor directives to support Windows in SummVM…
ankushdutt Jul 21, 2023
d3e6605
GUI: Fix graying out DLCs to use String for id
ankushdutt Jul 24, 2023
a7f96a0
BACKENDS: Implement get DLC list on request and redraw dialog once DL…
ankushdutt Jul 25, 2023
e2a987b
BACKENDS: Improve ScummVMCloud::extractZip()
ankushdutt Jul 26, 2023
af446e2
BACKENDS: Add more members in DLCDesc
ankushdutt Jul 27, 2023
62a4ca6
BACKENDS: Implement auto addition of DLC entry in ScummVM config afte…
ankushdutt Jul 27, 2023
818b281
BACKENDS: Create dlcspath for storing DLCs
ankushdutt Jul 28, 2023
7c15ccf
GUI: Remove CommandSender's target when DLC dialog is destructed
ankushdutt Jul 28, 2023
a7ea978
GUI: Initial code to show DLC download progress
ankushdutt Aug 2, 2023
48a0d8d
JANITORIAL: Rename download-games-dialog to dlcsdialog
ankushdutt Aug 2, 2023
a4113e8
BACKENDS: Implement interrupt/cancel pending DLC downloads
ankushdutt Aug 2, 2023
8360a4c
BACKENDS: Fix launcher does not refresh after DLC download if DLC dia…
ankushdutt Aug 2, 2023
5d5381e
BACKENDS: Restrict adding DLC in download queue if it's already in queue
ankushdutt Aug 3, 2023
a8b312e
GUI: Disable download button when no item is selected in DLC browsing…
ankushdutt Aug 3, 2023
cae2207
GUI: Improve DLC download request indication
ankushdutt Aug 3, 2023
916c2ad
GUI: Add error label in downloaddlcsdialog
ankushdutt Aug 4, 2023
c7fcfd5
DLC: Wrap ScummVM DLC in configure enabled feature, disabled by default
ankushdutt Aug 4, 2023
b2478dd
JANITORIAL: Fix defines and code formatting
ankushdutt Aug 5, 2023
0acb559
GUI: Fix crash if a game is downloaded when last item is selected in …
ankushdutt Aug 6, 2023
fbe6fa9
DLC: Use const, uint32 and reference where appropriate
ankushdutt Aug 6, 2023
24159e3
BACKENDS: DLC: Refresh DLC list after download is cancelled
ankushdutt Aug 6, 2023
1250e15
BACKENDS: Change DLC::DLCDesc to struct, deallocate DLCMan._dlcs
ankushdutt Aug 7, 2023
0cb978e
JANITORIAL: Move enum to cpp of downloaddlcsdialog.h
ankushdutt Aug 7, 2023
5d8c970
JANITORIAL: Change StaticTextWidget's text of dlcsdialog
ankushdutt Aug 7, 2023
a64e5a9
I18N: Add gui/dlcsdialog and gui/downloaddlcsdialog to POTFILES
ankushdutt Aug 7, 2023
8c96915
JANITORIAL: Fix formatting and define in scummvmcloud.h
ankushdutt Aug 7, 2023
dff57c9
JANITORIAL: Remove unneeded includes from store.h
ankushdutt Aug 7, 2023
15f64e2
JANITORIAL: Fix indentation in scummvmcloud
ankushdutt Aug 7, 2023
7409ad7
BACKENDS: Change return type of getDefaultDLCsPath() to Common::Path
ankushdutt Aug 7, 2023
90ddf60
DLC: Use forward declaration where appropriate
ankushdutt Aug 7, 2023
c5d3d5e
JANITORIAL: Use debug instead of commented warning in scummvmcloud.cpp
ankushdutt Aug 8, 2023
6e30fb5
JANITORIAL: Remove DLCMan.init() and its destroy call since it's not …
ankushdutt Aug 8, 2023
af052d7
DLC: Add USE_DLC in configure for general DLC integration
ankushdutt Aug 8, 2023
3f22e72
JANITORIAL: Remove unneeded includes from dlcmanager.cpp
ankushdutt Aug 8, 2023
77c78e3
BACKENDS: DLC: Improve code readability in scummvmcloud.cpp
ankushdutt Aug 9, 2023
18d88ad
DLC: Set kFeatureDLC and _dlcStore for ScummVMCloud, Playstore in bac…
ankushdutt Aug 9, 2023
387d09c
BACKENDS: DLC: Handle errors in ScummVMCloud::extractZip()
ankushdutt Aug 9, 2023
21cd92c
JANITORIAL: Improve code readability in scummvmcloud.cpp
ankushdutt Aug 9, 2023
409666d
DLC: Add lowres_layout.stx and generated theme files
ankushdutt Aug 9, 2023
8af36a0
JANITORIAL: Remove unneeded functions from dlcmanager.h
ankushdutt Aug 9, 2023
4a4696e
DLC: Remove Playstore code
ankushdutt Aug 9, 2023
64562da
DLC: Add dlcpath in Global Options
ankushdutt Aug 16, 2023
b986b40
DLC: Add generated theme files
ankushdutt Aug 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 57 additions & 0 deletions backends/dlc/dlcdesc.h
@@ -0,0 +1,57 @@
/* 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_DLCDESC_H
#define BACKENDS_DLC_DLCDESC_H

#include "common/str.h"

namespace DLC {

struct DLCDesc {

public:
enum State {
kAvailable,
kInProgress,
kDownloaded,
kCancelled,
kErrorDownloading
};
Common::String name;
sev- marked this conversation as resolved.
Show resolved Hide resolved
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 = 0;
uint32 idx = 0;
State state = State::kAvailable;
};


} // End of namespace DLC

#endif
131 changes: 131 additions & 0 deletions backends/dlc/dlcmanager.cpp
@@ -0,0 +1,131 @@
/* 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/system.h"

#include "backends/dlc/dlcmanager.h"
#include "backends/dlc/dlcdesc.h"
#include "backends/dlc/scummvmcloud.h"

#include "gui/dlcsdialog.h"
#include "gui/launcher.h"

namespace Common {

DECLARE_SINGLETON(DLC::DLCManager);

}

namespace DLC {

DLCManager::DLCManager() : CommandSender(nullptr) {
_store = g_system->getDLCStore();
}

DLCManager::~DLCManager() {
for (uint32 i = 0; i < _dlcs.size(); ++i) {
delete _dlcs[i];
}
}

void DLCManager::init() {}

void DLCManager::getAllDLCs() {
_store->getAllDLCs();
}

void DLCManager::refreshDLCList() {
sendCommand(GUI::kRefreshDLCList, 0);
}

void DLCManager::refreshLauncherGameList() {
if (_launcher) {
_launcher->rebuild();
}
}

void DLCManager::setLauncher(GUI::LauncherDialog *launcher) {
_launcher = 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]);
if (!_isDLCDownloading) {
// if queue is not already processing
DLCManager::processDownloadQueue();
}
}

void DLCManager::processDownloadQueue() {
_currentDownloadedSize = 0;
_isDLCDownloading = true;
if (!_queuedDownloadTasks.empty()) {
if (_queuedDownloadTasks.front()->state == DLCDesc::kInProgress) {
_currentDownloadingDLC = _queuedDownloadTasks.front()->id;
DLCManager::startDownloadAsync(_queuedDownloadTasks.front()->id, _queuedDownloadTasks.front()->url);
} else {
// state is already cancelled/downloaded -> skip download
_queuedDownloadTasks.pop();
_dlcsInProgress.remove_at(0);
// process next download in the queue
processDownloadQueue();
}
} else {
// no more download in queue
_isDLCDownloading = false;
_currentDownloadingDLC = "";
}
}

void DLCManager::startDownloadAsync(const Common::String &id, const Common::String &url) {
_store->startDownloadAsync(id, url);
}

bool DLCManager::cancelDownload(uint32 idx) {
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;
DLCMan.refreshDLCList();
}
return true;
}

Common::String DLCManager::getCurrentDownloadingDLC() const {
return _currentDownloadingDLC;
}

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;
}

} // End of namespace DLC
95 changes: 95 additions & 0 deletions backends/dlc/dlcmanager.h
@@ -0,0 +1,95 @@
/* 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_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 "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 {

Store *_store;
GUI::LauncherDialog *_launcher;

bool _isDLCDownloading = false;
Common::String _currentDownloadingDLC;

public:
bool _fetchDLCs = false;
bool _interruptCurrentDownload = false;
uint32 _currentDownloadedSize;
Common::String _errorText;
Common::Array<DLCDesc*> _dlcs;
Common::Array<DLCDesc*> _dlcsInProgress;
Common::Queue<DLCDesc*> _queuedDownloadTasks;

DLCManager();
virtual ~DLCManager();

void init();

// Runs only once
void getAllDLCs();

void refreshDLCList();

void refreshLauncherGameList();

void setLauncher(GUI::LauncherDialog *launcher);

// Add download task to queue, runs on click download button,
void addDownload(uint32 idx);

bool cancelDownload(uint32 idx);

void processDownloadQueue();

Common::String getCurrentDownloadingDLC() const;

int getDLCIdxFromId(const Common::String &id) const;

void startDownloadAsync(const Common::String &id, const Common::String &url);
};

#define DLCMan DLC::DLCManager::instance()

} // End of namespace DLC


#endif