xbmc
GUIActivePortList.h
1 /*
2  * Copyright (C) 2021-2023 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 #pragma once
10 
11 #include "IActivePortList.h"
12 #include "addons/AddonEvents.h"
13 #include "games/GameTypes.h"
14 #include "games/controllers/ControllerTypes.h"
15 #include "games/ports/types/PortNode.h"
16 #include "utils/Observer.h"
17 
18 #include <memory>
19 
20 class CFileItemList;
21 class CGUIWindow;
22 
23 namespace KODI
24 {
25 namespace GAME
26 {
27 class CController;
28 class IActivePortList;
29 
34 {
35 public:
36  CGUIActivePortList(CGUIWindow& window, int controlId, bool showInputDisabled);
37  ~CGUIActivePortList() override;
38 
39  // Implementation of IActivePortList
40  bool Initialize(GameClientPtr gameClient) override;
41  void Deinitialize() override;
42  void Refresh() override;
43 
44  // Implementation of Observer
45  void Notify(const Observable& obs, const ObservableMessage msg) override;
46 
47 private:
48  // Add-on API
49  void OnEvent(const ADDON::AddonEvent& event);
50 
51  // GUI helpers
52  void InitializeGUI();
53  void DeinitializeGUI();
54  void AddInputDisabled();
55  void AddItems(const PortVec& ports);
56  void AddItem(const ControllerPtr& controller, const std::string& controllerAddress);
57  void AddPadding();
58  void CleanupItems();
59 
60  // Construction parameters
61  CGUIWindow& m_guiWindow;
62  const int m_controlId;
63  const bool m_showInputDisabled;
64 
65  // GUI parameters
66  std::unique_ptr<CFileItemList> m_vecItems;
67  uint32_t m_alignment{0};
68 
69  // Game parameters
70  GameClientPtr m_gameClient;
71 };
72 } // namespace GAME
73 } // namespace KODI
Represents a list of files.
Definition: FileItem.h:721
A list populated by input ports on a game console.
Definition: IActivePortList.h:35
void Refresh() override
Refresh the contents of the list.
Definition: GUIActivePortList.cpp:79
Definition: AudioDecoder.h:18
Definition: GUIActivePortList.h:33
std::shared_ptr< CController > ControllerPtr
Smart pointer to a game controller (CController)
Definition: ControllerTypes.h:25
Definition: Observer.h:31
std::shared_ptr< CGameClient > GameClientPtr
Smart pointer to a game client (CGameClient)
Definition: GameTypes.h:29
Definition: AddonEvents.h:18
void Notify(const Observable &obs, const ObservableMessage msg) override
Process a message from an observable.
Definition: GUIActivePortList.cpp:103
Definition: GUIWindow.h:58
bool Initialize(GameClientPtr gameClient) override
Initialize resources.
Definition: GUIActivePortList.cpp:46
Definition: Observer.h:44
void Deinitialize() override
Deinitialize resources.
Definition: GUIActivePortList.cpp:65