| 1 |
/* |
| 2 |
* Copyright (C) 2017-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "GameClientSubsystem.h" |
| 10 |
|
| 11 |
#include "GameClient.h" |
| 12 |
#include "GameClientProperties.h" |
| 13 |
#include "addons/kodi-dev-kit/include/kodi/addon-instance/Game.h" |
| 14 |
#include "games/addons/cheevos/GameClientCheevos.h" |
| 15 |
#include "games/addons/input/GameClientInput.h" |
| 16 |
#include "games/addons/streams/GameClientStreams.h" |
| 17 |
|
| 18 |
#include <memory> |
| 19 |
|
| 20 |
using namespace KODI; |
| 21 |
using namespace GAME; |
| 22 |
|
| 23 |
CGameClientSubsystem::CGameClientSubsystem(CGameClient& gameClient, |
| 24 |
AddonInstance_Game& addonStruct, |
| 25 |
CCriticalSection& clientAccess) |
| 26 |
: m_gameClient(gameClient), m_struct(addonStruct), m_clientAccess(clientAccess) |
| 27 |
{ |
| 28 |
} |
| 29 |
|
| 30 |
CGameClientSubsystem::~CGameClientSubsystem() = default; |
| 31 |
|
| 32 |
GameClientSubsystems CGameClientSubsystem::CreateSubsystems(CGameClient& gameClient, |
| 33 |
AddonInstance_Game& gameStruct, |
| 34 |
CCriticalSection& clientAccess) |
| 35 |
{ |
| 36 |
GameClientSubsystems subsystems = {}; |
| 37 |
|
| 38 |
subsystems.Cheevos = std::make_unique<CGameClientCheevos>(gameClient, gameStruct); |
| 39 |
subsystems.Input = std::make_unique<CGameClientInput>(gameClient, gameStruct, clientAccess); |
| 40 |
subsystems.AddonProperties = |
| 41 |
std::make_unique<CGameClientProperties>(gameClient, *gameStruct.props); |
| 42 |
subsystems.Streams = std::make_unique<CGameClientStreams>(gameClient); |
| 43 |
|
| 44 |
return subsystems; |
| 45 |
} |
| 46 |
|
| 47 |
void CGameClientSubsystem::DestroySubsystems(GameClientSubsystems& subsystems) |
| 48 |
{ |
| 49 |
subsystems.Cheevos.reset(); |
| 50 |
subsystems.Input.reset(); |
| 51 |
subsystems.AddonProperties.reset(); |
| 52 |
subsystems.Streams.reset(); |
| 53 |
} |
| 54 |
|
| 55 |
CGameClientCheevos& CGameClientSubsystem::Cheevos() const |
| 56 |
{ |
| 57 |
return m_gameClient.Cheevos(); |
| 58 |
} |
| 59 |
|
| 60 |
CGameClientInput& CGameClientSubsystem::Input() const |
| 61 |
{ |
| 62 |
return m_gameClient.Input(); |
| 63 |
} |
| 64 |
|
| 65 |
CGameClientProperties& CGameClientSubsystem::AddonProperties() const |
| 66 |
{ |
| 67 |
return m_gameClient.AddonProperties(); |
| 68 |
} |
| 69 |
|
| 70 |
CGameClientStreams& CGameClientSubsystem::Streams() const |
| 71 |
{ |
| 72 |
return m_gameClient.Streams(); |
| 73 |
} |