This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/BigBaseV2/src/gui/window/window_log.cpp

36 lines
742 B
C++
Raw Normal View History

2021-05-21 12:44:43 +02:00
#include "gui/window.hpp"
#include "imgui.h"
#include "renderer.hpp"
#include "logger.hpp"
namespace big
{
static size_t iLastLogCount = 0;
void window::log()
{
ImGui::SetNextWindowSize({ 500, 250 }, ImGuiCond_FirstUseEver);
ImGui::SetNextWindowPos({ 50, 50 }, ImGuiCond_FirstUseEver);
if (g.window.log && ImGui::Begin("Log"))
{
ImGui::PushFont(g_renderer->m_monospace_font);
std::lock_guard lock(g_logger->m_mutex);
auto msgs = g_logger->get_messages();
for (size_t i = 0; i < msgs.second; i++)
{
ImGui::TextUnformatted(msgs.first[i].get());
}
if (iLastLogCount != msgs.second)
{
iLastLogCount = msgs.second;
ImGui::SetScrollHereY(1.f);
}
ImGui::PopFont();
ImGui::End();
}
}
}