Skip to content

Customizing Columns

Valentin Plyasinov edited this page Aug 12, 2022 · 8 revisions

Plugin supports adding custom columns to visualize some properties of subsystem.

To create a custom column type that has an icon to visualize if subsystem is a tickable:

  1. Add SubsystemBrowser module dependency in Build.cs

Since Subsystem Browser is an editor module it is recommended to access it only from other editor modules

When using a regular game module dependency has to be guarded with if (Target.bBuildEditor)

PrivateDependencyModuleNames.Add("SubsystemBrowser");
  1. Declare function for column registration in your module

Since Subsystem Browser is an editor module it is recommended to access it only from other editor modules

When using a regular game module access to editor-only types and headers has to be guarded with #if WITH_EDITOR

// Include module and common types
#include "SubsystemBrowserModule.h"

struct FMyEditorModule : public IModuleInterface
{
       virtual void StartupModule() override
       { 
           RegisterCustomColumns();// Call it on startup
       }

private:
       void RegisterCustomColumns();
};
  1. Implement column functionality inheriting FSubsystemDynamicColumn
// Include module and common types
#include "SubsystemBrowserModule.h"

// All columns inherit FSubsystemDynamicColumn
struct FSubsystemDynamicColumn_Tick : public FSubsystemDynamicColumn
{
        // Its your typical constructor
	FSubsystemDynamicColumn_Tick()
	{
		// Configure name and header title
		Name = TEXT("IsTickable");
		TableLabel = INVTEXT("");
		ConfigLabel = INVTEXT("Tickable");
		PreferredWidthRatio = 0.05f;
	}

        // Define how you want to visualize the column with Slate
	virtual TSharedPtr<SWidget> GenerateColumnWidget(TSharedRef<const ISubsystemTreeItem> Item, TSharedRef<SSubsystemTableItem> TableRow) const override
	{
		// Build a widget to represent value
		return SNew(SHorizontalBox)
			+ SHorizontalBox::Slot()
			.HAlign(HAlign_Center)
			[
				SNew(SImage)
				.ColorAndOpacity(FSlateColor::UseForeground())
				.Image(FEditorStyle::GetBrush(TEXT("GraphEditor.Conduit_16x")))
				.DesiredSizeOverride(FVector2d{16,16})
				.Visibility(this, &FSubsystemDynamicColumn_Tick::ExtractIsTickable, Item)
			];
	}
private:
	EVisibility ExtractIsTickable(TSharedRef<const ISubsystemTreeItem> Item) const
	{
		auto* Subsystem = Item->GetAsSubsystemDescriptor();
		return Subsystem && Subsystem->Class.IsValid() && Subsystem->Class->IsChildOf(UTickableWorldSubsystem::StaticClass())
			? EVisibility::Visible : EVisibility::Hidden;
	}
};
  1. Define a function that will create and register column
void FMyEditorModule::RegisterCategoryExample()
{
	// Get a reference to Subsystem Browser module instance or load it
	FSubsystemBrowserModule& Module = FModuleManager::LoadModuleChecked<FSubsystemBrowserModule>(TEXT("SubsystemBrowser"));
	// Construct and register new column
	Module.RegisterDynamicColumn(MakeShared<FSubsystemDynamicColumn_Tick>());
}
  1. Enjoy working with subsystems
Clone this wiki locally