void FActorLayerCollectionViewModel::OnLayersChanged( const ELayersAction::Type Action, const TWeakObjectPtr< ULayer >& ChangedLayer, const FName& ChangedProperty )
{
	check( !bIsRefreshing );
	bIsRefreshing = true;

	switch ( Action )
	{
		case ELayersAction::Add:
			{
				if( ChangedLayer.IsValid() )
				{
					TSharedRef< FActorLayerViewModel > NewFLayer = FActorLayerViewModel::Create( ChangedLayer, Actors, WorldLayers, Editor );

					if( DoAllActorsBelongtoLayer( NewFLayer ) )
					{
						Layers.Add( NewFLayer );
						SortLayers();
					}
				}
				else
				{
					RefreshLayers();
				}
			}
			break;

		case ELayersAction::Rename:
			{
				SortLayers();
			}
			break;

		case ELayersAction::Modify:
		case ELayersAction::Delete:
		case ELayersAction::Reset:
		default:
			{
				RefreshLayers();
			}
			break;
	}

	LayersChanged.Broadcast( Action, ChangedLayer, ChangedProperty );
	bIsRefreshing = false;
}
void FActorLayerCollectionViewModel::Initialize()
{
	WorldLayers->OnLayersChanged().AddSP( this, &FActorLayerCollectionViewModel::OnLayersChanged );

	if ( Editor.IsValid() )
	{
		Editor->RegisterForUndo( this );
	}

	RefreshLayers();
}
Exemplo n.º 3
0
void CLayerDlg::OnLayerUp() 
{
	// Get selection
	int Sel = m_layerListBox.GetCurSel();
	if (Sel == -1) return;

	// Bounds check
	if (Sel == 0) return;
	if (Sel == m_layerListBox.GetCount() - 1) return;

	// Delete it and move it down one space
	CLayer* pLayer = (CLayer*)m_layerListBox.GetItemDataPtr(Sel);

	if (pLayer->m_layerType == LAYER_NONFRAME) return;

	m_layerListBox.DeleteString(Sel);
	int Item = m_layerListBox.InsertString(Sel - 1, pLayer->GetName());
	m_layerListBox.SetItemDataPtr(Item, (void*)pLayer);

	// Get the layerlist, remove all items
	CLayerList* pLayerList = &layout_editor->layout->layers;
	while (pLayerList->GetCount() > 0)
		pLayerList->RemoveHead();

	// Add the layers back into the layerlist, in the order they are in the listbox
	CLayer *j;
	for (int i = 0; i < m_layerListBox.GetCount(); i++) {
		j = (CLayer*)m_layerListBox.GetItemDataPtr(i);
		pLayerList->AddHead(j);
	}

	layout_editor->layout->SetChanged(true);
	layout_editor->m_bUpdateFrame = true;
	layout_editor->Invalidate();

	m_layerListBox.SetRedraw();
	m_layerListBox.Invalidate();
	Invalidate();
	RefreshLayers();
}