#include "ConsolePanel.h" #include "Managers/LogSystem.h" #include "Core/LogEntry.h" #include namespace UI { ConsolePanel::ConsolePanel() : Panel("Console") { LogSystem::Get().AddLog(XCEngine::Debug::LogLevel::Info, "Engine initialized successfully"); LogSystem::Get().AddLog(XCEngine::Debug::LogLevel::Info, "Loading default scene..."); LogSystem::Get().AddLog(XCEngine::Debug::LogLevel::Warning, "Missing material on object 'Cube'"); LogSystem::Get().AddLog(XCEngine::Debug::LogLevel::Error, "Failed to load texture: 'Assets/Textures/missing.png'"); LogSystem::Get().AddLog(XCEngine::Debug::LogLevel::Info, "Scene loaded successfully"); } void ConsolePanel::Render() { ImGui::Begin(m_name.c_str(), nullptr, ImGuiWindowFlags_None); if (ImGui::Button("Clear")) { LogSystem::Get().Clear(); } ImGui::SameLine(); if (ImGui::Button("Info")) { LogSystem::Get().AddLog(XCEngine::Debug::LogLevel::Info, "Test info message"); } ImGui::SameLine(); if (ImGui::Button("Warn")) { LogSystem::Get().AddLog(XCEngine::Debug::LogLevel::Warning, "Test warning message"); } ImGui::SameLine(); if (ImGui::Button("Error")) { LogSystem::Get().AddLog(XCEngine::Debug::LogLevel::Error, "Test error message"); } ImGui::Separator(); ImGui::BeginChild("LogScroll", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar); for (const auto& log : LogSystem::Get().GetLogs()) { ImVec4 color; const char* prefix; switch (log.level) { case XCEngine::Debug::LogLevel::Info: color = ImVec4(0.7f, 0.7f, 0.7f, 1.0f); prefix = "[Info] "; break; case XCEngine::Debug::LogLevel::Warning: color = ImVec4(1.0f, 0.8f, 0.0f, 1.0f); prefix = "[Warn] "; break; case XCEngine::Debug::LogLevel::Error: color = ImVec4(1.0f, 0.3f, 0.3f, 1.0f); prefix = "[Error]"; break; } ImGui::TextColored(color, "%s%s", prefix, log.message.c_str()); } if (m_scrollToBottom) { ImGui::SetScrollHereY(1.0f); m_scrollToBottom = false; } ImGui::EndChild(); ImGui::End(); } }