diff --git a/source/client/gui/input/TouchscreenInput_TestFps.cpp b/source/client/gui/input/TouchscreenInput_TestFps.cpp index 2616840..820b9c6 100644 --- a/source/client/gui/input/TouchscreenInput_TestFps.cpp +++ b/source/client/gui/input/TouchscreenInput_TestFps.cpp @@ -17,8 +17,10 @@ TouchscreenInput_TestFps::TouchscreenInput_TestFps(Minecraft* pMinecraft, Option TouchInput(pMinecraft, pOptions), //m_rectArea(0.0f, 0.0f, 1.0f, 1.0f), //m_pOptions(pOptions), - field_40(false), - m_bJumpBeingHeld(false), + m_bForwardHeld(false), + m_bJumpingHeld(false), + m_bFlyActive(false), + m_jumpTick(0), //m_pMinecraft(pMinecraft), m_pAreaLeft(nullptr), m_pAreaRight(nullptr), @@ -40,6 +42,7 @@ void TouchscreenInput_TestFps::releaseAllKeys() { m_horzInput = 0.0f; m_vertInput = 0.0f; + m_flyInput = 0.0f; for (int i = 0; i < 5; i++) field_6C[i] = false; } @@ -140,6 +143,7 @@ void TouchscreenInput_TestFps::onTick(Player* pPlayer) { m_horzInput = 0.0f; m_vertInput = 0.0f; + m_flyInput = 0.0f; m_bJumpButton = false; for (int i = 0; i < 5; i++) @@ -148,7 +152,7 @@ void TouchscreenInput_TestFps::onTick(Player* pPlayer) const int* activePointers; int activePointerCount = Multitouch::getActivePointerIds(&activePointers); - bool bJumpPressed = false, bForwardPressed = false; + bool bJumpPressed = false, bForwardPressed = false, bBackwardPressed = false; for (int i = 0; i < activePointerCount; i++) { @@ -172,13 +176,26 @@ void TouchscreenInput_TestFps::onTick(Player* pPlayer) if (pointerId == 100 + INPUT_JUMP) // jump { - if (pPlayer->isInWater()) - m_bJumpButton = true; - else if (Multitouch::isPressed(finger)) - m_bJumpButton = true; - else if (field_40) + if (Multitouch::isPressed(finger)) { - pointerId = 100; // forward + m_bJumpButton = true; + int tick = getTimeMs(); + if (tick - m_jumpTick < 300) + { + m_jumpTick = tick; + m_bFlyActive = !m_bFlyActive; + m_pMinecraft->getOptions()->m_bFlyCheat = m_bFlyActive; + m_bJumpButton = false; + } + else m_jumpTick = tick; + } + else if (m_bFlyActive) + bJumpPressed = true; + else if (pPlayer->isInWater()) + m_bJumpButton = true; + else if (m_bForwardHeld) + { + pointerId = 100 + INPUT_FORWARD; bJumpPressed = true; m_vertInput += 1.0f; } @@ -196,6 +213,7 @@ void TouchscreenInput_TestFps::onTick(Player* pPlayer) break; case 100 + INPUT_BACKWARD: + bBackwardPressed = true; m_vertInput -= 1.0f; break; @@ -213,20 +231,29 @@ void TouchscreenInput_TestFps::onTick(Player* pPlayer) } } - field_40 = bForwardPressed; + m_bForwardHeld = bForwardPressed; if (bJumpPressed) { // Don't allow the player to hold jump to repeatedly jump. // Only let them jump once - have them jump again - if (!m_bJumpBeingHeld) + if (!m_bJumpingHeld && !m_bFlyActive) m_bJumpButton = true; - m_bJumpBeingHeld = true; + m_bJumpingHeld = true; + } + else if (m_bFlyActive && m_bJumpingHeld && (bForwardPressed || bBackwardPressed)) + { + if (bForwardPressed) + m_flyInput += 0.2f; + if (bBackwardPressed) + m_flyInput -= 0.2f; + + m_vertInput = 0.0f; } else { - m_bJumpBeingHeld = false; + m_bJumpingHeld = false; } } diff --git a/source/client/gui/input/TouchscreenInput_TestFps.hpp b/source/client/gui/input/TouchscreenInput_TestFps.hpp index a1f0d25..3346497 100644 --- a/source/client/gui/input/TouchscreenInput_TestFps.hpp +++ b/source/client/gui/input/TouchscreenInput_TestFps.hpp @@ -33,8 +33,10 @@ public: private: bool field_30[10]; - bool field_40; - bool m_bJumpBeingHeld; + bool m_bForwardHeld; + bool m_bJumpingHeld; + bool m_bFlyActive; + int m_jumpTick; TouchAreaModel m_touchAreaModel; PolygonArea* m_pAreaLeft; PolygonArea* m_pAreaRight; diff --git a/source/client/gui/screens/ChatScreen.cpp b/source/client/gui/screens/ChatScreen.cpp index f125b76..e2b56a6 100644 --- a/source/client/gui/screens/ChatScreen.cpp +++ b/source/client/gui/screens/ChatScreen.cpp @@ -7,6 +7,7 @@ ********************************************************************/ #include "ChatScreen.hpp" +#include "client/player/input/Multitouch.hpp" // @NOTE: This is unused. @@ -24,7 +25,10 @@ void ChatScreen::buttonClicked(Button* pButton) if (pButton->m_buttonId == m_btnSend.m_buttonId) sendMessageAndExit(); if (pButton->m_buttonId == m_btnBack.m_buttonId) + { + Multitouch::reset(); // HACK m_pMinecraft->setScreen(nullptr); + } } void ChatScreen::onInit() @@ -37,8 +41,8 @@ void ChatScreen::onInit() m_textChat.m_height = 20; m_btnSend.m_yPos = m_height - 20; m_btnSend.m_xPos = m_textChat.m_xPos + m_textChat.m_width; - m_btnBack.m_yPos = 10; - m_btnBack.m_xPos = m_width - m_btnBack.m_width - 10; + m_btnBack.m_yPos = 0; + m_btnBack.m_xPos = m_width - m_btnBack.m_width; // set focus directly on the chat text box m_textChat.onInit(m_pFont); @@ -62,7 +66,7 @@ void ChatScreen::onRender(int mouseX, int mouseY, float f) // override the default behavior of rendering chat messages m_pMinecraft->m_pGui->m_bRenderChatMessages = true; - m_btnBack.m_yPos = 10 + getYOffset(); + m_btnBack.m_yPos = getYOffset(); Screen::onRender(mouseX, mouseY, f); } diff --git a/source/client/player/LocalPlayer.cpp b/source/client/player/LocalPlayer.cpp index e06ee56..caa045f 100644 --- a/source/client/player/LocalPlayer.cpp +++ b/source/client/player/LocalPlayer.cpp @@ -69,12 +69,6 @@ void LocalPlayer::calculateFlight(float x, float y, float z) float x1 = f1 * x; float z1 = f1 * z; - float y1 = 0.0f; - if (Keyboard::isKeyDown(m_pMinecraft->getOptions()->getKey(KM_FLY_UP))) - y1 = f1 * 0.2f; - if (Keyboard::isKeyDown(m_pMinecraft->getOptions()->getKey(KM_FLY_DOWN))) - y1 = f1 * -0.2f; - field_BFC += x1; float f2 = m_pMinecraft->getOptions()->field_8 * 0.35f; float f3 = f2 * (field_BFC - field_C00); @@ -85,7 +79,7 @@ void LocalPlayer::calculateFlight(float x, float y, float z) field_C00 += f4; field_BF0 = f4 * 10.0f; - field_C08 += y1; + field_C08 += m_pMoveInput->m_flyInput; float f5 = f2 * (field_C08 - field_C0C); float f6 = field_C10 + 0.5f * (f5 - field_C10); field_C10 = f6; diff --git a/source/client/player/input/ControllerTurnInput.cpp b/source/client/player/input/ControllerTurnInput.cpp index e1d7b10..83e205c 100644 --- a/source/client/player/input/ControllerTurnInput.cpp +++ b/source/client/player/input/ControllerTurnInput.cpp @@ -75,7 +75,7 @@ TurnDelta ControllerTurnInput::getTurnDelta() deltaX = deltaTime * xt; deltaY = deltaTime * -yt; } - else if (field_8 != 2 || (!field_18 && !isTouched)) + else if (field_8 != 2 || (!field_18 && !isTouched)) { deltaX = 0.0f; deltaY = -0.0f; diff --git a/source/client/player/input/IMoveInput.cpp b/source/client/player/input/IMoveInput.cpp index 318ee6f..7c7244f 100644 --- a/source/client/player/input/IMoveInput.cpp +++ b/source/client/player/input/IMoveInput.cpp @@ -11,6 +11,7 @@ IMoveInput::IMoveInput() : m_horzInput(0.0f), m_vertInput(0.0f), + m_flyInput(0.0f), field_C(false), m_bJumpButton(false), m_bSneakButton(false) diff --git a/source/client/player/input/IMoveInput.hpp b/source/client/player/input/IMoveInput.hpp index f2e60d0..7d7fa00 100644 --- a/source/client/player/input/IMoveInput.hpp +++ b/source/client/player/input/IMoveInput.hpp @@ -35,6 +35,7 @@ public: public: float m_horzInput; float m_vertInput; + float m_flyInput; bool field_C; bool m_bJumpButton; bool m_bSneakButton; diff --git a/source/client/player/input/KeyboardInput.cpp b/source/client/player/input/KeyboardInput.cpp index 4ed3882..3ef69e6 100644 --- a/source/client/player/input/KeyboardInput.cpp +++ b/source/client/player/input/KeyboardInput.cpp @@ -49,6 +49,7 @@ void KeyboardInput::onTick(Player* pPlayer) { m_horzInput = 0.0f; m_vertInput = 0.0f; + m_flyInput = 0.0f; if (m_keys[INPUT_FORWARD]) m_vertInput += 1.0f; if (m_keys[INPUT_BACKWARD]) m_vertInput -= 1.0f;