Files
UnrealEngineUWP/Engine/Source/Developer/LogVisualizer/Private/LogVisualizerSettings.cpp
Marc Audy 4c41590c3d Copying //UE4/Dev-Framework to Dev-Main (//UE4/Dev-Main) @ 2879625
#lockdown Nick.Penwarden

==========================
MAJOR FEATURES + CHANGES
==========================
Change 2821607 on 2016/01/08 by Mieszko.Zielinski

	Added a way to limit amount of information logged by vlog by discarding logs from classes from outside of class whitelist #UE4

	This feature was followed by refactoring of functions taking FVisualLogEntry pointers to use references instead.

	#rb Lukasz.Furman

Change 2828384 on 2016/01/14 by Mieszko.Zielinski

	Back out of visual log refactor done as part of CL#2821607 #UE4

Change 2869215 on 2016/02/16 by Marc.Audy

	Store a WorldSettings pointer on ULevel instead of requiring it be index 0 in the Actors array. However, we will still generally attempt to keep it at index 0 for consistency with previous behavior
	#rb Bruce.Nesbit
	#jira UE-26417

Change 2869404 on 2016/02/16 by Ori.Cohen

	Improve UI for default collision. It now uses a single drop down and sets the appropriate flags under the hood.

	#rb Lina.Halper

Change 2870062 on 2016/02/17 by Jurre.deBaare

	Name parameter driven by bone controller
	#JIRA UE-25997
	#rb Thomas.Sarkanen

Change 2870280 on 2016/02/17 by Mieszko.Zielinski

	Vis log category handling fixes #UE4

	Also, a minor cleanup

	#rb Lukasz.Furman

Change 2871729 on 2016/02/18 by James.Golding

	UE-26663 Fix 'LOD For Collision' display name
	#rb thomas.sarkanen

Change 2871730 on 2016/02/18 by James.Golding

	UE-26580 Make ECollisionEnabled a BlueprintType
	UE-25373 Add a MakeHitResult node
	#rb thomas.sarkanen

Change 2871732 on 2016/02/18 by James.Golding

	UE-24397 Add 'test' option to async query API, and use it in places that made sense. Also removed deprecated (4.8) functions from API.
	#rb ori.cohen

Change 2872022 on 2016/02/18 by Lukasz.Furman

	gameplay debugger refactor
	#ue4

Change 2872082 on 2016/02/18 by Lukasz.Furman

	enabled old gameplay debugger as default one for now
	it will be deprecated with next version after testing in game projects
	#ue4

Change 2872390 on 2016/02/18 by Aaron.McLeran

	OR-15041 (CPU) Hitches due to audio decompression on Windows

	1) Moving ogg-vorbis file info parsing into a worker thread
	 - stat dumphitches now shows the vorbis stuff totally gone

	2) Moving async decoding tasks to be retrieved and started from OnBufferEnd callback

	#rb marc.audy

Change 2872418 on 2016/02/18 by Mieszko.Zielinski

	Fixed EQS debugger not storing data properly when subsequent Option is the one that produces result #UE4

	#rb Lukasz.Furman

Change 2872446 on 2016/02/18 by Aaron.McLeran

	Using cached value of ActualVolume in GetVolumeWeightedPriority

Change 2872770 on 2016/02/18 by Aaron.McLeran

	QAGame testing content for audio testing.

	Going to create a folder with specific sub-system testing maps for audio

Change 2873733 on 2016/02/19 by Jurre.deBaare

	- HLOD generated assets are now saved into a separate package instead of inside of the level asset
	#rb Ori.Cohen

Change 2873828 on 2016/02/19 by Ori.Cohen

	Distributions that bake out no longer load in cooked build.

	#JIRA UE-27126
	#rb Olaf.Piesche, Nick.Penwarden

Change 2874623 on 2016/02/19 by Aaron.McLeran

	UE-27131 Support for changing sound class volumes dynamically

	- new BP function to override a sound mix sound class adjuster
	- cleanup of AudioDevice.h and AudioDevice.cpp
	   - removing unnecessarily forward declares on various types
	   - removing unnecessary spaces and (void) params, etc

Change 2874922 on 2016/02/20 by Mieszko.Zielinski

	Fixed EQS tests being compiled out from Shipping and Test with WITH_DEV_AUTOMATION_TESTS macro #UE4

	#jira OR-15292
	#rb none

Change 2875838 on 2016/02/22 by Benn.Gallagher

[CL 2880055 by Marc Audy in Main branch]
2016-02-24 14:23:53 -05:00

