McRogueFace/src/ImGuiSceneExplorer.h
John McCardle c5cc022aa2 Add SDL2+OpenGL ES 2 renderer backend for Emscripten/WebGL
Implements Phase 1 of renderer abstraction plan:
- SDL2Types.h: SFML-compatible type stubs in sf:: namespace
- SDL2Renderer.h/cpp: OpenGL ES 2 rendering implementation
- EmscriptenStubs.cpp: Stubs for missing POSIX functions (wait3, wait4, wcsftime)

Build system changes:
- Add MCRF_SDL2 compile-time backend selection
- Add Emscripten SDL2 link options (-sUSE_SDL=2, -sFULL_ES2=1)
- Fix LONG_BIT mismatch for Emscripten in pyport.h

Code changes for SDL2/headless compatibility:
- Guard ImGui includes with !MCRF_HEADLESS && !MCRF_SDL2
- Defer GL shader initialization until after context creation

Current status: Python runs in browser, rendering WIP (canvas sizing issues)

Build commands:
  emcmake cmake -DMCRF_SDL2=ON -B build-emscripten
  emmake make -C build-emscripten

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 11:13:15 -05:00

51 lines
1.4 KiB
C++

#pragma once
// ImGuiSceneExplorer - excluded from headless and SDL2 builds (ImGui-SFML only)
#if !defined(MCRF_HEADLESS) && !defined(MCRF_SDL2)
#include <string>
#include <memory>
class GameEngine;
class UIDrawable;
class UIEntity;
class UIFrame;
class UIGrid;
/**
* @brief ImGui-based scene tree explorer for debugging
*
* Displays hierarchical view of all scenes and their UI elements.
* Allows switching between scenes and collapsing/expanding the tree.
* Activated by F4 key. Mutually exclusive with the console (grave key).
*/
class ImGuiSceneExplorer {
public:
ImGuiSceneExplorer() = default;
// Core functionality
void render(GameEngine& engine);
void toggle();
bool isVisible() const { return visible; }
void setVisible(bool v) { visible = v; }
// Configuration - uses same enabled flag as console
static bool isEnabled();
private:
bool visible = false;
// Tree rendering helpers
void renderSceneNode(GameEngine& engine, const std::string& sceneName, bool isActive);
void renderDrawableNode(std::shared_ptr<UIDrawable> drawable, int depth = 0);
void renderEntityNode(std::shared_ptr<UIEntity> entity);
// Get display name for a drawable (name or type + address)
std::string getDisplayName(UIDrawable* drawable);
std::string getEntityDisplayName(UIEntity* entity);
// Get type name string
const char* getTypeName(UIDrawable* drawable);
};
#endif // MCRF_HEADLESS