| 1 |
/* |
| 2 |
* Copyright (C) 2022-2024 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 "IAgentControllerList.h" |
| 12 |
#include "addons/AddonEvents.h" |
| 13 |
#include "games/GameTypes.h" |
| 14 |
#include "games/controllers/ControllerTypes.h" |
| 15 |
#include "utils/Observer.h" |
| 16 |
|
| 17 |
#include <map> |
| 18 |
#include <memory> |
| 19 |
#include <set> |
| 20 |
#include <string> |
| 21 |
|
| 22 |
class CFileItem; |
| 23 |
class CFileItemList; |
| 24 |
class CGUIViewControl; |
| 25 |
class CGUIWindow; |
| 26 |
|
| 27 |
namespace KODI |
| 28 |
{ |
| 29 |
namespace GAME |
| 30 |
{ |
| 31 |
class CAgentController; |
| 32 |
|
| 33 |
/*! |
| 34 |
* \ingroup games |
| 35 |
*/ |
| 36 |
class CGUIAgentControllerList : public IAgentControllerList, public Observer |
| 37 |
{ |
| 38 |
public: |
| 39 |
CGUIAgentControllerList(CGUIWindow& window); |
| 40 |
~CGUIAgentControllerList() override; |
| 41 |
|
| 42 |
// Implementation of IAgentControllerList |
| 43 |
void OnWindowLoaded() override; |
| 44 |
void OnWindowUnload() override; |
| 45 |
bool Initialize(GameClientPtr gameClient) override; |
| 46 |
void Deinitialize() override; |
| 47 |
bool HasControl(int controlId) const override; |
| 48 |
int GetCurrentControl() const override; |
| 49 |
void FrameMove() override; |
| 50 |
void Refresh() override; |
| 51 |
void SetFocused() override; |
| 52 |
void OnSelect() override; |
| 53 |
|
| 54 |
// Implementation of Observer |
| 55 |
void Notify(const Observable& obs, const ObservableMessage msg) override; |
| 56 |
|
| 57 |
private: |
| 58 |
// Add-on API |
| 59 |
void OnEvent(const ADDON::AddonEvent& event); |
| 60 |
|
| 61 |
// GUI functions |
| 62 |
void AddItem(const CAgentController& agentController); |
| 63 |
void CleanupItems(); |
| 64 |
void OnItemFocus(unsigned int itemIndex); |
| 65 |
void OnControllerFocus(const std::string& focusedAgent); |
| 66 |
void OnItemSelect(unsigned int itemIndex); |
| 67 |
void OnControllerSelect(const CFileItem& selectedAgentItem); |
| 68 |
void ShowControllerDialog(const CAgentController& agentController); |
| 69 |
|
| 70 |
// Construction parameters |
| 71 |
CGUIWindow& m_guiWindow; |
| 72 |
|
| 73 |
// GUI parameters |
| 74 |
std::unique_ptr<CGUIViewControl> m_viewControl; |
| 75 |
std::unique_ptr<CFileItemList> m_vecItems; |
| 76 |
unsigned int m_currentItem{0}; |
| 77 |
std::string m_currentAgent; |
| 78 |
|
| 79 |
// Game parameters |
| 80 |
GameClientPtr m_gameClient; |
| 81 |
}; |
| 82 |
} // namespace GAME |
| 83 |
} // namespace KODI |