void FNiagaraEffectEditor::InitNiagaraEffectEditor(const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, UNiagaraEffect* InEffect)
{
	Effect = InEffect;
	check(Effect != NULL);
	EffectInstance = new FNiagaraEffectInstance(InEffect);

	if (!Sequencer.IsValid())
	{
		FSequencerViewParams ViewParams;
		ViewParams.InitalViewRange = TRange<float>(-0.02f, 3.2f);
		ViewParams.InitialScrubPosition = 0;

		SequencerBindingManager = MakeShareable(new FNiagaraSequencerObjectBindingManager());

		MovieScene = NewObject<UMovieScene>(InEffect, FName("Niagara Effect MovieScene"), RF_RootSet);

		ISequencerModule &SeqModule = FModuleManager::LoadModuleChecked< ISequencerModule >("Sequencer");
		FDelegateHandle CreateTrackEditorHandle = SeqModule.RegisterTrackEditor_Handle(FOnCreateTrackEditor::CreateStatic(&FNiagaraEffectEditor::CreateTrackEditor));
		Sequencer = SeqModule.CreateSequencer(MovieScene, ViewParams, SequencerBindingManager.ToSharedRef());

		for (TSharedPtr<FNiagaraSimulation> Emitter : EffectInstance->GetEmitters())
		{
			UEmitterMovieSceneTrack *Track = Cast<UEmitterMovieSceneTrack> (MovieScene->AddMasterTrack(UEmitterMovieSceneTrack::StaticClass()) );
			 Track->SetEmitter(Emitter);
		}

	}




	TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout("Standalone_Niagara_Effect_Layout_v7")
		->AddArea
		(
			FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
			->Split
			(
				FTabManager::NewStack()
				->SetSizeCoefficient(0.1f)
				->AddTab(GetToolbarTabId(), ETabState::OpenedTab)
				->SetHideTabWell(true)
			)
			->Split
			(
				FTabManager::NewSplitter()->SetOrientation(Orient_Horizontal)
				->Split
				(
					FTabManager::NewStack()
					->SetSizeCoefficient(0.1f)
					->AddTab(ViewportTabID, ETabState::OpenedTab)
				)
				->Split
				(
					FTabManager::NewStack()
					->SetSizeCoefficient(0.3f)
					->AddTab(EmitterEditorTabID, ETabState::OpenedTab)
					->AddTab(DevEmitterEditorTabID, ETabState::OpenedTab)
				)
			)
			->Split
			(
			FTabManager::NewStack()
			->SetSizeCoefficient(0.3f)
			->AddTab(CurveEditorTabID, ETabState::OpenedTab)
			->AddTab(SequencerTabID, ETabState::OpenedTab)
			)
		);

	const bool bCreateDefaultStandaloneMenu = true;
	const bool bCreateDefaultToolbar = true;
	FAssetEditorToolkit::InitAssetEditor(Mode, InitToolkitHost, FNiagaraEditorModule::NiagaraEditorAppIdentifier, StandaloneDefaultLayout, bCreateDefaultStandaloneMenu, bCreateDefaultToolbar, Effect);
	
	FNiagaraEditorModule& NiagaraEditorModule = FModuleManager::LoadModuleChecked<FNiagaraEditorModule>("NiagaraEditor");
	AddMenuExtender(NiagaraEditorModule.GetMenuExtensibilityManager()->GetAllExtenders(GetToolkitCommands(), GetEditingObjects()));

	ExtendToolbar();
	RegenerateMenusAndToolbars();
}
void FNiagaraEffectEditor::ExtendToolbar()
{
	struct Local
	{
		static void FillToolbar(FToolBarBuilder& ToolbarBuilder, TSharedRef<SWidget> AddEmitterBox)
		{
			ToolbarBuilder.BeginSection("AddEmitter");
			{
				ToolbarBuilder.AddWidget(AddEmitterBox);
			}
			ToolbarBuilder.EndSection();
		}
	};

	TSharedPtr<FExtender> ToolbarExtender = MakeShareable(new FExtender);

	TSharedRef<SWidget> AddEmitterBox = SNew(SHorizontalBox)
		+ SHorizontalBox::Slot()
		.AutoWidth()
		.Padding(4)
		[
			SNew(SButton)
			.OnClicked(this, &FNiagaraEffectEditor::OnAddEmitterClicked)
			.Content()
			[
				SNew(SVerticalBox)
				+ SVerticalBox::Slot()
					.AutoHeight()
					[
						SNew(SImage)
						.Image(FEditorStyle::GetBrush("LevelEditor.Add"))
					]
				+ SVerticalBox::Slot()
					.AutoHeight()
					[
						SNew(STextBlock)
						.Text(LOCTEXT("NiagaraToolbar_AddEmitter", "Add Emitter"))
					]
			]
		];

	ToolbarExtender->AddToolBarExtension(
		"Asset",
		EExtensionHook::After,
		GetToolkitCommands(),
		FToolBarExtensionDelegate::CreateStatic(&Local::FillToolbar, AddEmitterBox)
		);

	AddToolbarExtender(ToolbarExtender);

	FNiagaraEditorModule& NiagaraEditorModule = FModuleManager::LoadModuleChecked<FNiagaraEditorModule>("NiagaraEditor");
	AddToolbarExtender(NiagaraEditorModule.GetToolBarExtensibilityManager()->GetAllExtenders(GetToolkitCommands(), GetEditingObjects()));
}
Пример #3
0
void FCurveAssetEditor::InitCurveAssetEditor( const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, UCurveBase* CurveToEdit )
{	
	TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout( "Standalone_CurveAssetEditor_Layout" )
	->AddArea
	(
		FTabManager::NewPrimaryArea()
		->SetOrientation(Orient_Vertical)
		->Split
		(
			FTabManager::NewStack()
			->SetSizeCoefficient(0.1f)
			->SetHideTabWell( true )
			->AddTab(GetToolbarTabId(), ETabState::OpenedTab)
		) 
		->Split
		(
			FTabManager::NewStack()
			->SetHideTabWell( true )
			->AddTab( CurveTabId, ETabState::OpenedTab )
		)
	);

	const bool bCreateDefaultStandaloneMenu = true;
	const bool bCreateDefaultToolbar = true;
	FAssetEditorToolkit::InitAssetEditor( Mode, InitToolkitHost, FCurveAssetEditorModule::CurveAssetEditorAppIdentifier, StandaloneDefaultLayout, bCreateDefaultStandaloneMenu, bCreateDefaultToolbar, CurveToEdit );
	
	FCurveAssetEditorModule& CurveAssetEditorModule = FModuleManager::LoadModuleChecked<FCurveAssetEditorModule>( "CurveAssetEditor" );
	AddMenuExtender(CurveAssetEditorModule.GetMenuExtensibilityManager()->GetAllExtenders(GetToolkitCommands(), GetEditingObjects()));
	AddToolbarExtender(GetToolbarExtender());

	// @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( CurveTabId, TabInitializationPayload, EToolkitTabSpot::Details );
	}*/

	if (TrackWidget.IsValid())
	{
		RegenerateMenusAndToolbars();
	}
}
/**
 * Builds the Matinee Tool Bar
 */
