blob: 3fed6b75640b464bb7d9b9160c6d097948a74e04 (
plain)
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
|
/*
* Copyright (C) 2021 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 "IPortList.h"
#include "addons/AddonEvents.h"
#include "games/GameTypes.h"
#include "games/controllers/ControllerTypes.h"
#include "games/controllers/dialogs/ControllerSelect.h"
#include "games/controllers/types/ControllerTree.h"
#include <map>
#include <memory>
#include <string>
class CFileItemList;
class CGUIViewControl;
class CGUIWindow;
namespace KODI
{
namespace GAME
{
class CGUIPortList : public IPortList
{
public:
CGUIPortList(CGUIWindow& window);
~CGUIPortList() override;
// Implementation of IPortList
void OnWindowLoaded() override;
void OnWindowUnload() override;
bool Initialize(GameClientPtr gameClient) override;
void Deinitialize() override;
bool HasControl(int controlId) override;
int GetCurrentControl() override;
void Refresh() override;
void FrameMove() override;
void SetFocused() override;
bool OnSelect() override;
void ResetPorts() override;
private:
// Add-on API
void OnEvent(const ADDON::AddonEvent& event);
bool AddItems(const CPortNode& port, unsigned int& itemId, const std::string& itemLabel);
void CleanupItems();
void OnItemFocus(unsigned int itemIndex);
void OnItemSelect(unsigned int itemIndex);
// Controller selection callback
void OnControllerSelected(const CPortNode& port, const ControllerPtr& controller);
static std::string GetLabel(const CPortNode& port);
// Construction parameters
CGUIWindow& m_guiWindow;
// GUI parameters
CControllerSelect m_controllerSelectDialog;
std::string m_focusedPort; // Address of focused port
int m_currentItem{-1}; // Index of the selected item, or -1 if no item is selected
std::unique_ptr<CGUIViewControl> m_viewControl;
std::unique_ptr<CFileItemList> m_vecItems;
// Game parameters
GameClientPtr m_gameClient;
std::map<unsigned int, std::string> m_itemToAddress; // item index -> port address
std::map<std::string, unsigned int> m_addressToItem; // port address -> item index
};
} // namespace GAME
} // namespace KODI
|