1414
1515TouchscreenInput_TestFps::TouchscreenInput_TestFps (Minecraft* pMinecraft, Options* pOptions) :
1616 m_rectArea(0 .0f , 0 .0f , 1 .0f , 1 .0f ),
17+ m_rightRectArea(0 .0f , 0 .0f , 1 .0f , 1 .0f ),
1718 m_pOptions(pOptions),
1819 field_40(false ),
1920 m_bJumpBeingHeld(false ),
@@ -33,7 +34,7 @@ TouchscreenInput_TestFps::TouchscreenInput_TestFps(Minecraft* pMinecraft, Option
3334
3435 // Note! Only the first five button entries are used.
3536 for (int i = 0 ; i < 8 ; i++)
36- field_6C [i] = 0 ;
37+ m_pressedInputs [i] = 0 ;
3738
3839 setScreenSize (Minecraft::width, Minecraft::height);
3940}
@@ -43,7 +44,7 @@ void TouchscreenInput_TestFps::releaseAllKeys()
4344 m_horzInput = 0 .0f ;
4445 m_vertInput = 0 .0f ;
4546 for (int i = 0 ; i < 5 ; i++)
46- field_6C [i] = false ;
47+ m_pressedInputs [i] = false ;
4748}
4849
4950void TouchscreenInput_TestFps::setKey (int eventKey, bool eventKeyState)
@@ -109,7 +110,10 @@ void TouchscreenInput_TestFps::setScreenSize(int width, int height)
109110 right = middleX + widthM * 2 ;
110111 bottom = middleY + heightM * 2 ;
111112
113+ float rightSideX = scaledWidth - widthM - 8 ;
114+
112115 m_rectArea = RectangleArea (left / Gui::InvGuiScale, top / Gui::InvGuiScale, right / Gui::InvGuiScale, bottom / Gui::InvGuiScale);
116+ m_rightRectArea = RectangleArea (rightSideX / Gui::InvGuiScale, middleY / Gui::InvGuiScale, (rightSideX + widthM) / Gui::InvGuiScale, (middleY + heightM) / Gui::InvGuiScale);
113117
114118 TransformArray (4 , x1, y1, x2, y2, middleX, middleY - heightM, 1 .0f , 1 .0f );
115119 m_pAreaForward = new PolygonArea (4 , x2, y2);
@@ -131,10 +135,9 @@ void TouchscreenInput_TestFps::setScreenSize(int width, int height)
131135 m_pAreaRight = new PolygonArea (4 , x2, y2);
132136 m_touchAreaModel.addArea (100 + INPUT_RIGHT , m_pAreaRight);
133137
134- /* float rightSideX = scaledWidth - widthM - 8;
135138 TransformArray (4 , x1, y1, x2, y2, rightSideX, middleY, 1 .0f , 1 .0f );
136139 m_pAreaSneak = new PolygonArea (4 , x2, y2);
137- m_touchAreaModel.addArea(100 + INPUT_SNEAK, m_pAreaSneak);*/
140+ m_touchAreaModel.addArea (100 + INPUT_SNEAK , m_pAreaSneak);
138141
139142 TransformArray (4 , x1, y1, x2, y2, middleX - widthM, middleY - heightM, 1 .0f , 1 .0f );
140143 m_pAreaForwardLeft = new PolygonArea (4 , x2, y2);
@@ -157,8 +160,8 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
157160 m_vertInput = 0 .0f ;
158161 m_bJumping = false ;
159162
160- for (int i = 0 ; i < 5 ; i++ )
161- field_6C[i] = false ;
163+ for (bool & value : m_pressedInputs )
164+ value = false ;
162165
163166 const int * activePointers;
164167 int activePointerCount = Multitouch::getActivePointerIds (&activePointers);
@@ -173,7 +176,7 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
173176 int pointerId = m_touchAreaModel.getPointerId (x * Gui::InvGuiScale, y * Gui::InvGuiScale, finger);
174177
175178 if (pointerId > 99 )
176- field_6C [pointerId - 100 ] = true ;
179+ m_pressedInputs [pointerId - 100 ] = true ;
177180
178181 if (pointerId == 100 + INPUT_SNEAK ) // sneak
179182 {
@@ -261,7 +264,11 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
261264 else
262265 {
263266 m_bSneakBeingHeld = false ;
267+ if (pPlayer->getAbilities ().m_bFlying )
268+ m_bSneaking = false ;
264269 }
270+
271+ IMoveInput::tick (pPlayer);
265272}
266273
267274static void RenderTouchButton (Tesselator* t, PolygonArea* pArea, int srcX, int srcY)
@@ -324,21 +331,22 @@ void TouchscreenInput_TestFps::render(float f)
324331 t.color (isButtonDown (100 + INPUT_JUMP ) ? 0xC0C0C0 : 0xFFFFFF , 0x80 );
325332 RenderTouchButton (&t, m_pAreaJump, 0 , 176 );
326333
327- /* t.color(isButtonDown(100 + INPUT_SNEAK) ? 0xC0C0C0 : 0xFFFFFF, 0x80);
328- RenderTouchButton(&t, m_pAreaSneak, 48, 176);*/
334+ t.color (m_bSneaking ? 0xC0C0C0 : 0xFFFFFF , 0x80 );
335+ RenderTouchButton (&t, m_pAreaSneak, 48 , 176 );
329336
330337 t.draw ();
331338
332339 glDisable (GL_BLEND );
333340 glEnable (GL_CULL_FACE );
334341}
335342
336- RectangleArea TouchscreenInput_TestFps::getRectangleArea ( )
343+ void TouchscreenInput_TestFps::addRectangleArea (std::vector<RectangleArea>& touchArea )
337344{
338- return m_rectArea;
345+ touchArea.push_back (m_rectArea);
346+ touchArea.push_back (m_rightRectArea);
339347}
340348
341349bool TouchscreenInput_TestFps::isButtonDown (int key)
342350{
343- return field_6C [key - 100 ];
351+ return m_pressedInputs [key - 100 ];
344352}
0 commit comments