Files
UnrealEngineUWP/Engine/Source/Runtime/Projects/Public/PluginDescriptor.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

120 lines
3.9 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Projects.h"
#include "ModuleDescriptor.h"
/**
* Version numbers for plugin descriptors.
*/
namespace EPluginDescriptorVersion
{
enum Type
{
Invalid = 0,
Initial = 1,
NameHash = 2,
ProjectPluginUnification = 3,
// !!!!!!!!!! IMPORTANT: Remember to also update LatestPluginDescriptorFileVersion in Plugins.cs (and Plugin system documentation) when this changes!!!!!!!!!!!
// -----<new versions can be added before this line>-------------------------------------------------
// - this needs to be the last line (see note below)
LatestPlusOne,
Latest = LatestPlusOne - 1
};
}
/**
* Descriptor for plugins. Contains all the information contained within a .uplugin file.
*/
struct PROJECTS_API FPluginDescriptor
{
/** Descriptor version number */
int32 FileVersion;
/** Version number for the plugin. The version number must increase with every version of the plugin, so that the system
can determine whether one version of a plugin is newer than another, or to enforce other requirements. This version
number is not displayed in front-facing UI. Use the VersionName for that. */
int32 Version;
/** Name of the version for this plugin. This is the front-facing part of the version number. It doesn't need to match
the version number numerically, but should be updated when the version number is increased accordingly. */
FString VersionName;
/** Friendly name of the plugin */
FString FriendlyName;
/** Description of the plugin */
FString Description;
/** The name of the category this plugin */
FString Category;
/** The company or individual who created this plugin. This is an optional field that may be displayed in the user interface. */
FString CreatedBy;
/** Hyperlink URL string for the company or individual who created this plugin. This is optional. */
FString CreatedByURL;
/** List of all modules associated with this plugin */
TArray<FModuleDescriptor> Modules;
/** Whether this plugin should be enabled by default for all projects */
bool bEnabledByDefault;
/** Can this plugin contain content? */
bool bCanContainContent;
/** Marks the plugin as beta in the UI */
bool bIsBetaVersion;
/** Constructor. */
FPluginDescriptor();
/** Loads the descriptor from the given file. */
bool Load(const FString& FileName, FText& OutFailReason);
/** Reads the descriptor from the given JSON object */
bool Read(const FJsonObject& Object, FText& OutFailReason);
};
/**
* Descriptor for a plugin reference. Contains the information required to enable or disable a plugin for a given platform.
*/
struct PROJECTS_API FPluginReferenceDescriptor
{
/** Name of the plugin */
FString Name;
/** Whether it should be enabled by default */
bool bEnabled;
/** Description of the plugin for users that do not have it installed. */
FString Description;
/** If enabled, list of platforms for which the plugin should be enabled (or all platforms if blank). */
TArray<FString> WhitelistPlatforms;
/** If enabled, list of platforms for which the plugin should be disabled. */
TArray<FString> BlacklistPlatforms;
/** Constructor */
FPluginReferenceDescriptor(const FString& InName = TEXT(""), bool bInEnabled = false);
/** Determines whether the plugin is enabled for the given platform */
bool IsEnabledForPlatform(const FString& Platform) const;
/** Reads the descriptor from the given JSON object */
bool Read(const FJsonObject& Object, FText& OutFailReason);
/** Reads an array of modules from the given JSON object */
static bool ReadArray(const FJsonObject& Object, const TCHAR* Name, TArray<FPluginReferenceDescriptor>& OutModules, FText& OutFailReason);
/** Writes a descriptor to JSON */
void Write(TJsonWriter<>& Writer) const;
/** Writes an array of modules to JSON */
static void WriteArray(TJsonWriter<>& Writer, const TCHAR* Name, const TArray<FPluginReferenceDescriptor>& Modules);
};