Minor update - Log window in Ui
This commit is contained in:
@@ -66,10 +66,10 @@ void imguiManager::SetupDockspace() {
|
||||
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
|
||||
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
|
||||
|
||||
ImGui::Begin("DockSpace Demo", nullptr, window_flags);
|
||||
ImGui::Begin("DockSpace", nullptr, window_flags);
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
|
||||
ImGuiID dockspace_id = ImGui::GetID("MainDockSpace");
|
||||
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_PassthruCentralNode);
|
||||
|
||||
ImGui::End();
|
||||
@@ -388,6 +388,11 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
|
||||
showEngineSettingsWindow = true;
|
||||
}
|
||||
|
||||
if (ImGui::Button("Open Log Window"))
|
||||
{
|
||||
showLogWindow = true;
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
// Show windows if their corresponding variables are true
|
||||
@@ -416,6 +421,11 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
|
||||
WidgetEngineSettingsWindow(app);
|
||||
}
|
||||
|
||||
if (showLogWindow)
|
||||
{
|
||||
WidgetLogWindow(app);
|
||||
}
|
||||
|
||||
WidgetRenderWindow(app, ImVec2(800, 600));
|
||||
|
||||
//render imgui
|
||||
@@ -463,6 +473,9 @@ void imguiManager::WidgetEngineSettingsWindow(ApplicationClass* app)
|
||||
{
|
||||
ImGui::Begin("Engine Settings", &showEngineSettingsWindow);
|
||||
|
||||
// Begining Of General Setting
|
||||
ImGui::Text("General");
|
||||
|
||||
// Checkbox for toggling vsync globally in the application class by calling the SetVsync function in the application class when the checkbox state changes
|
||||
bool vsync = app->GetVsync();
|
||||
if (ImGui::Checkbox("Vsync", &vsync))
|
||||
@@ -470,6 +483,11 @@ void imguiManager::WidgetEngineSettingsWindow(ApplicationClass* app)
|
||||
app->SetVsync(vsync);
|
||||
}
|
||||
|
||||
// End Of General Setting
|
||||
ImGui::Separator();
|
||||
// culling section
|
||||
ImGui::Text("Culling");
|
||||
|
||||
// float input for frustum tolerance
|
||||
float frustumTolerance = app->GetFrustumTolerance();
|
||||
if (ImGui::DragFloat("Frustum Tolerance", &frustumTolerance, 0.1f, 0.0f, 100.0f))
|
||||
@@ -477,6 +495,12 @@ void imguiManager::WidgetEngineSettingsWindow(ApplicationClass* app)
|
||||
app->SetFrustumTolerance(frustumTolerance);
|
||||
}
|
||||
|
||||
// End Of Culling Setting
|
||||
ImGui::Separator();
|
||||
|
||||
// Physics section
|
||||
ImGui::Text("Physics");
|
||||
|
||||
// Input To set the Fixed Update Interval
|
||||
int physicsInterval = app->GetPhysicsTickRate();
|
||||
if (ImGui::InputInt("Physics Tick Rate", &physicsInterval))
|
||||
@@ -484,9 +508,71 @@ void imguiManager::WidgetEngineSettingsWindow(ApplicationClass* app)
|
||||
app->SetPhysicsTickRate(physicsInterval);
|
||||
}
|
||||
|
||||
// Input to change the gravity on same line
|
||||
XMVECTOR gravity = app->GetPhysics()->GetGravity();
|
||||
float gravityValues[3] = { XMVectorGetX(gravity), XMVectorGetY(gravity), XMVectorGetZ(gravity) };
|
||||
if (ImGui::DragFloat3("Gravity", gravityValues))
|
||||
{
|
||||
app->GetPhysics()->SetGravity(XMVectorSet(gravityValues[0], gravityValues[1], gravityValues[2], 0.0f));
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void imguiManager::WidgetLogWindow(ApplicationClass* app)
|
||||
{
|
||||
ImGui::Begin("Log", &showLogWindow);
|
||||
|
||||
// R<>cup<75>rer les logs depuis le Logger
|
||||
const std::vector<Logger::LogEntry>& logs = Logger::Get().GetLogs();
|
||||
|
||||
// Afficher les logs dans ImGui
|
||||
for (const auto& log : logs)
|
||||
{
|
||||
switch (log.level)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
ImGui::TextUnformatted(log.message.c_str());
|
||||
|
||||
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)
|
||||
{
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll to the bottom of the log window
|
||||
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
|
||||
{
|
||||
ImGui::SetScrollHereY(1.0f);
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void imguiManager::WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize)
|
||||
{
|
||||
ImGui::Begin("Render Window");
|
||||
|
||||
Reference in New Issue
Block a user