| 1 |
/* |
| 2 |
* Copyright (C) 2017-2018 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 |
#include "GUIGameSettings.h" |
| 10 |
|
| 11 |
#include "cores/RetroPlayer/process/RPProcessInfo.h" |
| 12 |
#include "cores/RetroPlayer/rendering/RenderContext.h" |
| 13 |
#include "settings/GameSettings.h" |
| 14 |
|
| 15 |
#include <mutex> |
| 16 |
|
| 17 |
using namespace KODI; |
| 18 |
using namespace RETRO; |
| 19 |
|
| 20 |
CGUIGameSettings::CGUIGameSettings(CRPProcessInfo& processInfo) |
| 21 |
: m_processInfo(processInfo), m_guiSettings(processInfo.GetRenderContext().GetGameSettings()) |
| 22 |
{ |
| 23 |
// Reset game settings |
| 24 |
m_guiSettings = m_processInfo.GetRenderContext().GetDefaultGameSettings(); |
| 25 |
|
| 26 |
UpdateSettings(); |
| 27 |
|
| 28 |
m_guiSettings.RegisterObserver(this); |
| 29 |
} |
| 30 |
|
| 31 |
CGUIGameSettings::~CGUIGameSettings() |
| 32 |
{ |
| 33 |
m_guiSettings.UnregisterObserver(this); |
| 34 |
} |
| 35 |
|
| 36 |
CRenderSettings CGUIGameSettings::GetSettings() const |
| 37 |
{ |
| 38 |
std::unique_lock<CCriticalSection> lock(m_mutex); |
| 39 |
|
| 40 |
return m_renderSettings; |
| 41 |
} |
| 42 |
|
| 43 |
void CGUIGameSettings::Notify(const Observable& obs, const ObservableMessage msg) |
| 44 |
{ |
| 45 |
switch (msg) |
| 46 |
{ |
| 47 |
case ObservableMessageSettingsChanged: |
| 48 |
{ |
| 49 |
UpdateSettings(); |
| 50 |
break; |
| 51 |
} |
| 52 |
default: |
| 53 |
break; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
void CGUIGameSettings::UpdateSettings() |
| 58 |
{ |
| 59 |
std::unique_lock<CCriticalSection> lock(m_mutex); |
| 60 |
|
| 61 |
// Get settings from GUI |
| 62 |
std::string videoFilter = m_guiSettings.VideoFilter(); |
| 63 |
STRETCHMODE stretchMode = m_guiSettings.StretchMode(); |
| 64 |
unsigned int rotationDegCCW = m_guiSettings.RotationDegCCW(); |
| 65 |
|
| 66 |
// Save settings for renderer |
| 67 |
m_renderSettings.VideoSettings().SetVideoFilter(videoFilter); |
| 68 |
m_renderSettings.VideoSettings().SetRenderStretchMode(stretchMode); |
| 69 |
m_renderSettings.VideoSettings().SetRenderRotation(rotationDegCCW); |
| 70 |
} |