Files
UnrealEngineUWP/Engine/Source/Editor/Layers/Private/LayerViewModel.h

238 lines
7.6 KiB
C
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "CoreMinimal.h"
#include "UObject/WeakObjectPtr.h"
#include "EditorUndoClient.h"
#include "Layers/LayersSubsystem.h"
#include "Layers/Layer.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
class AActor;
class UEditorEngine;
/**
* The non-UI solution specific presentation logic for a single Layer
*/
class FLayerViewModel : public TSharedFromThis< FLayerViewModel >, public FEditorUndoClient
{
public:
/** FLayerViewModel destructor */
virtual ~FLayerViewModel();
/**
* Factory method which creates a new FLayerViewModel object
*
* @param InLayer The layer wrap
* @param InWorldLayers The layer management logic object
* @param InEditor The UEditorEngine to use
*/
static TSharedRef< FLayerViewModel > Create( const TWeakObjectPtr< ULayer >& InLayer, const TWeakObjectPtr< UEditorEngine >& InEditor )
{
TSharedRef< FLayerViewModel > NewLayer( new FLayerViewModel( InLayer, InEditor ) );
NewLayer->Initialize();
return NewLayer;
}
public:
/** @return The Layer's display name as a FName */
FName GetFName() const;
/** @return The Layer's display name as a FString */
FString GetName() const;
/** @return The Layer's display name as a FString */
FText GetNameAsText() const;
/** @return Whether the Layer is visible */
bool IsVisible() const;
/**
* Toggles the specified layer's visibility
*/
void ToggleVisibility();
/**
* Returns whether the layer can be assigned the specified name
*
* @param NewLayerName The Layers new name
* @param OutMessage [OUT] A returned description explaining the boolean result
* @return true then the name can be assigned
*/
bool CanRenameTo( const FName& NewLayerName, FString& OutMessage ) const;
/**
* Renames the Layer to the specified name
*
* @param NewLayerName The Layers new name
*/
void RenameTo( const FName& NewLayerName );
/**
* Returns whether the specified actors can be assigned to the Layer
*
* @param Actors The Actors to check if assignment is valid
* @param OutMessage [OUT] A returned description explaining the boolean result
* @return if true then at least one actor can be assigned;
* If false, either Invalid actors were discovered or all actors are already assigned
*/
bool CanAssignActors( const TArray< TWeakObjectPtr<AActor> > Actors, FText& OutMessage ) const;
/**
* Returns whether the specified actor can be assigned to the Layer
*
* @param Actor The Actor to check if assignment is valid
* @param OutMessage [OUT] A returned description explaining the boolean result
* @return if true then at least one actor can be assigned;
* If false, either the Actor is Invalid or already assigned
*/
bool CanAssignActor( const TWeakObjectPtr<AActor> Actor, FText& OutMessage ) const;
/**
* Appends all of the actors associated with this layer to the specified list
*
* @param InActors the list to append to
*/
void AppendActors( TArray< TWeakObjectPtr< AActor > >& InActors ) const;
/**
* Appends all of the actors associated with this layer to the specified list
*
* @param InActors the list to append to
*/
void AppendActorsOfSpecificType( TArray< TWeakObjectPtr< AActor > >& InActors, const TWeakObjectPtr< UClass >& Class );
/**
* Adds the specified actor to the layer
*
* @param Actor the actor to add
*/
void AddActor( const TWeakObjectPtr<AActor>& Actor );
/**
* Adds the specified actors to the layer
*
* @param Actors The actors to add
* @param LayerName The layer to add the actors to
*/
void AddActors( const TArray< TWeakObjectPtr<AActor> >& Actors );
/**
* Removes the specified actors from the layer
*
* @param Actors The actors to add
* @param LayerName The layer to add the actors to
*/
void RemoveActors( const TArray< TWeakObjectPtr<AActor> >& Actors );
/**
* Removes the specified actor from the layer
*
* @param Actor the actor to remove
*/
void RemoveActor( const TWeakObjectPtr<AActor>& Actor );
/**
* Selects in the Editor all the Actors assigned to the Layer, based on the specified conditions.
*
* @param bSelect if true actors will be selected; If false, actors will be deselected
* @param bNotify if true the editor will be notified of the selection change; If false, the editor will not
* @param bSelectEvenIfHidden if true actors that are hidden will be selected; If false, they will be skipped
* @param Filter Only actors which pass the filters restrictions will be selected
*/
void SelectActors( bool bSelect, bool bNotify, bool bSelectEvenIfHidden, const TSharedPtr< IFilter< const TWeakObjectPtr< AActor >& > >& Filter );
/**
* Retrieves the total number of actors of a specific type currently assigned to the Layer as a FString
*
* @param StatsIndex The array index of the FLayerActorStats
* @return The total actors as a FString
*/
FText GetActorStatTotal( int32 StatsIndex ) const;
/**
* Selected the Actors assigned to the Layer that are of a certain type
*/
void SelectActorsOfSpecificType( const TWeakObjectPtr< UClass >& Class );
/** @return An array of Actor stats regarding the Layer */
const TArray< FLayerActorStats >& GetActorStats() const;
/** Sets the ULayer this viewmodel should represent */
void SetDataSource( const TWeakObjectPtr< ULayer >& InLayer );
/** @return The ULayer this viewmodel represents */
const TWeakObjectPtr< ULayer > GetDataSource();
/********************************************************************
* EVENTS
********************************************************************/
/** Broadcasts whenever the layer changes */
DECLARE_EVENT( FLayerViewModel, FChangedEvent )
FChangedEvent& OnChanged() { return ChangedEvent; }
/** Broadcasts whenever renaming a layer is requested */
DECLARE_EVENT( FLayerViewModel, FRenamedRequestEvent )
FRenamedRequestEvent& OnRenamedRequest() { return RenamedRequestEvent; }
void BroadcastRenameRequest() { RenamedRequestEvent.Broadcast(); }
/** Broadcasts whenever a layer visibility toggle is requested */
DECLARE_EVENT_OneParam( FLayerViewModel, FVisibilityToggledEvent, const TSharedPtr<FLayerViewModel>& )
FVisibilityToggledEvent& OnVisibilityToggled() { return VisibilityToggledEvent; }
private:
/**
* FLayerViewModel Constructor
*
* @param InLayer The Layer to represent
* @param InEditor The UEditorEngine to use
*/
FLayerViewModel( const TWeakObjectPtr< ULayer >& InLayer, const TWeakObjectPtr< UEditorEngine >& InEditor );
/** Initializes the FLayerViewModel for use */
void Initialize();
/** Called when a change occurs regarding Layers */
void OnLayersChanged( const ELayersAction::Type Action, const TWeakObjectPtr< ULayer >& ChangedLayer, const FName& ChangedProperty );
/** Refreshes any cached information in the FLayerViewModel */
void Refresh();
/** Refreshes the cached ActorStats */
void RefreshActorStats();
// Begin FEditorUndoClient
virtual void PostUndo(bool bSuccess) override { Refresh(); }
virtual void PostRedo(bool bSuccess) override { PostUndo(bSuccess); }
// End of FEditorUndoClient
private:
/** The Actor stats of the Layer */
TArray< FLayerActorStats > ActorStats;
/** The UEditorEngine to use */
const TWeakObjectPtr< UEditorEngine > Editor;
/** The layer management logic object */
ULayersSubsystem* WorldLayers;
/** The Layer this object represents */
TWeakObjectPtr< ULayer > Layer;
/** Broadcasts whenever the layer changes */
FChangedEvent ChangedEvent;
/** Broadcasts whenever a rename is requested */
FRenamedRequestEvent RenamedRequestEvent;
/** Broadcasts whenever a layer visibility toggle is requested */
FVisibilityToggledEvent VisibilityToggledEvent;
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
};