minor log - update
This commit is contained in:
@@ -24,6 +24,7 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||
|
||||
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX11_Init(m_device, m_deviceContext);
|
||||
ImGui::StyleColorsDark();
|
||||
@@ -521,46 +522,77 @@ void imguiManager::WidgetEngineSettingsWindow(ApplicationClass* app)
|
||||
|
||||
void imguiManager::WidgetLogWindow(ApplicationClass* app)
|
||||
{
|
||||
static bool logLevelVisible[Logger::LogLevelCount] = { true };
|
||||
|
||||
ImGui::Begin("Log", &showLogWindow);
|
||||
|
||||
// R<EFBFBD>cup<EFBFBD>rer les logs depuis le Logger
|
||||
const std::vector<Logger::LogEntry>& logs = Logger::Get().GetLogs();
|
||||
// Champ de saisie pour le filtre
|
||||
static char filterBuffer[256] = "";
|
||||
ImGui::InputText("Filter", filterBuffer, IM_ARRAYSIZE(filterBuffer));
|
||||
|
||||
// Afficher les logs dans ImGui
|
||||
for (const auto& log : logs)
|
||||
ImGui::SameLine();
|
||||
|
||||
// Menu d<>roulant pour les niveaux de log
|
||||
if (ImGui::BeginMenu("Log Levels"))
|
||||
{
|
||||
switch (log.level)
|
||||
for (size_t i = 0; i < Logger::LogLevelCount; ++i)
|
||||
{
|
||||
case Logger::LogLevel::Info:
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.0f, 1.0f, 0.0f, 1.0f)); // Vert pour les messages d'info
|
||||
break;
|
||||
case Logger::LogLevel::Shutdown:
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.5f, 0.0f, 0.0f, 1.0f)); // Rouge sombre pour les messages de shutdown
|
||||
break;
|
||||
case Logger::LogLevel::Error:
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); // Rouge pour les messages d'erreur
|
||||
break;
|
||||
case Logger::LogLevel::Debug:
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.0f, 0.0f, 1.0f, 1.0f)); // Bleu pour les messages de debug
|
||||
break;
|
||||
case Logger::LogLevel::Initialize:
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 0.0f, 1.0f)); // Jaune pour les messages d'initialisation
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
bool isVisible = logLevelVisible[i];
|
||||
if (ImGui::Checkbox(Logger::LogLevelToString(static_cast<Logger::LogLevel>(i)), &isVisible))
|
||||
{
|
||||
logLevelVisible[i] = isVisible;
|
||||
if (isVisible)
|
||||
{
|
||||
Logger::Get().m_disabledLogLevels.erase(static_cast<Logger::LogLevel>(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().m_disabledLogLevels.insert(static_cast<Logger::LogLevel>(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::TextUnformatted(log.message.c_str());
|
||||
// R<>cup<75>rer les logs depuis le logBuffer
|
||||
const std::deque<Logger::LogEntry>& logs = logBuffer;
|
||||
|
||||
if (log.level == Logger::LogLevel::Info ||
|
||||
log.level == Logger::LogLevel::Shutdown ||
|
||||
log.level == Logger::LogLevel::Error ||
|
||||
log.level == Logger::LogLevel::Debug ||
|
||||
log.level == Logger::LogLevel::Initialize)
|
||||
// Afficher les logs dans ImGui avec le filtre
|
||||
ImGui::BeginChild("LogScrollRegion", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin(logs.size());
|
||||
while (clipper.Step())
|
||||
{
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; ++i)
|
||||
{
|
||||
ImGui::PopStyleColor();
|
||||
if (strstr(logs[i].message.c_str(), filterBuffer) != nullptr)
|
||||
{
|
||||
ImVec4 color;
|
||||
switch (logs[i].level)
|
||||
{
|
||||
case Logger::LogLevel::Error:
|
||||
color = ImVec4(1.0f, 0.0f, 0.0f, 1.0f); // Rouge pour les messages d'erreur
|
||||
break;
|
||||
case Logger::LogLevel::Warning:
|
||||
color = ImVec4(1.0f, 1.0f, 0.0f, 1.0f); // Jaune pour les messages d'avertissement
|
||||
break;
|
||||
case Logger::LogLevel::Info:
|
||||
color = ImVec4(0.0f, 1.0f, 0.0f, 1.0f); // Vert pour les messages d'info
|
||||
break;
|
||||
case Logger::LogLevel::Initialize:
|
||||
case Logger::LogLevel::Shutdown:
|
||||
default:
|
||||
color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // Blanc par d<>faut
|
||||
break;
|
||||
}
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, color);
|
||||
ImGui::TextUnformatted(logs[i].message.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
clipper.End();
|
||||
|
||||
// Scroll to the bottom of the log window
|
||||
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
|
||||
@@ -568,11 +600,12 @@ void imguiManager::WidgetLogWindow(ApplicationClass* app)
|
||||
ImGui::SetScrollHereY(1.0f);
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void imguiManager::WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize)
|
||||
{
|
||||
ImGui::Begin("Render Window");
|
||||
|
||||
Reference in New Issue
Block a user