Skip to content

Commit

Permalink
BACKENDS: Add base support for DLC Downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushdutt committed Jun 20, 2023
1 parent ef3604a commit bc3d788
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 3 deletions.
32 changes: 32 additions & 0 deletions common/dlc-downloader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* 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/dlc-downloader.h"
#include "common/system.h"

namespace Common {

DLCDownloader::DLCDownloader() {
_downloadProgress = 0;
}

}
47 changes: 47 additions & 0 deletions common/dlc-downloader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* 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_DOWNLOADER_ABSTRACT_H
#define BACKENDS_DLC_DOWNLOADER_ABSTRACT_H

#include "common/scummsys.h"
#include "common/str.h"

namespace Common {

class DLCDownloader {

public:
DLCDownloader();
virtual ~DLCDownloader() {}

virtual void startDownload(int id);

private:
int _downloadProgress;

};


} // End of namespace Common

#endif
1 change: 1 addition & 0 deletions common/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ MODULE_OBJS := \
coroutines.o \
dbcs-str.o \
debug.o \
dlc-downloader.o \
error.o \
events.o \
file.o \
Expand Down
5 changes: 5 additions & 0 deletions common/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "common/str-enc.h"
#include "common/textconsole.h"
#include "common/text-to-speech.h"
#include "common/dlc-downloader.h"

#include "backends/audiocd/default/default-audiocd.h"
#include "backends/fs/fs-factory.h"
Expand All @@ -52,6 +53,7 @@ OSystem::OSystem() {
_updateManager = nullptr;
#endif
_textToSpeechManager = nullptr;
_dlcDownloader = nullptr;
#if defined(USE_SYSDIALOGS)
_dialogManager = nullptr;
#endif
Expand Down Expand Up @@ -82,6 +84,9 @@ OSystem::~OSystem() {
delete _textToSpeechManager;
_textToSpeechManager = nullptr;

delete _dlcDownloader;
_dlcDownloader = nullptr;

#if defined(USE_SYSDIALOGS)
delete _dialogManager;
_dialogManager = nullptr;
Expand Down
7 changes: 7 additions & 0 deletions common/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class TaskbarManager;
class UpdateManager;
#endif
class TextToSpeechManager;
class DLCDownloader;
#if defined(USE_SYSDIALOGS)
class DialogManager;
#endif
Expand Down Expand Up @@ -243,6 +244,8 @@ class OSystem : Common::NonCopyable {
*/
Common::TextToSpeechManager *_textToSpeechManager;

Common::DLCDownloader *_dlcDownloader;

#if defined(USE_SYSDIALOGS)
/**
* No default value is provided for _dialogManager by OSystem.
Expand Down Expand Up @@ -1645,6 +1648,10 @@ class OSystem : Common::NonCopyable {
return _textToSpeechManager;
}

virtual Common::DLCDownloader *getDLCDownloader() {
return _dlcDownloader;
}

#if defined(USE_SYSDIALOGS)
/**
* Return the DialogManager, which is used to handle system dialogs.
Expand Down
13 changes: 10 additions & 3 deletions gui/download-games-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "gui/widget.h"
#include "gui/widgets/list.h"
#include "common/translation.h"
#include "common/dlc-downloader.h"

namespace GUI {

Expand All @@ -43,8 +44,8 @@ DownloadGamesDialog::DownloadGamesDialog()

// Populate the ListWidget
Common::U32StringArray games = {
_("Beneath a Steel Sky - Freeware CD Version"),
_("Beneath a Steel Sky - Freeware Floppy Version"),
_("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)"),
Expand Down Expand Up @@ -74,7 +75,6 @@ DownloadGamesDialog::DownloadGamesDialog()

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();
Expand All @@ -85,4 +85,11 @@ void DownloadGamesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
}
}

void DownloadGamesDialog::initDownload(int id) {
Common::DLCDownloader *dlcDownloader = g_system->getDLCDownloader();
if (dlcDownloader == nullptr) return;

dlcDownloader->startDownload(id);
}

} // End of namespace GUI
1 change: 1 addition & 0 deletions gui/download-games-dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class DownloadGamesDialog : public Dialog {
DownloadGamesDialog();

void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
void initDownload(int id);

private:
ListWidget *_gamesList;
Expand Down

0 comments on commit bc3d788

Please sign in to comment.