Skip to content

Commit

Permalink
Merge pull request #12367 from garbear/game-osd
Browse files Browse the repository at this point in the history
Game OSD
  • Loading branch information
garbear committed Jul 5, 2017
2 parents 5373dc2 + eb77a45 commit 6a12b09
Show file tree
Hide file tree
Showing 32 changed files with 972 additions and 25 deletions.
21 changes: 20 additions & 1 deletion addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -6504,6 +6504,7 @@ msgstr ""
#: xbmc/video/dialogs/GUIDialogVideoSettings.cpp
#: addons/skin.estuary/xml/Variables.xml
#: addons/skin.estuary/xml/Custom_1106_VideoOSDSettings.xml
#: addons/skin.estuary/xml/GameOSD.xml
msgctxt "#13395"
msgid "Video settings"
msgstr ""
Expand Down Expand Up @@ -16963,7 +16964,25 @@ msgctxt "#35220"
msgid "Game providers"
msgstr ""

#empty strings from id 35221 to 35249
#. Title of the game OSD menu
#: addons/skin.estuary/xml/GameOSD.xml
msgctxt "#35221"
msgid "Game Menu"
msgstr ""

#. Label of button in the in-game menu for stopping game playback
#: addons/skin.estuary/xml/GameOSD.xml
msgctxt "#35222"
msgid "Exit"
msgstr ""

#. Label of button in the in-game menu for opening the input configuration window
#: addons/skin.estuary/xml/GameOSD.xml
msgctxt "#35223"
msgid "Input settings"
msgstr ""

#empty strings from id 35224 to 35249

#: xbmc/windows/GUIMediaWindow.cpp
msgctxt "#35250"
Expand Down
1 change: 1 addition & 0 deletions addons/skin.estuary/xml/DialogSeekBar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<controls>
<include>PVRChannelNumberInput</include>
<control type="group">
<visible>!Player.HasGame</visible>
<bottom>0</bottom>
<height>190</height>
<control type="image">
Expand Down
71 changes: 71 additions & 0 deletions addons/skin.estuary/xml/GameOSD.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<window>
<defaultcontrol always="true">11101</defaultcontrol>
<include>Animation_DialogPopupOpenClose</include>
<controls>
<control type="group">
<centerleft>50%</centerleft>
<height>560</height>
<centertop>50%</centertop>
<width>700</width>
<visible>!Window.IsActive(GameVideoSettings) + !Window.IsActive(GameControllers)</visible>
<animation effect="fade" time="200">VisibleChange</animation>
<include content="DialogBackgroundCommons">
<param name="width" value="700" />
<param name="height" value="80" />
<param name="header_label" value="$LOCALIZE[35221]" />
<param name="header_id" value="1" />
</include>
<control type="group" id="11000">
<left>0</left>
<top>80</top>
<control type="grouplist" id="11101">
<width>700</width>
<height>360</height>
<itemgap>0</itemgap>
<onup>11100</onup>
<ondown>11100</ondown>
<orientation>vertical</orientation>
<control type="button" id="11102">
<description>Resume button</description>
<width>700</width>
<include>DialogSettingButton</include>
<label>$LOCALIZE[13404]</label>
<label2>Select + X</label2>
<onclick>Play</onclick>
</control>
<control type="button" id="11103">
<description>Reset button</description>
<width>700</width>
<include>DialogSettingButton</include>
<label>$LOCALIZE[10035]</label>
<label2>Select + B</label2>
<onclick>PlayerControl(Reset)</onclick>
</control>
<control type="button" id="11104">
<description>Stop button</description>
<width>700</width>
<include>DialogSettingButton</include>
<label>$LOCALIZE[35222]</label>
<label2>Select + Start</label2>
<onclick>Stop</onclick>
</control>
<control type="button" id="11107">
<description>Video settings button</description>
<width>700</width>
<include>DialogSettingButton</include>
<label>$LOCALIZE[13395]</label>
<onclick>ActivateWindow(gamevideosettings)</onclick>
</control>
<control type="button" id="11109">
<description>Input settings button</description>
<width>700</width>
<include>DialogSettingButton</include>
<label>$LOCALIZE[35223]</label>
<onclick>ActivateWindow(gamecontrollers)</onclick>
</control>
</control>
</control>
</control>
</controls>
</window>
1 change: 1 addition & 0 deletions cmake/treedata/common/games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ xbmc/games/controllers/dialogs games/controllers/dialogs
xbmc/games/controllers/guicontrols games/controllers/guicontrols
xbmc/games/controllers/windows games/controllers/windows
xbmc/games/dialogs games/dialogs
xbmc/games/dialogs/osd games/dialogs/osd
xbmc/games/ports games/ports
xbmc/games/tags games/tags
xbmc/games/windows games/windows
100 changes: 100 additions & 0 deletions xbmc/cores/RetroPlayer/RetroPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@
#include "cores/VideoPlayer/Process/ProcessInfo.h"
#include "games/addons/playback/IGameClientPlayback.h"
#include "games/addons/GameClient.h"
#include "games/ports/PortManager.h"
#include "games/tags/GameInfoTag.h"
#include "games/GameServices.h"
#include "games/GameUtils.h"
#include "guilib/GUIDialog.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/WindowIDs.h"
#include "input/Action.h"
#include "input/ActionIDs.h"
#include "settings/MediaSettings.h"
#include "threads/SingleLock.h"
#include "utils/log.h"
#include "utils/MathUtils.h"
#include "utils/StringUtils.h"
#include "FileItem.h"
#include "ServiceBroker.h"
#include "URL.h"