void FMatinee::ExtendToolbar()
{
    struct Local
    {
        static void FillToolbar(FToolBarBuilder& ToolbarBuilder, TSharedRef<SWidget> InterpolationBox, TSharedRef<SWidget> SpeedBox, TSharedRef<SWidget> SnapSettingBox)
        {
            ToolbarBuilder.BeginSection("CurveMode");
            {
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().AddKey);
            }
            ToolbarBuilder.EndSection();

            ToolbarBuilder.BeginSection("Interpolation");
            {
                ToolbarBuilder.AddWidget(InterpolationBox);
            }
            ToolbarBuilder.EndSection();

            ToolbarBuilder.BeginSection("Play");
            {
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().Play);
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().PlayLoop);
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().Stop);
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().PlayReverse);
            }
            ToolbarBuilder.EndSection();

            ToolbarBuilder.BeginSection("Camera");
            {
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().CreateCameraActor);
            }
            ToolbarBuilder.EndSection();

            ToolbarBuilder.BeginSection("Speed");
            {
                ToolbarBuilder.AddWidget(SpeedBox);
            }
            ToolbarBuilder.EndSection();

            //ToolbarBuilder.BeginSection("History");
            //{
            //	ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().Undo);
            //	ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().Redo);
            //}
            //ToolbarBuilder.EndSection();

            ToolbarBuilder.BeginSection("SnapSetting");
            {
                ToolbarBuilder.AddWidget(SnapSettingBox);
            }
            ToolbarBuilder.EndSection();

            ToolbarBuilder.BeginSection("Curve");
            {
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().ToggleCurveEditor);
            }
            ToolbarBuilder.EndSection();

            ToolbarBuilder.BeginSection("Snap");
            {
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().ToggleSnap);
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().ToggleSnapTimeToFrames);
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().FixedTimeStepPlayback);
            }
            ToolbarBuilder.EndSection();

            ToolbarBuilder.BeginSection("View");
            {
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().FitSequence);
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().FitViewToSelected);
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().FitLoop);
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().FitLoopSequence);
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().ViewEndofTrack);
            }
            ToolbarBuilder.EndSection();

            ToolbarBuilder.BeginSection("Record");
            {
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().LaunchRecordWindow);
                ToolbarBuilder.AddToolBarButton(FMatineeCommands::Get().CreateMovie);
            }
            ToolbarBuilder.EndSection();
        }
    };

    TSharedPtr<FExtender> ToolbarExtender = MakeShareable(new FExtender);

    InitialInterpModeStrings.Empty();
    InitialInterpModeStrings.Add( MakeShareable( new FString(NSLOCTEXT("Matinee", "Linear", "Linear").ToString()) ) );
    InitialInterpModeStrings.Add( MakeShareable( new FString(NSLOCTEXT("Matinee", "CurveAuto", "CurveAuto").ToString()) ) );
    InitialInterpModeStrings.Add( MakeShareable( new FString(NSLOCTEXT("Matinee", "Constant", "Constant").ToString()) ) );
    InitialInterpModeStrings.Add( MakeShareable( new FString(NSLOCTEXT("Matinee", "CurveUser", "CurveUser").ToString()) ) );
    InitialInterpModeStrings.Add( MakeShareable( new FString(NSLOCTEXT("Matinee", "CurveBreak", "CurveBreak").ToString()) ) );
    InitialInterpModeStrings.Add( MakeShareable( new FString(NSLOCTEXT("Matinee", "CurveAutoClamped", "CurveAutoClamped").ToString()) ) );

    InitialInterpModeComboBox =
        SNew( STextComboBox )
        .OptionsSource(&InitialInterpModeStrings)
        .InitiallySelectedItem(InitialInterpModeStrings[0])
        .OnSelectionChanged(this, &FMatinee::OnChangeInitialInterpMode)
        .ToolTipText(NSLOCTEXT("Matinee", "ToolTipInitialInterp", "Initial Interp Mode | Selects the curve interpolation mode for newly created keys"))
        ;

    TSharedRef<SWidget> InterpolationBox =
        SNew(SBox)
        .WidthOverride(150)
        [
            SNew(SVerticalBox)
            +SVerticalBox::Slot()
            .Padding(4)
            [
                SNew(STextBlock)
                .Text(NSLOCTEXT("Matinee.Toolbar", "InterpMode", "Interpolation:"))
                .Visibility( this, &FMatinee::GetLargeIconVisibility )
            ]
            +SVerticalBox::Slot()
            .AutoHeight()
            .Padding(4,0)
            [
                InitialInterpModeComboBox.ToSharedRef()
            ]
        ];

    SpeedSettingStrings.Empty();
    SpeedSettingStrings.Add( MakeShareable( new FString(NSLOCTEXT("UnrealEd", "FullSpeed", "100%").ToString()) ) );
    SpeedSettingStrings.Add( MakeShareable( new FString(NSLOCTEXT("UnrealEd", "50Speed", "50%").ToString()) ) );
    SpeedSettingStrings.Add( MakeShareable( new FString(NSLOCTEXT("UnrealEd", "25Speed", "25%").ToString()) ) );
    SpeedSettingStrings.Add( MakeShareable( new FString(NSLOCTEXT("UnrealEd", "10Speed", "10%").ToString()) ) );
    SpeedSettingStrings.Add( MakeShareable( new FString(NSLOCTEXT("UnrealEd", "1Speed", "1%").ToString()) ) );

    SpeedCombo =
        SNew(STextComboBox)
        .OptionsSource(&SpeedSettingStrings)
        .InitiallySelectedItem(SpeedSettingStrings[0])
        .OnSelectionChanged(this, &FMatinee::OnChangePlaySpeed)
        ;

    TSharedRef<SWidget> SpeedBox =
        SNew(SBox)
        .WidthOverride(103)
        [
            SNew(SVerticalBox)
            +SVerticalBox::Slot()
            .Padding(4)
            [
                SNew(STextBlock)
                .Text(NSLOCTEXT("Matinee.Toolbar", "PlaybackSpeed", "Playback Speed:"))
                .Visibility( this, &FMatinee::GetLargeIconVisibility )
            ]
            +SVerticalBox::Slot()
            .AutoHeight()
            .Padding(4,0)
            [
                SpeedCombo.ToSharedRef()
            ]
        ];

    // Append Second Snap Times
    SnapComboStrings.Empty();
    for(int32 i=0; i<ARRAY_COUNT(InterpEdSnapSizes); i++)
    {
        FString SnapCaption = FString::Printf( TEXT("%1.2f"), InterpEdSnapSizes[i] );
        SnapComboStrings.Add( MakeShareable( new FString(SnapCaption) ) );
    }
    // Append FPS Snap Times
    for(int32 i=0; i<ARRAY_COUNT(InterpEdFPSSnapSizes); i++)
    {
        FString SnapCaption = GetInterpEdFPSSnapSizeLocName( i );
        SnapComboStrings.Add( MakeShareable( new FString(SnapCaption) ) );
    }
    // Add option for snapping to other keys.
    SnapComboStrings.Add( MakeShareable( new FString(NSLOCTEXT("UnrealEd", "InterpEd_Snap_Keys", "Snap to Keys" ).ToString()) ) );

    SnapCombo =
        SNew(STextComboBox)
        .OptionsSource(&SnapComboStrings)
        .InitiallySelectedItem(SnapComboStrings[2])
        .OnSelectionChanged(this, &FMatinee::OnChangeSnapSize)
        .ToolTipText( NSLOCTEXT("Matinee", "SnapComboToolTip", "Snap Size | Selects the timeline granularity for snapping and visualization purposes") )
        ;

    TSharedRef<SWidget> SnapSettingBox =
        SNew(SBox)
        .WidthOverride(155)
        [
            SNew(SVerticalBox)
            +SVerticalBox::Slot()
            .Padding(4)
            [
                SNew(STextBlock)
                .Text(NSLOCTEXT("Matinee.Toolbar", "SnapSetting", "Snap Setting:"))
                .Visibility( this, &FMatinee::GetLargeIconVisibility )
            ]
            +SVerticalBox::Slot()
            .AutoHeight()
            .Padding(4,0)
            [
                SnapCombo.ToSharedRef()
            ]
        ];

    ToolbarExtender->AddToolBarExtension(
        "Asset",
        EExtensionHook::After,
        GetToolkitCommands(),
        FToolBarExtensionDelegate::CreateStatic( &Local::FillToolbar, InterpolationBox, SpeedBox, SnapSettingBox)
    );

    AddToolbarExtender(ToolbarExtender);

    IMatineeModule* MatineeModule = &FModuleManager::LoadModuleChecked<IMatineeModule>( "Matinee" );
    AddToolbarExtender(MatineeModule->GetToolBarExtensibilityManager()->GetAllExtenders(GetToolkitCommands(), GetEditingObjects()));
}
void FSoundClassEditor::InitSoundClassEditor( const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, UObject* ObjectToEdit )
{
	SoundClass = CastChecked<USoundClass>(ObjectToEdit);

	while (SoundClass->ParentClass)
	{
		SoundClass = SoundClass->ParentClass;
	}

	// Support undo/redo
	SoundClass->SetFlags(RF_Transactional);

	GEditor->RegisterForUndo(this);

	ToolkitCommands->MapAction(
		FGenericCommands::Get().Undo,
		FExecuteAction::CreateSP( this, &FSoundClassEditor::UndoGraphAction ));

	ToolkitCommands->MapAction(
		FGenericCommands::Get().Redo,
		FExecuteAction::CreateSP( this, &FSoundClassEditor::RedoGraphAction ));

	if( !SoundClass->SoundClassGraph )
	{
		SoundClass->SoundClassGraph = CastChecked<USoundClassGraph>(FBlueprintEditorUtils::CreateNewGraph(SoundClass, NAME_None, USoundClassGraph::StaticClass(), USoundClassGraphSchema::StaticClass()));
		SoundClass->SoundClassGraph->SetRootSoundClass(SoundClass);
	}

	SoundClass->SoundClassGraph->RebuildGraph();

	CreateInternalWidgets();

	TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout( "Standalone_SoundClassEditor_Layout_v2" )
	->AddArea
	(
		FTabManager::NewPrimaryArea() ->SetOrientation(Orient_Vertical)
		->Split
		(
			FTabManager::NewStack()
			->SetSizeCoefficient(0.1f)
			->SetHideTabWell( true )
			->AddTab(GetToolbarTabId(), ETabState::OpenedTab)
		)
		->Split
		(
			FTabManager::NewSplitter()
			->Split
			(
				FTabManager::NewStack()
				->SetSizeCoefficient(0.2f)
				->AddTab(PropertiesTabId, ETabState::OpenedTab)
			)
			->Split
			(
				FTabManager::NewStack()
				->SetSizeCoefficient(0.8f)
				->AddTab(GraphCanvasTabId, ETabState::OpenedTab)
			)
		)
	);

	const bool bCreateDefaultStandaloneMenu = true;
	const bool bCreateDefaultToolbar = true;
	FAssetEditorToolkit::InitAssetEditor( Mode, InitToolkitHost, SoundClassEditorAppIdentifier, StandaloneDefaultLayout, bCreateDefaultStandaloneMenu, bCreateDefaultToolbar, ObjectToEdit );

	ISoundClassEditorModule* SoundClassEditorModule = &FModuleManager::LoadModuleChecked<ISoundClassEditorModule>( "SoundClassEditor" );
	AddMenuExtender(SoundClassEditorModule->GetMenuExtensibilityManager()->GetAllExtenders(GetToolkitCommands(), GetEditingObjects()));
	AddToolbarExtender(SoundClassEditorModule->GetToolBarExtensibilityManager()->GetAllExtenders(GetToolkitCommands(), GetEditingObjects()));

	GraphEditor->SelectAllNodes();
	for (UObject* SelectedNode : GraphEditor->GetSelectedNodes())
	{
		USoundClassGraphNode* GraphNode = CastChecked<USoundClassGraphNode>(SelectedNode);
		if (GraphNode->SoundClass == ObjectToEdit)
		{
			GraphEditor->ClearSelectionSet();
			GraphEditor->SetNodeSelection(GraphNode, true);
			DetailsView->SetObject(ObjectToEdit);
			break;
		}
	}
}
Пример #6
0
void FNiagaraEditor::InitNiagaraEditor( const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, UNiagaraScript* InScript )
{	
	Script = InScript;
	check(Script != NULL);
	Source = CastChecked<UNiagaraScriptSource>(Script->Source);
	check(Source->NodeGraph != NULL);

	TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout( "Standalone_Niagara_Layout_v4" )
	->AddArea
	(
		FTabManager::NewPrimaryArea() ->SetOrientation(Orient_Vertical)
		->Split
		(
			FTabManager::NewStack()
			->SetSizeCoefficient(0.1f)
			->AddTab(GetToolbarTabId(), ETabState::OpenedTab) 
			->SetHideTabWell( true )
		)
		->Split
		(
			FTabManager::NewSplitter()->SetOrientation(Orient_Horizontal)->SetSizeCoefficient(0.9f)
			->Split
			(
				FTabManager::NewStack()
				->SetSizeCoefficient(0.2f)
				->AddTab(PropertiesTabId, ETabState::OpenedTab)
			)
			->Split
			(
				FTabManager::NewStack()
				->SetSizeCoefficient(0.8f)
				->AddTab(NodeGraphTabId, ETabState::OpenedTab)
			)
		)
	);

	FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
	const FDetailsViewArgs DetailsViewArgs(false, false, true, FDetailsViewArgs::HideNameArea, true, this);
	NiagaraDetailsView = PropertyEditorModule.CreateDetailView(DetailsViewArgs);

	const bool bCreateDefaultStandaloneMenu = true;
	const bool bCreateDefaultToolbar = true;
	FAssetEditorToolkit::InitAssetEditor( Mode, InitToolkitHost, FNiagaraEditorModule::NiagaraEditorAppIdentifier, StandaloneDefaultLayout, bCreateDefaultStandaloneMenu, bCreateDefaultToolbar, Script );

	FNiagaraEditorModule& NiagaraEditorModule = FModuleManager::LoadModuleChecked<FNiagaraEditorModule>( "NiagaraEditor" );
	AddMenuExtender(NiagaraEditorModule.GetMenuExtensibilityManager()->GetAllExtenders(GetToolkitCommands(), GetEditingObjects()));

	ExtendToolbar();
	RegenerateMenusAndToolbars();

	// @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( NodeGraphTabId, TabInitializationPayload, EToolkitTabSpot::Details );
	}*/
}