Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Games: Add Player Viewer (aka "Player Manager Light") #23548

Merged
merged 1 commit into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -17742,6 +17742,7 @@ msgstr ""
#empty strings from id 34409 to 34999

#: system/settings/settings.xml
#: xbmc/games/agents/windows/GUIAgentList.cpp
#: xbmc/peripherals/Peripherals.cpp
msgctxt "#35000"
msgid "Peripherals"
Expand All @@ -17763,6 +17764,7 @@ msgctxt "#35003"
msgid "Generic disk"
msgstr ""

#: xbmc/games/agents/windows/GUIAgentList.cpp
#: xbmc/peripherals/Peripherals.cpp
msgctxt "#35004"
msgid "There are no settings available for this peripheral."
Expand Down Expand Up @@ -18301,7 +18303,20 @@ msgctxt "#35171"
msgid "Mouse"
msgstr ""

#empty strings from id 35172 to 35199
#. Name of window for configuring players while playing a game
#: addons/skin.estuary/xml/GameOSD.xml
#: addons/skin.estuary/xml/Includes_Games.xml
msgctxt "#35172"
msgid "Players"
msgstr ""

#. Notification shown when no controllers are connected in the in-game dialog that lets users configure player assignment
#: xbmc/games/agents/windows/GUIAgentList.cpp
msgctxt "#35173"
msgid "No controllers connected"
msgstr ""

#empty strings from id 35174 to 35199