using namespace KODI;
Expand All @@ -54,6 +63,14 @@ bool CRetroPlayer::OpenFile(const CFileItem& file, const CPlayerOptions& options
std::string redactedPath = CURL::GetRedacted(file.GetPath());
CLog::Log(LOGINFO, "RetroPlayer: Opening: %s", redactedPath.c_str());

// Reset game settings
CMediaSettings::GetInstance().GetCurrentGameSettings() = CMediaSettings::GetInstance().GetDefaultGameSettings();

//! @todo - Remove this when RetroPlayer has a renderer
CVideoSettings &videoSettings = CMediaSettings::GetInstance().GetCurrentVideoSettings();
videoSettings.m_ScalingMethod = CMediaSettings::GetInstance().GetCurrentGameSettings().ScalingMethod();
videoSettings.m_ViewMode = CMediaSettings::GetInstance().GetCurrentGameSettings().ViewMode();

CSingleLock lock(m_mutex);

if (IsPlaying())
Expand Down Expand Up @@ -155,6 +172,9 @@ void CRetroPlayer::Pause()
{
m_gameClient->GetPlayback()->PauseUnpause();
m_audio->Enable(m_gameClient->GetPlayback()->GetSpeed() == 1.0);

if (m_gameClient->GetPlayback()->GetSpeed() != 0.0)
CloseOSD();
}
}

Expand Down Expand Up @@ -251,6 +271,9 @@ void CRetroPlayer::SeekTime(int64_t iTime /* = 0 */)
{
m_gameClient->GetPlayback()->SeekTimeMs(static_cast<unsigned int>(iTime));
m_audio->Enable(m_gameClient->GetPlayback()->GetSpeed() == 1.0);

if (m_gameClient->GetPlayback()->GetSpeed() != 0.0)
CloseOSD();
}
}

Expand Down Expand Up @@ -298,6 +321,9 @@ void CRetroPlayer::SetSpeed(float speed)

m_gameClient->GetPlayback()->SetSpeed(speed);
m_audio->Enable(m_gameClient->GetPlayback()->GetSpeed() == 1.0);

if (m_gameClient->GetPlayback()->GetSpeed() != 0.0)
CloseOSD();
}
}

Expand All @@ -308,6 +334,33 @@ float CRetroPlayer::GetSpeed()
return 0;
}

bool CRetroPlayer::OnAction(const CAction &action)
{
switch (action.GetID())
{
case ACTION_PLAYER_RESET:
{
if (m_gameClient)
{
double previousPlaySpeed = m_gameClient->GetPlayback()->GetSpeed();
m_gameClient->GetPlayback()->SetSpeed(0.0);
CServiceBroker::GetGameServices().PortManager().HardwareReset();
if (previousPlaySpeed > 0.0)
m_gameClient->GetPlayback()->SetSpeed(previousPlaySpeed);
else
m_gameClient->GetPlayback()->SetSpeed(1.0f);

CloseOSD();
}
return true;
}
default:
break;
}

return false;
}

std::string CRetroPlayer::GetPlayerState()
{
if (m_gameClient)
Expand All @@ -322,6 +375,46 @@ bool CRetroPlayer::SetPlayerState(const std::string& state)
return false;
}

void CRetroPlayer::FrameMove()
{
m_renderManager.FrameMove();

if (m_gameClient)
{
const bool bFullscreen = (g_windowManager.GetActiveWindowID() == WINDOW_FULLSCREEN_GAME);

switch (m_state)
{
case State::STARTING:
{
if (bFullscreen)
m_state = State::FULLSCREEN;
break;
}
case State::FULLSCREEN:
{
if (!bFullscreen)
{
m_priorSpeed = m_gameClient->GetPlayback()->GetSpeed();
m_gameClient->GetPlayback()->SetSpeed(0.0);
m_state = State::BACKGROUND;
}
break;
}
case State::BACKGROUND:
{
if (bFullscreen)
{
if (m_gameClient->GetPlayback()->GetSpeed() == 0.0)
m_gameClient->GetPlayback()->SetSpeed(m_priorSpeed);
m_state = State::FULLSCREEN;
}
break;
}
}
}
}

