Add ImGui Scene Explorer (F4) for runtime object inspection (#136)
New Features: - Scene Explorer window (F4) displays hierarchical tree of all scenes - Shows UIDrawable hierarchy with type, name, and visibility status - Click scene name to switch active scene - Double-click drawables to toggle visibility - Displays Python repr() for cached objects, enabling custom class debugging - Entity display within Grid nodes Bug Fixes: - Fix PythonObjectCache re-registration: when retrieving objects from collections, newly created Python wrappers are now re-registered in the cache. Previously, inline-created objects (e.g., scene.children.append(Frame(...))) would lose their cache entry when the temporary Python object was GC'd, causing repeated wrapper allocation on each access. - Fix console focus stealing: removed aggressive focus reclaim that caused title bar flashing when clicking in Scene Explorer Infrastructure: - Add GameEngine::getSceneNames() to expose scene list for explorer - Scene Explorer uses same enabled flag as console (ImGuiConsole::isEnabled()) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4be2502a10
commit
5e45ab015c
7 changed files with 378 additions and 3 deletions
|
|
@ -202,6 +202,16 @@ Scene* GameEngine::getScene(const std::string& name) {
|
|||
auto it = scenes.find(name);
|
||||
return (it != scenes.end()) ? it->second : nullptr;
|
||||
}
|
||||
|
||||
std::vector<std::string> GameEngine::getSceneNames() const {
|
||||
std::vector<std::string> names;
|
||||
names.reserve(scenes.size());
|
||||
for (const auto& [name, scene] : scenes) {
|
||||
names.push_back(name);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
void GameEngine::changeScene(std::string s)
|
||||
{
|
||||
changeScene(s, TransitionType::None, 0.0f);
|
||||
|
|
@ -346,9 +356,10 @@ void GameEngine::run()
|
|||
profilerOverlay->render(*render_target);
|
||||
}
|
||||
|
||||
// Render ImGui console overlay
|
||||
// Render ImGui overlays (console and scene explorer)
|
||||
if (imguiInitialized && !headless) {
|
||||
console.render();
|
||||
sceneExplorer.render(*this);
|
||||
ImGui::SFML::Render(*window);
|
||||
}
|
||||
|
||||
|
|
@ -550,6 +561,12 @@ void GameEngine::sUserInput()
|
|||
continue; // Don't pass grave key to game
|
||||
}
|
||||
|
||||
// Handle F4 for scene explorer toggle
|
||||
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::F4) {
|
||||
sceneExplorer.toggle();
|
||||
continue; // Don't pass F4 to game
|
||||
}
|
||||
|
||||
// If console wants keyboard, don't pass keyboard events to game
|
||||
if (console.wantsKeyboardInput()) {
|
||||
// Still process non-keyboard events (mouse, window close, etc.)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue