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 Gizmo_SnapToggle,
104 Gizmo_SnapCycleMode,
105
106 // ----- Debug -----
107 Debug_Wireframe,
108 Debug_Collision,
109 Debug_Proxy,
110 Debug_PathTracing,
111 Debug_BoundsCycle,
112
113 // ----- UI Panes -----
114 UI_ToggleLeftPane,
115 UI_ToggleRightPane,
116 UI_ToggleAll,
117
118 // ----- Quick Spawn (Alt+Number) -----
119 Spawn_StaticMesh,
120 Spawn_PointLight,
121 Spawn_Node3D,
122 Spawn_DirLight,
123 Spawn_SkeletalMesh,
124 Spawn_Box,
125 Spawn_Sphere,
126 Spawn_Particle,
127 Spawn_Audio,
128 Spawn_Scene,
129 Spawn_SpotLight,
130
131 // ----- Spawn Menus -----
132 Spawn_Basic3DMenu,
133 Spawn_BasicWidgetMenu,
134 Spawn_NodeMenu,
135
136 // ----- Hierarchy / Asset Browser -----
137 Hier_ReorderUp,
138 Hier_ReorderDown,
139 Hier_Rename,
140 Asset_CreateScene,
141 Asset_CreateMaterial,
142 Asset_CreateParticle,
143 Asset_Rename,
144
145 // ----- Inspector -----
146 Inspector_ToggleLock,
147
148 // ----- Tool / Placement -----
149 Tool_DropActorToGround,
150 Tool_DropActorWithRotation,
151
152 // ----- Paint -----
153 Paint_ToggleErase,
154 Paint_BrushAdjust,
155
156 // ----- Version Control -----
157 Git_OpenPanel,
158 Git_Commit,
159 Git_RefreshStatus,
160 Git_Fetch,
161 Git_Pull,
162 Git_Push,
163 Git_QuickSwitchBranch,
164 Git_SearchHistory,
165
166 // ----- Lua Debugger -----
167 Debug_LuaToggleBreakpoint, // F9 -- toggle bp at cursor in Script Editor
168 Debug_LuaContinue, // F5 -- only fires while debugger is paused
169
170 Count
171};
172
173// A binding is a key + an exact-match modifier signature. The "RequireSpace"
174// flag covers the small handful of Space+G/R/S gizmo gestures.
175struct KeyBinding
176{
177 int32_t mKeyCode = -1; // -1 = unbound
178 bool mCtrl = false;
179 bool mShift = false;
180 bool mAlt = false;
181 bool mRequireSpace = false;
182
183 bool IsValid() const { return mKeyCode >= 0; }
184
185 bool operator==(const KeyBinding& other) const
186 {
187 return mKeyCode == other.mKeyCode
188 && mCtrl == other.mCtrl
189 && mShift == other.mShift
190 && mAlt == other.mAlt
191 && mRequireSpace == other.mRequireSpace;
192 }
193};
194
195// Metadata for one EditorAction. Filled in by sActionMetadata in EditorAction.cpp.
196struct EditorActionInfo
197{
198 const char* mName; // Display name shown in the remap window
199 const char* mCategory; // Category header ("File", "Camera", "Debug", etc.)
200 const char* mDescription; // Tooltip
201 const char* mSerializeKey; // Stable identifier used in JSON (e.g. "Camera_Forward")
202 KeyBinding mDefault; // Default binding
203};
204
205const EditorActionInfo& GetEditorActionInfo(EditorAction action);
206
207// Lookup an action by its serialize key (used by preset import). Returns
208// EditorAction::Count if no match.
209EditorAction FindEditorActionByKey(const char* serializeKey);
210
211// True for Ctrl/Shift/Alt — used by the capture overlay to skip modifier presses.
212bool EditorActionKeyCodeIsModifier(int32_t keyCode);
213
214// Convert a key code to a stable symbolic name ("A", "F11", "Numpad 5") and
215// vice-versa. JSON presets store keys by name so they're portable across
216// platforms (POLYPHASE_KEY_Z = 90 on Windows but 52 on Linux).
217const char* EditorActionKeyCodeToSymbol(int32_t keyCode);
218int32_t EditorActionSymbolToKeyCode(const char* symbol);
219
220#endif