Polyphase Game Engine
Loading...
Searching...
No Matches
InputPromptMapInspector.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include "InputCaptureModal.h"
7
8#include <string>
9
10class InputPromptMap;
11
12// Standalone editor window for InputPromptMap. Opened on asset double-click via
13// OpenInputPromptMapForEditing(); also exposed in the asset Inspector through a
14// small "Open Editor..." button so single-click flow still works.
15//
16// Lifecycle mirrors SpriteAnimationAtlasEditor: singleton, persistent across
17// asset switches (Open() retargets), and self-draws when DrawWindow() is
18// called once per editor frame.
19class InputPromptMapInspector
20{
21public:
22
23 static InputPromptMapInspector* Get();
24
25 // Retarget the editor window at `map` and ensure it's visible. Safe to call
26 // even if the window is already open with a different asset.
27 void Open(InputPromptMap* map);
28
29 // Close the window without changing the assigned target (next Open() reuses
30 // existing UI state — filter, selection, etc.).
31 void Close();
32
33 bool IsOpen() const { return mIsOpen; }
34
35 // Per-frame entry point. Call once from EditorImguiDraw().
36 void DrawWindow();
37
38 // Small Inspector stub (still called from the EditorImgui.cpp type-dispatch
39 // chain). Renders "Open Editor..." button so single-click users can launch
40 // the full window without going through double-click.
41 void DrawInspectorButton(InputPromptMap* map);
42
43private:
44
45 InputPromptMapInspector() = default;
46
47 void DrawToolbar(InputPromptMap* map);
48 void DrawFilterRow();
49 void DrawEntryTable(InputPromptMap* map);
50 void DrawValidationStrip(InputPromptMap* map);
51
52 void AddEntry(InputPromptMap* map);
53 void DuplicateEntry(InputPromptMap* map, int32_t idx);
54 void DeleteEntry(InputPromptMap* map, int32_t idx);
55 void MoveEntry(InputPromptMap* map, int32_t idx, int32_t delta);
56 void MarkDirty(InputPromptMap* map);
57
58 static InputPromptMapInspector* sInstance;
59
60 InputPromptMap* mTarget = nullptr;
61 bool mIsOpen = false;
62
63 int32_t mSelectedEntry = -1;
64 int32_t mCaptureRowIndex = -1;
65 InputCaptureModal mCapture;
66
67 int32_t mFilterPlatform = -1; // -1 == any
68 int32_t mFilterGamepad = -1; // -1 == any
69 std::string mFilterPath;
70
71 int32_t mTestDeviceKind = -1;
72 int32_t mTestGamepadType = (int)GamepadType::Standard;
73};
74
75// Convenience hook used from the asset-browser double-click dispatch in
76// EditorImgui.cpp. Wraps Get()->Open() so the call site doesn't need to
77// include this header.
78void OpenInputPromptMapForEditing(InputPromptMap* map);
79
80#endif // EDITOR
Definition InputPromptMap.h:49