1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*
* Copyright (C) 2012-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "GameTypes.h"
#include <set>
#include <string>
class CFileItem;
class CURL;
namespace ADDON
{
class IAddon;
using AddonPtr = std::shared_ptr<IAddon>;
using VECADDONS = std::vector<AddonPtr>;
} // namespace ADDON
namespace KODI
{
namespace GAME
{
/*!
* \ingroup games
* \brief Game related utilities.
*/
class CGameUtils
{
public:
/*!
* \brief Set the game client property, prompt the user for a savestate if there are any
* (savestates store the information of which game client created it).
* If there are no savestates or the user wants a new savestate, prompt the user
* for a game client.
*
* \param item The item with or without a game client in its info tag
* \param savestatePath Output. The path to the savestate selected. Empty if new savestate was
* selected
*
* \return True if the item has a valid game client ID in its info tag
*/
static bool FillInGameClient(CFileItem& item, std::string& savestatePath);
/*!
* \brief Check if the file extension is supported by an add-on in
* a local or remote repository
*
* \param path The path of the game file
*
* \return true if the path's extension is supported by a known game client
*/
static bool HasGameExtension(const std::string& path);
/*!
* \brief Get all game extensions
*/
static std::set<std::string> GetGameExtensions();
/*!
* \brief Check if game script or game add-on can be launched directly
*
* \return true if the add-on can be launched, false otherwise
*/
static bool IsStandaloneGame(const ADDON::AddonPtr& addon);
private:
static void GetGameClients(const CFileItem& file,
GameClientVector& candidates,
GameClientVector& installable,
bool& bHasVfsGameClient);
static void GetGameClients(const ADDON::VECADDONS& addons,
const CURL& translatedUrl,
GameClientVector& candidates,
bool& bHasVfsGameClient);
/*!
* \brief Install the specified game client
*
* If the game client is not installed, a model dialog is shown installing
* the game client. If the installation fails, an error dialog is shown.
*
* \param gameClient The game client to install
*
* \return True if the game client is installed, false otherwise
*/
static bool Install(const std::string& gameClient);
/*!
* \brief Enable the specified game client
*
* \param gameClient the game client to enable
*
* \return True if the game client is enabled, false otherwise
*/
static bool Enable(const std::string& gameClient);
};
} // namespace GAME
} // namespace KODI
|