Skip to content

Commit

Permalink
Games: Add Agent Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
garbear committed Jul 18, 2023
1 parent 97d4534 commit ac31332
Show file tree
Hide file tree
Showing 48 changed files with 2,277 additions and 17 deletions.
22 changes: 21 additions & 1 deletion addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -18290,7 +18290,27 @@ 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 ""

#. Name of window for viewing players while playing a game
#: addons/skin.estuary/xml/GameOSD.xml
#: addons/skin.estuary/xml/Includes_Games.xml
msgctxt "#35173"
msgid "View 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 "#35174"
msgid "No controllers connected"
msgstr ""

#empty strings from id 35175 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
Loading
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,11 +5,12 @@
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>
<controls>
</controls>
Expand Down
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[35173]</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[35173]" />
<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>GameDialogAgentList</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>GameDialogAgentList</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="GameDialogAgentList">
<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)
71 changes: 71 additions & 0 deletions xbmc/games/agents/GameAgent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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() = default;

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;
}

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

ControllerPtr CGameAgent::GetController() const
{
return m_peripheral->ControllerProfile();
}

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

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

0 comments on commit ac31332

Please sign in to comment.