mirror of
https://github.com/Ed94/Cog.git
synced 2026-07-15 05:51:29 -07:00
First Submit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class CogDebugEditor : ModuleRules
|
||||
{
|
||||
public CogDebugEditor(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.Add(ModuleDirectory + "/Public");
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"AssetTools",
|
||||
"CogDebug",
|
||||
"EditorStyle",
|
||||
"EditorWidgets",
|
||||
"InputCore",
|
||||
"PropertyEditor",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
"SubobjectEditor",
|
||||
"ToolMenus",
|
||||
"UnrealEd",
|
||||
"BlueprintGraph",
|
||||
"GraphEditor",
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "CogDebugEditorModule.h"
|
||||
|
||||
#include "CogDebugGraphPanelPinFactory.h"
|
||||
#include "CogDebugLogCategoryDetails.h"
|
||||
#include "IAssetTools.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "GameplayCoreEditorModule"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
class FCogDebugEditorModule : public ICogDebugEditorModule
|
||||
{
|
||||
public:
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
private:
|
||||
/** Pin factory for abilities graph; Cached so it can be unregistered */
|
||||
TSharedPtr<FCogGraphPanelPinFactory> GraphPanelPinFactory;
|
||||
|
||||
EAssetTypeCategories::Type AssetCategory;
|
||||
};
|
||||
|
||||
IMPLEMENT_MODULE(FCogDebugEditorModule, CogEditor);
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugEditorModule::StartupModule()
|
||||
{
|
||||
FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
|
||||
PropertyModule.RegisterCustomPropertyTypeLayout("CogLogCategory", FOnGetPropertyTypeCustomizationInstance::CreateStatic(&FCogLogCategoryDetails::MakeInstance));
|
||||
|
||||
// Register factories for pins and nodes
|
||||
GraphPanelPinFactory = MakeShareable(new FCogGraphPanelPinFactory());
|
||||
FEdGraphUtilities::RegisterVisualPinFactory(GraphPanelPinFactory);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void FCogDebugEditorModule::ShutdownModule()
|
||||
{
|
||||
if (FModuleManager::Get().IsModuleLoaded("PropertyEditor"))
|
||||
{
|
||||
FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
|
||||
PropertyModule.UnregisterCustomPropertyTypeLayout("CogLogCategory");
|
||||
}
|
||||
|
||||
// Unregister graph factories
|
||||
if (GraphPanelPinFactory.IsValid())
|
||||
{
|
||||
FEdGraphUtilities::UnregisterVisualPinFactory(GraphPanelPinFactory);
|
||||
GraphPanelPinFactory.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -0,0 +1,81 @@
|
||||
#include "CogDebugLogCategoryDetails.h"
|
||||
|
||||
#include "CogDebugLogCategory.h"
|
||||
#include "CogDebugLogCategoryManager.h"
|
||||
#include "DetailWidgetRow.h"
|
||||
#include "Editor.h"
|
||||
#include "IPropertyUtilities.h"
|
||||
#include "Misc/TextFilter.h"
|
||||
#include "PropertyHandle.h"
|
||||
#include "SCogDebugLogCategoryWidget.h"
|
||||
#include "SlateOptMacros.h"
|
||||
#include "Widgets/Input/SSearchBox.h"
|
||||
#include "Widgets/Layout/SSeparator.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "AttributeDetailsCustomization"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TSharedRef<IPropertyTypeCustomization> FCogLogCategoryDetails::MakeInstance()
|
||||
{
|
||||
return MakeShareable(new FCogLogCategoryDetails());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogLogCategoryDetails::CustomizeHeader(TSharedRef<IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
|
||||
{
|
||||
NameProperty = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FCogLogCategory, Name));
|
||||
|
||||
PropertyOptions.Empty();
|
||||
PropertyOptions.Add(MakeShareable(new FString("None")));
|
||||
for (auto& Entry : FCogDebugLogCategoryManager::GetLogCategories())
|
||||
{
|
||||
PropertyOptions.Add(MakeShareable(new FString(Entry.Value.LogCategory->GetCategoryName().ToString())));
|
||||
}
|
||||
|
||||
const FString& FilterMetaStr = StructPropertyHandle->GetProperty()->GetMetaData(TEXT("FilterMetaTag"));
|
||||
|
||||
FName Value;
|
||||
if (NameProperty.IsValid())
|
||||
{
|
||||
NameProperty->GetValue(Value);
|
||||
}
|
||||
|
||||
HeaderRow.
|
||||
NameContent()
|
||||
[
|
||||
StructPropertyHandle->CreatePropertyNameWidget()
|
||||
]
|
||||
.ValueContent()
|
||||
.MinDesiredWidth(500)
|
||||
.MaxDesiredWidth(4096)
|
||||
[
|
||||
SNew(SHorizontalBox)
|
||||
+ SHorizontalBox::Slot()
|
||||
//.FillWidth(1.0f)
|
||||
.HAlign(HAlign_Fill)
|
||||
.Padding(0.f, 0.f, 2.f, 0.f)
|
||||
[
|
||||
SNew(SCogLogCategoryWidget)
|
||||
.OnLogCategoryChanged(this, &FCogLogCategoryDetails::OnLogCategoryChanged)
|
||||
.DefaultName(Value)
|
||||
.FilterMetaData(FilterMetaStr)
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogLogCategoryDetails::CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogLogCategoryDetails::OnLogCategoryChanged(FName SelectedName)
|
||||
{
|
||||
if (NameProperty.IsValid())
|
||||
{
|
||||
NameProperty->SetValue(SelectedName);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -0,0 +1,63 @@
|
||||
#include "SCogDebugLogCategoryGraphPin.h"
|
||||
|
||||
#include "ScopedTransaction.h"
|
||||
#include "SCogDebugLogCategoryWidget.h"
|
||||
#include "UObject/CoreRedirects.h"
|
||||
#include "UObject/UObjectIterator.h"
|
||||
#include "Widgets/SBoxPanel.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "K2Node"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void SCogLogCategoryGraphPin::Construct(const FArguments& InArgs, UEdGraphPin* InGraphPinObj)
|
||||
{
|
||||
SGraphPin::Construct( SGraphPin::FArguments(), InGraphPinObj );
|
||||
LastSelectedName = FName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TSharedRef<SWidget> SCogLogCategoryGraphPin::GetDefaultValueWidget()
|
||||
{
|
||||
// Parse out current default value
|
||||
FString DefaultString = GraphPinObj->GetDefaultAsString();
|
||||
FCogLogCategory DefaultLogCategory;
|
||||
|
||||
UScriptStruct* PinLiteralStructType = FCogLogCategory::StaticStruct();
|
||||
if (!DefaultString.IsEmpty())
|
||||
{
|
||||
PinLiteralStructType->ImportText(*DefaultString, &DefaultLogCategory, nullptr, EPropertyPortFlags::PPF_SerializedAsImportText, GError, PinLiteralStructType->GetName(), true);
|
||||
}
|
||||
|
||||
//Create widget
|
||||
return SNew(SVerticalBox)
|
||||
+SVerticalBox::Slot()
|
||||
.AutoHeight()
|
||||
[
|
||||
SNew(SCogLogCategoryWidget)
|
||||
.OnLogCategoryChanged(this, &SCogLogCategoryGraphPin::OnLogCategoryChanged)
|
||||
.DefaultName(DefaultLogCategory.Name)
|
||||
.Visibility(this, &SGraphPin::GetDefaultValueVisibility)
|
||||
.IsEnabled(this, &SCogLogCategoryGraphPin::GetDefaultValueIsEnabled)
|
||||
];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void SCogLogCategoryGraphPin::OnLogCategoryChanged(FName SelectedName)
|
||||
{
|
||||
FString FinalValue;
|
||||
FCogLogCategory NewLogCategoryStruct;
|
||||
NewLogCategoryStruct.Name = SelectedName;
|
||||
|
||||
FCogLogCategory::StaticStruct()->ExportText(FinalValue, &NewLogCategoryStruct, &NewLogCategoryStruct, nullptr, EPropertyPortFlags::PPF_SerializedAsImportText, nullptr);
|
||||
|
||||
if (FinalValue != GraphPinObj->GetDefaultAsString())
|
||||
{
|
||||
const FScopedTransaction Transaction(NSLOCTEXT("GraphEditor", "ChangePinValue", "Change Pin Value"));
|
||||
GraphPinObj->Modify();
|
||||
GraphPinObj->GetSchema()->TrySetDefaultValue(*GraphPinObj, FinalValue);
|
||||
}
|
||||
|
||||
LastSelectedName = SelectedName;
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -0,0 +1,348 @@
|
||||
#include "SCogDebugLogCategoryWidget.h"
|
||||
|
||||
#include "Misc/TextFilter.h"
|
||||
#include "SlateOptMacros.h"
|
||||
#include "UObject/UnrealType.h"
|
||||
#include "UObject/UObjectHash.h"
|
||||
#include "UObject/UObjectIterator.h"
|
||||
#include "Widgets/Input/SComboBox.h"
|
||||
#include "Widgets/Input/SSearchBox.h"
|
||||
#include "Widgets/Layout/SBox.h"
|
||||
#include "Widgets/Layout/SSeparator.h"
|
||||
#include "Widgets/Views/SListView.h"
|
||||
#include "Widgets/Views/STableRow.h"
|
||||
#include "Widgets/Views/STableViewBase.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "K2Node"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
DECLARE_DELEGATE_OneParam(FOnLogCategoryPicked, FName);
|
||||
|
||||
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
struct FLogCategoryViewerNode
|
||||
{
|
||||
public:
|
||||
FLogCategoryViewerNode(FName InName)
|
||||
{
|
||||
Name = InName;
|
||||
}
|
||||
|
||||
FName Name;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class SLogCategoryItem : public SComboRow<TSharedPtr<FLogCategoryViewerNode>>
|
||||
{
|
||||
public:
|
||||
|
||||
SLATE_BEGIN_ARGS(SLogCategoryItem)
|
||||
: _HighlightText()
|
||||
, _TextColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.0f))
|
||||
{}
|
||||
|
||||
SLATE_ARGUMENT(FText, HighlightText)
|
||||
SLATE_ARGUMENT(FSlateColor, TextColor)
|
||||
SLATE_ARGUMENT(TSharedPtr<FLogCategoryViewerNode>, AssociatedNode)
|
||||
|
||||
SLATE_END_ARGS()
|
||||
|
||||
void Construct(const FArguments& InArgs, const TSharedRef<STableViewBase>& InOwnerTableView)
|
||||
{
|
||||
AssociatedNode = InArgs._AssociatedNode;
|
||||
|
||||
this->ChildSlot
|
||||
[
|
||||
SNew(SHorizontalBox)
|
||||
|
||||
+ SHorizontalBox::Slot()
|
||||
.FillWidth(1.0f)
|
||||
.Padding(0.0f, 3.0f, 6.0f, 3.0f)
|
||||
.VAlign(VAlign_Center)
|
||||
[
|
||||
SNew(STextBlock)
|
||||
.Text(FText::FromString(*AssociatedNode->Name.ToString()))
|
||||
.HighlightText(InArgs._HighlightText)
|
||||
.ColorAndOpacity(this, &SLogCategoryItem::GetTextColor)
|
||||
.IsEnabled(true)
|
||||
]
|
||||
];
|
||||
|
||||
TextColor = InArgs._TextColor;
|
||||
|
||||
STableRow< TSharedPtr<FLogCategoryViewerNode> >::ConstructInternal(
|
||||
STableRow::FArguments()
|
||||
.ShowSelection(true),
|
||||
InOwnerTableView
|
||||
);
|
||||
}
|
||||
|
||||
/** Returns the text color for the item based on if it is selected or not. */
|
||||
FSlateColor GetTextColor() const
|
||||
{
|
||||
const TSharedPtr<ITypedTableView<TSharedPtr<FLogCategoryViewerNode>>> OwnerWidget = OwnerTablePtr.Pin();
|
||||
const TSharedPtr<FLogCategoryViewerNode>* MyItem = OwnerWidget->Private_ItemFromWidget(this);
|
||||
const bool bIsSelected = OwnerWidget->Private_IsItemSelected(*MyItem);
|
||||
|
||||
if (bIsSelected)
|
||||
{
|
||||
return FSlateColor::UseForeground();
|
||||
}
|
||||
|
||||
return TextColor;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** The text color for this item. */
|
||||
FSlateColor TextColor;
|
||||
|
||||
/** The LogCategory Viewer Node this item is associated with. */
|
||||
TSharedPtr<FLogCategoryViewerNode> AssociatedNode;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
class SLogCategoryListWidget : public SCompoundWidget
|
||||
{
|
||||
public:
|
||||
SLATE_BEGIN_ARGS(SLogCategoryListWidget)
|
||||
{
|
||||
}
|
||||
|
||||
SLATE_ARGUMENT(FString, FilterMetaData)
|
||||
SLATE_ARGUMENT(FOnLogCategoryPicked, OnLogCategoryPickedDelegate)
|
||||
|
||||
SLATE_END_ARGS()
|
||||
|
||||
/**
|
||||
* Construct the widget
|
||||
*
|
||||
* @param InArgs A declaration from which to construct the widget
|
||||
*/
|
||||
void Construct(const FArguments& InArgs);
|
||||
|
||||
virtual ~SLogCategoryListWidget();
|
||||
|
||||
private:
|
||||
typedef TTextFilter<const FName&> FLogCategoryTextFilter;
|
||||
|
||||
/** Called by Slate when the filter box changes text. */
|
||||
void OnFilterTextChanged(const FText& InFilterText);
|
||||
|
||||
/** Creates the row widget when called by Slate when an item appears on the list. */
|
||||
TSharedRef< ITableRow > OnGenerateRowForLogCategoryViewer(TSharedPtr<FLogCategoryViewerNode> Item, const TSharedRef< STableViewBase >& OwnerTable);
|
||||
|
||||
/** Called by Slate when an item is selected from the tree/list. */
|
||||
void OnLogCategorySelectionChanged(TSharedPtr<FLogCategoryViewerNode> Item, ESelectInfo::Type SelectInfo);
|
||||
|
||||
/** Updates the list of items in the dropdown menu */
|
||||
TSharedPtr<FLogCategoryViewerNode> UpdatePropertyOptions();
|
||||
|
||||
/** Delegate to be called when an LogCategory is picked from the list */
|
||||
FOnLogCategoryPicked OnLogCategoryPicked;
|
||||
|
||||
/** The search box */
|
||||
TSharedPtr<SSearchBox> SearchBoxPtr;
|
||||
|
||||
/** Holds the Slate List widget which holds the LogCategorys for the LogCategory Viewer. */
|
||||
TSharedPtr<SListView<TSharedPtr< FLogCategoryViewerNode > >> LogCategoryList;
|
||||
|
||||
/** Array of items that can be selected in the dropdown menu */
|
||||
TArray<TSharedPtr<FLogCategoryViewerNode>> PropertyOptions;
|
||||
|
||||
/** Filters needed for filtering the assets */
|
||||
TSharedPtr<FLogCategoryTextFilter> LogCategoryTextFilter;
|
||||
|
||||
/** Filter for meta data */
|
||||
FString FilterMetaData;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
SLogCategoryListWidget::~SLogCategoryListWidget()
|
||||
{
|
||||
if (OnLogCategoryPicked.IsBound())
|
||||
{
|
||||
OnLogCategoryPicked.Unbind();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void SLogCategoryListWidget::Construct(const FArguments& InArgs)
|
||||
{
|
||||
struct Local
|
||||
{
|
||||
static void LogCategoryToStringArray(const FName& Name, OUT TArray< FString >& StringArray)
|
||||
{
|
||||
StringArray.Add(Name.ToString());
|
||||
}
|
||||
};
|
||||
|
||||
FilterMetaData = InArgs._FilterMetaData;
|
||||
OnLogCategoryPicked = InArgs._OnLogCategoryPickedDelegate;
|
||||
|
||||
// Setup text filtering
|
||||
LogCategoryTextFilter = MakeShareable(new FLogCategoryTextFilter(FLogCategoryTextFilter::FItemToStringArray::CreateStatic(&Local::LogCategoryToStringArray)));
|
||||
|
||||
UpdatePropertyOptions();
|
||||
|
||||
TSharedPtr< SWidget > ClassViewerContent;
|
||||
|
||||
SAssignNew(ClassViewerContent, SVerticalBox)
|
||||
+ SVerticalBox::Slot()
|
||||
.AutoHeight()
|
||||
[
|
||||
SAssignNew(SearchBoxPtr, SSearchBox)
|
||||
.HintText(NSLOCTEXT("Log", "SearchBoxHint", "Search LogCategories"))
|
||||
.OnTextChanged(this, &SLogCategoryListWidget::OnFilterTextChanged)
|
||||
.DelayChangeNotificationsWhileTyping(true)
|
||||
]
|
||||
|
||||
+ SVerticalBox::Slot()
|
||||
.AutoHeight()
|
||||
[
|
||||
SNew(SSeparator)
|
||||
.Visibility(EVisibility::Collapsed)
|
||||
]
|
||||
|
||||
+ SVerticalBox::Slot()
|
||||
.FillHeight(1.0f)
|
||||
[
|
||||
SAssignNew(LogCategoryList, SListView<TSharedPtr<FLogCategoryViewerNode>>)
|
||||
.Visibility(EVisibility::Visible)
|
||||
.SelectionMode(ESelectionMode::Single)
|
||||
.ListItemsSource(&PropertyOptions)
|
||||
|
||||
// Generates the actual widget for a tree item
|
||||
.OnGenerateRow(this, &SLogCategoryListWidget::OnGenerateRowForLogCategoryViewer)
|
||||
|
||||
// Find out when the user selects something in the tree
|
||||
.OnSelectionChanged(this, &SLogCategoryListWidget::OnLogCategorySelectionChanged)
|
||||
];
|
||||
|
||||
|
||||
ChildSlot
|
||||
[
|
||||
ClassViewerContent.ToSharedRef()
|
||||
];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TSharedRef<ITableRow> SLogCategoryListWidget::OnGenerateRowForLogCategoryViewer(TSharedPtr<FLogCategoryViewerNode> Item, const TSharedRef< STableViewBase >& OwnerTable)
|
||||
{
|
||||
TSharedRef< SLogCategoryItem > ReturnRow = SNew(SLogCategoryItem, OwnerTable)
|
||||
.HighlightText(SearchBoxPtr->GetText())
|
||||
.TextColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.f))
|
||||
.AssociatedNode(Item);
|
||||
|
||||
return ReturnRow;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TSharedPtr<FLogCategoryViewerNode> SLogCategoryListWidget::UpdatePropertyOptions()
|
||||
{
|
||||
PropertyOptions.Empty();
|
||||
TSharedPtr<FLogCategoryViewerNode> InitiallySelected = MakeShareable(new FLogCategoryViewerNode(FName()));
|
||||
|
||||
PropertyOptions.Add(InitiallySelected);
|
||||
|
||||
// Gather all ULogCategory classes
|
||||
for (auto& Entry : FCogDebugLogCategoryManager::GetLogCategories())
|
||||
{
|
||||
// if we have a search string and this doesn't match, don't show it
|
||||
if (LogCategoryTextFilter.IsValid() && !LogCategoryTextFilter->PassesFilter(Entry.Value.LogCategory->GetCategoryName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
TSharedPtr<FLogCategoryViewerNode> SelectableProperty = MakeShareable(new FLogCategoryViewerNode(Entry.Value.LogCategory->GetCategoryName()));
|
||||
PropertyOptions.Add(SelectableProperty);
|
||||
}
|
||||
|
||||
return InitiallySelected;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void SLogCategoryListWidget::OnFilterTextChanged(const FText& InFilterText)
|
||||
{
|
||||
LogCategoryTextFilter->SetRawFilterText(InFilterText);
|
||||
SearchBoxPtr->SetError(LogCategoryTextFilter->GetFilterErrorText());
|
||||
|
||||
UpdatePropertyOptions();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void SLogCategoryListWidget::OnLogCategorySelectionChanged(TSharedPtr<FLogCategoryViewerNode> Item, ESelectInfo::Type SelectInfo)
|
||||
{
|
||||
OnLogCategoryPicked.ExecuteIfBound(Item->Name);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void SCogLogCategoryWidget::Construct(const FArguments& InArgs)
|
||||
{
|
||||
FilterMetaData = InArgs._FilterMetaData;
|
||||
OnLogCategoryChanged = InArgs._OnLogCategoryChanged;
|
||||
SelectedName = InArgs._DefaultName;
|
||||
|
||||
// set up the combo button
|
||||
SAssignNew(ComboButton, SComboButton)
|
||||
.OnGetMenuContent(this, &SCogLogCategoryWidget::GenerateLogCategoryPicker)
|
||||
.ContentPadding(FMargin(2.0f, 2.0f))
|
||||
.ToolTipText(this, &SCogLogCategoryWidget::GetSelectedValueAsText)
|
||||
.ButtonContent()
|
||||
[
|
||||
SNew(STextBlock)
|
||||
.Text(this, &SCogLogCategoryWidget::GetSelectedValueAsText)
|
||||
];
|
||||
|
||||
ChildSlot
|
||||
[
|
||||
ComboButton.ToSharedRef()
|
||||
];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void SCogLogCategoryWidget::OnItemPicked(FName Name)
|
||||
{
|
||||
if (OnLogCategoryChanged.IsBound())
|
||||
{
|
||||
OnLogCategoryChanged.Execute(Name);
|
||||
}
|
||||
|
||||
// Update the selected item for displaying
|
||||
SelectedName = Name;
|
||||
|
||||
// close the list
|
||||
ComboButton->SetIsOpen(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TSharedRef<SWidget> SCogLogCategoryWidget::GenerateLogCategoryPicker()
|
||||
{
|
||||
FOnLogCategoryPicked OnPicked(FOnLogCategoryPicked::CreateRaw(this, &SCogLogCategoryWidget::OnItemPicked));
|
||||
|
||||
return SNew(SBox)
|
||||
.WidthOverride(280)
|
||||
[
|
||||
SNew(SVerticalBox)
|
||||
+ SVerticalBox::Slot()
|
||||
.AutoHeight()
|
||||
.MaxHeight(500)
|
||||
[
|
||||
SNew(SLogCategoryListWidget)
|
||||
.OnLogCategoryPickedDelegate(OnPicked)
|
||||
.FilterMetaData(FilterMetaData)
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FText SCogLogCategoryWidget::GetSelectedValueAsText() const
|
||||
{
|
||||
return FText::FromName(SelectedName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleInterface.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class ICogDebugEditorModule : public IModuleInterface
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static inline ICogDebugEditorModule& Get() { return FModuleManager::LoadModuleChecked<ICogDebugEditorModule>("CogDebugEditor"); }
|
||||
|
||||
static inline bool IsAvailable() { return FModuleManager::Get().IsModuleLoaded("CogDebugEditor"); }
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogDebugGraphPanelPinFactory.h"
|
||||
#include "CogDebugLogCategory.h"
|
||||
#include "EdGraphSchema_K2.h"
|
||||
#include "EdGraphUtilities.h"
|
||||
#include "SCogDebugLogCategoryGraphPin.h"
|
||||
#include "SGraphPin.h"
|
||||
#include "Widgets/DeclarativeSyntaxSupport.h"
|
||||
|
||||
class FCogGraphPanelPinFactory : public FGraphPanelPinFactory
|
||||
{
|
||||
virtual TSharedPtr<class SGraphPin> CreatePin(class UEdGraphPin* InPin) const override
|
||||
{
|
||||
if (InPin->PinType.PinCategory == UEdGraphSchema_K2::PC_Struct && InPin->PinType.PinSubCategoryObject == FCogLogCategory::StaticStruct())
|
||||
{
|
||||
return SNew(SCogLogCategoryGraphPin, InPin);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "IPropertyTypeCustomization.h"
|
||||
#include "Layout/Visibility.h"
|
||||
#include "PropertyEditorModule.h"
|
||||
#include "Widgets/SWidget.h"
|
||||
|
||||
class FCogLogCategoryDetails : public IPropertyTypeCustomization
|
||||
{
|
||||
public:
|
||||
static TSharedRef<IPropertyTypeCustomization> MakeInstance();
|
||||
|
||||
/** IPropertyTypeCustomization interface */
|
||||
virtual void CustomizeHeader(TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override;
|
||||
virtual void CustomizeChildren(TSharedRef<class IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override;
|
||||
|
||||
private:
|
||||
|
||||
TSharedPtr<IPropertyHandle> NameProperty;
|
||||
TArray<TSharedPtr<FString>> PropertyOptions;
|
||||
|
||||
void OnLogCategoryChanged(FName SelectedName);
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Widgets/DeclarativeSyntaxSupport.h"
|
||||
#include "Widgets/SWidget.h"
|
||||
#include "SGraphPin.h"
|
||||
|
||||
class SCogLogCategoryGraphPin : public SGraphPin
|
||||
{
|
||||
public:
|
||||
SLATE_BEGIN_ARGS(SCogLogCategoryGraphPin) {}
|
||||
SLATE_END_ARGS()
|
||||
|
||||
void Construct(const FArguments& InArgs, UEdGraphPin* InGraphPinObj);
|
||||
|
||||
//~ Begin SGraphPin Interface
|
||||
virtual TSharedRef<SWidget> GetDefaultValueWidget() override;
|
||||
//~ End SGraphPin Interface
|
||||
|
||||
void OnLogCategoryChanged(FName SelectedName);
|
||||
|
||||
FName LastSelectedName;
|
||||
|
||||
private:
|
||||
bool GetDefaultValueIsEnabled() const
|
||||
{
|
||||
return !GraphPinObj->bDefaultValueIsReadOnly;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Widgets/SWidget.h"
|
||||
#include "Widgets/SCompoundWidget.h"
|
||||
#include "Widgets/DeclarativeSyntaxSupport.h"
|
||||
#include "Widgets/Input/SComboButton.h"
|
||||
|
||||
class SCogLogCategoryWidget : public SCompoundWidget
|
||||
{
|
||||
public:
|
||||
DECLARE_DELEGATE_OneParam(FOnLogCategoryChanged, FName)
|
||||
|
||||
SLATE_BEGIN_ARGS(SCogLogCategoryWidget)
|
||||
: _FilterMetaData()
|
||||
, _DefaultName()
|
||||
{}
|
||||
SLATE_ARGUMENT(FString, FilterMetaData)
|
||||
SLATE_ARGUMENT(FName, DefaultName)
|
||||
SLATE_EVENT(FOnLogCategoryChanged, OnLogCategoryChanged)
|
||||
SLATE_END_ARGS()
|
||||
|
||||
void Construct(const FArguments& InArgs);
|
||||
|
||||
private:
|
||||
TSharedRef<SWidget> GenerateLogCategoryPicker();
|
||||
FText GetSelectedValueAsText() const;
|
||||
void OnItemPicked(FName Name);
|
||||
|
||||
FOnLogCategoryChanged OnLogCategoryChanged;
|
||||
FString FilterMetaData;
|
||||
FName SelectedName;
|
||||
TSharedPtr<class SComboButton> ComboButton;
|
||||
};
|
||||
Reference in New Issue
Block a user