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 "LayersPrivatePCH.h"
|
2014-11-12 04:43:54 -05:00
|
|
|
#include "Layers/Layer.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
#include "ScopedTransaction.h"
|
|
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "Layer"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FActorLayerViewModel::FActorLayerViewModel( const TWeakObjectPtr< ULayer >& InLayer, const TArray< TWeakObjectPtr< AActor > >& InActors, const TSharedRef< ILayers >& InWorldLayers, const TWeakObjectPtr< UEditorEngine >& InEditor )
|
|
|
|
|
: WorldLayers( InWorldLayers )
|
|
|
|
|
, Editor( InEditor )
|
2014-07-31 15:43:08 -04:00
|
|
|
, Layer( InLayer )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
Actors.Append( InActors );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FActorLayerViewModel::Initialize()
|
|
|
|
|
{
|
|
|
|
|
WorldLayers->OnLayersChanged().AddSP( this, &FActorLayerViewModel::OnLayersChanged );
|
|
|
|
|
|
|
|
|
|
if ( Editor.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
Editor->RegisterForUndo(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FActorLayerViewModel::~FActorLayerViewModel()
|
|
|
|
|
{
|
|
|
|
|
WorldLayers->OnLayersChanged().RemoveAll( this );
|
|
|
|
|
|
|
|
|
|
if ( Editor.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
Editor->UnregisterForUndo(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FName FActorLayerViewModel::GetFName() const
|
|
|
|
|
{
|
|
|
|
|
if( !Layer.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
return NAME_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Layer->LayerName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-01-07 09:52:40 -05:00
|
|
|
FText FActorLayerViewModel::GetName() const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
if( !Layer.IsValid() )
|
|
|
|
|
{
|
2015-01-07 09:52:40 -05:00
|
|
|
return LOCTEXT("Invalid layer Name", "");
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2015-01-07 09:52:40 -05:00
|
|
|
return FText::FromName(Layer->LayerName);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool FActorLayerViewModel::IsVisible() const
|
|
|
|
|
{
|
|
|
|
|
if( !Layer.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Layer->bIsVisible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FActorLayerViewModel::OnLayersChanged( const ELayersAction::Type Action, const TWeakObjectPtr< ULayer >& ChangedLayer, const FName& ChangedProperty )
|
|
|
|
|
{
|
|
|
|
|
if( Action != ELayersAction::Modify && Action != ELayersAction::Reset )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( ChangedLayer.IsValid() && ChangedLayer != Layer )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Changed.Broadcast();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FActorLayerViewModel::Refresh()
|
|
|
|
|
{
|
|
|
|
|
OnLayersChanged( ELayersAction::Reset, NULL, NAME_None );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|