328 lines
8.6 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "LogVisualizer.h"
#include "Misc/CoreMisc.h"
#include "LogVisualizerSettings.h"
#if WITH_EDITOR
#include "Editor/EditorEngine.h"
#include "ISettingsModule.h"
#include "UnrealEdMisc.h"
#endif // WITH_EDITOR
ULogVisualizerSettings::ULogVisualizerSettings(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, DebugMeshMaterialFakeLightName(TEXT("/Engine/EngineDebugMaterials/DebugMeshMaterialFakeLight.DebugMeshMaterialFakeLight"))
{
TrivialLogsThreshold = 1;
DefaultCameraDistance = 150;
bSearchInsideLogs = true;
GraphsBackgroundColor = FColor(0, 0, 0, 70);
bResetDataWithNewSession = false;
bDrawExtremesOnGraphs = false;
bUsePlayersOnlyForPause = true;
}
class UMaterial* ULogVisualizerSettings::GetDebugMeshMaterial()
{
if (DebugMeshMaterialFakeLight == nullptr)
{
DebugMeshMaterialFakeLight = LoadObject<UMaterial>(NULL, *DebugMeshMaterialFakeLightName, NULL, LOAD_None, NULL);
}
return DebugMeshMaterialFakeLight;
}
void ULogVisualizerSettings::SavePresistentData()
{
if (bPresistentFilters)
{
PresistentFilters = FVisualLoggerFilters::Get();
for (int32 Index = PresistentFilters.Categories.Num() - 1; Index >= 0; --Index)
{
FCategoryFilter& Category = PresistentFilters.Categories[Index];
if (Category.bIsInUse == false)
{
PresistentFilters.Categories.RemoveAt(Index);
}
}
}
else
{
PresistentFilters = FVisualLoggerFilters();
}
SaveConfig();
}
void ULogVisualizerSettings::ClearPresistentData()
{
if (bPresistentFilters)
{
PresistentFilters = FVisualLoggerFilters();
}
}
void ULogVisualizerSettings::LoadPresistentData()
{
if (bPresistentFilters)
{
for (int32 Index = PresistentFilters.Categories.Num() - 1; Index >= 0; --Index)
{
FCategoryFilter& Category = PresistentFilters.Categories[Index];
Category.bIsInUse = false;
}
FVisualLoggerFilters::Get().InitWith(PresistentFilters);
}
else
{
FVisualLoggerFilters::Get().Reset();
}
}
#if WITH_EDITOR
void ULogVisualizerSettings::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
const FName Name = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
if (!FUnrealEdMisc::Get().IsDeletePreferences())
{
SaveConfig();
}
SettingChangedEvent.Broadcast(Name);
}
#endif
//////////////////////////////////////////////////////////////////////////
// FVisualLoggerFilters
//////////////////////////////////////////////////////////////////////////
TSharedPtr< struct FVisualLoggerFilters > FVisualLoggerFilters::StaticInstance;
FVisualLoggerFilters& FVisualLoggerFilters::Get()
{
return *StaticInstance;
}
void FVisualLoggerFilters::Initialize()
{
StaticInstance = MakeShareable(new FVisualLoggerFilters);
FVisualLoggerDatabase::Get().GetEvents().OnNewItem.AddRaw(StaticInstance.Get(), &FVisualLoggerFilters::OnNewItemHandler);
}
void FVisualLoggerFilters::Shutdown()
{
FVisualLoggerDatabase::Get().GetEvents().OnNewItem.RemoveAll(StaticInstance.Get());
StaticInstance.Reset();
}
void FVisualLoggerFilters::OnNewItemHandler(const FVisualLoggerDBRow& DBRow, int32 ItemIndex)
{
const FVisualLogDevice::FVisualLogEntryItem& Item = DBRow.GetItems()[ItemIndex];
TArray<FVisualLoggerCategoryVerbosityPair> Categories;
FVisualLoggerHelpers::GetCategories(Item.Entry, Categories);
for (auto& CategoryAndVerbosity : Categories)
{
AddCategory(CategoryAndVerbosity.CategoryName.ToString(), ELogVerbosity::All);
}
TMap<FString, TArray<FString> > OutCategories;
FVisualLoggerHelpers::GetHistogramCategories(Item.Entry, OutCategories);
for (const auto& CurrentCategory : OutCategories)
{
for (const auto& CurrentDataName : CurrentCategory.Value)
{
const FString GraphFilterName = CurrentCategory.Key + TEXT("$") + CurrentDataName;
AddCategory(GraphFilterName, ELogVerbosity::All);
}
}
}
void FVisualLoggerFilters::AddCategory(FString InName, ELogVerbosity::Type InVerbosity)
{
const int32 Num = Categories.Num();
for (int32 Index = 0; Index < Num; ++Index)
{
FCategoryFilter& Filter = Categories[Index];
if (Filter.CategoryName == InName)
{
Filter.bIsInUse = true;
return;
}
}
FCategoryFilter Filter;
Filter.CategoryName = InName;
Filter.LogVerbosity = InVerbosity;
Filter.Enabled = true;
Filter.bIsInUse = true;
Categories.Add(Filter);
FastCategoryFilterMap.Reset(); // we need to recreate cache - pointers can be broken
FastCategoryFilterMap.Reserve(Categories.Num());
for (int32 Index = 0; Index < Categories.Num(); Index++)
{
FastCategoryFilterMap.Add(*Categories[Index].CategoryName, &Categories[Index]);
}
OnFilterCategoryAdded.Broadcast(InName, InVerbosity);
}
void FVisualLoggerFilters::RemoveCategory(FString InName)
{
for (int32 Index = 0; Index < Categories.Num(); ++Index)
{
const FCategoryFilter& Filter = Categories[Index];
if (Filter.CategoryName == InName)
{
Categories.RemoveAt(Index);
FastCategoryFilterMap.Remove(*InName);
break;
}
}
OnFilterCategoryRemoved.Broadcast(InName);
}
FCategoryFilter& FVisualLoggerFilters::GetCategoryByName(const FName& InName)
{
FCategoryFilter* FilterPtr = FastCategoryFilterMap.Contains(InName) ? FastCategoryFilterMap[InName] : nullptr;
if (FilterPtr)
{
return *FilterPtr;
}
static FCategoryFilter NoCategory;
return NoCategory;
}
FCategoryFilter& FVisualLoggerFilters::GetCategoryByName(const FString& InName)
{
const FName NameAsName = *InName;
FCategoryFilter* FilterPtr = FastCategoryFilterMap.Contains(NameAsName) ? FastCategoryFilterMap[NameAsName] : nullptr;
if (FilterPtr)
{
return *FilterPtr;
}
static FCategoryFilter NoCategory;
return NoCategory;
}
bool FVisualLoggerFilters::MatchObjectName(FString String)
{
return SelectedClasses.Num() == 0 || SelectedClasses.Find(String) != INDEX_NONE;
}
void FVisualLoggerFilters::SelectObject(FString ObjectName)
{
SelectedClasses.AddUnique(ObjectName);
}
void FVisualLoggerFilters::RemoveObjectFromSelection(FString ObjectName)
{
SelectedClasses.Remove(ObjectName);
}
const TArray<FString>& FVisualLoggerFilters::GetSelectedObjects() const
{
return SelectedClasses;
}
bool FVisualLoggerFilters::MatchCategoryFilters(FString String, ELogVerbosity::Type Verbosity)
{
ULogVisualizerSettings* Settings = ULogVisualizerSettings::StaticClass()->GetDefaultObject<ULogVisualizerSettings>();
bool bFoundFilter = false;
for (const FCategoryFilter& Filter : Categories)
{
bFoundFilter = Filter.CategoryName == String;
if (bFoundFilter)
{
if (Filter.Enabled)
{
const bool bFineWithSearchString = Settings->bSearchInsideLogs == true || (SearchBoxFilter.Len() == 0 || Filter.CategoryName.Find(SearchBoxFilter) != INDEX_NONE);
return bFineWithSearchString && Verbosity <= Filter.LogVerbosity;
}
else
{
return false;
}
}
}
return bFoundFilter;
}
void FVisualLoggerFilters::DeactivateAllButThis(const FString& InName)
{
for (FCategoryFilter& Filter : Categories)
{
Filter.Enabled = Filter.CategoryName != InName ? false : true;
}
}
void FVisualLoggerFilters::EnableAllCategories()
{
for (FCategoryFilter& Filter : Categories)
{
Filter.Enabled = true;
}
}
void FVisualLoggerFilters::Reset()
{
if (ULogVisualizerSettings::StaticClass()->GetDefaultObject<ULogVisualizerSettings>()->bResetDataWithNewSession == false)
{
for (int32 Index = Categories.Num() - 1; Index >= 0; --Index)
{
Categories[Index].bIsInUse = false;
}
}
else
{
FastCategoryFilterMap.Reset();
Categories.Reset();
}
SearchBoxFilter = FString();
ObjectNameFilter = FString();
SelectedClasses.Reset();
}
void FVisualLoggerFilters::InitWith(const FVisualLoggerFiltersData& NewFiltersData)
{
SearchBoxFilter = NewFiltersData.SearchBoxFilter;
ObjectNameFilter = NewFiltersData.ObjectNameFilter;
Categories = NewFiltersData.Categories;
SelectedClasses = NewFiltersData.SelectedClasses;
FastCategoryFilterMap.Reset(); // we need to recreate cache - pointers can be broken
FastCategoryFilterMap.Reserve(Categories.Num());
for (int32 Index = 0; Index < Categories.Num(); Index++)
{
FastCategoryFilterMap.Add(*Categories[Index].CategoryName, &Categories[Index]);
}
}
void FVisualLoggerFilters::DisableGraphData(FName GraphName, FName DataName, bool SetAsDisabled)
{
const FName FullName = *(GraphName.ToString() + TEXT("$") + DataName.ToString());
if (SetAsDisabled)
{
DisabledGraphDatas.AddUnique(FullName);
}
else
{
DisabledGraphDatas.RemoveSwap(FullName);
}
}
bool FVisualLoggerFilters::IsGraphDataDisabled(FName GraphName, FName DataName)
{
const FName FullName = *(GraphName.ToString() + TEXT("$") + DataName.ToString());
return DisabledGraphDatas.Find(FullName) != INDEX_NONE;
}