mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-04 14:48:45 +00:00
Notification Window: Improve usability
This commit is contained in:
@@ -635,15 +635,6 @@ void FCogEngineWindow_Console::ExecuteCommand(const FString& InCommand)
|
|||||||
{
|
{
|
||||||
IConsoleManager::Get().AddConsoleHistoryEntry(TEXT(""), *CleanupCommand);
|
IConsoleManager::Get().AddConsoleHistoryEntry(TEXT(""), *CleanupCommand);
|
||||||
GEngine->DeferredCommands.Add(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)
|
if (bIsWidgetMode)
|
||||||
|
|||||||
@@ -12,6 +12,13 @@
|
|||||||
#include "Misc/Paths.h"
|
#include "Misc/Paths.h"
|
||||||
#include "NetImgui_Api.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()
|
void FCogEngineWindow_NetImgui::Initialize()
|
||||||
{
|
{
|
||||||
@@ -76,13 +83,6 @@ void FCogEngineWindow_NetImgui::Shutdown()
|
|||||||
CloseServer();
|
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)
|
void FCogEngineWindow_NetImgui::RenderTick(float DeltaTime)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,21 +2,21 @@
|
|||||||
|
|
||||||
#include "CogCommon.h"
|
#include "CogCommon.h"
|
||||||
#include "CogCommonLogCategory.h"
|
#include "CogCommonLogCategory.h"
|
||||||
#include "CogDebugHelper.h"
|
#include "CogDebugDraw.h"
|
||||||
|
#include "CogDebugDrawHelper.h"
|
||||||
|
#include "CogDebugDrawImGui.h"
|
||||||
#include "CogImguiHelper.h"
|
#include "CogImguiHelper.h"
|
||||||
#include "CogWindowWidgets.h"
|
#include "CogWindowWidgets.h"
|
||||||
#include "imgui_internal.h"
|
|
||||||
#include "Engine/Engine.h"
|
#include "Engine/Engine.h"
|
||||||
#include "GenericPlatform/GenericPlatformSurvey.h"
|
|
||||||
#include "Math/UnitConversion.h"
|
|
||||||
#include "Misc/StringBuilder.h"
|
#include "Misc/StringBuilder.h"
|
||||||
|
|
||||||
|
int32 FCogEngineWindow_Notifications::NotificationsId = 0;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void FCogEngineWindow_Notifications::Initialize()
|
void FCogEngineWindow_Notifications::Initialize()
|
||||||
{
|
{
|
||||||
Super::Initialize();
|
Super::Initialize();
|
||||||
|
|
||||||
bHasMenu = true;
|
|
||||||
OutputDevice.Notifications = this;
|
OutputDevice.Notifications = this;
|
||||||
|
|
||||||
Config = GetConfig<UCogEngineConfig_Notifications>();
|
Config = GetConfig<UCogEngineConfig_Notifications>();
|
||||||
@@ -25,10 +25,7 @@ void FCogEngineWindow_Notifications::Initialize()
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void FCogEngineWindow_Notifications::RenderHelp()
|
void FCogEngineWindow_Notifications::RenderHelp()
|
||||||
{
|
{
|
||||||
ImGui::Text(
|
ImGui::Text("This window manage the notifications.");
|
||||||
"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. "
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -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.Id = FString::Printf(TEXT("###Notify%d"), NotificationsId);
|
||||||
FNotification& Notification = Notifications.AddDefaulted_GetRef();
|
Notification.Time = FDateTime::Now();
|
||||||
Notification.Frame = GFrameCounter;
|
Notification.Verbosity = InVerbosity;
|
||||||
Notification.Time = FDateTime::Now();
|
Notification.Message = InMessage;
|
||||||
Notification.Verbosity = InVerbosity;
|
|
||||||
Notification.Category = InCategory;
|
NotificationsId++;
|
||||||
Notification.Message = InMessage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
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;
|
if (Config->DisableNotifications)
|
||||||
switch (InNotification.Verbosity)
|
{ return; }
|
||||||
{
|
|
||||||
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->ShowVerbosity)
|
static FName CmdName("Cmd");
|
||||||
{
|
|
||||||
if (InShowAsTableRow)
|
|
||||||
{
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::TextUnformatted(StringCast<ANSICHAR>(ToString(InNotification.Verbosity)).Get());
|
|
||||||
|
|
||||||
if (InShowAsTableRow == false)
|
|
||||||
{
|
|
||||||
ImGui::SameLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InShowAsTableRow)
|
|
||||||
{
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::TextUnformatted(StringCast<ANSICHAR>(*InNotification.Message).Get());
|
if (InCategory == LogCogNotify.GetCategoryName()
|
||||||
|
|| (InCategory == CmdName && Config->NotifyConsoleCommands)
|
||||||
ImGui::PopStyleColor();
|
|| (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);
|
Super::RenderTick(DeltaTime);
|
||||||
|
|
||||||
|
if (Config->DisableNotifications)
|
||||||
|
{ return; }
|
||||||
|
|
||||||
RenderNotifications();
|
RenderNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,13 +87,14 @@ void FCogEngineWindow_Notifications::RenderNotifications()
|
|||||||
| ImGuiWindowFlags_AlwaysAutoResize
|
| ImGuiWindowFlags_AlwaysAutoResize
|
||||||
| ImGuiWindowFlags_NoSavedSettings
|
| ImGuiWindowFlags_NoSavedSettings
|
||||||
| ImGuiWindowFlags_NoFocusOnAppearing
|
| ImGuiWindowFlags_NoFocusOnAppearing
|
||||||
| ImGuiWindowFlags_NoNav
|
| ImGuiWindowFlags_NoNav;
|
||||||
| ImGuiWindowFlags_NoSavedSettings;
|
|
||||||
|
|
||||||
const ImGuiViewport* Viewport = ImGui::GetMainViewport();
|
const ImGuiViewport* Viewport = ImGui::GetMainViewport();
|
||||||
const ImVec2 ViewportPos = Viewport->WorkPos;
|
const ImVec2 ViewportPos = Viewport->WorkPos;
|
||||||
const ImVec2 ViewportSize = Viewport->WorkSize;
|
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 IsRight = static_cast<int32>(Config->Location) & 1;
|
||||||
const bool IsBottom = static_cast<int32>(Config->Location) & 2;
|
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);
|
const ImVec2 WindowPosPivot(IsRight ? 1.0f : 0.0f, IsBottom ? 1.0f : 0.0f);
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, Config->WindowRounding);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, Config->Rounding);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, Config->WindowBorder);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, Config->ShowBorder);
|
||||||
|
|
||||||
|
const FDateTime Now = FDateTime::Now();
|
||||||
|
|
||||||
for (int32 i = Notifications.Num() - 1; i >= 0; i--)
|
for (int32 i = Notifications.Num() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
const FNotification& Notification = Notifications[i];
|
const FNotification& Notification = Notifications[i];
|
||||||
|
|
||||||
const FTimespan Span = FDateTime::Now() - Notification.Time;
|
const FTimespan Span = Now - Notification.Time;
|
||||||
if (Span > FTimespan::FromSeconds(Config->VisibleDuration))
|
if (Span > FTimespan::FromSeconds(Config->Duration + Config->FadeOut))
|
||||||
{
|
{
|
||||||
Notifications.RemoveAt(i);
|
Notifications.RemoveAt(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImU32 TextColor, BackColor, BorderColor;
|
ImVec4 TextColor, BackColor, BorderColor;
|
||||||
switch (Notification.Verbosity)
|
switch (Notification.Verbosity)
|
||||||
{
|
{
|
||||||
case ELogVerbosity::Error:
|
case ELogVerbosity::Error:
|
||||||
{
|
{
|
||||||
TextColor = FCogImguiHelper::ToImColor(Config->TextErrorColor);
|
TextColor = FCogImguiHelper::ToImVec4(Config->TextErrorColor);
|
||||||
BackColor = FCogImguiHelper::ToImColor(Config->BackgroundErrorColor);
|
BackColor = FCogImguiHelper::ToImVec4(Config->BackgroundErrorColor);
|
||||||
BorderColor = FCogImguiHelper::ToImColor(Config->BorderErrorColor);
|
BorderColor = FCogImguiHelper::ToImVec4(Config->BorderErrorColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ELogVerbosity::Warning:
|
case ELogVerbosity::Warning:
|
||||||
{
|
{
|
||||||
TextColor = FCogImguiHelper::ToImColor(Config->TextWarningColor);
|
TextColor = FCogImguiHelper::ToImVec4(Config->TextWarningColor);
|
||||||
BackColor = FCogImguiHelper::ToImColor(Config->BackgroundWarningColor);
|
BackColor = FCogImguiHelper::ToImVec4(Config->BackgroundWarningColor);
|
||||||
BorderColor = FCogImguiHelper::ToImColor(Config->BorderWarningColor);
|
BorderColor = FCogImguiHelper::ToImVec4(Config->BorderWarningColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
TextColor = FCogImguiHelper::ToImColor(Config->TextDefaultColor);
|
TextColor = FCogImguiHelper::ToImVec4(Config->TextDefaultColor);
|
||||||
BackColor = FCogImguiHelper::ToImColor(Config->BackgroundDefaultColor);
|
BackColor = FCogImguiHelper::ToImVec4(Config->BackgroundDefaultColor);
|
||||||
BorderColor = FCogImguiHelper::ToImColor(Config->BorderDefaultColor);
|
BorderColor = FCogImguiHelper::ToImVec4(Config->BorderDefaultColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SetNextWindowPos(WindowPos, ImGuiCond_Always, WindowPosPivot);
|
const float ElapsedTime = Span.GetTotalSeconds();
|
||||||
ImGui::SetNextWindowViewport(Viewport->ID);
|
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_WindowBg, BackColor);
|
||||||
ImGui::PushStyleColor(ImGuiCol_Border, BorderColor);
|
ImGui::PushStyleColor(ImGuiCol_Border, BorderColor);
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, TextColor);
|
ImGui::PushStyleColor(ImGuiCol_Text, TextColor);
|
||||||
|
|
||||||
static char WindowNameBuffer[32];
|
const auto Message = StringCast<ANSICHAR>(*Notification.Message);
|
||||||
ImFormatString(WindowNameBuffer, IM_ARRAYSIZE(WindowNameBuffer), "CogNotification%d", i);
|
const float WrapWidth = Config->TextWrapping * ImGui::GetFontSize();
|
||||||
if (ImGui::Begin(WindowNameBuffer, nullptr, Flags))
|
|
||||||
|
ImGui::SetNextWindowViewport(Viewport->ID);
|
||||||
|
ImGui::SetNextWindowPos(WindowPos, ImGuiCond_Always, WindowPosPivot);
|
||||||
|
if (Config->UseFixedWidth)
|
||||||
{
|
{
|
||||||
ImGui::PushTextWrapPos(Config->TextWrapping * ImGui::GetFontSize());
|
ImGui::SetNextWindowSizeConstraints(ImVec2(WrapWidth, 0) + WindowPadding * 2, ImVec2(WrapWidth, Config->MaxHeight * ImGui::GetFontSize()) + WindowPadding * 2);
|
||||||
ImGui::TextUnformatted(StringCast<ANSICHAR>(*Notification.Message).Get());
|
}
|
||||||
|
|
||||||
|
if (ImGui::Begin(StringCast<ANSICHAR>(*Notification.Id).Get(), nullptr, Flags))
|
||||||
|
{
|
||||||
|
ImGui::PushTextWrapPos(WrapWidth);
|
||||||
|
ImGui::TextUnformatted(Message.Get());
|
||||||
ImGui::PopTextWrapPos();
|
ImGui::PopTextWrapPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopStyleColor(3);
|
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();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,195 +196,115 @@ void FCogEngineWindow_Notifications::RenderContent()
|
|||||||
{
|
{
|
||||||
Super::RenderContent();
|
Super::RenderContent();
|
||||||
|
|
||||||
if (ImGui::BeginMenuBar())
|
if (ImGui::Button("Clear Notifications", ImVec2(-1, 0)))
|
||||||
{
|
{
|
||||||
if (ImGui::BeginMenu("Options"))
|
Notifications.Empty();
|
||||||
{
|
}
|
||||||
ImGui::Checkbox("Auto Scroll", &Config->AutoScroll);
|
|
||||||
ImGui::Checkbox("Show Verbosity", &Config->ShowVerbosity);
|
FCogWindowWidgets::ThinSeparatorText("Notification Test");
|
||||||
ImGui::Checkbox("Show As Table", &Config->ShowAsTable);
|
|
||||||
ImGui::Checkbox("Window Border", &Config->WindowBorder);
|
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();
|
FCogImguiHelper::ColorEdit4("##BorderDef", Config->BorderDefaultColor, ColorEditFlags);
|
||||||
FCogWindowWidgets::ComboboxEnum("Notification Location", Config->Location);
|
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();
|
FCogImguiHelper::ColorEdit4("##TextDef", Config->TextDefaultColor, ColorEditFlags);
|
||||||
ImGui::SliderFloat("Visible Duration", &Config->VisibleDuration, 1, 10, "%0.1f");
|
ImGui::SameLine();
|
||||||
|
ImGui::SetItemTooltip("Text Default");
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
FCogImguiHelper::ColorEdit4("##TextWarn", Config->TextWarningColor, ColorEditFlags);
|
||||||
ImGui::SliderFloat("Fade Duration", &Config->FadeDuration, 0, 3, "%0.1f");
|
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::Separator();
|
||||||
ImGui::DragInt("Text Wrapping", &Config->TextWrapping, 1, 0, INT_MAX);
|
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
|
||||||
ImGui::DragInt("Padding", &Config->Padding, 1, 0, INT_MAX);
|
|
||||||
|
|
||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
if (ImGui::Button("Reset Settings", ImVec2(-1, 0)))
|
||||||
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::BeginTable("LogTable", ColumnCount, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ScrollX | ImGuiTableFlags_NoHostExtendX))
|
ResetConfig();
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,6 +330,6 @@ void FCogNotificationOutputDevice::Serialize(const TCHAR* Message, const ELogVer
|
|||||||
{
|
{
|
||||||
if (Notifications != nullptr)
|
if (Notifications != nullptr)
|
||||||
{
|
{
|
||||||
Notifications->AddLog(Message, Verbosity, Category);
|
Notifications->OnLogReceived(Message, Verbosity, Category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,21 +42,19 @@ public:
|
|||||||
|
|
||||||
virtual void Initialize() override;
|
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 Clear();
|
||||||
|
void AddNotification(const TCHAR* InMessage, ELogVerbosity::Type InVerbosity);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
struct FNotification
|
struct FNotification
|
||||||
{
|
{
|
||||||
int32 LineStart = 0;
|
FString Id;
|
||||||
int32 LineEnd = 0;
|
|
||||||
uint64 Frame = 0;
|
|
||||||
FDateTime Time;
|
FDateTime Time;
|
||||||
ELogVerbosity::Type Verbosity;
|
ELogVerbosity::Type Verbosity;
|
||||||
FName Category;
|
FString Message;
|
||||||
FString Message;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void RenderHelp() override;
|
virtual void RenderHelp() override;
|
||||||
@@ -67,16 +65,17 @@ protected:
|
|||||||
|
|
||||||
virtual void RenderNotifications();
|
virtual void RenderNotifications();
|
||||||
|
|
||||||
virtual void DrawRow(const FNotification& InNotification, bool InShowAsTableRow) const;
|
virtual void RenderSettings();
|
||||||
|
|
||||||
ImGuiTextFilter Filter;
|
ImGuiTextFilter Filter;
|
||||||
|
|
||||||
FCogNotificationOutputDevice OutputDevice;
|
FCogNotificationOutputDevice OutputDevice;
|
||||||
|
|
||||||
TArray<FNotification> Notifications;
|
TArray<FNotification> Notifications;
|
||||||
|
|
||||||
|
static int32 NotificationsId;
|
||||||
|
|
||||||
TWeakObjectPtr<UCogEngineConfig_Notifications> Config;
|
TWeakObjectPtr<UCogEngineConfig_Notifications> Config;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -86,19 +85,19 @@ class UCogEngineConfig_Notifications : public UCogCommonConfig
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool DisableNotifications = false;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
bool AutoScroll = true;
|
bool NotifyAllWarnings = false;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
bool ShowVerbosity = false;
|
bool NotifyAllErrors = false;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
int32 VerbosityFilter = ELogVerbosity::VeryVerbose;
|
bool NotifyConsoleCommands = true;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
|
||||||
bool ShowAsTable = false;
|
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
FColor BackgroundDefaultColor = FColor::White;
|
FColor BackgroundDefaultColor = FColor::White;
|
||||||
|
|
||||||
@@ -133,42 +132,48 @@ public:
|
|||||||
int Padding = 10;
|
int Padding = 10;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
int32 TextWrapping = 30;
|
bool UseFixedWidth = true;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
int32 WindowRounding = 6;
|
int32 MaxHeight = 10;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
int32 TextWrapping = 20;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
bool WindowBorder = false;
|
int32 Rounding = 6;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
float VisibleDuration = 3.0f;
|
bool ShowBorder = true;
|
||||||
|
|
||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
float FadeDuration = 0.5f;
|
float Duration = 5.0f;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
float FadeOut = 0.5f;
|
||||||
|
|
||||||
virtual void Reset() override
|
virtual void Reset() override
|
||||||
{
|
{
|
||||||
Super::Reset();
|
Super::Reset();
|
||||||
|
|
||||||
AutoScroll = true;
|
TextDefaultColor = FColor(200, 200, 200, 255);
|
||||||
ShowVerbosity = false;
|
TextWarningColor = FColor(255, 200, 0, 255);
|
||||||
VerbosityFilter = ELogVerbosity::VeryVerbose;
|
TextErrorColor = FColor(240, 77, 77, 255);
|
||||||
ShowAsTable = false;
|
BackgroundDefaultColor = FColor( 15, 15, 15, 150);
|
||||||
TextDefaultColor = FColor(200, 200, 200, 255);
|
BackgroundWarningColor = FColor( 23, 9, 0, 150);
|
||||||
TextWarningColor = FColor(255, 200, 0, 255);
|
BackgroundErrorColor = FColor( 21, 0, 0, 150);
|
||||||
TextErrorColor = FColor(255, 0, 0, 255);
|
BorderDefaultColor = FColor(200, 200, 200, 100);
|
||||||
BackgroundDefaultColor = FColor(0, 0, 0, 170);
|
BorderWarningColor = FColor(255, 200, 0, 100);
|
||||||
BackgroundWarningColor = FColor(50, 20, 0, 170);
|
BorderErrorColor = FColor(240, 77, 77, 100);
|
||||||
BackgroundErrorColor = FColor(50, 0, 0, 170);
|
|
||||||
BorderDefaultColor = FColor(200, 200, 200, 100);
|
|
||||||
BorderWarningColor = FColor(255, 200, 0, 100);
|
|
||||||
BorderErrorColor = FColor(255, 0, 0, 100);
|
|
||||||
|
|
||||||
Location = ECogEngineNotificationLocation::BottomRight;
|
Location = ECogEngineNotificationLocation::BottomRight;
|
||||||
Padding = 10;
|
Padding = 10;
|
||||||
TextWrapping = 40;
|
UseFixedWidth = true;
|
||||||
WindowRounding = 6;
|
TextWrapping = 20;
|
||||||
WindowBorder = true;
|
MaxHeight = 10;
|
||||||
|
Rounding = 6;
|
||||||
|
ShowBorder = true;
|
||||||
|
Duration = 5.0f;
|
||||||
|
FadeOut = 0.5f;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "CogWindow_Settings.h"
|
#include "CogWindow_Settings.h"
|
||||||
|
|
||||||
|
#include "CogCommon.h"
|
||||||
#include "CogImguiHelper.h"
|
#include "CogImguiHelper.h"
|
||||||
#include "CogImguiInputHelper.h"
|
#include "CogImguiInputHelper.h"
|
||||||
#include "CogWindowManager.h"
|
#include "CogWindowManager.h"
|
||||||
@@ -285,6 +286,7 @@ void FCogWindow_Settings::SetDPIScale(float Value) const
|
|||||||
{
|
{
|
||||||
Config->DPIScale = Value;
|
Config->DPIScale = Value;
|
||||||
GetOwner()->GetContext().SetDPIScale(Config->DPIScale);
|
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_NetImgui>("Engine.Net ImGui");
|
||||||
|
|
||||||
CogWindowManager.AddWindow<FCogEngineWindow_OutputLog>("Engine.Output Log");
|
|
||||||
|
|
||||||
CogWindowManager.AddWindow<FCogEngineWindow_Notifications>("Engine.Notifications");
|
CogWindowManager.AddWindow<FCogEngineWindow_Notifications>("Engine.Notifications");
|
||||||
|
|
||||||
|
CogWindowManager.AddWindow<FCogEngineWindow_OutputLog>("Engine.Output Log");
|
||||||
|
|
||||||
CogWindowManager.AddWindow<FCogEngineWindow_Plots>("Engine.Plots");
|
CogWindowManager.AddWindow<FCogEngineWindow_Plots>("Engine.Plots");
|
||||||
|
|
||||||
FCogEngineWindow_Selection* SelectionWindow = CogWindowManager.AddWindow<FCogEngineWindow_Selection>("Engine.Selection");
|
FCogEngineWindow_Selection* SelectionWindow = CogWindowManager.AddWindow<FCogEngineWindow_Selection>("Engine.Selection");
|
||||||
|
|||||||
Reference in New Issue
Block a user