the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "UI.h"
3#include "UIControl_Slider.h"
4
5UIControl_Slider::UIControl_Slider()
6{
7 m_id = 0;
8 m_min = 0;
9 m_max = 100;
10 m_current = 0;
11}
12
13bool UIControl_Slider::setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName)
14{
15 UIControl::setControlType(UIControl::eSlider);
16 bool success = UIControl_Base::setupControl(scene,parent,controlName);
17
18 //Slider specific initialisers
19 m_funcSetRelativeSliderPos = registerFastName(L"SetRelativeSliderPos");
20 m_funcGetRealWidth = registerFastName(L"GetRealWidth");
21
22 return success;
23}
24
25void UIControl_Slider::init(UIString label, int id, int min, int max, int current)
26{
27 m_label = label;
28 m_id = id;
29 m_min = min;
30 m_max = max;
31 m_current = current;
32
33 IggyDataValue result;
34 IggyDataValue value[5];
35 value[0].type = IGGY_DATATYPE_string_UTF16;
36 IggyStringUTF16 stringVal;
37
38 stringVal.string = (IggyUTF16*)label.c_str();
39 stringVal.length = label.length();
40 value[0].string16 = stringVal;
41
42 value[1].type = IGGY_DATATYPE_number;
43 value[1].number = (int)id;
44
45 value[2].type = IGGY_DATATYPE_number;
46 value[2].number = (int)min;
47
48 value[3].type = IGGY_DATATYPE_number;
49 value[3].number = (int)max;
50
51 value[4].type = IGGY_DATATYPE_number;
52 value[4].number = (int)current;
53 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 5 , value );
54
55#ifdef __PSVITA__
56 // 4J-TomK - add slider to the vita touch box list
57
58 switch(m_parentScene->GetParentLayer()->m_iLayer)
59 {
60 case eUILayer_Fullscreen:
61 case eUILayer_Scene:
62 case eUILayer_HUD:
63 ui.TouchBoxAdd(this,m_parentScene);
64 break;
65 }
66#endif
67}
68
69void UIControl_Slider::handleSliderMove(int newValue)
70{
71 if (m_current!=newValue)
72 {
73 ui.PlayUISFX(eSFX_Scroll);
74 m_current = newValue;
75
76 if(newValue < m_allPossibleLabels.size())
77 {
78 setLabel(m_allPossibleLabels[newValue]);
79 }
80 }
81}
82
83void UIControl_Slider::SetSliderTouchPos(float fTouchPos)
84{
85 IggyDataValue result;
86 IggyDataValue value[1];
87 value[0].type = IGGY_DATATYPE_number;
88 value[0].number = fTouchPos;
89 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcSetRelativeSliderPos , 1 , value );
90 }
91
92S32 UIControl_Slider::GetRealWidth()
93{
94 IggyDataValue result;
95 IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_funcGetRealWidth , 0 , NULL );
96
97 S32 iRealWidth = m_width;
98 if(result.type == IGGY_DATATYPE_number)
99 {
100 iRealWidth = (S32)result.number;
101 }
102 return iRealWidth;
103}
104
105void UIControl_Slider::setAllPossibleLabels(int labelCount, wchar_t labels[][256])
106{
107 m_allPossibleLabels.clear();
108 for(unsigned int i = 0; i < labelCount; ++i)
109 {
110 m_allPossibleLabels.push_back(labels[i]);
111 }
112 UIControl_Base::setAllPossibleLabels(labelCount, labels);
113}
114
115void UIControl_Slider::ReInit()
116{
117 UIControl_Base::ReInit();
118
119 init(m_label, m_id, m_min, m_max, m_current);
120}