Notification Window: Improve usability

This commit is contained in:
Arnaud Jamin
2025-02-06 00:21:02 -05:00
parent 816889ba7c
commit cee4787d9a
6 changed files with 233 additions and 321 deletions
@@ -635,15 +635,6 @@ void FCogEngineWindow_Console::ExecuteCommand(const FString& InCommand)
{
IConsoleManager::Get().AddConsoleHistoryEntry(TEXT(""), *CleanupCommand);
GEngine->DeferredCommands.Add(CleanupCommand);
if (GetCommandObjectFromCommandLine(InCommand) != nullptr)
{
COG_NOTIFY(TEXT("Command: %s"), *CleanupCommand);
}
else
{
COG_NOTIFY_ERROR(TEXT("Unknown Command: %s"), *CleanupCommand);
}
}
if (bIsWidgetMode)
@@ -12,6 +12,13 @@
#include "Misc/Paths.h"
#include "NetImgui_Api.h"
//--------------------------------------------------------------------------------------------------------------------------
void FCogEngineWindow_NetImgui::RenderHelp()
{
ImGui::Text("This window manage the connection to the NetImgui server."
"See https://github.com/sammyfreg/netImgui for more info.");
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogEngineWindow_NetImgui::Initialize()
{
@@ -76,13 +83,6 @@ void FCogEngineWindow_NetImgui::Shutdown()
CloseServer();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogEngineWindow_NetImgui::RenderHelp()
{
ImGui::Text("This window manage the connection to the NetImgui server."
"See https://github.com/sammyfreg/netImgui for more info.");
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogEngineWindow_NetImgui::RenderTick(float DeltaTime)
{
@@ -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);
}
}
@@ -42,21 +42,19 @@ public:
virtual void Initialize() override;
void AddLog(const TCHAR* InMessage, ELogVerbosity::Type InVerbosity, const FName& InCategory);
void OnLogReceived(const TCHAR* InMessage, ELogVerbosity::Type InVerbosity, const FName& InCategory);
void Clear();
void AddNotification(const TCHAR* InMessage, ELogVerbosity::Type InVerbosity);
protected:
struct FNotification
{
int32 LineStart = 0;
int32 LineEnd = 0;
uint64 Frame = 0;
FString Id;
FDateTime Time;
ELogVerbosity::Type Verbosity;
FName Category;
FString Message;
FString Message;
};
virtual void RenderHelp() override;
@@ -67,16 +65,17 @@ protected:
virtual void RenderNotifications();
virtual void DrawRow(const FNotification& InNotification, bool InShowAsTableRow) const;
virtual void RenderSettings();
ImGuiTextFilter Filter;
FCogNotificationOutputDevice OutputDevice;
TArray<FNotification> Notifications;
static int32 NotificationsId;
TWeakObjectPtr<UCogEngineConfig_Notifications> Config;
};
//--------------------------------------------------------------------------------------------------------------------------
@@ -86,19 +85,19 @@ class UCogEngineConfig_Notifications : public UCogCommonConfig
GENERATED_BODY()
public:
UPROPERTY(Config)
bool DisableNotifications = false;
UPROPERTY(Config)
bool AutoScroll = true;
bool NotifyAllWarnings = false;
UPROPERTY(Config)
bool ShowVerbosity = false;
bool NotifyAllErrors = false;
UPROPERTY(Config)
int32 VerbosityFilter = ELogVerbosity::VeryVerbose;
UPROPERTY(Config)
bool ShowAsTable = false;
bool NotifyConsoleCommands = true;
UPROPERTY(Config)
FColor BackgroundDefaultColor = FColor::White;
@@ -133,42 +132,48 @@ public:
int Padding = 10;
UPROPERTY(Config)
int32 TextWrapping = 30;
bool UseFixedWidth = true;
UPROPERTY(Config)
int32 WindowRounding = 6;
int32 MaxHeight = 10;
UPROPERTY(Config)
int32 TextWrapping = 20;
UPROPERTY(Config)
bool WindowBorder = false;
int32 Rounding = 6;
UPROPERTY(Config)
float VisibleDuration = 3.0f;
bool ShowBorder = true;
UPROPERTY(Config)
float FadeDuration = 0.5f;
float Duration = 5.0f;
UPROPERTY(Config)
float FadeOut = 0.5f;
virtual void Reset() override
{
Super::Reset();
AutoScroll = true;
ShowVerbosity = false;
VerbosityFilter = ELogVerbosity::VeryVerbose;
ShowAsTable = false;
TextDefaultColor = FColor(200, 200, 200, 255);
TextWarningColor = FColor(255, 200, 0, 255);
TextErrorColor = FColor(255, 0, 0, 255);
BackgroundDefaultColor = FColor(0, 0, 0, 170);
BackgroundWarningColor = FColor(50, 20, 0, 170);
BackgroundErrorColor = FColor(50, 0, 0, 170);
BorderDefaultColor = FColor(200, 200, 200, 100);
BorderWarningColor = FColor(255, 200, 0, 100);
BorderErrorColor = FColor(255, 0, 0, 100);
TextDefaultColor = FColor(200, 200, 200, 255);
TextWarningColor = FColor(255, 200, 0, 255);
TextErrorColor = FColor(240, 77, 77, 255);
BackgroundDefaultColor = FColor( 15, 15, 15, 150);
BackgroundWarningColor = FColor( 23, 9, 0, 150);
BackgroundErrorColor = FColor( 21, 0, 0, 150);
BorderDefaultColor = FColor(200, 200, 200, 100);
BorderWarningColor = FColor(255, 200, 0, 100);
BorderErrorColor = FColor(240, 77, 77, 100);
Location = ECogEngineNotificationLocation::BottomRight;
Padding = 10;
TextWrapping = 40;
WindowRounding = 6;
WindowBorder = true;
UseFixedWidth = true;
TextWrapping = 20;
MaxHeight = 10;
Rounding = 6;
ShowBorder = true;
Duration = 5.0f;
FadeOut = 0.5f;
}
};
@@ -1,5 +1,6 @@
#include "CogWindow_Settings.h"
#include "CogCommon.h"
#include "CogImguiHelper.h"
#include "CogImguiInputHelper.h"
#include "CogWindowManager.h"
@@ -285,6 +286,7 @@ void FCogWindow_Settings::SetDPIScale(float Value) const
{
Config->DPIScale = Value;
GetOwner()->GetContext().SetDPIScale(Config->DPIScale);
COG_NOTIFY(TEXT("DPI Scale: %0.2f"), Value);
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -76,10 +76,10 @@ void Cog::AddAllWindows(UCogWindowManager& CogWindowManager)
CogWindowManager.AddWindow<FCogEngineWindow_NetImgui>("Engine.Net ImGui");
CogWindowManager.AddWindow<FCogEngineWindow_OutputLog>("Engine.Output Log");
CogWindowManager.AddWindow<FCogEngineWindow_Notifications>("Engine.Notifications");
CogWindowManager.AddWindow<FCogEngineWindow_OutputLog>("Engine.Output Log");
CogWindowManager.AddWindow<FCogEngineWindow_Plots>("Engine.Plots");
FCogEngineWindow_Selection* SelectionWindow = CogWindowManager.AddWindow<FCogEngineWindow_Selection>("Engine.Selection");