EditorContext class

EditorContext — owns all editor UI state and panel drawing.

Called by the renderer between ImGui::NewFrame() and ImGui::Render(). All ImGui:: calls for editor panels live here, keeping editor logic separated from engine rendering code.

Public static variables

static size_t MaxUndo constexpr

Constructors, destructors, conversion operators

EditorContext()
~EditorContext()

Public functions

void Initialize(TrinyxEngine* engine, LogicThreadBase* logic)
void BuildFrame()
void LoadScene(const std::string& path, bool bReset = true)
void OpenConstructEditor(const char* typeName, const char* filePath = nullptr)
void OpenEntityEditor(const char* typeName, const char* filePath = nullptr)
void OpenPrefabEditor(const std::string& filePath)
void ShowImportDialog()
Show the mesh import dialog (called from ContentBrowserPanel).
void HandleDroppedFile(const std::string& path)
Handle a file dropped onto the window (called from EditorRenderer on render thread).
void SpawnPrefab(const std::string& prefabPath)
Spawn a prefab into the current scene. Called from content browser drag-drop or double-click.
void DeleteSelectedEntity()
Delete the currently selected entity (deferred via Spawn handshake).
void StartPIELocal()
PIE local mode: single solo world, replaces primary window with game viewport.
void StartPIE()
PIE networked mode: server + client worlds in floating viewports.
void StopPIE()
Stop whichever PIE mode is active.
auto IsPIEActive() const -> bool
template<typename T, typename... Args>
auto AddPanel(Args && ... args) -> T*
Register a panel. EditorContext takes ownership.
auto GetViewportPanelPos() const -> ImVec2
void PushCommand(std::unique_ptr<UndoCommand> cmd)
void Undo()
void Redo()
auto CanUndo() const -> bool
auto CanRedo() const -> bool
auto GetState() -> EditorState&

Public variables

bool bPIEStopRequested
std::vector<std::unique_ptr<UndoCommand>> UndoStack
size_t UndoIndex

Function documentation

void EditorContext::BuildFrame()

Build the editor UI for this frame. Called on the render thread after ImGui::NewFrame(), before ImGui::Render().

void EditorContext::LoadScene(const std::string& path, bool bReset = true)

Load a scene file: reset registry, spawn entities, update editor state. If bReset is false, skips ResetRegistry (used for initial load into an empty world).

void EditorContext::OpenConstructEditor(const char* typeName, const char* filePath = nullptr)

Open the Construct editor and create/focus a tab for the given type name. filePath is the absolute path to the header — when provided the doc is parsed from disk.

void EditorContext::OpenEntityEditor(const char* typeName, const char* filePath = nullptr)

Open the Entity editor and create/focus a tab for the given type name. filePath is the absolute path to the header — when provided the doc is parsed from disk.

void EditorContext::OpenPrefabEditor(const std::string& filePath)

Open the Prefab editor and create/focus a tab for the given .tnxprefab file. Switches to the Asset workspace automatically.

ImVec2 EditorContext::GetViewportPanelPos() const

Returns the screen-space top-left of the 3D viewport panel (logical pixels). Updated each frame during DrawEditorViewportPanel(); valid after BuildFrame() returns.