From 14c99db20dcf91665aa653532bebaef59183e14e Mon Sep 17 00:00:00 2001 From: ApfelTeeSaft <91074565+ApfelTeeSaft@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:17:33 +0100 Subject: [PATCH] Check desc Removed my Stupid ass Variable Defined Menu Bool as extern in a new Header Now blocking all input when pressing Escape (even movement) --- ScuffedMinecraft/ScuffedMinecraft.vcxproj | 1 + ScuffedMinecraft/ScuffedMinecraft.vcxproj.filters | 3 +++ ScuffedMinecraft/src/Application.cpp | 4 +--- ScuffedMinecraft/src/Application.h | 3 +++ ScuffedMinecraft/src/Camera.cpp | 2 ++ 5 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 ScuffedMinecraft/src/Application.h diff --git a/ScuffedMinecraft/ScuffedMinecraft.vcxproj b/ScuffedMinecraft/ScuffedMinecraft.vcxproj index 0d702c2..6993f99 100644 --- a/ScuffedMinecraft/ScuffedMinecraft.vcxproj +++ b/ScuffedMinecraft/ScuffedMinecraft.vcxproj @@ -177,6 +177,7 @@ + diff --git a/ScuffedMinecraft/ScuffedMinecraft.vcxproj.filters b/ScuffedMinecraft/ScuffedMinecraft.vcxproj.filters index 45330a1..d729130 100644 --- a/ScuffedMinecraft/ScuffedMinecraft.vcxproj.filters +++ b/ScuffedMinecraft/ScuffedMinecraft.vcxproj.filters @@ -152,6 +152,9 @@ Header Files + + Header Files + diff --git a/ScuffedMinecraft/src/Application.cpp b/ScuffedMinecraft/src/Application.cpp index 69f24b0..16dcd84 100644 --- a/ScuffedMinecraft/src/Application.cpp +++ b/ScuffedMinecraft/src/Application.cpp @@ -32,7 +32,6 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos); void scroll_callback(GLFWwindow* window, double xoffset, double yoffset); void mouse_button_callback(GLFWwindow* window, int button, int action, int mods); -bool inEscMenu = false; float deltaTime = 0.0f; float lastFrame = 0.0f; int fpsCount = 0; @@ -565,7 +564,6 @@ void processInput(GLFWwindow* window) escapeDown = true; menuMode = !menuMode; glfwSetInputMode(window, GLFW_CURSOR, menuMode ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED); - inEscMenu = menuMode; firstMouse = true; //glfwSetWindowShouldClose(window, true); } @@ -605,7 +603,7 @@ void processInput(GLFWwindow* window) void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { - if (inEscMenu) return; + if (menuMode) return; if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) { auto result = Physics::Raycast(camera.Position, camera.Front, 5); diff --git a/ScuffedMinecraft/src/Application.h b/ScuffedMinecraft/src/Application.h new file mode 100644 index 0000000..40ebeb5 --- /dev/null +++ b/ScuffedMinecraft/src/Application.h @@ -0,0 +1,3 @@ +#pragma once + +extern bool menuMode; \ No newline at end of file diff --git a/ScuffedMinecraft/src/Camera.cpp b/ScuffedMinecraft/src/Camera.cpp index fd9e3b5..9bbc97a 100644 --- a/ScuffedMinecraft/src/Camera.cpp +++ b/ScuffedMinecraft/src/Camera.cpp @@ -1,4 +1,5 @@ #include "Camera.h" +#include "Application.h" Camera::Camera(glm::vec3 position, glm::vec3 up, float yaw, float pitch) : Front(glm::vec3(0.0f, 0.0f, -1.0f)), MovementSpeed(SPEED), MouseSensitivity(SENSITIVITY), Zoom(ZOOM) { @@ -28,6 +29,7 @@ glm::mat4 Camera::GetViewMatrix() // processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems) void Camera::ProcessKeyboard(Camera_Movement direction, float deltaTime) { + if (menuMode) return; float velocity = MovementSpeed * deltaTime; if (direction == FORWARD) Position += Front * velocity;