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:
@@ -26,8 +26,6 @@
|
||||
#include <imgui_internal.h> // DockBuilder*(内部 API)
|
||||
#include <ImGuizmo.h>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
@@ -283,8 +281,9 @@ void Editor::DrawMenuBar()
|
||||
void Editor::DrawToolbar()
|
||||
{
|
||||
const ImGuiIO& io = ImGui::GetIO();
|
||||
// Ctrl+P:文本输入中(改名/路径框)不触发,防打字误切 PIE
|
||||
if (!m_Playing && io.KeyCtrl && !io.WantTextInput &&
|
||||
// Ctrl+P 全局热键:编辑态进 PIE,运行态停回编辑器(双向)。
|
||||
// 文本输入中(改名/路径框)不触发,防打字误切
|
||||
if (io.KeyCtrl && !io.WantTextInput &&
|
||||
ImGui::IsKeyPressed(ImGuiKey_P, false))
|
||||
{
|
||||
TogglePlay();
|
||||
@@ -293,12 +292,14 @@ void Editor::DrawToolbar()
|
||||
// 按钮加大触感(工具栏行高 = 一个按钮高;DockSpace avail 自适应)
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(12.0f, 4.0f));
|
||||
const ImGuiStyle& st = ImGui::GetStyle();
|
||||
const char* pauseLabel = m_Paused ? "Resume" : "Pause";
|
||||
|
||||
// Play 组宽度 → 水平居中(编辑态 1 钮 / 运行态 2 钮)
|
||||
float groupW = 0.0f;
|
||||
if (m_Playing)
|
||||
{
|
||||
groupW = ImGui::CalcTextSize("Pause").x + ImGui::CalcTextSize("Stop").x +
|
||||
groupW = ImGui::CalcTextSize(pauseLabel).x +
|
||||
ImGui::CalcTextSize("Stop").x +
|
||||
4.0f * st.FramePadding.x + st.ItemSpacing.x;
|
||||
}
|
||||
else
|
||||
@@ -309,7 +310,7 @@ void Editor::DrawToolbar()
|
||||
|
||||
if (m_Playing)
|
||||
{
|
||||
// Pause:暂停中亮黄常驻(UE 按下态),运行中暗黄
|
||||
// Pause/Resume:暂停中亮黄常驻(UE 按下态),运行中暗黄
|
||||
ImGui::PushStyleColor(ImGuiCol_Button,
|
||||
m_Paused ? ImVec4(0.85f, 0.62f, 0.12f, 1.0f)
|
||||
: ImVec4(0.55f, 0.42f, 0.10f, 1.0f));
|
||||
@@ -318,7 +319,7 @@ void Editor::DrawToolbar()
|
||||
: ImVec4(0.65f, 0.50f, 0.14f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive,
|
||||
ImVec4(0.95f, 0.76f, 0.24f, 1.0f));
|
||||
if (ImGui::Button("Pause"))
|
||||
if (ImGui::Button(pauseLabel))
|
||||
{
|
||||
TogglePause();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user