コード例 #1
0
ファイル: UnrealEdEngine.cpp プロジェクト: johndpope/UE4
void UUnrealEdEngine::OnPackageCheckedOut(const FSourceControlOperationRef& SourceControlOp, ECommandResult::Type ResultType, TWeakObjectPtr<UPackage> Package)
{
	if (Package.IsValid())
	{
		// Get the source control state of the package
		ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
		FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(Package.Get(), EStateCacheUsage::Use);

		FFormatNamedArguments Arguments;
		Arguments.Add(TEXT("Package"), FText::FromString(Package->GetName()));

		if (ResultType == ECommandResult::Succeeded)
		{
			if (SourceControlState.IsValid() && SourceControlState->IsCheckedOut())
	{
				FNotificationInfo Notification(FText::Format(NSLOCTEXT("SourceControl", "AutoCheckOutNotification", "Package '{Package}' automatically checked out."), Arguments));
				Notification.bFireAndForget = true;
				Notification.ExpireDuration = 4.0f;
				Notification.bUseThrobber = true;

				FSlateNotificationManager::Get().AddNotification(Notification);

				return;
			}
		}

		FNotificationInfo ErrorNotification(FText::Format(NSLOCTEXT("SourceControl", "AutoCheckOutFailedNotification", "Unable to automatically check out Package '{Package}'."), Arguments));
		ErrorNotification.bFireAndForget = true;
		ErrorNotification.ExpireDuration = 4.0f;
		ErrorNotification.bUseThrobber = true;

		FSlateNotificationManager::Get().AddNotification(ErrorNotification);

		// Automatic checkout failed - pop up the notification for manual checkout
		PackageToNotifyState.Add(Package, SourceControlState->CanCheckout() ? NS_PendingPrompt : NS_PendingWarning);
		bNeedToPromptForCheckout = true;
	}
}