You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
#include "UnrealEd.h"
|
|
#include "ScopedTransaction.h"
|
|
|
|
FScopedTransaction::FScopedTransaction(const FText& SessionName, const bool bShouldActuallyTransact )
|
|
{
|
|
Construct( TEXT(""), SessionName, NULL, bShouldActuallyTransact);
|
|
}
|
|
|
|
FScopedTransaction::FScopedTransaction(const TCHAR* TransactionContext, const FText& SessionName, UObject* PrimaryObject, const bool bShouldActuallyTransact)
|
|
{
|
|
Construct( TransactionContext, SessionName, PrimaryObject, bShouldActuallyTransact);
|
|
}
|
|
|
|
void FScopedTransaction::Construct (const TCHAR* TransactionContext, const FText& SessionName, UObject* PrimaryObject, const bool bShouldActuallyTransact)
|
|
{
|
|
if( bShouldActuallyTransact && GEditor && GEditor->Trans && !GEditor->bIsSimulatingInEditor)
|
|
{
|
|
FSlateApplication::Get().OnLogSlateEvent(EEventLog::BeginTransaction, SessionName );
|
|
Index = GEditor->BeginTransaction( TransactionContext, SessionName, PrimaryObject );
|
|
check( IsOutstanding() );
|
|
}
|
|
else
|
|
{
|
|
Index = -1;
|
|
}
|
|
}
|
|
|
|
FScopedTransaction::~FScopedTransaction()
|
|
{
|
|
if ( IsOutstanding() )
|
|
{
|
|
FSlateApplication::Get().OnLogSlateEvent(EEventLog::EndTransaction);
|
|
GEditor->EndTransaction();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Cancels the transaction. Reentrant.
|
|
*/
|
|
void FScopedTransaction::Cancel()
|
|
{
|
|
if ( IsOutstanding() )
|
|
{
|
|
GEditor->CancelTransaction( Index );
|
|
Index = -1;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return true if the transaction is still outstanding (that is, has not been cancelled).
|
|
*/
|
|
bool FScopedTransaction::IsOutstanding() const
|
|
{
|
|
return Index >= 0;
|
|
}
|