#. This string is an early meme from the late 1990's that made fun of the poor translation in the 16-bit game Zero Wing from the late 1980's. DO NOT TRANSLATE!
#: system/settings/settings.xml
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions addons/skin.estuary/xml/DialogGameControllers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
but adding new XML windows breaks old skins, so it has been repurposed
for any game-related windows.
</description>
<defaultcontrol>3</defaultcontrol>
<defaultcontrol always="true">3</defaultcontrol>
<include>Animation_DialogPopupOpenClose</include>
<controls>
<include condition="Window.IsActive(gamecontrollers)">GameDialogControllers</include>
<include condition="Window.IsActive(gameports)">GameDialogPorts</include>
<include condition="Window.IsDialogTopMost(gamecontrollers)">GameDialogControllers</include>
<include condition="Window.IsDialogTopMost(gameports)">GameDialogPorts</include>
<include condition="Window.IsDialogTopMost(gameagents)">GameDialogAgents</include>
</controls>
</window>
14 changes: 10 additions & 4 deletions addons/skin.estuary/xml/GameOSD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<depth>DepthOSD</depth>
<controls>
<control type="group" id="1">
<visible>!Window.IsActive(1101) + !Window.IsActive(GameVideoFilter) + !Window.IsActive(GameStretchMode) + !Window.IsActive(GameControllers) + !Window.IsActive(GameVideoRotation) + !Window.IsActive(InGameSaves)</visible>
<visible>!Window.IsActive(1101) + !Window.IsActive(GameVideoFilter) + !Window.IsActive(GameStretchMode) + !Window.IsActive(GameControllers) + !Window.IsActive(GameVideoRotation) + !Window.IsActive(InGameSaves) + !Window.IsActive(GameAgents)</visible>
<include>Visible_Fade</include>
<control type="group" id="10">
<visible>System.GetBool(gamesgeneral.showosdhelp)</visible>
Expand Down Expand Up @@ -64,21 +64,21 @@
<control type="group" id="20">
<visible>!System.GetBool(gamesgeneral.showosdhelp)</visible>
<centerleft>50%</centerleft>
<height>480</height>
<height>560</height>
<centertop>50%</centertop>
<width>700</width>
<animation effect="fade" time="200">VisibleChange</animation>
<include content="DialogBackgroundCommons">
<param name="width" value="700" />
<param name="height" value="480" />
<param name="height" value="560" />
<param name="header_label" value="$LOCALIZE[35221]" />
<param name="header_id" value="3" />
</include>
<control type="group" id="2000">
<top>80</top>
<control type="list" id="1103">
<defaultcontrol always="true">2101</defaultcontrol>
<height>480</height>
<height>560</height>
<orientation>vertical</orientation>
<itemlayout condition="!Control.IsVisible(2200)" width="700" height="80">
<control type="image">
Expand Down Expand Up @@ -214,6 +214,12 @@
<icon>osd/fullscreen/buttons/saves.png</icon>
<onclick>ActivateWindow(InGameSaves)</onclick>
</item>
<item>
<description>Players button</description>
<label>$LOCALIZE[35172]</label>
<icon>osd/fullscreen/buttons/agent.png</icon>
<onclick>ActivateWindow(GameAgents)</onclick>
</item>
<item>
<description>Reset button</description>
<label>$LOCALIZE[13007]</label>
Expand Down
152 changes: 152 additions & 0 deletions addons/skin.estuary/xml/Includes_Games.xml
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,156 @@
</control>
</control>
</include>
<include name="GameDialogAgents">
<control type="group">
<centertop>50%</centertop>
<centerleft>50%</centerleft>
<width>1820</width>
<height>962</height>
<include content="DialogBackgroundCommons">
<param name="width" value="1820" />
<param name="height" value="962" />
<param name="header_label" value="$LOCALIZE[35172]" />
<param name="header_id" value="2" />
</include>
<control type="group">
<description>Content area</description>
<top>110</top>
<bottom>40</bottom>
<left>40</left>
<right>40</right>
<control type="group">
<description>Area of the dialog for ports</description>
<height>96</height>
<control type="button" id="3">
<description>Ports button</description>
<top>-20</top>
<bottom>-20</bottom>
<left>-20</left>
<right>-20</right>
<ondown>5</ondown>
<label>$LOCALIZE[35110]</label>
<font>font37</font>
<textoffsetx>36</textoffsetx>
<align>left</align>
<aligny>center</aligny>
<texturefocus border="40" colordiffuse="button_focus">buttons/dialogbutton-fo.png</texturefocus>
<texturenofocus border="40">buttons/dialogbutton-nofo.png</texturenofocus>
<onclick>ActivateWindow(GamePorts)</onclick>
</control>
<control type="gamecontrollerlist" id="4">
<description>Active port list. Length should fit 13 listitems (12 controllers and one "controller disconnected" indicator).</description>
<right>0</right>
<width>1248</width>
<orientation>horizontal</orientation>
<align>right</align>
<enable>false</enable>
<itemlayout width="96" height="96">
<control type="gamecontroller">
<texture>$INFO[ListItem.Icon]</texture>
<controlleraddress>$INFO[ListItem.FilenameAndPath]</controlleraddress>
<controllerdiffuse>button_focus</controllerdiffuse>
</control>
</itemlayout>
<focusedlayout width="96" height="96">
<control type="gamecontroller">
<texture>$INFO[ListItem.Icon]</texture>
<controlleraddress>$INFO[ListItem.FilenameAndPath]</controlleraddress>
<controllerdiffuse>button_focus</controllerdiffuse>
</control>
</focusedlayout>
</control>
</control>
<control type="group">
<description>Area of the dialog for players</description>
<top>136</top>
<height>576</height>
<control type="image">
<description>Player list background</description>
<top>-20</top>
<bottom>-20</bottom>
<left>-20</left>
<right>-20</right>
<texture border="40">buttons/dialogbutton-nofo.png</texture>
</control>
<control type="list" id="5">
<description>Player list</description>
<onup>3</onup>
<ondown>6</ondown>
<pagecontrol>61</pagecontrol>
<scrolltime tween="sine">200</scrolltime>
<orientation>vertical</orientation>
<itemlayout width="1740" height="96">
<include>GameDialogAgentLayout</include>
</itemlayout>
<focusedlayout width="1740" height="96">
<control type="image">
<top>-20</top>
<bottom>-20</bottom>
<left>-20</left>
<right>-20</right>
<texture border="40" colordiffuse="button_focus">buttons/dialogbutton-fo.png</texture>
<visible>Control.HasFocus(5)</visible>
</control>
<include>GameDialogAgentLayout</include>
</focusedlayout>
</control>
</control>
<control type="scrollbar" id="61">
<description>Agent list scroll bar</description>
<top>136</top>
<height>576</height>
<right>-12</right>
<width>12</width>
<orientation>vertical</orientation>
</control>
<control type="grouplist" id="6">
<description>Action buttons</description>
<left>-20</left>
<right>-20</right>
<bottom>-20</bottom>
<height>100</height>
<onup>5</onup>
<orientation>horizontal</orientation>
<itemgap>dialogbuttons_itemgap</itemgap>
<include content="DefaultDialogButton">
<param name="width" value="330" />
<param name="id" value="18" />
<param name="label" value="$LOCALIZE[186]" />
</include>
</control>
</control>
</control>
</include>
<include name="GameDialogAgentLayout">
<control type="label">
<description>Player name</description>
<top>20</top>
<left>20</left>
<label>$INFO[ListItem.Label]</label>
<font>font37</font>
<shadowcolor>text_shadow</shadowcolor>
<align>left</align>
</control>
<control type="gamecontrollerlist">
<description>Player's game controller list. Length should fit 13 listitems (12 players and one "input disabled" indicator).</description>
<right>0</right>
<width>1248</width>
<orientation>horizontal</orientation>
<align>right</align>
<enable>false</enable>
<itemlayout width="96" height="96">
<control type="gamecontroller">
<peripherallocation>$INFO[ListItem.FilenameAndPath]</peripherallocation>
<controllerdiffuse>button_focus</controllerdiffuse>
</control>
</itemlayout>
<focusedlayout width="96" height="96">
<control type="gamecontroller">
<peripherallocation>$INFO[ListItem.FilenameAndPath]</peripherallocation>
<controllerdiffuse>button_focus</controllerdiffuse>
</control>
</focusedlayout>
</control>
</include>
</includes>
4 changes: 4 additions & 0 deletions cmake/treedata/common/games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ xbmc/games/addons/cheevos games/addons/cheevos
xbmc/games/addons/input games/addons/input
xbmc/games/addons/streams games/addons/streams
xbmc/games/agents games/agents
xbmc/games/agents/input games/agents/input
xbmc/games/agents/windows games/agents/windows
xbmc/games/controllers games/controllers
xbmc/games/controllers/dialogs games/controllers/dialogs
xbmc/games/controllers/guicontrols games/controllers/guicontrols
xbmc/games/controllers/input games/controllers/input
xbmc/games/controllers/listproviders games/controllers/listproviders
xbmc/games/controllers/types games/controllers/types
xbmc/games/controllers/windows games/controllers/windows
xbmc/games/dialogs games/dialogs
xbmc/games/dialogs/osd games/dialogs/osd
xbmc/games/ports/guicontrols games/ports/guicontrols
xbmc/games/ports/input games/ports/input
xbmc/games/ports/types games/ports/types
xbmc/games/ports/windows games/ports/windows
Expand Down
4 changes: 4 additions & 0 deletions xbmc/games/GameTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@ class CGameClientDevice;
using GameClientDevicePtr = std::unique_ptr<CGameClientDevice>;
using GameClientDeviceVec = std::vector<GameClientDevicePtr>;

