blob: 98c1e077e896280c30625e2ad55b9279a212c446 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*
* Copyright (C) 2017-2018 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 "DialogGameStretchMode.h"
#include "FileItem.h"
#include "cores/RetroPlayer/RetroPlayerUtils.h"
#include "cores/RetroPlayer/guibridge/GUIGameVideoHandle.h"
#include "guilib/LocalizeStrings.h"
#include "guilib/WindowIDs.h"
#include "settings/GameSettings.h"
#include "settings/MediaSettings.h"
#include "utils/Variant.h"
using namespace KODI;
using namespace GAME;
const std::vector<CDialogGameStretchMode::StretchModeProperties>
CDialogGameStretchMode::m_allStretchModes = {
{630, RETRO::STRETCHMODE::Normal},
// { 631, RETRO::STRETCHMODE::Zoom }, //! @todo RetroArch allows trimming some outer
// pixels
{632, RETRO::STRETCHMODE::Stretch4x3},
{35232, RETRO::STRETCHMODE::Fullscreen},
{635, RETRO::STRETCHMODE::Original},
};
CDialogGameStretchMode::CDialogGameStretchMode()
: CDialogGameVideoSelect(WINDOW_DIALOG_GAME_STRETCH_MODE)
{
}
std::string CDialogGameStretchMode::GetHeading()
{
return g_localizeStrings.Get(35233); // "Stretch mode"
}
void CDialogGameStretchMode::PreInit()
{
m_stretchModes.clear();
for (const auto& stretchMode : m_allStretchModes)
{
bool bSupported = false;
switch (stretchMode.stretchMode)
{
case RETRO::STRETCHMODE::Normal:
case RETRO::STRETCHMODE::Original:
bSupported = true;
break;
case RETRO::STRETCHMODE::Stretch4x3:
case RETRO::STRETCHMODE::Fullscreen:
if (m_gameVideoHandle)
{
bSupported = m_gameVideoHandle->SupportsRenderFeature(RETRO::RENDERFEATURE::STRETCH) ||
m_gameVideoHandle->SupportsRenderFeature(RETRO::RENDERFEATURE::PIXEL_RATIO);
}
break;
default:
break;
}
if (bSupported)
m_stretchModes.emplace_back(stretchMode);
}
}
void CDialogGameStretchMode::GetItems(CFileItemList& items)
{
for (const auto& stretchMode : m_stretchModes)
{
CFileItemPtr item = std::make_shared<CFileItem>(g_localizeStrings.Get(stretchMode.stringIndex));
const std::string stretchModeId =
RETRO::CRetroPlayerUtils::StretchModeToIdentifier(stretchMode.stretchMode);
if (!stretchModeId.empty())
item->SetProperty("game.stretchmode", CVariant{stretchModeId});
items.Add(std::move(item));
}
}
void CDialogGameStretchMode::OnItemFocus(unsigned int index)
{
if (index < m_stretchModes.size())
{
const RETRO::STRETCHMODE stretchMode = m_stretchModes[index].stretchMode;
CGameSettings& gameSettings = CMediaSettings::GetInstance().GetCurrentGameSettings();
if (gameSettings.StretchMode() != stretchMode)
{
gameSettings.SetStretchMode(stretchMode);
gameSettings.NotifyObservers(ObservableMessageSettingsChanged);
}
}
}
unsigned int CDialogGameStretchMode::GetFocusedItem() const
{
CGameSettings& gameSettings = CMediaSettings::GetInstance().GetCurrentGameSettings();
for (unsigned int i = 0; i < m_stretchModes.size(); i++)
{
const RETRO::STRETCHMODE stretchMode = m_stretchModes[i].stretchMode;
if (stretchMode == gameSettings.StretchMode())
return i;
}
return 0;
}
void CDialogGameStretchMode::PostExit()
{
m_stretchModes.clear();
}
bool CDialogGameStretchMode::OnClickAction()
{
Close();
return true;
}
|