Unify input behind Engine::Input facade; fix Ctrl+P and Pause button

New Engine/Core/Input.h/.cpp: static input facade with a Key/MouseButton
enum (values map to GLFW key codes internally) so scripts and game logic
no longer touch GLFW directly - window backend becomes swappable and the
facade is the surface to expose when embedding scripting later. Wired up
in Application's constructor; Camera (editor camera WASD/RMB/MMB), the
WASDMove script and SandboxApp key handling now query Input only.

Ctrl+P hotkey fix: the !m_Playing guard made the hotkey dead exactly
when it was needed - after pressing Play. Now toggles both ways.

Toolbar Pause button now reads "Resume" while paused (tooltip follows).
This commit is contained in:
2026-10-05 11:34:27 +08:00
parent c083ee5cb7
commit 641b255cb2
7 changed files with 161 additions and 29 deletions
+5 -4
View File
@@ -24,8 +24,8 @@
#include <Engine/Renderer/Renderer.h>
#include <Engine/Renderer/EditorCamera.h>
#include <GLFW/glfw3.h>
#include <Engine/Core/Input.h>
#include "Editor.h"
#include "EditorContext.h"
@@ -94,11 +94,12 @@ namespace
void OnKeyPress(const Event& event) override
{
if (event.key == GLFW_KEY_GRAVE_ACCENT)
// 键码统一走 Input::Key(App 层零 GLFW 依赖)
if (event.key == static_cast<int>(Input::Key::GraveAccent))
{
SetImGuiEnabled(!GetImGuiEnabled());
}
if (event.key == GLFW_KEY_F1)
if (event.key == static_cast<int>(Input::Key::F1))
{
STATS.PrintComparison();
}