2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# include "LandscapeEditorPrivatePCH.h"
# include "LandscapeEditorCommands.h"
# include "LandscapeEdMode.h"
# include "LandscapeEditorClasses.h"
2014-04-23 20:18:55 -04:00
2014-03-14 14:13:41 -04:00
# include "LandscapeEditorDetails.h"
# include "LandscapeEditorDetailCustomizations.h"
# include "PropertyEditorModule.h"
# include "PropertyEditorDelegates.h"
# include "Editor/LevelEditor/Public/LevelEditor.h"
2014-10-16 05:16:44 -04:00
# include "Landscape.h"
# include "LandscapeRender.h"
2014-05-22 07:52:43 -04:00
2014-03-14 14:13:41 -04:00
# define LOCTEXT_NAMESPACE "LandscapeEditor"
class FLandscapeEditorModule : public ILandscapeEditorModule
{
public :
/**
* Called right after the module ' s DLL has been loaded and the module object has been created
*/
2014-06-13 06:14:46 -04:00
virtual void StartupModule ( ) override
2014-03-14 14:13:41 -04:00
{
FLandscapeEditorCommands : : Register ( ) ;
// register the editor mode
2014-06-18 10:16:16 -04:00
FEditorModeRegistry : : Get ( ) . RegisterMode < FEdModeLandscape > (
FBuiltinEditorModes : : EM_Landscape ,
NSLOCTEXT ( " EditorModes " , " LandscapeMode " , " Landscape " ) ,
FSlateIcon ( FEditorStyle : : GetStyleSetName ( ) , " LevelEditor.LandscapeMode " , " LevelEditor.LandscapeMode.Small " ) ,
true ,
300
) ;
2014-03-14 14:13:41 -04:00
FPropertyEditorModule & PropertyModule = FModuleManager : : GetModuleChecked < FPropertyEditorModule > ( " PropertyEditor " ) ;
2014-06-04 12:11:33 -04:00
PropertyModule . RegisterCustomClassLayout ( " LandscapeEditorObject " , FOnGetDetailCustomizationInstance : : CreateStatic ( & FLandscapeEditorDetails : : MakeInstance ) ) ;
2014-06-04 10:16:14 -04:00
PropertyModule . RegisterCustomPropertyTypeLayout ( " GizmoImportLayer " , FOnGetPropertyTypeCustomizationInstance : : CreateStatic ( & FLandscapeEditorStructCustomization_FGizmoImportLayer : : MakeInstance ) ) ;
PropertyModule . RegisterCustomPropertyTypeLayout ( " LandscapeImportLayer " , FOnGetPropertyTypeCustomizationInstance : : CreateStatic ( & FLandscapeEditorStructCustomization_FLandscapeImportLayer : : MakeInstance ) ) ;
2014-03-14 14:13:41 -04:00
TSharedRef < FUICommandList > CommandList = MakeShareable ( new FUICommandList ) ;
const FLandscapeEditorCommands & LandscapeActions = FLandscapeEditorCommands : : Get ( ) ;
CommandList - > MapAction ( LandscapeActions . ViewModeNormal , FExecuteAction : : CreateStatic ( & ChangeLandscapeViewMode , ELandscapeViewMode : : Normal ) , FCanExecuteAction ( ) , FIsActionChecked : : CreateStatic ( & IsLandscapeViewModeSelected , ELandscapeViewMode : : Normal ) ) ;
CommandList - > MapAction ( LandscapeActions . ViewModeLOD , FExecuteAction : : CreateStatic ( & ChangeLandscapeViewMode , ELandscapeViewMode : : LOD ) , FCanExecuteAction ( ) , FIsActionChecked : : CreateStatic ( & IsLandscapeViewModeSelected , ELandscapeViewMode : : LOD ) ) ;
CommandList - > MapAction ( LandscapeActions . ViewModeLayerDensity , FExecuteAction : : CreateStatic ( & ChangeLandscapeViewMode , ELandscapeViewMode : : LayerDensity ) , FCanExecuteAction ( ) , FIsActionChecked : : CreateStatic ( & IsLandscapeViewModeSelected , ELandscapeViewMode : : LayerDensity ) ) ;
CommandList - > MapAction ( LandscapeActions . ViewModeLayerDebug , FExecuteAction : : CreateStatic ( & ChangeLandscapeViewMode , ELandscapeViewMode : : DebugLayer ) , FCanExecuteAction ( ) , FIsActionChecked : : CreateStatic ( & IsLandscapeViewModeSelected , ELandscapeViewMode : : DebugLayer ) ) ;
2014-12-08 09:30:58 -05:00
CommandList - > MapAction ( LandscapeActions . ViewModeWireframeOnTop , FExecuteAction : : CreateStatic ( & ChangeLandscapeViewMode , ELandscapeViewMode : : WireframeOnTop ) , FCanExecuteAction ( ) , FIsActionChecked : : CreateStatic ( & IsLandscapeViewModeSelected , ELandscapeViewMode : : WireframeOnTop ) ) ;
2014-03-14 14:13:41 -04:00
TSharedRef < FExtender > ViewportMenuExtender = MakeShareable ( new FExtender ) ;
2014-04-02 18:09:23 -04:00
ViewportMenuExtender - > AddMenuExtension ( " LevelViewportLandscape " , EExtensionHook : : First , CommandList , FMenuExtensionDelegate : : CreateStatic ( & ConstructLandscapeViewportMenu ) ) ;
2014-03-14 14:13:41 -04:00
FLevelEditorModule & LevelEditorModule = FModuleManager : : LoadModuleChecked < FLevelEditorModule > ( " LevelEditor " ) ;
LevelEditorModule . GetMenuExtensibilityManager ( ) - > AddExtender ( ViewportMenuExtender ) ;
// Actor Factories
2015-02-03 05:40:57 -05:00
UActorFactoryLandscape * LandscapeActorFactory = NewObject < UActorFactoryLandscape > ( ) ;
2014-03-14 14:13:41 -04:00
LandscapeActorFactory - > NewActorClass = ALandscape : : StaticClass ( ) ;
GEditor - > ActorFactories . Add ( LandscapeActorFactory ) ;
2015-02-03 05:40:57 -05:00
UActorFactoryLandscape * LandscapeProxyActorFactory = NewObject < UActorFactoryLandscape > ( ) ;
2014-03-14 14:13:41 -04:00
LandscapeProxyActorFactory - > NewActorClass = ALandscapeProxy : : StaticClass ( ) ;
GEditor - > ActorFactories . Add ( LandscapeProxyActorFactory ) ;
}
/**
* Called before the module is unloaded , right before the module object is destroyed .
*/
2014-06-13 06:14:46 -04:00
virtual void ShutdownModule ( ) override
2014-03-14 14:13:41 -04:00
{
FLandscapeEditorCommands : : Unregister ( ) ;
// unregister the editor mode
2014-06-18 10:16:16 -04:00
FEditorModeRegistry : : Get ( ) . UnregisterMode ( FBuiltinEditorModes : : EM_Landscape ) ;
2014-03-14 14:13:41 -04:00
}
static void ConstructLandscapeViewportMenu ( FMenuBuilder & MenuBuilder )
{
2014-04-02 18:09:23 -04:00
struct Local
{
2014-05-29 17:14:20 -04:00
static void BuildLandscapeVisualizersMenu ( FMenuBuilder & InMenuBuilder )
2014-04-02 18:09:23 -04:00
{
2014-03-14 14:13:41 -04:00
const FLandscapeEditorCommands & LandscapeActions = FLandscapeEditorCommands : : Get ( ) ;
2014-05-29 17:14:20 -04:00
InMenuBuilder . BeginSection ( " LandscapeVisualizers " , LOCTEXT ( " LandscapeHeader " , " Landscape Visualizers " ) ) ;
2014-04-02 18:09:23 -04:00
{
2014-05-29 17:14:20 -04:00
InMenuBuilder . AddMenuEntry ( LandscapeActions . ViewModeNormal , NAME_None , LOCTEXT ( " LandscapeViewModeNormal " , " Normal " ) ) ;
InMenuBuilder . AddMenuEntry ( LandscapeActions . ViewModeLOD , NAME_None , LOCTEXT ( " LandscapeViewModeLOD " , " LOD " ) ) ;
InMenuBuilder . AddMenuEntry ( LandscapeActions . ViewModeLayerDensity , NAME_None , LOCTEXT ( " LandscapeViewModeLayerDensity " , " Layer Density " ) ) ;
InMenuBuilder . AddMenuEntry ( LandscapeActions . ViewModeLayerDebug , NAME_None , LOCTEXT ( " LandscapeViewModeLayerDebug " , " Layer Debug " ) ) ;
2014-12-08 09:30:58 -05:00
InMenuBuilder . AddMenuEntry ( LandscapeActions . ViewModeWireframeOnTop , NAME_None , LOCTEXT ( " LandscapeViewModeWireframeOnTop " , " Wireframe on Top " ) ) ;
2014-04-02 18:09:23 -04:00
}
2014-05-29 17:14:20 -04:00
InMenuBuilder . EndSection ( ) ;
2014-04-02 18:09:23 -04:00
}
} ;
MenuBuilder . AddSubMenu ( LOCTEXT ( " LandscapeSubMenu " , " Visualizers " ) , LOCTEXT ( " LandscapeSubMenu_ToolTip " , " Select a Landscape visualiser " ) , FNewMenuDelegate : : CreateStatic ( & Local : : BuildLandscapeVisualizersMenu ) ) ;
2014-03-14 14:13:41 -04:00
}
static void ChangeLandscapeViewMode ( ELandscapeViewMode : : Type ViewMode )
{
GLandscapeViewMode = ViewMode ;
}
static bool IsLandscapeViewModeSelected ( ELandscapeViewMode : : Type ViewMode )
{
return GLandscapeViewMode = = ViewMode ;
}
} ;
IMPLEMENT_MODULE ( FLandscapeEditorModule , LandscapeEditor ) ;
# undef LOCTEXT_NAMESPACE