bool CRetroPlayer::Supports(EINTERLACEMETHOD method)
{
return m_processInfo->Supports(method);
Expand All @@ -342,6 +435,13 @@ void CRetroPlayer::UpdateRenderInfo(CRenderInfo &info)
m_processInfo->UpdateRenderInfo(info);
}

void CRetroPlayer::CloseOSD()
{
CGUIDialog *pDialog = g_windowManager.GetDialog(WINDOW_DIALOG_GAME_OSD);
if (pDialog)
pDialog->Close(true, WINDOW_FULLSCREEN_GAME);
}

void CRetroPlayer::PrintGameInfo(const CFileItem &file) const
{
const CGameInfoTag *tag = file.GetGameInfoTag();
Expand Down
17 changes: 16 additions & 1 deletion xbmc/cores/RetroPlayer/RetroPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ namespace RETRO
//virtual bool HasMenu() const override { return false; }
//virtual void DoAudioWork() override { }
//virtual bool OnAction(const CAction &action) override { return false; }
bool OnAction(const CAction &action) override;
std::string GetPlayerState() override;
bool SetPlayerState(const std::string& state) override;
//virtual std::string GetPlayingTitle() override { return ""; }
//virtual bool SwitchChannel(const PVR::CPVRChannelPtr &channel) override { return false; }
//virtual void GetAudioCapabilities(std::vector<int> &audioCaps) override { audioCaps.assign(1,IPC_AUD_ALL); }
//virtual void GetSubtitleCapabilities(std::vector<int> &subCaps) override { subCaps.assign(1,IPC_SUBS_ALL); }
void FrameMove() override { m_renderManager.FrameMove(); }
void FrameMove() override;
void Render(bool clear, uint32_t alpha = 255, bool gui = true) override { m_renderManager.Render(clear, 0, alpha, gui); }
void FlushRenderer() override { m_renderManager.Flush(); }
void SetRenderViewMode(int mode) override { m_renderManager.SetViewMode(mode); }
Expand All @@ -146,11 +147,25 @@ namespace RETRO
void UpdateRenderBuffers(int queued, int discard, int free) override {}

private:
/*!
* \brief Closes the OSD and shows the FullscreenGame window
*/
void CloseOSD();

/**
* \brief Dump game information (if any) to the debug log.
*/
void PrintGameInfo(const CFileItem &file) const;

enum class State
{
STARTING,
FULLSCREEN,
BACKGROUND,
};

State m_state = State::STARTING;
double m_priorSpeed = 0.0f; // Speed of gameplay before entering OSD
CDVDClock m_clock;
CRenderManager m_renderManager;
std::unique_ptr<CProcessInfo> m_processInfo;
Expand Down
2 changes: 2 additions & 0 deletions xbmc/games/addons/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(SOURCES GameClient.cpp
GameClientHardware.cpp
GameClientInGameSaves.cpp
GameClientJoystick.cpp
GameClientKeyboard.cpp
Expand All @@ -9,6 +10,7 @@ set(SOURCES GameClient.cpp

set(HEADERS GameClient.h
GameClientCallbacks.h
GameClientHardware.h
GameClientInGameSaves.h
GameClientJoystick.h
GameClientKeyboard.h
Expand Down
11 changes: 9 additions & 2 deletions xbmc/games/addons/GameClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "GameClient.h"
#include "GameClientCallbacks.h"
#include "GameClientHardware.h"
#include "GameClientInGameSaves.h"
#include "GameClientJoystick.h"
#include "GameClientKeyboard.h"
Expand Down Expand Up @@ -485,7 +486,7 @@ void CGameClient::ResetPlayback()
m_playback.reset(new CGameClientRealtimePlayback);
}

void CGameClient::Reset()
void CGameClient::Reset(unsigned int port)
{
ResetPlayback();

Expand Down Expand Up @@ -517,6 +518,8 @@ void CGameClient::CloseFile()

ClearPorts();

m_hardware.reset();

if (m_bSupportsKeyboard)
CloseKeyboard();

Expand Down Expand Up @@ -744,6 +747,10 @@ bool CGameClient::OpenPort(unsigned int port)
if (m_ports.find(port) != m_ports.end())
return false;

// Ensure hardware is open to receive events from the port
if (!m_hardware)
m_hardware.reset(new CGameClientHardware(this));

ControllerVector controllers = GetControllers();
if (!controllers.empty())
{
Expand All @@ -757,7 +764,7 @@ bool CGameClient::OpenPort(unsigned int port)
if (m_bSupportsKeyboard)
device = PERIPHERALS::PERIPHERAL_JOYSTICK;

CServiceBroker::GetGameServices().PortManager().OpenPort(m_ports[port].get(), this, port, device);
CServiceBroker::GetGameServices().PortManager().OpenPort(m_ports[port].get(), m_hardware.get(), this, port, device);

UpdatePort(port, controller);

Expand Down
Loading

0 comments on commit 6a12b09

Please sign in to comment.