|
|
|
@@ -2,21 +2,21 @@
|
|
|
|
|
|
|
|
|
|
#include "CogCommon.h"
|
|
|
|
|
#include "CogCommonLogCategory.h"
|
|
|
|
|
#include "CogDebugHelper.h"
|
|
|
|
|
#include "CogDebugDraw.h"
|
|
|
|
|
#include "CogDebugDrawHelper.h"
|
|
|
|
|
#include "CogDebugDrawImGui.h"
|
|
|
|
|
#include "CogImguiHelper.h"
|
|
|
|
|
#include "CogWindowWidgets.h"
|
|
|
|
|
#include "imgui_internal.h"
|
|
|
|
|
#include "Engine/Engine.h"
|
|
|
|
|
#include "GenericPlatform/GenericPlatformSurvey.h"
|
|
|
|
|
#include "Math/UnitConversion.h"
|
|
|
|
|
#include "Misc/StringBuilder.h"
|
|
|
|
|
|
|
|
|
|
int32 FCogEngineWindow_Notifications::NotificationsId = 0;
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void FCogEngineWindow_Notifications::Initialize()
|
|
|
|
|
{
|
|
|
|
|
Super::Initialize();
|
|
|
|
|
|
|
|
|
|
bHasMenu = true;
|
|
|
|
|
OutputDevice.Notifications = this;
|
|
|
|
|
|
|
|
|
|
Config = GetConfig<UCogEngineConfig_Notifications>();
|
|
|
|
@@ -25,10 +25,7 @@ void FCogEngineWindow_Notifications::Initialize()
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void FCogEngineWindow_Notifications::RenderHelp()
|
|
|
|
|
{
|
|
|
|
|
ImGui::Text(
|
|
|
|
|
"This window output the log based on each log categories verbosity. "
|
|
|
|
|
"The verbosity of each log category can be configured in the 'Log Categories' window. "
|
|
|
|
|
);
|
|
|
|
|
ImGui::Text("This window manage the notifications.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
@@ -38,60 +35,32 @@ void FCogEngineWindow_Notifications::Clear()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void FCogEngineWindow_Notifications::AddLog(const TCHAR* InMessage, ELogVerbosity::Type InVerbosity, const class FName& InCategory)
|
|
|
|
|
void FCogEngineWindow_Notifications::AddNotification(const TCHAR* InMessage, ELogVerbosity::Type InVerbosity)
|
|
|
|
|
{
|
|
|
|
|
if (InCategory == LogCogNotify.GetCategoryName())
|
|
|
|
|
{
|
|
|
|
|
FNotification& Notification = Notifications.AddDefaulted_GetRef();
|
|
|
|
|
Notification.Frame = GFrameCounter;
|
|
|
|
|
Notification.Time = FDateTime::Now();
|
|
|
|
|
Notification.Verbosity = InVerbosity;
|
|
|
|
|
Notification.Category = InCategory;
|
|
|
|
|
Notification.Message = InMessage;
|
|
|
|
|
}
|
|
|
|
|
FNotification& Notification = Notifications.AddDefaulted_GetRef();
|
|
|
|
|
Notification.Id = FString::Printf(TEXT("###Notify%d"), NotificationsId);
|
|
|
|
|
Notification.Time = FDateTime::Now();
|
|
|
|
|
Notification.Verbosity = InVerbosity;
|
|
|
|
|
Notification.Message = InMessage;
|
|
|
|
|
|
|
|
|
|
NotificationsId++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void FCogEngineWindow_Notifications::DrawRow(const FNotification& InNotification, bool InShowAsTableRow) const
|
|
|
|
|
void FCogEngineWindow_Notifications::OnLogReceived(const TCHAR* InMessage, ELogVerbosity::Type InVerbosity, const class FName& InCategory)
|
|
|
|
|
{
|
|
|
|
|
ImU32 Color;
|
|
|
|
|
switch (InNotification.Verbosity)
|
|
|
|
|
{
|
|
|
|
|
case ELogVerbosity::Error: Color = FCogImguiHelper::ToImColor(Config->TextErrorColor); break;
|
|
|
|
|
case ELogVerbosity::Warning: Color = FCogImguiHelper::ToImColor(Config->TextWarningColor); break;
|
|
|
|
|
default: Color = FCogImguiHelper::ToImColor(Config->TextDefaultColor); break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text, Color);
|
|
|
|
|
|
|
|
|
|
if (InShowAsTableRow)
|
|
|
|
|
{
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
}
|
|
|
|
|
if (Config->DisableNotifications)
|
|
|
|
|
{ return; }
|
|
|
|
|
|
|
|
|
|
if (Config->ShowVerbosity)
|
|
|
|
|
{
|
|
|
|
|
if (InShowAsTableRow)
|
|
|
|
|
{
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::TextUnformatted(StringCast<ANSICHAR>(ToString(InNotification.Verbosity)).Get());
|
|
|
|
|
|
|
|
|
|
if (InShowAsTableRow == false)
|
|
|
|
|
{
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (InShowAsTableRow)
|
|
|
|
|
{
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
}
|
|
|
|
|
static FName CmdName("Cmd");
|
|
|
|
|
|
|
|
|
|
ImGui::TextUnformatted(StringCast<ANSICHAR>(*InNotification.Message).Get());
|
|
|
|
|
|
|
|
|
|
ImGui::PopStyleColor();
|
|
|
|
|
if (InCategory == LogCogNotify.GetCategoryName()
|
|
|
|
|
|| (InCategory == CmdName && Config->NotifyConsoleCommands)
|
|
|
|
|
|| (InVerbosity == ELogVerbosity::Warning && Config->NotifyAllWarnings)
|
|
|
|
|
|| (InVerbosity == ELogVerbosity::Error && Config->NotifyAllErrors))
|
|
|
|
|
{
|
|
|
|
|
AddNotification(InMessage, InVerbosity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
@@ -99,6 +68,9 @@ void FCogEngineWindow_Notifications::RenderTick(float DeltaTime)
|
|
|
|
|
{
|
|
|
|
|
Super::RenderTick(DeltaTime);
|
|
|
|
|
|
|
|
|
|
if (Config->DisableNotifications)
|
|
|
|
|
{ return; }
|
|
|
|
|
|
|
|
|
|
RenderNotifications();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -115,13 +87,14 @@ void FCogEngineWindow_Notifications::RenderNotifications()
|
|
|
|
|
| ImGuiWindowFlags_AlwaysAutoResize
|
|
|
|
|
| ImGuiWindowFlags_NoSavedSettings
|
|
|
|
|
| ImGuiWindowFlags_NoFocusOnAppearing
|
|
|
|
|
| ImGuiWindowFlags_NoNav
|
|
|
|
|
| ImGuiWindowFlags_NoSavedSettings;
|
|
|
|
|
| ImGuiWindowFlags_NoNav;
|
|
|
|
|
|
|
|
|
|
const ImGuiViewport* Viewport = ImGui::GetMainViewport();
|
|
|
|
|
const ImVec2 ViewportPos = Viewport->WorkPos;
|
|
|
|
|
const ImVec2 ViewportSize = Viewport->WorkSize;
|
|
|
|
|
|
|
|
|
|
const ImVec2 WindowPadding = ImGui::GetStyle().WindowPadding;
|
|
|
|
|
const ImVec2 ItemSpacing = ImGui::GetStyle().ItemSpacing;
|
|
|
|
|
|
|
|
|
|
const bool IsRight = static_cast<int32>(Config->Location) & 1;
|
|
|
|
|
const bool IsBottom = static_cast<int32>(Config->Location) & 2;
|
|
|
|
|
|
|
|
|
@@ -131,66 +104,87 @@ void FCogEngineWindow_Notifications::RenderNotifications()
|
|
|
|
|
|
|
|
|
|
const ImVec2 WindowPosPivot(IsRight ? 1.0f : 0.0f, IsBottom ? 1.0f : 0.0f);
|
|
|
|
|
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, Config->WindowRounding);
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, Config->WindowBorder);
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, Config->Rounding);
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, Config->ShowBorder);
|
|
|
|
|
|
|
|
|
|
const FDateTime Now = FDateTime::Now();
|
|
|
|
|
|
|
|
|
|
for (int32 i = Notifications.Num() - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
const FNotification& Notification = Notifications[i];
|
|
|
|
|
|
|
|
|
|
const FTimespan Span = FDateTime::Now() - Notification.Time;
|
|
|
|
|
if (Span > FTimespan::FromSeconds(Config->VisibleDuration))
|
|
|
|
|
const FTimespan Span = Now - Notification.Time;
|
|
|
|
|
if (Span > FTimespan::FromSeconds(Config->Duration + Config->FadeOut))
|
|
|
|
|
{
|
|
|
|
|
Notifications.RemoveAt(i);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImU32 TextColor, BackColor, BorderColor;
|
|
|
|
|
ImVec4 TextColor, BackColor, BorderColor;
|
|
|
|
|
switch (Notification.Verbosity)
|
|
|
|
|
{
|
|
|
|
|
case ELogVerbosity::Error:
|
|
|
|
|
{
|
|
|
|
|
TextColor = FCogImguiHelper::ToImColor(Config->TextErrorColor);
|
|
|
|
|
BackColor = FCogImguiHelper::ToImColor(Config->BackgroundErrorColor);
|
|
|
|
|
BorderColor = FCogImguiHelper::ToImColor(Config->BorderErrorColor);
|
|
|
|
|
TextColor = FCogImguiHelper::ToImVec4(Config->TextErrorColor);
|
|
|
|
|
BackColor = FCogImguiHelper::ToImVec4(Config->BackgroundErrorColor);
|
|
|
|
|
BorderColor = FCogImguiHelper::ToImVec4(Config->BorderErrorColor);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case ELogVerbosity::Warning:
|
|
|
|
|
{
|
|
|
|
|
TextColor = FCogImguiHelper::ToImColor(Config->TextWarningColor);
|
|
|
|
|
BackColor = FCogImguiHelper::ToImColor(Config->BackgroundWarningColor);
|
|
|
|
|
BorderColor = FCogImguiHelper::ToImColor(Config->BorderWarningColor);
|
|
|
|
|
TextColor = FCogImguiHelper::ToImVec4(Config->TextWarningColor);
|
|
|
|
|
BackColor = FCogImguiHelper::ToImVec4(Config->BackgroundWarningColor);
|
|
|
|
|
BorderColor = FCogImguiHelper::ToImVec4(Config->BorderWarningColor);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
TextColor = FCogImguiHelper::ToImColor(Config->TextDefaultColor);
|
|
|
|
|
BackColor = FCogImguiHelper::ToImColor(Config->BackgroundDefaultColor);
|
|
|
|
|
BorderColor = FCogImguiHelper::ToImColor(Config->BorderDefaultColor);
|
|
|
|
|
TextColor = FCogImguiHelper::ToImVec4(Config->TextDefaultColor);
|
|
|
|
|
BackColor = FCogImguiHelper::ToImVec4(Config->BackgroundDefaultColor);
|
|
|
|
|
BorderColor = FCogImguiHelper::ToImVec4(Config->BorderDefaultColor);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::SetNextWindowPos(WindowPos, ImGuiCond_Always, WindowPosPivot);
|
|
|
|
|
ImGui::SetNextWindowViewport(Viewport->ID);
|
|
|
|
|
|
|
|
|
|
const float ElapsedTime = Span.GetTotalSeconds();
|
|
|
|
|
const float Alpha = FMath::GetMappedRangeValueClamped(FVector2d(Config->Duration, Config->Duration + Config->FadeOut), FVector2d(1.0f, 0.0f), ElapsedTime);
|
|
|
|
|
|
|
|
|
|
BackColor.w *= Alpha;
|
|
|
|
|
TextColor.w *= Alpha;
|
|
|
|
|
BorderColor.w *= Alpha;
|
|
|
|
|
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_WindowBg, BackColor);
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Border, BorderColor);
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text, TextColor);
|
|
|
|
|
|
|
|
|
|
static char WindowNameBuffer[32];
|
|
|
|
|
ImFormatString(WindowNameBuffer, IM_ARRAYSIZE(WindowNameBuffer), "CogNotification%d", i);
|
|
|
|
|
if (ImGui::Begin(WindowNameBuffer, nullptr, Flags))
|
|
|
|
|
const auto Message = StringCast<ANSICHAR>(*Notification.Message);
|
|
|
|
|
const float WrapWidth = Config->TextWrapping * ImGui::GetFontSize();
|
|
|
|
|
|
|
|
|
|
ImGui::SetNextWindowViewport(Viewport->ID);
|
|
|
|
|
ImGui::SetNextWindowPos(WindowPos, ImGuiCond_Always, WindowPosPivot);
|
|
|
|
|
if (Config->UseFixedWidth)
|
|
|
|
|
{
|
|
|
|
|
ImGui::PushTextWrapPos(Config->TextWrapping * ImGui::GetFontSize());
|
|
|
|
|
ImGui::TextUnformatted(StringCast<ANSICHAR>(*Notification.Message).Get());
|
|
|
|
|
ImGui::SetNextWindowSizeConstraints(ImVec2(WrapWidth, 0) + WindowPadding * 2, ImVec2(WrapWidth, Config->MaxHeight * ImGui::GetFontSize()) + WindowPadding * 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::Begin(StringCast<ANSICHAR>(*Notification.Id).Get(), nullptr, Flags))
|
|
|
|
|
{
|
|
|
|
|
ImGui::PushTextWrapPos(WrapWidth);
|
|
|
|
|
ImGui::TextUnformatted(Message.Get());
|
|
|
|
|
ImGui::PopTextWrapPos();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::PopStyleColor(3);
|
|
|
|
|
|
|
|
|
|
WindowPos.y += (ImGui::GetWindowHeight() + ImGui::GetStyle().ItemSpacing.y) * (IsBottom ? -1 : 1);
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
// Compute ourself window height otherwise we get a one frame glitch,
|
|
|
|
|
// maybe because the real window size is computed the next frame.
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
const ImVec2 TextSize = ImGui::CalcTextSize(Message.Get(), nullptr, false, WrapWidth);
|
|
|
|
|
const float WindowHeight = TextSize.y + (WindowPadding.y * 2);
|
|
|
|
|
WindowPos.y += (WindowHeight + ItemSpacing.y) * (IsBottom ? -1 : 1);
|
|
|
|
|
ImGui::End();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -202,195 +196,115 @@ void FCogEngineWindow_Notifications::RenderContent()
|
|
|
|
|
{
|
|
|
|
|
Super::RenderContent();
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginMenuBar())
|
|
|
|
|
if (ImGui::Button("Clear Notifications", ImVec2(-1, 0)))
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::BeginMenu("Options"))
|
|
|
|
|
{
|
|
|
|
|
ImGui::Checkbox("Auto Scroll", &Config->AutoScroll);
|
|
|
|
|
ImGui::Checkbox("Show Verbosity", &Config->ShowVerbosity);
|
|
|
|
|
ImGui::Checkbox("Show As Table", &Config->ShowAsTable);
|
|
|
|
|
ImGui::Checkbox("Window Border", &Config->WindowBorder);
|
|
|
|
|
Notifications.Empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::ThinSeparatorText("Notification Test");
|
|
|
|
|
|
|
|
|
|
if (ImGui::Button("Notify Normal", ImVec2(-1, 0)))
|
|
|
|
|
{
|
|
|
|
|
COG_NOTIFY(TEXT("A notification test. Frame:%llu"), GFrameCounter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::Button("Notify Warning", ImVec2(-1, 0)))
|
|
|
|
|
{
|
|
|
|
|
COG_NOTIFY_WARNING(TEXT("A long long long long long long long long long long long long long long long long long long long long long warning notification test. Frame:%llu"), GFrameCounter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::Button("Notify Error", ImVec2(-1, 0)))
|
|
|
|
|
{
|
|
|
|
|
COG_NOTIFY_ERROR(TEXT("An error notification test. Frame:%llu"), GFrameCounter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RenderSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void FCogEngineWindow_Notifications::RenderSettings()
|
|
|
|
|
{
|
|
|
|
|
FCogWindowWidgets::ThinSeparatorText("Filtering");
|
|
|
|
|
|
|
|
|
|
ImGui::Checkbox("Disable Notifications", &Config->DisableNotifications);
|
|
|
|
|
|
|
|
|
|
ImGui::Checkbox("Notify Console Commands", &Config->NotifyConsoleCommands);
|
|
|
|
|
|
|
|
|
|
ImGui::Checkbox("Notify All Warnings", &Config->NotifyAllWarnings);
|
|
|
|
|
|
|
|
|
|
ImGui::Checkbox("Notify All Errors", &Config->NotifyAllErrors);
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::ThinSeparatorText("Location & Size");
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
FCogWindowWidgets::ComboboxEnum("Location", Config->Location);
|
|
|
|
|
|
|
|
|
|
ImGui::Checkbox("Use Fixed Width", &Config->UseFixedWidth);
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::DragInt("Text Wrapping", &Config->TextWrapping, 1, 0, INT_MAX);
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::DragInt("Max Height", &Config->MaxHeight, 1, 0, INT_MAX);
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::DragInt("Padding", &Config->Padding, 1, 0, INT_MAX);
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::ThinSeparatorText("Display");
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::SliderFloat("Duration", &Config->Duration, 1, 10, "%0.1f");
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::SliderFloat("Fade Out", &Config->FadeOut, 0, 3, "%0.1f");
|
|
|
|
|
|
|
|
|
|
ImGui::Checkbox("Show Border", &Config->ShowBorder);
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::SliderInt("Rounding", &Config->Rounding, 0, 12);
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::ThinSeparatorText("Colors");
|
|
|
|
|
|
|
|
|
|
constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf;
|
|
|
|
|
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BackDef", Config->BackgroundDefaultColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Background Default");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BackWarn", Config->BackgroundWarningColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Background Warning");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BackError", Config->BackgroundErrorColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Background Error");
|
|
|
|
|
ImGui::TextUnformatted("Background Color");
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
FCogWindowWidgets::ComboboxEnum("Notification Location", Config->Location);
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BorderDef", Config->BorderDefaultColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Border Default");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BorderWarn", Config->BorderWarningColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Border Warning");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BorderError", Config->BorderErrorColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Border Error");
|
|
|
|
|
ImGui::TextUnformatted("Border Color");
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::SliderFloat("Visible Duration", &Config->VisibleDuration, 1, 10, "%0.1f");
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::SliderFloat("Fade Duration", &Config->FadeDuration, 0, 3, "%0.1f");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##TextDef", Config->TextDefaultColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Text Default");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##TextWarn", Config->TextWarningColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Text Warning");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##TextError", Config->TextErrorColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Text Error");
|
|
|
|
|
ImGui::TextUnformatted("Text Color");
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::DragInt("Text Wrapping", &Config->TextWrapping, 1, 0, INT_MAX);
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::DragInt("Padding", &Config->Padding, 1, 0, INT_MAX);
|
|
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
|
|
|
ImGui::SliderInt("Window Rounding", &Config->WindowRounding, 0, 12);
|
|
|
|
|
|
|
|
|
|
constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf;
|
|
|
|
|
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BackDef", Config->BackgroundDefaultColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Background Default");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BackWarn", Config->BackgroundWarningColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Background Warning");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BackError", Config->BackgroundErrorColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Background Error");
|
|
|
|
|
ImGui::TextUnformatted("Background Color");
|
|
|
|
|
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BorderDef", Config->BorderDefaultColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Border Default");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BorderWarn", Config->BorderWarningColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Border Warning");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##BorderError", Config->BorderErrorColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Border Error");
|
|
|
|
|
ImGui::TextUnformatted("Border Color");
|
|
|
|
|
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##TextDef", Config->TextDefaultColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Text Default");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##TextWarn", Config->TextWarningColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Text Warning");
|
|
|
|
|
FCogImguiHelper::ColorEdit4("##TextError", Config->TextErrorColor, ColorEditFlags);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::SetItemTooltip("Text Error");
|
|
|
|
|
ImGui::TextUnformatted("Text Color");
|
|
|
|
|
|
|
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
|
|
if (ImGui::Button("Reset Settings", ImVec2(-1, 0)))
|
|
|
|
|
{
|
|
|
|
|
ResetConfig();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::EndMenu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Clear"))
|
|
|
|
|
{
|
|
|
|
|
Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
|
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 9);
|
|
|
|
|
if (ImGui::BeginCombo("##Verbosity", FCogDebugHelper::VerbosityToString(static_cast<ELogVerbosity::Type>(Config->VerbosityFilter))))
|
|
|
|
|
{
|
|
|
|
|
for (int32 i = ELogVerbosity::Error; i <= static_cast<int32>(ELogVerbosity::VeryVerbose); ++i)
|
|
|
|
|
{
|
|
|
|
|
const bool IsSelected = i == Config->VerbosityFilter;
|
|
|
|
|
const ELogVerbosity::Type Verbosity = static_cast<ELogVerbosity::Type>(i);
|
|
|
|
|
|
|
|
|
|
if (ImGui::Selectable(FCogDebugHelper::VerbosityToString(Verbosity), IsSelected))
|
|
|
|
|
{
|
|
|
|
|
Config->VerbosityFilter = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndCombo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FCogWindowWidgets::SearchBar("##Filter", Filter);
|
|
|
|
|
|
|
|
|
|
ImGui::EndMenuBar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32 ColumnCount = 1;
|
|
|
|
|
ColumnCount += static_cast<int32>(Config->ShowVerbosity);
|
|
|
|
|
|
|
|
|
|
bool IsTableShown = false;
|
|
|
|
|
if (Config->ShowAsTable)
|
|
|
|
|
if (ImGui::Button("Reset Settings", ImVec2(-1, 0)))
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::BeginTable("LogTable", ColumnCount, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ScrollX | ImGuiTableFlags_NoHostExtendX))
|
|
|
|
|
{
|
|
|
|
|
IsTableShown = true;
|
|
|
|
|
if (Config->ShowVerbosity)
|
|
|
|
|
{
|
|
|
|
|
ImGui::TableSetupColumn("Verbosity", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::TableSetupColumn("Message", ImGuiTableColumnFlags_WidthStretch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsTableShown == false)
|
|
|
|
|
{
|
|
|
|
|
ImGui::BeginChild("Scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Filter.IsActive())
|
|
|
|
|
{
|
|
|
|
|
for (int32 i = 0; i < Notifications.Num(); i++)
|
|
|
|
|
{
|
|
|
|
|
const FNotification& Notification = Notifications[i];
|
|
|
|
|
const auto& Message = StringCast<ANSICHAR>(*Notification.Message);
|
|
|
|
|
if (Filter.PassFilter(Message.Get()))
|
|
|
|
|
{
|
|
|
|
|
DrawRow(Notification, IsTableShown);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (Config->VerbosityFilter != ELogVerbosity::VeryVerbose)
|
|
|
|
|
{
|
|
|
|
|
for (int32 i = 0; i < Notifications.Num(); i++)
|
|
|
|
|
{
|
|
|
|
|
const FNotification& Notification = Notifications[i];
|
|
|
|
|
|
|
|
|
|
if (Notification.Verbosity <= static_cast<ELogVerbosity::Type>(Config->VerbosityFilter))
|
|
|
|
|
{
|
|
|
|
|
DrawRow(Notification, IsTableShown);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ImGuiListClipper Clipper;
|
|
|
|
|
Clipper.Begin(Notifications.Num());
|
|
|
|
|
while (Clipper.Step())
|
|
|
|
|
{
|
|
|
|
|
for (int32 LineIndex = Clipper.DisplayStart; LineIndex < Clipper.DisplayEnd; LineIndex++)
|
|
|
|
|
{
|
|
|
|
|
if (Notifications.IsValidIndex(LineIndex))
|
|
|
|
|
{
|
|
|
|
|
const FNotification& Notification = Notifications[LineIndex];
|
|
|
|
|
DrawRow(Notification, IsTableShown);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Clipper.End();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Config->AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
|
|
|
|
|
{
|
|
|
|
|
ImGui::SetScrollHereY(1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsTableShown)
|
|
|
|
|
{
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginPopupContextItem("Notifications"))
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::MenuItem("Clear"))
|
|
|
|
|
{
|
|
|
|
|
Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
|
ResetConfig();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -416,6 +330,6 @@ void FCogNotificationOutputDevice::Serialize(const TCHAR* Message, const ELogVer
|
|
|
|
|
{
|
|
|
|
|
if (Notifications != nullptr)
|
|
|
|
|
{
|
|
|
|
|
Notifications->AddLog(Message, Verbosity, Category);
|
|
|
|
|
Notifications->OnLogReceived(Message, Verbosity, Category);
|
|
|
|
|
}
|
|
|
|
|
}
|