Files
sophia/engine/src/ui/debug_ui.cpp
T
2026-09-23 04:20:43 +00:00

50 lines
1.2 KiB
C++

#include <sophia/ui/debug_ui.hpp>
#include "panels/console_panel.hpp"
#include "panels/frame_stats_panel.hpp"
#include "panels/panel_registry_panel.hpp"
namespace sophia {
DebugUI::DebugUI(PanelRegistry& registry, ConsoleCommandRegistry& commands)
: registry{registry} {
// #ifndef NDEBUG
this->panelRegistryHandle = registry.emplace<PanelRegistryPanel>(registry);
this->frameStatsHandle = registry.emplace<FrameStatsPanel>();
this->consoleHandle = registry.emplace<ConsolePanel>(commands);
hide();
// #endif // !NDEBUG
}
void DebugUI::show() {
showPanelRegistry(true);
showFrameStats(true);
showConsole(true);
}
void DebugUI::hide() {
showPanelRegistry(false);
showFrameStats(false);
showConsole(false);
}
void DebugUI::showPanelRegistry(bool show) {
if (registry.isValid(panelRegistryHandle)) {
registry.get(panelRegistryHandle).setVisible(show);
}
}
void DebugUI::showFrameStats(bool show) {
if (registry.isValid(frameStatsHandle)) {
registry.get(frameStatsHandle).setVisible(show);
}
}
void DebugUI::showConsole(bool show) {
if (registry.isValid(consoleHandle)) {
registry.get(consoleHandle).setVisible(show);
}
}
} // namespace sophia