Skip to content

Commit

Permalink
BACKENDS: Add initial code for DLC Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushdutt committed Jun 23, 2023
1 parent bc3d788 commit e658658
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 2 deletions.
52 changes: 52 additions & 0 deletions backends/dlc/dlcmanager.cpp
@@ -0,0 +1,52 @@
/* 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 "backends/dlc/dlcmanager.h"
#include "backends/dlc/playstore/playstore.h"

namespace Common {

DECLARE_SINGLETON(DLC::DLCManager);

}

namespace DLC {

DLCManager::DLCManager() {
// if --playstore flag
_store = new DLC::PlayStore::PlayStore();
}

void DLCManager::init() {

}

void DLCManager::initDownload() {
_store->requestDownload();
// handle errors
}

bool DLCManager::getFeatureState(DLC::Feature f) {
return false;
}

} // End of namespace DLC
71 changes: 71 additions & 0 deletions backends/dlc/dlcmanager.h
@@ -0,0 +1,71 @@
/* 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 DLC_DLCMANAGER_H
#define DLC_DLCMANAGER_H

#include "common/str.h"
#include "common/singleton.h"
#include "backends/dlc/store.h"

namespace DLC {

enum Feature {
kInProgress
};

class DLCManager : public Common::Singleton<DLCManager> {

struct DLCDesc {
Common::String name;
Common::String description;
uint32 size;
uint32 game_id;
};

Store* _store;

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

void init();

DLCDesc getDLCList();

void initDownload();

void cancelDownload();

bool getFeatureState(DLC::Feature f);
void setFeatureState(DLC::Feature f, bool enable);

void getPercentDownloaded();

uint32 getInProgressGame();
};

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

} // End of namespace DLC


#endif
54 changes: 54 additions & 0 deletions backends/dlc/playstore/playstore.h
@@ -0,0 +1,54 @@
/* 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_PLAYSTORE_PLAYSTORE_H
#define BACKENDS_DLC_PLAYSTORE_PLAYSTORE_H

#include "backends/dlc/store.h"
#include "common/callback.h"

namespace DLC {
namespace PlayStore {

class PlayStore: public DLC::Store {

public:
PlayStore() {}
virtual ~PlayStore() {}

virtual void init() override {}

virtual void requestInfo() override {}

virtual void getDownloadState() override {}

virtual void requestDownload() override {}

virtual void getBytesDownloaded() override {}

virtual void cancelDownload() override {}
};

} // End of namespace PlayStore
} // End of namespace DLC

#endif
49 changes: 49 additions & 0 deletions backends/dlc/store.h
@@ -0,0 +1,49 @@
/* 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 DLC_STORE_H
#define DLC_STORE_H

namespace DLC {

class Store {

public:
Store() {}
virtual ~Store() {}

virtual void init() = 0;

virtual void requestInfo() = 0;

virtual void getDownloadState() = 0;

virtual void requestDownload() = 0;

virtual void getBytesDownloaded() = 0;

virtual void cancelDownload() = 0;
};

} // End of namespace DLC


#endif
1 change: 1 addition & 0 deletions backends/module.mk
Expand Up @@ -5,6 +5,7 @@ MODULE_OBJS := \
modular-backend.o \
audiocd/audiocd-stream.o \
audiocd/default/default-audiocd.o \
dlc/dlcmanager.o \
events/default/default-events.o \
fs/abstract-fs.o \
fs/stdiostream.o \
Expand Down
1 change: 1 addition & 0 deletions backends/platform/android/android.cpp
Expand Up @@ -632,6 +632,7 @@ bool OSystem_Android::hasFeature(Feature f) {
f == kFeatureJoystickDeadzone) {
return true;
}
if (f == kFeatureDLC) return true;
/* Even if we are using the 2D graphics manager,
* we are at one initGraphics3d call of supporting GLES2 */
if (f == kFeatureOpenGLForGame) return true;
Expand Down
4 changes: 4 additions & 0 deletions base/main.cpp
Expand Up @@ -71,6 +71,7 @@
#include "backends/keymapper/action.h"
#include "backends/keymapper/keymap.h"
#include "backends/keymapper/keymapper.h"
#include "backends/dlc/dlcmanager.h"

#ifdef USE_CLOUD
#ifdef USE_LIBCURL
Expand Down Expand Up @@ -699,6 +700,8 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
CloudMan.syncSaves();
#endif

DLCMan.init();

// Unless a game was specified, show the launcher dialog
if (nullptr == ConfMan.getActiveDomain())
launcherDialog();
Expand Down Expand Up @@ -848,6 +851,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
Cloud::CloudManager::destroy();
#endif
#endif
DLC::DLCManager::destroy();
PluginManager::instance().unloadDetectionPlugin();
PluginManager::instance().unloadAllPlugins();
PluginManager::destroy();
Expand Down
5 changes: 5 additions & 0 deletions common/system.h
Expand Up @@ -542,6 +542,11 @@ class OSystem : Common::NonCopyable {
*/
kFeatureShaders,

/**
* Support for downloading DLC packages.
*/
kFeatureDLC,

/**
* Support for using the native system file browser dialog
* through the DialogManager.
Expand Down
7 changes: 5 additions & 2 deletions gui/launcher.cpp
Expand Up @@ -256,8 +256,11 @@ void LauncherDialog::build() {
new ButtonWidget(this, _title + ".AboutButton", _("A~b~out"), _("About ScummVM"), kAboutCmd);
// 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"));
// I18N: Button download games button.
new ButtonWidget(this, _title + ".DownloadGamesButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);

if (g_system->hasFeature(OSystem::kFeatureDLC)) {
// I18N: Button browse downloadable games (DLC)
new ButtonWidget(this, _title + ".DownloadGamesButton", _("Download Games"), _("Download freeware games for ScummVM"), kDownloadGameCmd);
}

// Above the lowest button rows: two more buttons (directly below the list box)
DropdownButtonWidget *addButton =
Expand Down

0 comments on commit e658658

Please sign in to comment.