Polyphase Game Engine
Loading...
Searching...
No Matches
EditorAction.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <stdint.h>
6
7// Single source of truth for every rebindable editor action.
8//
9// Add new actions to this enum, then add a matching row to sActionMetadata
10// in EditorAction.cpp. Do NOT use INP_IsKeyJustDown / IsKeyJustDown directly
11// in editor code -- always go through EditorHotkeyMap so users can remap.
12//
13// Keys that intentionally remain hardcoded (NOT in this enum):
14// - PIE safety: Escape, F8, Alt+P (during PIE), F10, Ctrl+Alt+P
15// - Transform axis-lock: X / Y / Z while inside an active rotate/scale mode
16// - Dialog confirm/cancel: Enter / Escape inside modals
17enum class EditorAction : int32_t
18{
19 // ----- File -----
20 File_OpenProject,
21 File_NewProject,
22 File_SaveScene,
23 File_SaveAllAssets,
24 File_SaveSelectedAsset,
25 File_OpenScene,
26 File_ImportAsset,
27
28 // ----- Edit -----
29 Edit_Undo,
30 Edit_Redo,
31 Edit_ReloadScripts,
32 Edit_SelectAll,
33 Edit_DeselectAll,
34 Edit_Duplicate,
35 Edit_DeleteSelected,
36 Edit_CopyNodes,
37 Edit_PasteNodes,
38 Edit_CutNodes,
39
40 // ----- Scene Mode -----
41 Mode_Scene,
42 Mode_Scene2D,
43 Mode_Scene3D,
44 Mode_PaintColor,
45 Mode_PaintInstance,
46
47 // ----- Play-In-Editor -----
48 PIE_Toggle,
49
50 // ----- Camera (Pilot Mode) -----
51 Camera_Forward,
52 Camera_Back,
53 Camera_Left,
54 Camera_Right,
55 Camera_Up,
56 Camera_Down,
57
58 // ----- View Navigation -----
59 View_Front,
60 View_Back,
61 View_Right,
62 View_Left,
63 View_Top,
64 View_Bottom,
65 View_PerspToggle,
66 View_FocusSelection,
67 View_PositionAtCamera,
68
69 // ----- Gizmo / Transform -----
70 Gizmo_Translate,
71 Gizmo_Rotate,
72 Gizmo_Scale,
73 Gizmo_TranslateImGuizmo,
74 Gizmo_RotateImGuizmo,
75 Gizmo_ScaleImGuizmo,
76 Gizmo_TransformLocalToggle,
77 Gizmo_GridToggle,
78
79 // ----- Debug -----
80 Debug_Wireframe,
81 Debug_Collision,
82 Debug_Proxy,
83 Debug_PathTracing,
84 Debug_BoundsCycle,
85
86 // ----- UI Panes -----
87 UI_ToggleLeftPane,
88 UI_ToggleRightPane,
89 UI_ToggleAll,
90
91 // ----- Quick Spawn (Alt+Number) -----
92 Spawn_StaticMesh,
93 Spawn_PointLight,
94 Spawn_Node3D,
95 Spawn_DirLight,
96 Spawn_SkeletalMesh,
97 Spawn_Box,
98 Spawn_Sphere,
99 Spawn_Particle,
100 Spawn_Audio,
101 Spawn_Scene,
102
103 // ----- Spawn Menus -----
104 Spawn_Basic3DMenu,
105 Spawn_BasicWidgetMenu,
106 Spawn_NodeMenu,
107
108 // ----- Hierarchy / Asset Browser -----
109 Hier_ReorderUp,
110 Hier_ReorderDown,
111 Hier_Rename,
112 Asset_CreateScene,
113 Asset_CreateMaterial,
114 Asset_CreateParticle,
115 Asset_Rename,
116
117 // ----- Inspector -----
118 Inspector_ToggleLock,
119
120 // ----- Tool / Placement -----
121 Tool_DropActorToGround,
122 Tool_DropActorWithRotation,
123
124 // ----- Paint -----
125 Paint_ToggleErase,
126 Paint_BrushAdjust,
127
128 // ----- Version Control -----
129 Git_OpenPanel,
130 Git_Commit,
131 Git_RefreshStatus,
132 Git_Fetch,
133 Git_Pull,
134 Git_Push,
135 Git_QuickSwitchBranch,
136 Git_SearchHistory,
137
138 // ----- Lua Debugger -----
139 Debug_LuaToggleBreakpoint, // F9 -- toggle bp at cursor in Script Editor
140 Debug_LuaContinue, // F5 -- only fires while debugger is paused
141
142 Count
143};
144
145// A binding is a key + an exact-match modifier signature. The "RequireSpace"
146// flag covers the small handful of Space+G/R/S gizmo gestures.
147struct KeyBinding
148{
149 int32_t mKeyCode = -1; // -1 = unbound
150 bool mCtrl = false;
151 bool mShift = false;
152 bool mAlt = false;
153 bool mRequireSpace = false;
154
155 bool IsValid() const { return mKeyCode >= 0; }
156
157 bool operator==(const KeyBinding& other) const
158 {
159 return mKeyCode == other.mKeyCode
160 && mCtrl == other.mCtrl
161 && mShift == other.mShift
162 && mAlt == other.mAlt
163 && mRequireSpace == other.mRequireSpace;
164 }
165};
166
167// Metadata for one EditorAction. Filled in by sActionMetadata in EditorAction.cpp.
168struct EditorActionInfo
169{
170 const char* mName; // Display name shown in the remap window
171 const char* mCategory; // Category header ("File", "Camera", "Debug", etc.)
172 const char* mDescription; // Tooltip
173 const char* mSerializeKey; // Stable identifier used in JSON (e.g. "Camera_Forward")
174 KeyBinding mDefault; // Default binding
175};
176
177const EditorActionInfo& GetEditorActionInfo(EditorAction action);
178
179// Lookup an action by its serialize key (used by preset import). Returns
180// EditorAction::Count if no match.
181EditorAction FindEditorActionByKey(const char* serializeKey);
182
183// True for Ctrl/Shift/Alt — used by the capture overlay to skip modifier presses.
184bool EditorActionKeyCodeIsModifier(int32_t keyCode);
185
186// Convert a key code to a stable symbolic name ("A", "F11", "Numpad 5") and
187// vice-versa. JSON presets store keys by name so they're portable across
188// platforms (POLYPHASE_KEY_Z = 90 on Windows but 52 on Linux).
189const char* EditorActionKeyCodeToSymbol(int32_t keyCode);
190int32_t EditorActionSymbolToKeyCode(const char* symbol);
191
192#endif