Files
UnrealEngineUWP/Engine/Source/Runtime/Projects/Private/PluginManager.h
Ben Marsh a66e704793 Require all plugins to be present for a project to load, rather than attempting to carry on without them. Plugins may define object types, and loading packages without them can cause corruption. Can revisit in the future to allow for 'editor-only' plugins.
Plugin reference in the .uproject file has a "Description" field which allows setting a customizable message if the plugin is not available. Allows distribution of samples which require a plugin, but without including the plugin itself.

[CL 2237188 by Ben Marsh in Main branch]
2014-07-30 13:16:05 -04:00

100 lines
2.7 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "PluginDescriptor.h"
/**
* Enum for where a plugin is loaded from
*/
struct EPluginLoadedFrom
{
enum Type
{
/** Plugin is built-in to the engine */
Engine,
/** Project-specific plugin, stored within a game project directory */
GameProject
};
};
/**
* Instance of a plugin in memory
*/
class FPluginInstance
{
public:
/** The name of the plugin */
FString Name;
/** The filename that the plugin was loaded from */
FString FileName;
/** The plugin's settings */
FPluginDescriptor Descriptor;
/** Where does this plugin live? */
EPluginLoadedFrom::Type LoadedFrom;
/** True if the plugin is marked as enabled */
bool bEnabled;
/**
* FPlugin constructor
*/
FPluginInstance(const FString &FileName, const FPluginDescriptor& InDescriptor, EPluginLoadedFrom::Type InLoadedFrom);
};
/**
* FPluginManager manages available code and content extensions (both loaded and not loaded.)
*/
class FPluginManager : public IPluginManager
{
public:
/** Constructor */
FPluginManager();
/** Destructor */
~FPluginManager();
/** IPluginManager interface */
virtual bool LoadModulesForEnabledPlugins( const ELoadingPhase::Type LoadingPhase ) override;
virtual void SetRegisterMountPointDelegate( const FRegisterMountPointDelegate& Delegate ) override;
virtual bool AreRequiredPluginsAvailable() override;
virtual bool AreEnabledPluginModulesUpToDate() override;
virtual TArray< FPluginStatus > QueryStatusForAllPlugins() const override;
virtual const TArray< FPluginContentFolder >& GetPluginContentFolders() const override;
private:
/** Searches for all plugins on disk and builds up the array of plugin objects. Doesn't load any plugins.
This is called when the plugin manager singleton is first accessed. */
void DiscoverAllPlugins();
/** Sets the bPluginEnabled flag on all plugins found from DiscoverAllPlugins that are enabled in config */
bool ConfigureEnabledPlugins();
/** Gets the instance of a given plugin */
TSharedPtr<FPluginInstance> FindPluginInstance(const FString& Name);
private:
/** All of the plugins that we know about */
TArray< TSharedRef< FPluginInstance > > AllPlugins;
/** All the plugin content folders */
TArray<FPluginContentFolder> ContentFolders;
/** Delegate for mounting content paths. Bound by FPackageName code in CoreUObject, so that we can access
content path mounting functionality from Core. */
FRegisterMountPointDelegate RegisterMountPointDelegate;
/** Set when all the appropriate plugins have been marked as enabled */
bool bHaveConfiguredEnabledPlugins;
/** Set if all the required plugins are available */
bool bHaveAllRequiredPlugins;
};