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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
#include "stdafx.h"
#include "UI.h"
#include "UIControl_Slider.h"
UIControl_Slider::UIControl_Slider()
{
m_id = 0;
m_min = 0;
m_max = 100;
m_current = 0;
}
bool UIControl_Slider::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
{
UIControl::setControlType(UIControl::eSlider);
bool success = UIControl_Base::setupControl(scene,parent,controlName);
//Slider specific initialisers
m_funcSetRelativeSliderPos = registerFastName(L"SetRelativeSliderPos");
m_funcGetRealWidth = registerFastName(L"GetRealWidth");
return success;
}
void UIControl_Slider::init(UIString label, int id, int min, int max, int current)
{
m_label = label;
m_id = id;
m_min = min;
m_max = max;
m_current = current;
IggyDataValue result;
IggyDataValue value[5];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = (int)id;
value[2].type = IGGY_DATATYPE_number;
value[2].number = (int)min;
value[3].type = IGGY_DATATYPE_number;
value[3].number = (int)max;
value[4].type = IGGY_DATATYPE_number;
value[4].number = (int)current;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 5 , value );
#ifdef __PSVITA__
// 4J-TomK - add slider to the vita touch box list
switch(m_parentScene->GetParentLayer()->m_iLayer)
{
case eUILayer_Fullscreen:
case eUILayer_Scene:
case eUILayer_HUD:
ui.TouchBoxAdd(this,m_parentScene);
break;
}
#endif
}
bool IsUsingKeyboardMouse()
{
#ifdef _WINDOWS64
if (g_KBMInput.IsKBMActive()) return true;
return g_KBMInput.HasAnyInput();
#else
return false;
#endif
}
void UIControl_Slider::handleSliderMove(int newValue)
{
if (m_current!=newValue)
{
int valueCount = 1;
if (!m_allPossibleLabels.empty()) {
valueCount = static_cast<int>(m_allPossibleLabels.size());
}
else {
long long range = static_cast<long long>(m_max) - static_cast<long long>(m_min) + 1;
if (range <= 0) range = 1;
valueCount = static_cast<int>(range);
}
if (IsUsingKeyboardMouse() == true) {
if (newValue % 10 == 0) {
ui.PlayUISFX(eSFX_Scroll);
m_current = newValue;
} else if (valueCount <= 20) {
ui.PlayUISFX(eSFX_Scroll);
m_current = newValue;
}
} else {
ui.PlayUISFX(eSFX_Scroll);
m_current = newValue;
}
if(newValue < m_allPossibleLabels.size())
{
setLabel(m_allPossibleLabels[newValue]);
}
}
}
void UIControl_Slider::SetSliderTouchPos(float fTouchPos)
{
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_number;
value[0].number = fTouchPos;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcSetRelativeSliderPos , 1 , value );
}
S32 UIControl_Slider::GetRealWidth()
{
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealWidth , 0 , nullptr );
S32 iRealWidth = m_width;
if(result.type == IGGY_DATATYPE_number)
{
iRealWidth = static_cast<S32>(result.number);
}
return iRealWidth;
}
void UIControl_Slider::setAllPossibleLabels(int labelCount, wchar_t labels[][256])
{
m_allPossibleLabels.clear();
for(unsigned int i = 0; i < labelCount; ++i)
{
m_allPossibleLabels.push_back(labels[i]);
}
UIControl_Base::setAllPossibleLabels(labelCount, labels);
}
void UIControl_Slider::ReInit()
{
UIControl_Base::ReInit();
init(m_label, m_id, m_min, m_max, m_current);
}
|