void FLandscapeToolKit::Init(const TSharedPtr<IToolkitHost>& InitToolkitHost) { auto NameToCommandMap = FLandscapeEditorCommands::Get().NameToCommandMap; FEdModeLandscape* LandscapeEdMode = GetEditorMode(); TSharedRef<FUICommandList> CommandList = LandscapeEdMode->GetUICommandList(); #define MAP_MODE(ModeName) CommandList->MapAction(NameToCommandMap.FindChecked(ModeName), FUIAction(FExecuteAction::CreateSP(this, &FLandscapeToolKit::OnChangeMode, FName(ModeName)), FCanExecuteAction::CreateSP(this, &FLandscapeToolKit::IsModeEnabled, FName(ModeName)), FIsActionChecked::CreateSP(this, &FLandscapeToolKit::IsModeActive, FName(ModeName)))); MAP_MODE("ToolMode_Manage"); MAP_MODE("ToolMode_Sculpt"); MAP_MODE("ToolMode_Paint"); #undef MAP_MODE #define MAP_TOOL(ToolName) CommandList->MapAction(NameToCommandMap.FindChecked("Tool_" ToolName), FUIAction(FExecuteAction::CreateSP(this, &FLandscapeToolKit::OnChangeTool, FName(ToolName)), FCanExecuteAction::CreateSP(this, &FLandscapeToolKit::IsToolEnabled, FName(ToolName)), FIsActionChecked::CreateSP(this, &FLandscapeToolKit::IsToolActive, FName(ToolName)))); MAP_TOOL("NewLandscape"); MAP_TOOL("ResizeLandscape"); MAP_TOOL("Sculpt"); MAP_TOOL("Paint"); MAP_TOOL("Smooth"); MAP_TOOL("Flatten"); MAP_TOOL("Ramp"); MAP_TOOL("Erosion"); MAP_TOOL("HydraErosion"); MAP_TOOL("Noise"); MAP_TOOL("Retopologize"); MAP_TOOL("Visibility"); MAP_TOOL("Select"); MAP_TOOL("AddComponent"); MAP_TOOL("DeleteComponent"); MAP_TOOL("MoveToLevel"); MAP_TOOL("Mask"); MAP_TOOL("CopyPaste"); MAP_TOOL("Mirror"); MAP_TOOL("Splines"); #undef MAP_TOOL #define MAP_BRUSH_SET(BrushSetName) CommandList->MapAction(NameToCommandMap.FindChecked(BrushSetName), FUIAction(FExecuteAction::CreateSP(this, &FLandscapeToolKit::OnChangeBrushSet, FName(BrushSetName)), FCanExecuteAction::CreateSP(this, &FLandscapeToolKit::IsBrushSetEnabled, FName(BrushSetName)), FIsActionChecked::CreateSP(this, &FLandscapeToolKit::IsBrushSetActive, FName(BrushSetName)))); MAP_BRUSH_SET("BrushSet_Circle"); MAP_BRUSH_SET("BrushSet_Alpha"); MAP_BRUSH_SET("BrushSet_Pattern"); MAP_BRUSH_SET("BrushSet_Component"); MAP_BRUSH_SET("BrushSet_Gizmo"); #undef MAP_BRUSH_SET #define MAP_BRUSH(BrushName) CommandList->MapAction(NameToCommandMap.FindChecked(BrushName), FUIAction(FExecuteAction::CreateSP(this, &FLandscapeToolKit::OnChangeBrush, FName(BrushName)), FCanExecuteAction(), FIsActionChecked::CreateSP(this, &FLandscapeToolKit::IsBrushActive, FName(BrushName)))); MAP_BRUSH("Circle_Smooth"); MAP_BRUSH("Circle_Linear"); MAP_BRUSH("Circle_Spherical"); MAP_BRUSH("Circle_Tip"); #undef MAP_BRUSH LandscapeEditorWidgets = SNew(SLandscapeEditor, SharedThis(this)); FModeToolkit::Init(InitToolkitHost); }
void FLandscapeEditorDetails::OnChangeBrush(FName BrushName) { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != NULL) { LandscapeEdMode->SetCurrentBrush(BrushName); } }
void FLandscapeToolKit::OnChangeBrush(FName BrushName) { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != nullptr) { LandscapeEdMode->SetCurrentBrush(BrushName); } }
void FLandscapeEditorDetailCustomization_MiscTools::OnbUseAutoRotateControlPointChanged(ECheckBoxState NewState) { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode) { LandscapeEdMode->SetbUseAutoRotateOnJoin(NewState == ECheckBoxState::Checked); } }
void FLandscapeToolKit::OnChangeMode(FName ModeName) { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode) { LandscapeEdMode->SetCurrentToolMode(ModeName); } }
void FLandscapeEditorDetails::OnChangeTool(FName ToolSetName) { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != NULL) { LandscapeEdMode->SetCurrentTool(ToolSetName); } }
ECheckBoxState FLandscapeEditorDetailCustomization_MiscTools::GetbUseAutoRotateControlPoint() const { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode) { return LandscapeEdMode->GetbUseAutoRotateOnJoin() ? ECheckBoxState::Checked : ECheckBoxState::Unchecked; } return ECheckBoxState::Unchecked; }
FReply FLandscapeSplineDetails::OnMoveToCurrentLevelButtonClicked() { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode && LandscapeEdMode->CurrentToolTarget.LandscapeInfo.IsValid() && LandscapeEdMode->CurrentToolTarget.LandscapeInfo->GetCurrentLevelLandscapeProxy(true)) { LandscapeEdMode->SplineMoveToCurrentLevel(); } return FReply::Handled(); }
FReply FLandscapeSplineDetails::OnSelectConnectedSegmentsButtonClicked() { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode && LandscapeEdMode->CurrentToolTarget.LandscapeInfo.IsValid()) { LandscapeEdMode->SelectAllConnectedSplineSegments(); } return FReply::Handled(); }
bool SLandscapeEditor::GetLandscapeEditorIsEnabled() const { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode) { Error->SetError(GetErrorText()); return LandscapeEdMode->GetEditingState() == ELandscapeEditingState::Enabled; } return false; }
EVisibility FLandscapeEditorDetails::GetTargetLandscapeSelectorVisibility() { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode && LandscapeEdMode->GetLandscapeList().Num() > 1) { return EVisibility::Visible; } return EVisibility::Collapsed; }
FReply FLandscapeEditorDetailCustomization_MiscTools::OnResetMirrorPointButtonClicked() { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != NULL && IsToolActive(FName("Mirror"))) { LandscapeEdMode->CenterMirrorTool(); } return FReply::Handled(); }
FReply FLandscapeEditorDetailCustomization_MiscTools::OnResetRampButtonClicked() { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != NULL && IsToolActive(FName("Ramp"))) { LandscapeEdMode->ResetRampTool(); } return FReply::Handled(); }
bool FLandscapeEditorDetailCustomization_MiscTools::GetApplyRampButtonIsEnabled() { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != NULL && IsToolActive(FName("Ramp"))) { return LandscapeEdMode->CanApplyRampTool(); } return false; }
END_SLATE_FUNCTION_BUILD_OPTIMIZATION FReply FLandscapeEditorDetailCustomization_CopyPaste::OnCopyToGizmoButtonClicked() { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != NULL) { LandscapeEdMode->CopyDataToGizmo(); } return FReply::Handled(); }
bool FLandscapeEditorDetails::IsToolEnabled(FName ToolSetName) const { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != NULL) { if (ToolSetName == "ToolSet_NewLandscape" || LandscapeEdMode->GetLandscapeList().Num() > 0) { return true; } } return false; }
bool FLandscapeToolKit::IsToolEnabled(FName ToolName) const { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode != nullptr) { if (ToolName == "NewLandscape" || LandscapeEdMode->GetLandscapeList().Num() > 0) { return true; } } return false; }
bool FLandscapeEditorDetails::GetToolSelectorIsVisible() const { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode && LandscapeEdMode->CurrentToolSet) { if (!IsToolActive("ToolSet_NewLandscape") || LandscapeEdMode->GetLandscapeList().Num() > 0) { return true; } } return false; }
void FLandscapeEditorDetails::OnChangeTargetLandscape(TWeakObjectPtr<ULandscapeInfo> LandscapeInfo) { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode) { LandscapeEdMode->CurrentToolTarget.LandscapeInfo = LandscapeInfo.Get(); LandscapeEdMode->UpdateTargetList(); if (LandscapeEdMode->CurrentGizmoActor.IsValid()) { LandscapeEdMode->CurrentGizmoActor->SetTargetLandscape(LandscapeEdMode->CurrentToolTarget.LandscapeInfo.Get()); } } }
bool FLandscapeToolKit::IsModeEnabled(FName ModeName) const { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode) { // Manage is the only mode enabled if we have no landscape if (ModeName == "ToolMode_Manage" || LandscapeEdMode->GetLandscapeList().Num() > 0) { return true; } } return false; }
void FLandscapeEditorDetails::OnChangeTargetLandscape(TWeakObjectPtr<ULandscapeInfo> LandscapeInfo) { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode) { LandscapeEdMode->CurrentToolTarget.LandscapeInfo = LandscapeInfo.Get(); LandscapeEdMode->UpdateTargetList(); // force a Leave and Enter the current tool, in case it has something about the current landscape cached LandscapeEdMode->SetCurrentTool(LandscapeEdMode->CurrentToolIndex); if (LandscapeEdMode->CurrentGizmoActor.IsValid()) { LandscapeEdMode->CurrentGizmoActor->SetTargetLandscape(LandscapeEdMode->CurrentToolTarget.LandscapeInfo.Get()); } } }
bool ALandscapePlaceholder::TeleportTo(const FVector& DestLocation, const FRotator& DestRotation, bool bIsATest /*= false*/, bool bNoCheck /*= false*/) { bool bResult = Super::TeleportTo(DestLocation, DestRotation, bIsATest, bNoCheck); GLevelEditorModeTools().ActivateMode(FBuiltinEditorModes::EM_Landscape); FEdModeLandscape* EdMode = (FEdModeLandscape*)GLevelEditorModeTools().GetActiveMode(FBuiltinEditorModes::EM_Landscape); EdMode->UISettings->NewLandscape_Location = GetActorLocation(); EdMode->UISettings->NewLandscape_Rotation = GetActorRotation(); EdMode->SetCurrentTool("NewLandscape"); return bResult; }
AActor* UActorFactoryLandscape::SpawnActor(UObject* Asset, ULevel* InLevel, const FVector& Location, const FRotator& Rotation, EObjectFlags ObjectFlags, const FName& Name) { GLevelEditorModeTools().ActivateMode(FBuiltinEditorModes::EM_Landscape); FEdModeLandscape* EdMode = (FEdModeLandscape*)GLevelEditorModeTools().GetActiveMode(FBuiltinEditorModes::EM_Landscape); EdMode->UISettings->NewLandscape_Location = Location; EdMode->UISettings->NewLandscape_Rotation = Rotation; EdMode->SetCurrentTool("NewLandscape"); FActorSpawnParameters SpawnInfo; SpawnInfo.OverrideLevel = InLevel; SpawnInfo.ObjectFlags = ObjectFlags; SpawnInfo.Name = Name; return InLevel->OwningWorld->SpawnActor(ALandscapePlaceholder::StaticClass(), &Location, &Rotation, SpawnInfo); }
TSharedRef<SWidget> FLandscapeEditorDetails::GetTargetLandscapeMenu() { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); if (LandscapeEdMode) { FMenuBuilder MenuBuilder(true, NULL); const TArray<FLandscapeListInfo>& LandscapeList = LandscapeEdMode->GetLandscapeList(); for (auto It = LandscapeList.CreateConstIterator(); It; It++) { FUIAction Action = FUIAction(FExecuteAction::CreateStatic(&FLandscapeEditorDetails::OnChangeTargetLandscape, TWeakObjectPtr<ULandscapeInfo>(It->Info))); MenuBuilder.AddMenuEntry( FText::FromString( It->Info->GetLandscapeProxy()->GetActorLabel() ), FText(), FSlateIcon(), Action); } return MenuBuilder.MakeWidget(); } return SNullWidget::NullWidget; }
void FLandscapeEditorDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) { FEdModeLandscape* LandscapeEdMode = GetEditorMode(); CommandList = LandscapeEdMode->GetUICommandList(); static const FLinearColor BorderColor = FLinearColor(0.2f, 0.2f, 0.2f, 0.2f); static const FSlateBrush* BorderStyle = FEditorStyle::GetBrush("DetailsView.GroupSection"); IDetailCategoryBuilder& LandscapeEditorCategory = DetailBuilder.EditCategory("LandscapeEditor", FText::GetEmpty(), ECategoryPriority::TypeSpecific); LandscapeEditorCategory.AddCustomRow(FText::GetEmpty()) .Visibility(TAttribute<EVisibility>::Create(TAttribute<EVisibility>::FGetter::CreateStatic(&FLandscapeEditorDetails::GetTargetLandscapeSelectorVisibility))) [ SNew(SComboButton) .OnGetMenuContent_Static(&FLandscapeEditorDetails::GetTargetLandscapeMenu) .ButtonContent() [ SNew(STextBlock) .Text_Static(&FLandscapeEditorDetails::GetTargetLandscapeName) ] ]; FToolSelectorBuilder ToolBrushSelectorButtons(CommandList, FMultiBoxCustomization::None); { FUIAction ToolSelectorUIAction; //ToolSelectorUIAction.IsActionVisibleDelegate.BindSP(this, &FLandscapeEditorDetails::GetToolSelectorIsVisible); ToolBrushSelectorButtons.AddComboButton( ToolSelectorUIAction, FOnGetContent::CreateSP(this, &FLandscapeEditorDetails::GetToolSelector), LOCTEXT("ToolSelector", "Tool"), TAttribute<FText>(this, &FLandscapeEditorDetails::GetCurrentToolName), LOCTEXT("ToolSelector.Tooltip", "Select Tool"), TAttribute<FSlateIcon>(this, &FLandscapeEditorDetails::GetCurrentToolIcon) ); FUIAction BrushSelectorUIAction; BrushSelectorUIAction.IsActionVisibleDelegate.BindSP(this, &FLandscapeEditorDetails::GetBrushSelectorIsVisible); ToolBrushSelectorButtons.AddComboButton( BrushSelectorUIAction, FOnGetContent::CreateSP(this, &FLandscapeEditorDetails::GetBrushSelector), LOCTEXT("BrushSelector", "Brush"), TAttribute<FText>(this, &FLandscapeEditorDetails::GetCurrentBrushName), LOCTEXT("BrushSelector.Tooltip", "Select Brush"), TAttribute<FSlateIcon>(this, &FLandscapeEditorDetails::GetCurrentBrushIcon) ); FUIAction BrushFalloffSelectorUIAction; BrushFalloffSelectorUIAction.IsActionVisibleDelegate.BindSP(this, &FLandscapeEditorDetails::GetBrushFalloffSelectorIsVisible); ToolBrushSelectorButtons.AddComboButton( BrushFalloffSelectorUIAction, FOnGetContent::CreateSP(this, &FLandscapeEditorDetails::GetBrushFalloffSelector), LOCTEXT("BrushFalloffSelector", "Falloff"), TAttribute<FText>(this, &FLandscapeEditorDetails::GetCurrentBrushFalloffName), LOCTEXT("BrushFalloffSelector.Tooltip", "Select Brush Falloff Type"), TAttribute<FSlateIcon>(this, &FLandscapeEditorDetails::GetCurrentBrushFalloffIcon) ); } LandscapeEditorCategory.AddCustomRow(FText::GetEmpty()) .Visibility(TAttribute<EVisibility>::Create(TAttribute<EVisibility>::FGetter::CreateSP(this, &FLandscapeEditorDetails::GetToolSelectorVisibility))) [ ToolBrushSelectorButtons.MakeWidget() ]; // Tools: Customization_NewLandscape = MakeShareable(new FLandscapeEditorDetailCustomization_NewLandscape); Customization_NewLandscape->CustomizeDetails(DetailBuilder); Customization_ResizeLandscape = MakeShareable(new FLandscapeEditorDetailCustomization_ResizeLandscape); Customization_ResizeLandscape->CustomizeDetails(DetailBuilder); Customization_CopyPaste = MakeShareable(new FLandscapeEditorDetailCustomization_CopyPaste); Customization_CopyPaste->CustomizeDetails(DetailBuilder); Customization_MiscTools = MakeShareable(new FLandscapeEditorDetailCustomization_MiscTools); Customization_MiscTools->CustomizeDetails(DetailBuilder); // Brushes: Customization_AlphaBrush = MakeShareable(new FLandscapeEditorDetailCustomization_AlphaBrush); Customization_AlphaBrush->CustomizeDetails(DetailBuilder); // Target Layers: Customization_TargetLayers = MakeShareable(new FLandscapeEditorDetailCustomization_TargetLayers); Customization_TargetLayers->CustomizeDetails(DetailBuilder); }