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 // ----- View Camera Bookmarks (Unreal-style) -----
70 // The number after each name is the user-facing slot label, not the
71 // enum/array index. SaveBookmark1 -> slot 0, SaveBookmark0 -> slot 9,
72 // so the labels read "1, 2, 3, ..., 9, 0" in keyboard order.
73 View_SaveBookmark1,
74 View_SaveBookmark2,
75 View_SaveBookmark3,
76 View_SaveBookmark4,
77 View_SaveBookmark5,
78 View_SaveBookmark6,
79 View_SaveBookmark7,
80 View_SaveBookmark8,
81 View_SaveBookmark9,
82 View_SaveBookmark0,
83 View_GotoBookmark1,
84 View_GotoBookmark2,
85 View_GotoBookmark3,
86 View_GotoBookmark4,
87 View_GotoBookmark5,
88 View_GotoBookmark6,
89 View_GotoBookmark7,
90 View_GotoBookmark8,
91 View_GotoBookmark9,
92 View_GotoBookmark0,
93
94 // ----- Gizmo / Transform -----
95 Gizmo_Translate,
96 Gizmo_Rotate,
97 Gizmo_Scale,
98 Gizmo_TranslateImGuizmo,
99 Gizmo_RotateImGuizmo,
100 Gizmo_ScaleImGuizmo,
101 Gizmo_TransformLocalToggle,
102 Gizmo_GridToggle,
103
104 // ----- Debug -----
105 Debug_Wireframe,
106 Debug_Collision,
107 Debug_Proxy,
108 Debug_PathTracing,
109 Debug_BoundsCycle,
110
111 // ----- UI Panes -----
112 UI_ToggleLeftPane,
113 UI_ToggleRightPane,
114 UI_ToggleAll,
115
116 // ----- Quick Spawn (Alt+Number) -----
117 Spawn_StaticMesh,
118 Spawn_PointLight,
119 Spawn_Node3D,
120 Spawn_DirLight,
121 Spawn_SkeletalMesh,
122 Spawn_Box,
123 Spawn_Sphere,
124 Spawn_Particle,
125 Spawn_Audio,
126 Spawn_Scene,
127
128 // ----- Spawn Menus -----
129 Spawn_Basic3DMenu,
130 Spawn_BasicWidgetMenu,
131 Spawn_NodeMenu,
132
133 // ----- Hierarchy / Asset Browser -----
134 Hier_ReorderUp,
135 Hier_ReorderDown,
136 Hier_Rename,
137 Asset_CreateScene,
138 Asset_CreateMaterial,
139 Asset_CreateParticle,
140 Asset_Rename,
141
142 // ----- Inspector -----
143 Inspector_ToggleLock,
144
145 // ----- Tool / Placement -----
146 Tool_DropActorToGround,
147 Tool_DropActorWithRotation,
148
149 // ----- Paint -----
150 Paint_ToggleErase,
151 Paint_BrushAdjust,
152
153 // ----- Version Control -----
154 Git_OpenPanel,
155 Git_Commit,
156 Git_RefreshStatus,
157 Git_Fetch,
158 Git_Pull,
159 Git_Push,
160 Git_QuickSwitchBranch,
161 Git_SearchHistory,
162
163 // ----- Lua Debugger -----
164 Debug_LuaToggleBreakpoint, // F9 -- toggle bp at cursor in Script Editor
165 Debug_LuaContinue, // F5 -- only fires while debugger is paused
166
167 Count
168};
169
170// A binding is a key + an exact-match modifier signature. The "RequireSpace"
171// flag covers the small handful of Space+G/R/S gizmo gestures.
172struct KeyBinding
173{
174 int32_t mKeyCode = -1; // -1 = unbound
175 bool mCtrl = false;
176 bool mShift = false;
177 bool mAlt = false;
178 bool mRequireSpace = false;
179
180 bool IsValid() const { return mKeyCode >= 0; }
181
182 bool operator==(const KeyBinding& other) const
183 {
184 return mKeyCode == other.mKeyCode
185 && mCtrl == other.mCtrl
186 && mShift == other.mShift
187 && mAlt == other.mAlt
188 && mRequireSpace == other.mRequireSpace;
189 }
190};
191
192// Metadata for one EditorAction. Filled in by sActionMetadata in EditorAction.cpp.
193struct EditorActionInfo
194{
195 const char* mName; // Display name shown in the remap window
196 const char* mCategory; // Category header ("File", "Camera", "Debug", etc.)
197 const char* mDescription; // Tooltip
198 const char* mSerializeKey; // Stable identifier used in JSON (e.g. "Camera_Forward")
199 KeyBinding mDefault; // Default binding
200};
201
202const EditorActionInfo& GetEditorActionInfo(EditorAction action);
203
204// Lookup an action by its serialize key (used by preset import). Returns
205// EditorAction::Count if no match.
206EditorAction FindEditorActionByKey(const char* serializeKey);
207
208// True for Ctrl/Shift/Alt — used by the capture overlay to skip modifier presses.
209bool EditorActionKeyCodeIsModifier(int32_t keyCode);
210
211// Convert a key code to a stable symbolic name ("A", "F11", "Numpad 5") and
212// vice-versa. JSON presets store keys by name so they're portable across
213// platforms (POLYPHASE_KEY_Z = 90 on Windows but 52 on Linux).
214const char* EditorActionKeyCodeToSymbol(int32_t keyCode);
215int32_t EditorActionSymbolToKeyCode(const char* symbol);
216
217#endif