72 lines
2.1 KiB
C#
72 lines
2.1 KiB
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using Pilz.Cryptography;
|
|
using Pilz.Json.Converters;
|
|
using System.Collections.Specialized;
|
|
using System.ComponentModel;
|
|
|
|
namespace SM64Lib.Patching;
|
|
|
|
/// <summary>
|
|
/// A Profile containing a script and some descriptions.
|
|
/// </summary>
|
|
public class PatchScript
|
|
{
|
|
/// <summary>
|
|
/// The Name of this Script.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[DefaultValue("")]
|
|
public string Name { get; set; } = string.Empty;
|
|
/// <summary>
|
|
/// The Script.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[DefaultValue("")]
|
|
public string Script { get; set; } = string.Empty;
|
|
/// <summary>
|
|
/// Defines the syntax of the script.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public ScriptType Type { get; set; } = ScriptType.TweakScript;
|
|
/// <summary>
|
|
/// The description of this Script.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[DefaultValue("")]
|
|
public string Description { get; set; } = string.Empty;
|
|
/// <summary>
|
|
/// A collection of Reference Assemblies to bind at compiling script.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[JsonProperty("ReferencesV2")]
|
|
public PatchScriptReferences References { get; set; } = [];
|
|
/// <summary>
|
|
/// Defines an uniquie ID to identify this script (e.g. for undo patch).
|
|
/// </summary>
|
|
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
|
|
[JsonConverter(typeof(UniquieIDStringJsonConverter))]
|
|
public UniquieID ID { get; set; } = new();
|
|
/// <summary>
|
|
/// Defines if undo is allowed for this script.
|
|
/// </summary>
|
|
public bool AllowRevert { get; set; } = false;
|
|
|
|
[JsonProperty("References"), Obsolete]
|
|
private StringCollection ReferencesV1
|
|
{
|
|
set
|
|
{
|
|
foreach (var reference in value)
|
|
{
|
|
References.Add(new PatchScriptReference
|
|
{
|
|
Name = reference,
|
|
ReferenceType = PatchScriptReferenceType.AssemblyName
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|