You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#UE4 Made the Curve Table editor use a SUniformGridPanel instead of just displaying a text dump. -------- Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2221460 by Bob.Tellez on 2014/07/16 18:43:16. [CL 2221465 by Bob Tellez in Main branch]
170 lines
4.7 KiB
C++
170 lines
4.7 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "CurveTableEditorPrivatePCH.h"
|
|
|
|
#include "CurveTableEditor.h"
|
|
#include "Toolkits/IToolkitHost.h"
|
|
#include "Editor/WorkspaceMenuStructure/Public/WorkspaceMenuStructureModule.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "CurveTableEditor"
|
|
|
|
const FName FCurveTableEditor::CurveTableTabId( TEXT( "CurveTableEditor_CurveTable" ) );
|
|
|
|
void FCurveTableEditor::RegisterTabSpawners(const TSharedRef<class FTabManager>& TabManager)
|
|
{
|
|
const IWorkspaceMenuStructure& MenuStructure = WorkspaceMenu::GetMenuStructure();
|
|
|
|
TabManager->RegisterTabSpawner( CurveTableTabId, FOnSpawnTab::CreateSP(this, &FCurveTableEditor::SpawnTab_CurveTable) )
|
|
.SetDisplayName( LOCTEXT("CurveTableTab", "Curve Table") )
|
|
.SetGroup( MenuStructure.GetAssetEditorCategory() );
|
|
}
|
|
|
|
void FCurveTableEditor::UnregisterTabSpawners(const TSharedRef<class FTabManager>& TabManager)
|
|
{
|
|
TabManager->UnregisterTabSpawner( CurveTableTabId );
|
|
}
|
|
|
|
FCurveTableEditor::~FCurveTableEditor()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
void FCurveTableEditor::InitCurveTableEditor( const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, UCurveTable* Table )
|
|
{
|
|
const TSharedRef< FTabManager::FLayout > StandaloneDefaultLayout = FTabManager::NewLayout("Standalone_CurveTableEditor_Layout")
|
|
->AddArea
|
|
(
|
|
FTabManager::NewPrimaryArea()
|
|
->Split
|
|
(
|
|
FTabManager::NewStack()
|
|
->AddTab( CurveTableTabId, ETabState::OpenedTab )
|
|
)
|
|
);
|
|
|
|
const bool bCreateDefaultStandaloneMenu = true;
|
|
const bool bCreateDefaultToolbar = false;
|
|
FAssetEditorToolkit::InitAssetEditor( Mode, InitToolkitHost, FCurveTableEditorModule::CurveTableEditorAppIdentifier, StandaloneDefaultLayout, bCreateDefaultStandaloneMenu, bCreateDefaultToolbar, Table );
|
|
|
|
FCurveTableEditorModule& CurveTableEditorModule = FModuleManager::LoadModuleChecked<FCurveTableEditorModule>( "CurveTableEditor" );
|
|
AddMenuExtender(CurveTableEditorModule.GetMenuExtensibilityManager()->GetAllExtenders(GetToolkitCommands(), GetEditingObjects()));
|
|
|
|
// @todo toolkit world centric editing
|
|
/*// Setup our tool's layout
|
|
if( IsWorldCentricAssetEditor() )
|
|
{
|
|
const FString TabInitializationPayload(TEXT("")); // NOTE: Payload not currently used for table properties
|
|
SpawnToolkitTab( CurveTableTabId, TabInitializationPayload, EToolkitTabSpot::Details );
|
|
}*/
|
|
|
|
// NOTE: Could fill in asset editor commands here!
|
|
}
|
|
|
|
FName FCurveTableEditor::GetToolkitFName() const
|
|
{
|
|
return FName("CurveTableEditor");
|
|
}
|
|
|
|
FText FCurveTableEditor::GetBaseToolkitName() const
|
|
{
|
|
return LOCTEXT( "AppLabel", "CurveTable Editor" );
|
|
}
|
|
|
|
|
|
FString FCurveTableEditor::GetWorldCentricTabPrefix() const
|
|
{
|
|
return LOCTEXT("WorldCentricTabPrefix", "CurveTable ").ToString();
|
|
}
|
|
|
|
|
|
FLinearColor FCurveTableEditor::GetWorldCentricTabColorScale() const
|
|
{
|
|
return FLinearColor( 0.0f, 0.0f, 0.2f, 0.5f );
|
|
}
|
|
|
|
|
|
TSharedRef<SUniformGridPanel> FCurveTableEditor::CreateGridPanel() const
|
|
{
|
|
TSharedRef<SUniformGridPanel> GridPanel = SNew(SUniformGridPanel).SlotPadding(FMargin(2.0f));
|
|
|
|
UCurveTable* Table = Cast<UCurveTable>(GetEditingObject());
|
|
if (Table != NULL)
|
|
{
|
|
int32 RowIdx = 0;
|
|
for ( auto RowIt = Table->RowMap.CreateConstIterator(); RowIt; ++RowIt )
|
|
{
|
|
const FName RowName = RowIt.Key();
|
|
const FRichCurve* RowCurve = RowIt.Value();
|
|
|
|
// Make sure this row is valid
|
|
if ( RowCurve )
|
|
{
|
|
FLinearColor RowColor = (RowIdx % 2 == 0) ? FLinearColor::Gray : FLinearColor::Black;
|
|
int32 ColumnIdx = 0;
|
|
|
|
// Row name
|
|
GridPanel->AddSlot(ColumnIdx++, RowIdx)
|
|
[
|
|
SNew(SBorder)
|
|
.Padding(1)
|
|
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
|
|
.BorderBackgroundColor(RowColor)
|
|
[
|
|
SNew(STextBlock) .Text(FText::FromName(RowName))
|
|
]
|
|
];
|
|
|
|
// Row Values
|
|
for (auto ValueIt(RowCurve->GetKeyIterator()); ValueIt; ++ValueIt)
|
|
{
|
|
GridPanel->AddSlot(ColumnIdx++, RowIdx)
|
|
[
|
|
SNew(SBorder)
|
|
.Padding(1)
|
|
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
|
|
.BorderBackgroundColor(RowColor)
|
|
[
|
|
SNew(STextBlock).Text(FText::AsNumber(ValueIt->Value))
|
|
]
|
|
];
|
|
}
|
|
|
|
RowIdx++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return GridPanel;
|
|
}
|
|
|
|
|
|
TSharedRef<SDockTab> FCurveTableEditor::SpawnTab_CurveTable( const FSpawnTabArgs& Args )
|
|
{
|
|
check( Args.GetTabId().TabType == CurveTableTabId );
|
|
|
|
return SNew(SDockTab)
|
|
.Icon( FEditorStyle::GetBrush("CurveTableEditor.Tabs.Properties") )
|
|
.Label( LOCTEXT("CurveTableTitle", "Curve Table") )
|
|
.TabColorScale( GetTabColorScale() )
|
|
[
|
|
SNew(SBorder)
|
|
.Padding(2)
|
|
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
|
|
[
|
|
SNew(SScrollBox)
|
|
+ SScrollBox::Slot()
|
|
[
|
|
SNew(SBox)
|
|
.VAlign(VAlign_Top)
|
|
.HAlign(HAlign_Left)
|
|
[
|
|
CreateGridPanel()
|
|
]
|
|
]
|
|
]
|
|
];
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|