class CGameAgent;
using GameAgentPtr = std::shared_ptr<CGameAgent>;
using GameAgentVec = std::vector<GameAgentPtr>;

} // namespace GAME
} // namespace KODI
6 changes: 4 additions & 2 deletions xbmc/games/agents/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
set(SOURCES GameAgentManager.cpp
set(SOURCES GameAgent.cpp
GameAgentManager.cpp
)

set(HEADERS GameAgentManager.h
set(HEADERS GameAgent.h
GameAgentManager.h
)

core_add_library(games_agents)
80 changes: 80 additions & 0 deletions xbmc/games/agents/GameAgent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (C) 2017-2023 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.
*/

#include "GameAgent.h"

#include "games/agents/input/GameAgentJoystick.h"
#include "games/controllers/Controller.h"
#include "games/controllers/ControllerLayout.h"
#include "peripherals/devices/Peripheral.h"

using namespace KODI;
using namespace GAME;

CGameAgent::CGameAgent(PERIPHERALS::PeripheralPtr peripheral)
: m_peripheral(std::move(peripheral)),
m_joystick(std::make_unique<CGameAgentJoystick>(m_peripheral))
{
Initialize();
}

CGameAgent::~CGameAgent()
{
Deinitialize();
}

void CGameAgent::Initialize()
{
m_joystick->Initialize();
}

void CGameAgent::Deinitialize()
{
m_joystick->Deinitialize();
}

std::string CGameAgent::GetPeripheralName() const
{
std::string deviceName = m_peripheral->DeviceName();

// Handle unknown device name
if (deviceName.empty())
{
ControllerPtr controller = m_peripheral->ControllerProfile();
if (controller)
deviceName = controller->Layout().Label();
}

return deviceName;
}

const std::string& CGameAgent::GetPeripheralLocation() const
{
return m_peripheral->Location();
}

ControllerPtr CGameAgent::GetController() const
{
// Use joystick controller if joystick is initialized
ControllerPtr controller = m_joystick->Appearance();
if (controller)
return controller;

// Use peripheral controller if joystick is deinitialized
return m_peripheral->ControllerProfile();
}

CDateTime CGameAgent::LastActive() const
{
return m_peripheral->LastActive();
}

float CGameAgent::GetActivation() const
{
return m_joystick->GetActivation();
}