blob: 7037a6b35c3b4ef56c22ceb5881afab984617be5 (
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
|
/*
* Copyright (C) 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 "DialogGameVideoRotation.h"
#include "FileItem.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;
CDialogGameVideoRotation::CDialogGameVideoRotation()
: CDialogGameVideoSelect(WINDOW_DIALOG_GAME_VIDEO_ROTATION)
{
}
std::string CDialogGameVideoRotation::GetHeading()
{
return g_localizeStrings.Get(35227); // "Rotation"
}
void CDialogGameVideoRotation::PreInit()
{
m_rotations.clear();
// Present the user with clockwise rotation
m_rotations.push_back(0);
m_rotations.push_back(270);
m_rotations.push_back(180);
m_rotations.push_back(90);
}
void CDialogGameVideoRotation::GetItems(CFileItemList& items)
{
for (unsigned int rotation : m_rotations)
{
CFileItemPtr item = std::make_shared<CFileItem>(GetRotationLabel(rotation));
item->SetProperty("game.videorotation", CVariant{rotation});
items.Add(std::move(item));
}
}
void CDialogGameVideoRotation::OnItemFocus(unsigned int index)
{
if (index < m_rotations.size())
{
const unsigned int rotationDegCCW = m_rotations[index];
CGameSettings& gameSettings = CMediaSettings::GetInstance().GetCurrentGameSettings();
if (gameSettings.RotationDegCCW() != rotationDegCCW)
{
gameSettings.SetRotationDegCCW(rotationDegCCW);
gameSettings.NotifyObservers(ObservableMessageSettingsChanged);
}
}
}
unsigned int CDialogGameVideoRotation::GetFocusedItem() const
{
CGameSettings& gameSettings = CMediaSettings::GetInstance().GetCurrentGameSettings();
for (unsigned int i = 0; i < m_rotations.size(); i++)
{
const unsigned int rotationDegCCW = m_rotations[i];
if (rotationDegCCW == gameSettings.RotationDegCCW())
return i;
}
return 0;
}
void CDialogGameVideoRotation::PostExit()
{
m_rotations.clear();
}
bool CDialogGameVideoRotation::OnClickAction()
{
Close();
return true;
}
std::string CDialogGameVideoRotation::GetRotationLabel(unsigned int rotationDegCCW)
{
switch (rotationDegCCW)
{
case 0:
return g_localizeStrings.Get(35228); // 0
case 90:
return g_localizeStrings.Get(35231); // 270
case 180:
return g_localizeStrings.Get(35230); // 180
case 270:
return g_localizeStrings.Get(35229); // 90
default:
break;
}
return "";
}
|