Esempio n. 1
0
bool FProjectManager::SetPluginEnabled(const FString& PluginName, bool bEnabled, FText& OutFailReason, const FString& MarketplaceURL)
{
	// Don't go any further if there's no project loaded
	if(!CurrentProject.IsValid())
	{
		OutFailReason = LOCTEXT("NoProjectLoaded", "No project is currently loaded");
		return false;
	}

	// Find or create the index of any existing reference in the project descriptor
	int PluginRefIdx = 0;
	for(;;PluginRefIdx++)
	{
		if(PluginRefIdx == CurrentProject->Plugins.Num())
		{
			PluginRefIdx = CurrentProject->Plugins.Add(FPluginReferenceDescriptor(PluginName, bEnabled, MarketplaceURL));
			break;
		}
		else if(CurrentProject->Plugins[PluginRefIdx].Name == PluginName)
		{
			CurrentProject->Plugins[PluginRefIdx].bEnabled = bEnabled;
			break;
		}
	}

	// If the current plugin reference is the default, just remove it from the list
	const FPluginReferenceDescriptor* PluginRef = &CurrentProject->Plugins[PluginRefIdx];
	if(PluginRef->WhitelistPlatforms.Num() == 0 && PluginRef->BlacklistPlatforms.Num() == 0)
	{
		// We alway need to be explicit about installed plugins, because they'll be auto-enabled again if we're not.
		TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(PluginName);
		if(!Plugin.IsValid() || !Plugin->GetDescriptor().bInstalled)
		{
			// Get the default list of enabled plugins
			TArray<FString> DefaultEnabledPlugins;
			GetDefaultEnabledPlugins(DefaultEnabledPlugins, false);

			// Check the enabled state is the same in that
			if(DefaultEnabledPlugins.Contains(PluginName) == bEnabled)
			{
				CurrentProject->Plugins.RemoveAt(PluginRefIdx);
				PluginRefIdx = INDEX_NONE;
			}
		}
	}

	// Mark project as dirty
	bIsCurrentProjectDirty = true;

	return true;
}
Esempio n. 2
0
bool FProjectManager::SetPluginEnabled(const FString& PluginName, bool bEnabled, FText& OutFailReason)
{
	// Don't go any further if there's no project loaded
	if(!CurrentProject.IsValid())
	{
		OutFailReason = LOCTEXT("NoProjectLoaded", "No project is currently loaded");
		return false;
	}

	// Find or create the index of any existing reference in the project descriptor
	int PluginRefIdx = 0;
	for(;;PluginRefIdx++)
	{
		if(PluginRefIdx == CurrentProject->Plugins.Num())
		{
			PluginRefIdx = CurrentProject->Plugins.Add(FPluginReferenceDescriptor(PluginName, bEnabled));
			break;
		}
		else if(CurrentProject->Plugins[PluginRefIdx].Name == PluginName)
		{
			CurrentProject->Plugins[PluginRefIdx].bEnabled = bEnabled;
			break;
		}
	}

	// If the current plugin reference is the default, just remove it from the list
	const FPluginReferenceDescriptor* PluginRef = &CurrentProject->Plugins[PluginRefIdx];
	if(PluginRef->WhitelistPlatforms.Num() == 0 && PluginRef->BlacklistPlatforms.Num() == 0)
	{
		// Get the default list of enabled plugins
		TArray<FString> DefaultEnabledPlugins;
		GetDefaultEnabledPlugins(DefaultEnabledPlugins);

		// Check the enabled state is the same in that
		if(DefaultEnabledPlugins.Contains(PluginName) == bEnabled)
		{
			CurrentProject->Plugins.RemoveAt(PluginRefIdx);
			PluginRefIdx = INDEX_NONE;
		}
	}

	// Try to save the project file
	if(!CurrentProject->Save(*FPaths::GetProjectFilePath(), OutFailReason))
	{
		return false;
	}

	// Flag that a restart is required and return
	bRestartRequired = true;
	return true;
}
Esempio n. 3
0
void FProjectManager::GetEnabledPlugins(TArray<FString>& OutPluginNames) const
{
	// Get the default list of plugin names
	GetDefaultEnabledPlugins(OutPluginNames, true);

	// Modify that with the list of plugins in the project file
	const FProjectDescriptor *Project = GetCurrentProject();
	if(Project != NULL)
	{
		for(const FPluginReferenceDescriptor& Plugin: Project->Plugins)
		{
			if(Plugin.IsEnabledForPlatform(FPlatformMisc::GetUBTPlatform()))
			{
				OutPluginNames.AddUnique(Plugin.Name);
			}
			else
			{
				OutPluginNames.Remove(Plugin.Name);
			}
		}
	}
}