// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Linq;
using Tools.DotNETCommon;
namespace UnrealBuildTool
{
///
///
///
public enum LocalizationTargetDescriptorLoadingPolicy
{
///
///
///
Never,
///
///
///
Always,
///
///
///
Editor,
///
///
///
Game,
///
///
///
PropertyNames,
///
///
///
ToolTips,
};
///
///
///
[DebuggerDisplay("Name={Name}")]
public class LocalizationTargetDescriptor
{
///
/// Name of this target
///
public readonly string Name;
///
/// When should the localization data associated with a target should be loaded?
///
public LocalizationTargetDescriptorLoadingPolicy LoadingPolicy;
///
/// Constructor
///
/// Name of the target
/// When should the localization data associated with a target should be loaded?
public LocalizationTargetDescriptor(string InName, LocalizationTargetDescriptorLoadingPolicy InLoadingPolicy)
{
Name = InName;
LoadingPolicy = InLoadingPolicy;
}
///
/// Constructs a LocalizationTargetDescriptor from a Json object
///
///
/// The new localization target descriptor
public static LocalizationTargetDescriptor FromJsonObject(JsonObject InObject)
{
return new LocalizationTargetDescriptor(InObject.GetStringField("Name"), InObject.GetEnumField("LoadingPolicy"));
}
///
/// Write this target to a JsonWriter
///
/// Writer to output to
void Write(JsonWriter Writer)
{
Writer.WriteObjectStart();
Writer.WriteValue("Name", Name);
Writer.WriteValue("LoadingPolicy", LoadingPolicy.ToString());
Writer.WriteObjectEnd();
}
///
/// Write an array of target descriptors
///
/// The Json writer to output to
/// Name of the array
/// Array of targets
public static void WriteArray(JsonWriter Writer, string Name, LocalizationTargetDescriptor[] Targets)
{
if (Targets != null && Targets.Length > 0)
{
Writer.WriteArrayStart(Name);
foreach (LocalizationTargetDescriptor Target in Targets)
{
Target.Write(Writer);
}
Writer.WriteArrayEnd();
}
}
}
}