Exemple #1
0
void STileLayerList::Construct(const FArguments& InArgs, UPaperTileMap* InTileMap, FNotifyHook* InNotifyHook)
{
	TileMapPtr = InTileMap;
	NotifyHook = InNotifyHook;

	FTileMapEditorCommands::Register();
	const FTileMapEditorCommands& Commands = FTileMapEditorCommands::Get();

	CommandList = MakeShareable(new FUICommandList);

	CommandList->MapAction(
		Commands.AddNewLayerAbove,
		FExecuteAction::CreateSP(this, &STileLayerList::AddNewLayerAbove));

	CommandList->MapAction(
		Commands.AddNewLayerBelow,
		FExecuteAction::CreateSP(this, &STileLayerList::AddNewLayerBelow));

	CommandList->MapAction(
		Commands.DeleteLayer,
		FExecuteAction::CreateSP(this, &STileLayerList::DeleteLayer),
		FCanExecuteAction::CreateSP(this, &STileLayerList::CanExecuteActionNeedingSelectedLayer));

	CommandList->MapAction(
		Commands.DuplicateLayer,
		FExecuteAction::CreateSP(this, &STileLayerList::DuplicateLayer),
		FCanExecuteAction::CreateSP(this, &STileLayerList::CanExecuteActionNeedingSelectedLayer));

	CommandList->MapAction(
		Commands.MergeLayerDown,
		FExecuteAction::CreateSP(this, &STileLayerList::MergeLayerDown),
		FCanExecuteAction::CreateSP(this, &STileLayerList::CanExecuteActionNeedingLayerBelow));

	CommandList->MapAction(
		Commands.MoveLayerUp,
		FExecuteAction::CreateSP(this, &STileLayerList::MoveLayerUp),
		FCanExecuteAction::CreateSP(this, &STileLayerList::CanExecuteActionNeedingLayerAbove));

	CommandList->MapAction(
		Commands.MoveLayerDown,
		FExecuteAction::CreateSP(this, &STileLayerList::MoveLayerDown),
		FCanExecuteAction::CreateSP(this, &STileLayerList::CanExecuteActionNeedingLayerBelow));
	
	FToolBarBuilder ToolbarBuilder(CommandList, FMultiBoxCustomization("TileLayerBrowserToolbar"), TSharedPtr<FExtender>(), Orient_Horizontal, /*InForceSmallIcons=*/ true);
	ToolbarBuilder.SetLabelVisibility(EVisibility::Collapsed);

	ToolbarBuilder.AddToolBarButton(Commands.AddNewLayerAbove);
	ToolbarBuilder.AddToolBarButton(Commands.MoveLayerUp);
	ToolbarBuilder.AddToolBarButton(Commands.MoveLayerDown);
	ToolbarBuilder.AddToolBarButton(Commands.DuplicateLayer);
	ToolbarBuilder.AddToolBarButton(Commands.DeleteLayer);

	TSharedRef<SWidget> Toolbar = ToolbarBuilder.MakeWidget();

	RefreshMirrorList();

	ListViewWidget = SNew(SPaperLayerListView)
		.SelectionMode(ESelectionMode::Single)
		.ClearSelectionOnClick(false)
		.ListItemsSource(&MirrorList)
		.OnSelectionChanged(this, &STileLayerList::OnSelectionChanged)
		.OnGenerateRow(this, &STileLayerList::OnGenerateLayerListRow)
		.OnContextMenuOpening(this, &STileLayerList::OnConstructContextMenu);

	// Restore the selection
	InTileMap->ValidateSelectedLayerIndex();
	if (InTileMap->TileLayers.IsValidIndex(InTileMap->SelectedLayerIndex))
	{
		UPaperTileLayer* SelectedLayer = InTileMap->TileLayers[InTileMap->SelectedLayerIndex];
		SetSelectedLayer(SelectedLayer);
	}

	ChildSlot
	[
		SNew(SVerticalBox)
		+SVerticalBox::Slot()
		[
			SNew(SBox)
			.HeightOverride(115.0f)
			[
				ListViewWidget.ToSharedRef()
			]
		]
		+SVerticalBox::Slot()
		.AutoHeight()
		[
			Toolbar
		]
	];
}
FMultiBoxCustomization FMultiBoxBuilder::GetCustomization() const
{
	return FMultiBoxCustomization( MultiBox->GetCustomizationName() ); 
}