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 "XUI_Ctrl_SliderWrapper.h"
3
4#define NO_SOUND_TIMER 0
5
6HRESULT CXuiCtrlSliderWrapper::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
7{
8 VOID *pObj;
9 HXUIOBJ hObjChild;
10
11 XuiElementGetChildById(m_hObj,L"FocusSink",&hObjChild);
12 XuiObjectFromHandle( hObjChild, &pObj );
13 m_pFocusSink = (CXuiControl *)pObj;
14
15 XuiElementGetChildById(m_hObj,L"XuiSlider",&hObjChild);
16 XuiObjectFromHandle( hObjChild, &pObj );
17 m_pSlider = (CXuiSlider *)pObj;
18
19 m_sliderActive = false;
20 m_bDisplayVal=true;
21 m_bPlaySound=false; // make this false to avoid a sound being played in the first setting of the slider value in a scene
22 XuiSetTimer( m_hObj,NO_SOUND_TIMER,50);
23 bHandled = TRUE;
24 return S_OK;
25}
26
27HRESULT CXuiCtrlSliderWrapper::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled)
28{
29 ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode);
30
31// switch(pInputData->dwKeyCode)
32// {
33
34// case VK_PAD_A:
35// // 4J-PB - IGNORE !
36// if(m_sliderActive)
37// {
38// m_pFocusSink->SetFocus(pInputData->UserIndex);
39// m_sliderActive = false;
40// }
41// else
42// {
43// m_pSlider->SetFocus(pInputData->UserIndex);
44// m_sliderActive = true;
45// }
46// rfHandled = TRUE;
47//
48// break;
49// default:
50// m_pSlider->SetFocus(pInputData->UserIndex);
51// m_sliderActive = false;
52// break;
53//
54// }
55//
56 return S_OK;
57}
58
59HRESULT CXuiCtrlSliderWrapper::OnNotifyValueChanged (HXUIOBJ hObjSource, XUINotifyValueChanged* pValueChangedData, BOOL& rfHandled)
60{
61 XUIMessage Message;
62 XUINotify Notify;
63 XUINotifyValueChanged MsgValueChanged;
64 HRESULT hr;
65 HXUIOBJ hObj;
66
67 if(m_bPlaySound)
68 {
69 m_bPlaySound=false;
70 CXuiSceneBase::PlayUISFX(eSFX_Scroll);
71 XuiSetTimer( m_hObj,NO_SOUND_TIMER,150);
72 }
73
74 //app.DebugPrintf("Slider val changed - %d\n",pValueChangedData->nValue);
75
76 XuiNotifyValueChanged(&Message,&Notify,&MsgValueChanged,hObjSource,pValueChangedData->nValue);
77
78 hr = GetParent(&hObj);
79
80 if (HRESULT_SUCCEEDED(hr))
81 {
82 hr = XuiBubbleMessage(hObj, &Message);
83 rfHandled = TRUE;
84 }
85 return S_OK;
86}
87
88
89HRESULT CXuiCtrlSliderWrapper::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled)
90{
91 if(pData->nId==NO_SOUND_TIMER)
92 {
93 XuiKillTimer(m_hObj,NO_SOUND_TIMER);
94 m_bPlaySound=true;
95 }
96
97 return S_OK;
98}
99
100HRESULT CXuiCtrlSliderWrapper::SetValue( int nValue )
101{
102 CXuiCtrlSliderWrapper *pThis;
103 HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
104 if (FAILED(hr))
105 return hr;
106
107 pThis->m_pSlider->SetValue(nValue);
108 return S_OK;
109}
110
111HRESULT CXuiCtrlSliderWrapper::SetValueDisplay( BOOL bShow )
112{
113 CXuiCtrlSliderWrapper *pThis;
114 HXUIOBJ hVisual,hText;
115 HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
116 if (FAILED(hr))
117 return hr;
118
119 hr=XuiControlGetVisual(pThis->m_pSlider->m_hObj,&hVisual);
120 hr=XuiElementGetChildById(hVisual,L"Text_Value",&hText);
121
122 if(hText!=NULL)
123 {
124 XuiElementSetShow(hText,bShow);
125 }
126
127 return S_OK;
128}
129
130LPCWSTR CXuiCtrlSliderWrapper::GetText( )
131{
132 CXuiCtrlSliderWrapper *pThis;
133 HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
134 if (FAILED(hr))
135 return NULL;
136 return pThis->m_pSlider->GetText();
137 //return S_OK;
138}
139
140HRESULT CXuiCtrlSliderWrapper::SetText(LPCWSTR text , int iDataAssoc)
141{
142 CXuiCtrlSliderWrapper *pThis;
143 HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
144 if (FAILED(hr))
145 return hr;
146
147 // if there's a data assoc value, find the right control for it
148 if(iDataAssoc!=0)
149 {
150
151 }
152
153 pThis->m_pSlider->SetText(text);
154 return hr;
155}
156
157HXUIOBJ CXuiCtrlSliderWrapper::GetSlider()
158{
159 CXuiCtrlSliderWrapper *pThis;
160 HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
161 if (FAILED(hr))
162 return NULL;
163 return pThis->m_pSlider->m_hObj;
164}
165
166HRESULT CXuiCtrlSliderWrapper::SetRange( int nRangeMin, int nRangeMax)
167{
168 CXuiCtrlSliderWrapper *pThis;
169 HRESULT hr = XuiObjectFromHandle(m_hObj, (void **) &pThis);
170 if (FAILED(hr))
171 return hr;
172 pThis->m_pSlider->SetRange(nRangeMin, nRangeMax);
173 return S_OK;
174}