mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 04:23:09 +00:00
Big BYAML and AAMP update!
- AAMP can now save back to YAML! - Added text editor for AAMP editor - AAMP library has been improved signifcantly, now using one library for all versions. - BYAML now uses YAML by default. You can still right click in the editor and export as XML if needed. - BYAML saving speed improved signifcantly. - BYAML now supports reference nodes and works with 3DW byml files. - BYAML can now load shift JIS encoding for japanese characters. - YAML syntax for text editor improved with proper folding and highlighting for certain values.
This commit is contained in:
parent
63130cfad6
commit
c922ff1e4f
38 changed files with 1510 additions and 1269 deletions
|
@ -5,9 +5,8 @@ using Toolbox.Library;
|
|||
using Toolbox.Library.IO;
|
||||
using Toolbox.Library.Forms;
|
||||
using System.Windows.Forms;
|
||||
using aampv1 = AampV1Library;
|
||||
using aampv2 = AampV2Library;
|
||||
using FirstPlugin.Forms;
|
||||
using AampLibraryCSharp;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
|
@ -54,20 +53,16 @@ namespace FirstPlugin
|
|||
|
||||
#region Text Converter Interface
|
||||
public TextFileType TextFileType => TextFileType.Yaml;
|
||||
public bool CanConvertBack => false;
|
||||
public bool CanConvertBack => true;
|
||||
|
||||
public string ConvertToString()
|
||||
{
|
||||
if (aampFileV1 != null)
|
||||
return AampYamlConverter.ToYaml(aampFileV1);
|
||||
else
|
||||
return AampYamlConverter.ToYaml(aampFileV2);
|
||||
return YamlConverter.ToYaml(aampFile);
|
||||
}
|
||||
|
||||
public void ConvertFromString(string text)
|
||||
{
|
||||
if (aampFileV1 != null)
|
||||
AampYamlConverter.ToAamp(aampFileV1, text);
|
||||
aampFile = YamlConverter.FromYaml(text);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -98,54 +93,26 @@ namespace FirstPlugin
|
|||
throw new Exception("File not a valid BFRES file!");
|
||||
|
||||
//Check version instance
|
||||
if (((AAMP)File).aampFileV1 != null)
|
||||
foreach (var val in ((AAMP)File).aampFile.RootNode.childParams)
|
||||
{
|
||||
foreach (var val in ((AAMP)File).aampFileV1.RootNode.childParams)
|
||||
{
|
||||
foreach (var param in val.paramObjects)
|
||||
{
|
||||
switch (param.HashString)
|
||||
{
|
||||
case "grid":
|
||||
GenerateGridData((BFRES)Bfres, param.paramEntries);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var param in ((AAMP)File).aampFileV1.RootNode.paramObjects)
|
||||
foreach (var param in val.paramObjects)
|
||||
{
|
||||
switch (param.HashString)
|
||||
{
|
||||
case "root_grid":
|
||||
case "grid":
|
||||
GenerateGridData((BFRES)Bfres, param.paramEntries);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var val in ((AAMP)File).aampFileV2.RootNode.childParams)
|
||||
{
|
||||
foreach (var param in val.paramObjects)
|
||||
{
|
||||
switch (param.HashString)
|
||||
{
|
||||
case "grid":
|
||||
GenerateGridData((BFRES)Bfres, param.paramEntries);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var param in ((AAMP)File).aampFileV2.RootNode.paramObjects)
|
||||
foreach (var param in ((AAMP)File).aampFile.RootNode.paramObjects)
|
||||
{
|
||||
switch (param.HashString)
|
||||
{
|
||||
switch (param.HashString)
|
||||
{
|
||||
case "root_grid":
|
||||
GenerateGridData((BFRES)Bfres, param.paramEntries);
|
||||
break;
|
||||
}
|
||||
case "root_grid":
|
||||
GenerateGridData((BFRES)Bfres, param.paramEntries);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,7 +129,7 @@ namespace FirstPlugin
|
|||
}
|
||||
}
|
||||
|
||||
private static void GenerateGridData(BFRES bfres, aampv2.ParamEntry[] paramEntries)
|
||||
private static void GenerateGridData(BFRES bfres, ParamEntry[] paramEntries)
|
||||
{
|
||||
//Load the grid min nad max and set them
|
||||
var boundings = bfres.GetBoundingBox();
|
||||
|
@ -176,35 +143,12 @@ namespace FirstPlugin
|
|||
}
|
||||
}
|
||||
|
||||
private static void GenerateGridData(BFRES bfres, aampv1.ParamEntry[] paramEntries)
|
||||
{
|
||||
var boundings = bfres.GetBoundingBox();
|
||||
|
||||
foreach (var entry in paramEntries)
|
||||
{
|
||||
if (entry.HashString == "aabb_min_pos")
|
||||
entry.Value = new Syroot.Maths.Vector3F(boundings.Min.X, boundings.Min.Y, boundings.Min.Z);
|
||||
if (entry.HashString == "aabb_max_pos")
|
||||
entry.Value = new Syroot.Maths.Vector3F(boundings.Max.X, boundings.Max.Y, boundings.Max.Z);
|
||||
}
|
||||
}
|
||||
|
||||
public AampEditorBase OpenForm()
|
||||
{
|
||||
if (aampFileV1 != null)
|
||||
{
|
||||
AampV1Editor editor = new AampV1Editor(this, IsSaveDialog);
|
||||
editor.Text = FileName;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
return editor;
|
||||
}
|
||||
else
|
||||
{
|
||||
AampV2Editor editor = new AampV2Editor(this, IsSaveDialog);
|
||||
editor.Text = FileName;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
return editor;
|
||||
}
|
||||
AampEditor editor = new AampEditor(this, IsSaveDialog);
|
||||
editor.Text = FileName;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
return editor;
|
||||
}
|
||||
|
||||
public void FillEditor(UserControl control)
|
||||
|
@ -212,8 +156,7 @@ namespace FirstPlugin
|
|||
}
|
||||
|
||||
|
||||
public aampv1.AampFile aampFileV1;
|
||||
public aampv2.AampFile aampFileV2;
|
||||
public AampFile aampFile;
|
||||
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
|
@ -221,22 +164,9 @@ namespace FirstPlugin
|
|||
|
||||
IsSaveDialog = IFileInfo != null && IFileInfo.InArchive;
|
||||
|
||||
uint Version = CheckVersion(stream);
|
||||
|
||||
if (Version == 1)
|
||||
{
|
||||
aampFileV1 = new aampv1.AampFile(stream);
|
||||
}
|
||||
else if (Version == 2)
|
||||
{
|
||||
aampFileV2 = new aampv2.AampFile(stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Unsupported AAMP version! {Version}");
|
||||
}
|
||||
aampFile = AampFile.LoadFile(stream);
|
||||
}
|
||||
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
|
||||
|
@ -244,10 +174,8 @@ namespace FirstPlugin
|
|||
|
||||
public void Save(System.IO.Stream stream)
|
||||
{
|
||||
if (aampFileV1 != null)
|
||||
aampFileV1.Save(stream);
|
||||
else
|
||||
aampFileV2.Save(stream);
|
||||
if (aampFile != null)
|
||||
aampFile.Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,9 @@ namespace FirstPlugin
|
|||
files[i].FileName = $"File {i}";
|
||||
files[i].DataOffset = reader.Position;
|
||||
reader.Seek((int)files[i].CompressedSize);
|
||||
reader.Align((int)files[i].Alignment);
|
||||
|
||||
if (files[i].Alignment != 0)
|
||||
reader.Align((int)files[i].Alignment);
|
||||
}
|
||||
|
||||
//Try to get file names from file formats inside
|
||||
|
|
|
@ -10,6 +10,9 @@ using Toolbox.Library.Forms;
|
|||
using Toolbox.Library.IO;
|
||||
using ByamlExt.Byaml;
|
||||
using ByamlExt;
|
||||
using SharpYaml.Serialization;
|
||||
using SharpYaml;
|
||||
using Syroot.BinaryData;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
|
@ -50,19 +53,23 @@ namespace FirstPlugin
|
|||
}
|
||||
|
||||
#region Text Converter Interface
|
||||
public TextFileType TextFileType => TextFileType.Xml;
|
||||
public TextFileType TextFileType => TextFileType.Yaml;
|
||||
public bool CanConvertBack => true;
|
||||
|
||||
public string ConvertToString()
|
||||
{
|
||||
return XmlConverter.ToXml(data);
|
||||
if (TextFileType == TextFileType.Xml)
|
||||
return XmlByamlConverter.ToXML(BymlData);
|
||||
else
|
||||
return YamlByamlConverter.ToYaml(BymlData);
|
||||
}
|
||||
|
||||
public void ConvertFromString(string text)
|
||||
{
|
||||
byte[] TextData = Encoding.Unicode.GetBytes(text);
|
||||
StreamReader t = new StreamReader(new MemoryStream(TextData), Encoding.GetEncoding(932));
|
||||
data = XmlConverter.ToByml(t.ReadToEnd());
|
||||
if (TextFileType == TextFileType.Xml)
|
||||
BymlData = XmlByamlConverter.FromXML(text);
|
||||
else
|
||||
BymlData = YamlByamlConverter.FromYaml(text);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -97,7 +104,7 @@ namespace FirstPlugin
|
|||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
byamlF.Load(new FileStream(ofd.FileName, FileMode.Open));
|
||||
byamlF.data.byteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
|
||||
byamlF.BymlData.byteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
|
||||
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = Utils.GetAllFilters(byamlF);
|
||||
|
@ -119,7 +126,7 @@ namespace FirstPlugin
|
|||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
byamlF.Load(new FileStream(ofd.FileName, FileMode.Open));
|
||||
byamlF.data.byteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
|
||||
byamlF.BymlData.byteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
|
||||
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = Utils.GetAllFilters(byamlF);
|
||||
|
@ -157,7 +164,7 @@ namespace FirstPlugin
|
|||
}
|
||||
|
||||
bool IsDialog = false;
|
||||
BymlFileData data;
|
||||
public BymlFileData BymlData;
|
||||
|
||||
public ByamlEditor OpenForm()
|
||||
{
|
||||
|
@ -175,25 +182,48 @@ namespace FirstPlugin
|
|||
return editor;
|
||||
}
|
||||
|
||||
public void UpdateByamlRoot(dynamic root)
|
||||
{
|
||||
if (data != null)
|
||||
data.RootNode = root;
|
||||
}
|
||||
|
||||
public void FillEditor(UserControl control)
|
||||
{
|
||||
((ByamlEditor)control).UpdateByaml(data.RootNode, data.SupportPaths, data.Version, data.byteOrder, IsDialog, this);
|
||||
((ByamlEditor)control).UpdateByaml(
|
||||
BymlData.RootNode,
|
||||
BymlData.SupportPaths,
|
||||
BymlData.Version,
|
||||
BymlData.byteOrder,
|
||||
IsDialog, this);
|
||||
}
|
||||
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
CanSave = true;
|
||||
|
||||
//Keep the stream open.
|
||||
//This is for the file to optionally be reloaded for different encoding types
|
||||
IsDialog = IFileInfo != null && IFileInfo.InArchive;
|
||||
|
||||
data = ByamlFile.LoadN(stream);
|
||||
BymlData = ByamlFile.LoadN(stream);
|
||||
}
|
||||
|
||||
public void ReloadEncoding(Encoding encoding) {
|
||||
BymlFileData.Encoding = encoding;
|
||||
|
||||
//Reopen and reload the byml data
|
||||
if (IFileInfo.ArchiveParent != null)
|
||||
{
|
||||
foreach (var file in IFileInfo.ArchiveParent.Files)
|
||||
{
|
||||
var name = Path.GetFileName(file.FileName);
|
||||
if (name == FileName)
|
||||
BymlData = ByamlFile.LoadN(new MemoryStream(file.FileData));
|
||||
}
|
||||
}
|
||||
else if (File.Exists(FilePath))
|
||||
{
|
||||
var file = File.OpenRead(FilePath);
|
||||
BymlData = ByamlFile.LoadN(file);
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
|
||||
|
@ -203,10 +233,10 @@ namespace FirstPlugin
|
|||
{
|
||||
ByamlFile.SaveN(stream, new BymlFileData
|
||||
{
|
||||
Version = data.Version,
|
||||
byteOrder = data.byteOrder,
|
||||
SupportPaths = data.SupportPaths,
|
||||
RootNode = data.RootNode
|
||||
Version = BymlData.Version,
|
||||
byteOrder = BymlData.byteOrder,
|
||||
SupportPaths = BymlData.SupportPaths,
|
||||
RootNode = BymlData.RootNode
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
232
File_Format_Library/FileFormats/Byaml/XmlByamlConverter.cs
Normal file
232
File_Format_Library/FileFormats/Byaml/XmlByamlConverter.cs
Normal file
|
@ -0,0 +1,232 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Syroot.BinaryData;
|
||||
using Syroot.Maths;
|
||||
using ByamlExt.Byaml;
|
||||
using System.Globalization;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
//From https://gitlab.com/Syroot/NintenTools.Byaml/-/blob/master/src/Syroot.NintenTools.Byaml/XmlConverter.cs
|
||||
//This allows xml to with with yamlconv and it looks better using attributes for properties
|
||||
//Todo this needs to support reference nodes
|
||||
public class XmlByamlConverter
|
||||
{
|
||||
private static readonly XNamespace _yamlconvNs = "yamlconv";
|
||||
|
||||
public static string ToXML(BymlFileData data)
|
||||
{
|
||||
XDocument doc = ToXDocument(data.RootNode, data);
|
||||
using (StringWriter writer = new StringWriter())
|
||||
{
|
||||
doc.Save(writer);
|
||||
return writer.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static BymlFileData FromXML(string text) {
|
||||
return FromXDocument(XDocument.Parse(text));
|
||||
}
|
||||
|
||||
internal static BymlFileData FromXDocument(XDocument xDocument)
|
||||
{
|
||||
if (xDocument == null)
|
||||
throw new ArgumentNullException(nameof(xDocument));
|
||||
if (xDocument.Root?.Name != "yaml")
|
||||
throw new ArgumentException("Incompatible XML data. A \"yaml\" root element is required.");
|
||||
|
||||
// Retrieve information from root node.
|
||||
BymlFileData data = new BymlFileData();
|
||||
switch (xDocument.Root.Attribute(_yamlconvNs + "endianness")?.Value)
|
||||
{
|
||||
case "big": data.byteOrder = ByteOrder.BigEndian; break;
|
||||
case "little": data.byteOrder = ByteOrder.LittleEndian; break;
|
||||
default: data.byteOrder = ByteOrder.LittleEndian; break;
|
||||
}
|
||||
data.Version = UInt16.TryParse(xDocument.Root.Attribute(_yamlconvNs + "version")?.Value,
|
||||
out ushort version) ? version : (ushort)1;
|
||||
|
||||
// Generate the root node.
|
||||
data.RootNode = ReadNode(xDocument.Root);
|
||||
return data;
|
||||
}
|
||||
|
||||
private static dynamic ReadNode(XElement node)
|
||||
{
|
||||
dynamic convertValue(string value)
|
||||
{
|
||||
if (value == "null")
|
||||
return null;
|
||||
if (value == string.Empty)
|
||||
return "";
|
||||
else if (value == "true")
|
||||
return true;
|
||||
else if (value == "false")
|
||||
return false;
|
||||
else if (value.EndsWith("f"))
|
||||
return Single.Parse(value.Substring(0, value.Length - "f".Length), CultureInfo.InvariantCulture);
|
||||
else if (value.EndsWith("u"))
|
||||
return UInt32.Parse(value.Substring(0, value.Length - "u".Length), CultureInfo.InvariantCulture);
|
||||
else if (value.EndsWith("i64"))
|
||||
return Int64.Parse(value.Substring(0, value.Length - "i64".Length), CultureInfo.InvariantCulture);
|
||||
else if (value.EndsWith("u64"))
|
||||
return UInt64.Parse(value.Substring(0, value.Length - "u64".Length), CultureInfo.InvariantCulture);
|
||||
else if (value.EndsWith("d"))
|
||||
return Double.Parse(value.Substring(0, value.Length - "d".Length), CultureInfo.InvariantCulture);
|
||||
else
|
||||
return Int32.Parse(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
string convertString() => node.Value.ToString();
|
||||
|
||||
List<ByamlPathPoint> convertPath()
|
||||
{
|
||||
List<ByamlPathPoint> path = new List<ByamlPathPoint>();
|
||||
foreach (XElement pathPoint in node.Elements("point"))
|
||||
path.Add(convertPathPoint(pathPoint));
|
||||
return path;
|
||||
}
|
||||
|
||||
ByamlPathPoint convertPathPoint(XElement pathPoint)
|
||||
{
|
||||
return new ByamlPathPoint
|
||||
{
|
||||
Position = new Vector3F(
|
||||
convertValue(pathPoint.Attribute("x")?.Value ?? "0f"),
|
||||
convertValue(pathPoint.Attribute("y")?.Value ?? "0f"),
|
||||
convertValue(pathPoint.Attribute("z")?.Value ?? "0f")),
|
||||
Normal = new Vector3F(
|
||||
convertValue(pathPoint.Attribute("nx")?.Value ?? "0f"),
|
||||
convertValue(pathPoint.Attribute("ny")?.Value ?? "0f"),
|
||||
convertValue(pathPoint.Attribute("nz")?.Value ?? "0f")),
|
||||
Unknown = convertValue(pathPoint.Attribute("val")?.Value ?? "0")
|
||||
};
|
||||
}
|
||||
|
||||
Dictionary<string, dynamic> convertDictionary()
|
||||
{
|
||||
Dictionary<string, dynamic> dictionary = new Dictionary<string, dynamic>();
|
||||
foreach (XElement element in node.Elements())
|
||||
dictionary.Add(XmlConvert.DecodeName(element.Name.ToString()), ReadNode(element));
|
||||
// Only keep non-namespaced attributes for now to filter out yamlconv and xml(ns) ones.
|
||||
foreach (XAttribute attribute in node.Attributes().Where(x => x.Name.Namespace == XNamespace.None))
|
||||
dictionary.Add(XmlConvert.DecodeName(attribute.Name.ToString()), convertValue(attribute.Value));
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
List<dynamic> convertArray()
|
||||
{
|
||||
List<dynamic> array = new List<dynamic>();
|
||||
foreach (XElement element in node.Elements("value"))
|
||||
array.Add(ReadNode(element));
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
// Detecting the special "type" attribute like this is unsafe as it could also be a dictionary with a "type"
|
||||
// key. Yamlconv should have namespaced its attribute to safely identify it.
|
||||
switch (node.Attributes("type").SingleOrDefault()?.Value)
|
||||
{
|
||||
// TODO: Add null support. Can null be set for value types?
|
||||
// TODO: Add reference support. Use Element with encoded XPath.
|
||||
case null when node.HasAttributes || node.HasElements: return convertDictionary();
|
||||
case null: return convertValue(node.Value);
|
||||
case "array": return convertArray();
|
||||
case "path": return convertPath();
|
||||
case "string": return convertString();
|
||||
default: throw new ByamlException("Unknown XML contents.");
|
||||
}
|
||||
}
|
||||
|
||||
internal static XDocument ToXDocument(dynamic root, BymlFileData data)
|
||||
{
|
||||
XElement rootNode = SaveNode("yaml", root, false);
|
||||
|
||||
List<XAttribute> attribs = rootNode.Attributes().ToList();
|
||||
attribs.Insert(0, new XAttribute(XNamespace.Xmlns + "yamlconv", "yamlconv"));
|
||||
attribs.Insert(1, new XAttribute(_yamlconvNs + "endianness",
|
||||
data.byteOrder == ByteOrder.LittleEndian ? "little" : "big"));
|
||||
attribs.Insert(2, new XAttribute(_yamlconvNs + "offsetCount", data.SupportPaths ? 4 : 3));
|
||||
attribs.Insert(3, new XAttribute(_yamlconvNs + "byamlVersion", data.Version));
|
||||
rootNode.Attributes().Remove();
|
||||
rootNode.Add(attribs);
|
||||
|
||||
return new XDocument(new XDeclaration("1.0", "utf-8", null), rootNode);
|
||||
}
|
||||
|
||||
private static XObject SaveNode(string name, dynamic node, bool isArrayElement)
|
||||
{
|
||||
XObject convertValue(object value)
|
||||
=> isArrayElement ? new XElement(name, value) : (XObject)new XAttribute(name, value);
|
||||
|
||||
XElement convertString(string stringNode)
|
||||
=> new XElement(name, new XAttribute("type", "string"), stringNode);
|
||||
|
||||
XElement convertPathPoint(ByamlPathPoint pathPointNode)
|
||||
{
|
||||
return new XElement("point",
|
||||
new XAttribute("x", getSingleString(pathPointNode.Position.X)),
|
||||
new XAttribute("y", getSingleString(pathPointNode.Position.Y)),
|
||||
new XAttribute("z", getSingleString(pathPointNode.Position.Z)),
|
||||
new XAttribute("nx", getSingleString(pathPointNode.Normal.X)),
|
||||
new XAttribute("ny", getSingleString(pathPointNode.Normal.Y)),
|
||||
new XAttribute("nz", getSingleString(pathPointNode.Normal.Z)),
|
||||
new XAttribute("val", getUInt32String(pathPointNode.Unknown)));
|
||||
}
|
||||
|
||||
XObject convertPath(List<ByamlPathPoint> pathNode)
|
||||
{
|
||||
XElement xElement = new XElement(name, new XAttribute("type", "path"));
|
||||
foreach (dynamic element in pathNode)
|
||||
xElement.Add(SaveNode("point", element, true));
|
||||
return xElement;
|
||||
}
|
||||
|
||||
XElement convertDictionary(IDictionary<string, dynamic> dictionaryNode)
|
||||
{
|
||||
XElement xElement = new XElement(name);
|
||||
foreach (KeyValuePair<string, dynamic> element in dictionaryNode.OrderBy(x => x.Key, StringComparer.Ordinal))
|
||||
xElement.Add(SaveNode(element.Key, element.Value, false));
|
||||
return xElement;
|
||||
}
|
||||
|
||||
XElement convertArray(IEnumerable<dynamic> arrayNode)
|
||||
{
|
||||
XElement xElement = new XElement(name, new XAttribute("type", "array"));
|
||||
foreach (dynamic element in arrayNode)
|
||||
xElement.Add(SaveNode("value", element, true));
|
||||
return xElement;
|
||||
}
|
||||
|
||||
string getBooleanString(Boolean value) => value ? "true" : "false";
|
||||
string getInt32String(Int32 value) => value.ToString(CultureInfo.InvariantCulture);
|
||||
string getSingleString(Single value) => value.ToString(CultureInfo.InvariantCulture) + "f";
|
||||
string getUInt32String(UInt32 value) => value.ToString(CultureInfo.InvariantCulture) + "u";
|
||||
string getInt64String(Int64 value) => value.ToString(CultureInfo.InvariantCulture) + "i64";
|
||||
string getUInt64String(UInt64 value) => value.ToString(CultureInfo.InvariantCulture) + "u64";
|
||||
string getDoubleString(Double value) => value.ToString(CultureInfo.InvariantCulture) + "d";
|
||||
|
||||
if (node == null) return convertString("null");
|
||||
|
||||
name = XmlConvert.EncodeName(name);
|
||||
if (node is bool) return convertValue(getBooleanString((bool)node));
|
||||
else if (node is int) return convertValue(getInt32String((int)node));
|
||||
else if (node is uint) return convertValue(getUInt32String((uint)node));
|
||||
else if (node is float) return convertValue(getSingleString((float)node));
|
||||
else if (node is UInt64) return convertValue(getUInt64String((UInt64)node));
|
||||
else if (node is Int64) return convertValue(getInt64String((Int64)node));
|
||||
else if (node is Double) return convertValue(getDoubleString((Double)node));
|
||||
else if (node is string) return convertString(node);
|
||||
else if (node is ByamlPathPoint) return convertPathPoint((ByamlPathPoint)node);
|
||||
else if (node is List<ByamlPathPoint>) return convertPath((List<ByamlPathPoint>)node);
|
||||
else if (node is IDictionary<string, dynamic>) return convertDictionary(node);
|
||||
else if (node is IEnumerable<dynamic>) return convertArray(node);
|
||||
else throw new Exception("Unsupported node type! " + node.GetType());
|
||||
}
|
||||
}
|
||||
}
|
265
File_Format_Library/FileFormats/Byaml/YamlByamlConverter.cs
Normal file
265
File_Format_Library/FileFormats/Byaml/YamlByamlConverter.cs
Normal file
|
@ -0,0 +1,265 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using AampLibraryCSharp.IO;
|
||||
using SharpYaml.Serialization;
|
||||
using System.Globalization;
|
||||
using Syroot.BinaryData;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class YamlByamlConverter
|
||||
{
|
||||
//Generate a list of all complex dynamic values that are used for reference nodes
|
||||
//The tag will be an ID to set the dynamic value
|
||||
private static Dictionary<dynamic, YamlNode> NodePaths = new Dictionary<dynamic, YamlNode>();
|
||||
|
||||
//Used for saving by mapping tags to dynamic values
|
||||
private static Dictionary<string, dynamic> ReferenceNodes = new Dictionary<string, dynamic>();
|
||||
|
||||
//id to keep track of reference nodes
|
||||
static int refNodeId = 0;
|
||||
|
||||
public static string ToYaml(ByamlExt.Byaml.BymlFileData data)
|
||||
{
|
||||
/* var settings = new SerializerSettings()
|
||||
{
|
||||
EmitTags = false,
|
||||
EmitAlias = false,
|
||||
DefaultStyle = SharpYaml.YamlStyle.Flow,
|
||||
SortKeyForMapping = false,
|
||||
EmitShortTypeName = true,
|
||||
EmitCapacityForList = false,
|
||||
LimitPrimitiveFlowSequence = 4,
|
||||
};
|
||||
|
||||
settings.RegisterTagMapping("!u", typeof(uint));
|
||||
settings.RegisterTagMapping("!l", typeof(int));
|
||||
settings.RegisterTagMapping("!d", typeof(double));
|
||||
settings.RegisterTagMapping("!ul", typeof(ulong));
|
||||
settings.RegisterTagMapping("!ll", typeof(long));
|
||||
|
||||
var serializer = new Serializer(settings);*/
|
||||
|
||||
NodePaths.Clear();
|
||||
refNodeId = 0;
|
||||
|
||||
YamlNode root = SaveNode("root", data.RootNode);
|
||||
YamlMappingNode mapping = new YamlMappingNode();
|
||||
mapping.Add("Version", data.Version.ToString());
|
||||
mapping.Add("IsBigEndian", (data.byteOrder == ByteOrder.BigEndian).ToString());
|
||||
mapping.Add("SupportPaths", data.SupportPaths.ToString());
|
||||
mapping.Add("HasReferenceNodes", (refNodeId != 0).ToString());
|
||||
mapping.Add("root", root);
|
||||
|
||||
NodePaths.Clear();
|
||||
refNodeId = 0;
|
||||
var doc = new YamlDocument(mapping);
|
||||
|
||||
YamlStream stream = new YamlStream(doc);
|
||||
var buffer = new StringBuilder();
|
||||
using (var writer = new StringWriter(buffer)) {
|
||||
stream.Save(writer, true);
|
||||
return writer.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static ByamlExt.Byaml.BymlFileData FromYaml(string text)
|
||||
{
|
||||
NodePaths.Clear();
|
||||
ReferenceNodes.Clear();
|
||||
|
||||
var data = new ByamlExt.Byaml.BymlFileData();
|
||||
var yaml = new YamlStream();
|
||||
yaml.Load(new StringReader(text));
|
||||
var mapping = (YamlMappingNode)yaml.Documents[0].RootNode;
|
||||
|
||||
foreach (var child in mapping.Children)
|
||||
{
|
||||
var key = ((YamlScalarNode)child.Key).Value;
|
||||
var value = child.Value.ToString();
|
||||
|
||||
if (key == "Version")
|
||||
data.Version = ushort.Parse(value);
|
||||
if (key == "IsBigEndian")
|
||||
data.byteOrder = bool.Parse(value) ? ByteOrder.BigEndian : ByteOrder.LittleEndian;
|
||||
if (key == "SupportPaths")
|
||||
data.SupportPaths = bool.Parse(value);
|
||||
|
||||
if (child.Value is YamlMappingNode)
|
||||
data.RootNode = ParseNode(child.Value);
|
||||
if (child.Value is YamlSequenceNode)
|
||||
data.RootNode = ParseNode(child.Value);
|
||||
}
|
||||
|
||||
ReferenceNodes.Clear();
|
||||
NodePaths.Clear();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static dynamic ParseNode(YamlNode node)
|
||||
{
|
||||
if (node is YamlMappingNode)
|
||||
{
|
||||
var values = new Dictionary<string, dynamic>();
|
||||
if (IsValidReference(node))
|
||||
ReferenceNodes.Add(node.Tag, values);
|
||||
|
||||
foreach (var child in ((YamlMappingNode)node).Children)
|
||||
values.Add(((YamlScalarNode)child.Key).Value, ParseNode(child.Value));
|
||||
return values;
|
||||
}
|
||||
else if (node is YamlSequenceNode) {
|
||||
var values = new List<dynamic>();
|
||||
if (IsValidReference(node))
|
||||
ReferenceNodes.Add(node.Tag, values);
|
||||
|
||||
foreach (var child in ((YamlSequenceNode)node).Children)
|
||||
values.Add(ParseNode(child));
|
||||
return values;
|
||||
} //Reference node
|
||||
else if (node is YamlScalarNode && ((YamlScalarNode)node).Value.Contains("!refTag=")) {
|
||||
string tag = ((YamlScalarNode)node).Value.Replace("!refTag=", string.Empty);
|
||||
Console.WriteLine($"refNode {tag} {ReferenceNodes.ContainsKey(tag)}");
|
||||
if (ReferenceNodes.ContainsKey(tag))
|
||||
return ReferenceNodes[tag];
|
||||
else {
|
||||
Console.WriteLine("Failed to find reference node! " + tag);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return ConvertValue(((YamlScalarNode)node).Value, ((YamlScalarNode)node).Tag);
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsValidReference(YamlNode node) {
|
||||
return node.Tag != null && node.Tag.Contains("!ref") && !ReferenceNodes.ContainsKey(node.Tag);
|
||||
}
|
||||
|
||||
static dynamic ConvertValue(string value, string tag)
|
||||
{
|
||||
if (tag == null)
|
||||
tag = "";
|
||||
|
||||
if (value == "null")
|
||||
return null;
|
||||
else if (value == "true")
|
||||
return true;
|
||||
else if (value == "false")
|
||||
return false;
|
||||
else if (tag == "!u")
|
||||
return UInt32.Parse(value, CultureInfo.InvariantCulture);
|
||||
else if (tag == "!l")
|
||||
return Int32.Parse(value, CultureInfo.InvariantCulture);
|
||||
else if (tag == "!d")
|
||||
return Double.Parse(value, CultureInfo.InvariantCulture);
|
||||
else if (tag == "!ul")
|
||||
return UInt64.Parse(value, CultureInfo.InvariantCulture);
|
||||
else if (tag == "!ll")
|
||||
return Int64.Parse(value, CultureInfo.InvariantCulture);
|
||||
else
|
||||
{
|
||||
float floatValue = 0;
|
||||
bool isFloat = float.TryParse(value, out floatValue);
|
||||
if (isFloat)
|
||||
return floatValue;
|
||||
else
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static YamlNode SaveNode(string name, dynamic node)
|
||||
{
|
||||
if (node == null) {
|
||||
return new YamlScalarNode("null");
|
||||
}
|
||||
else if (NodePaths.ContainsKey(node))
|
||||
{
|
||||
if (NodePaths[node].Tag == null)
|
||||
NodePaths[node].Tag = $"!ref{refNodeId++}";
|
||||
return new YamlScalarNode($"!refTag={NodePaths[node].Tag}");
|
||||
}
|
||||
else if ((node is IList<dynamic>))
|
||||
{
|
||||
var yamlNode = new YamlSequenceNode();
|
||||
NodePaths.Add(node, yamlNode);
|
||||
|
||||
if (!HasEnumerables((IList<dynamic>)node) &&
|
||||
((IList<dynamic>)node).Count < 6)
|
||||
yamlNode.Style = SharpYaml.YamlStyle.Flow;
|
||||
|
||||
foreach (var item in (IList<dynamic>)node)
|
||||
yamlNode.Add(SaveNode(null, item));
|
||||
|
||||
return yamlNode;
|
||||
}
|
||||
else if (node is IDictionary<string, dynamic>)
|
||||
{
|
||||
var yamlNode = new YamlMappingNode();
|
||||
NodePaths.Add(node, yamlNode);
|
||||
|
||||
if (!HasEnumerables((IDictionary<string, dynamic>)node) &&
|
||||
((IDictionary<string, dynamic>)node).Count < 6)
|
||||
yamlNode.Style = SharpYaml.YamlStyle.Flow;
|
||||
|
||||
foreach (var item in (IDictionary<string, dynamic>)node)
|
||||
yamlNode.Add(item.Key, SaveNode(item.Key, item.Value));
|
||||
return yamlNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
string tag = null;
|
||||
if (node is int) tag = "!l";
|
||||
else if (node is uint) tag = "!u";
|
||||
else if (node is Int64) tag = "!ul";
|
||||
else if (node is double) tag = "!d";
|
||||
|
||||
var yamlNode = new YamlScalarNode(ConvertValue(node));
|
||||
if (tag != null) yamlNode.Tag = tag;
|
||||
return yamlNode;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool HasEnumerables(IDictionary<string, dynamic> node)
|
||||
{
|
||||
foreach (var item in node.Values)
|
||||
{
|
||||
if (item == null)
|
||||
continue;
|
||||
if (item is IList<dynamic>)
|
||||
return true;
|
||||
else if (item is IDictionary<string, dynamic>)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool HasEnumerables(IList<dynamic> node)
|
||||
{
|
||||
foreach (var item in node)
|
||||
{
|
||||
if (node == null)
|
||||
continue;
|
||||
if (node is IList<dynamic>)
|
||||
return true;
|
||||
else if (node is IDictionary<string, dynamic>)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static string ConvertValue(dynamic node)
|
||||
{
|
||||
string getBooleanString(Boolean value) => value ? "true" : "false";
|
||||
|
||||
if (node is bool) return getBooleanString((bool)node);
|
||||
else return node.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,17 +39,8 @@
|
|||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AampCommon">
|
||||
<HintPath>..\Toolbox\Lib\AampCommon.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="AampV1Library">
|
||||
<HintPath>..\Toolbox\Lib\AampV1Library.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="AampV2Library">
|
||||
<HintPath>..\Toolbox\Lib\AampV2Library.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<Reference Include="AampLibraryCSharp">
|
||||
<HintPath>..\Toolbox\Lib\AampLibraryCSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BarsLibrary">
|
||||
<HintPath>..\Toolbox\Lib\BarsLibrary.dll</HintPath>
|
||||
|
@ -236,6 +227,8 @@
|
|||
<Compile Include="FileFormats\BCH\Wrappers\Model\H3DModelWrapper.cs" />
|
||||
<Compile Include="FileFormats\BCH\Wrappers\Model\H3DSkeletonWrapper.cs" />
|
||||
<Compile Include="FileFormats\BCH\Wrappers\SkeletalAnimation\H3DSkeletalAnimWrapper.cs" />
|
||||
<Compile Include="FileFormats\Byaml\XmlByamlConverter.cs" />
|
||||
<Compile Include="FileFormats\Byaml\YamlByamlConverter.cs" />
|
||||
<Compile Include="FileFormats\LM1\LM1_MDL.cs" />
|
||||
<Compile Include="FileFormats\MarioParty\HSF.cs" />
|
||||
<Compile Include="FileFormats\MKAGPDX\LM2_ARCADE_Model.cs" />
|
||||
|
@ -325,10 +318,10 @@
|
|||
<Compile Include="FileFormats\Effects\PTCL_3DS.cs" />
|
||||
<Compile Include="FileFormats\Effects\PTCL_WiiU.cs" />
|
||||
<Compile Include="FileFormats\Font\BFFNT.cs" />
|
||||
<Compile Include="FileFormats\Font\BFOTF.cs" />
|
||||
<Compile Include="FileFormats\Audio\Archives\BFGRP.cs" />
|
||||
<Compile Include="FileFormats\Font\BffntCharSet2Xlor.cs" />
|
||||
<Compile Include="FileFormats\Font\BFTTF.cs" />
|
||||
<Compile Include="FileFormats\Font\BFOTF.cs" />
|
||||
<Compile Include="FileFormats\HyruleWarriors\G1M\G1M.cs" />
|
||||
<Compile Include="FileFormats\HyruleWarriors\LINKDATA.cs" />
|
||||
<Compile Include="FileFormats\Layout\Animation\LytAnimGroup.cs" />
|
||||
|
@ -404,6 +397,7 @@
|
|||
<Compile Include="GL\BFRES\BFRESRenderBase.cs" />
|
||||
<Compile Include="GL\BMD_Renderer.cs" />
|
||||
<Compile Include="GL\CMB_Renderer.cs" />
|
||||
<Compile Include="GL\G1M_Renderer.cs" />
|
||||
<Compile Include="GL\GXToOpenGL.cs" />
|
||||
<Compile Include="GL\KCL_Render.cs" />
|
||||
<Compile Include="GL\LM2_Render.cs" />
|
||||
|
@ -852,11 +846,11 @@
|
|||
<Compile Include="FileFormats\Audio\BRSTM.cs" />
|
||||
<Compile Include="GL\Helpers\AlphaGLControl.cs" />
|
||||
<Compile Include="GL\Helpers\ColorGLControl.cs" />
|
||||
<Compile Include="GUI\AAMP\AampEditor.cs">
|
||||
<Compile Include="GUI\AAMP\AampEditorBase.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI\AAMP\AampEditor.Designer.cs">
|
||||
<DependentUpon>AampEditor.cs</DependentUpon>
|
||||
<Compile Include="GUI\AAMP\AampEditorBase.Designer.cs">
|
||||
<DependentUpon>AampEditorBase.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GUI\BFRES\ParamAnim\ParamPatternMaterialEditor.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
@ -969,7 +963,6 @@
|
|||
<Compile Include="Scenes\SMO\LevelObj.cs" />
|
||||
<Compile Include="Scenes\SMO_Scene.cs" />
|
||||
<Compile Include="Scenes\ZTP_Scene.cs" />
|
||||
<Compile Include="YAML\YamlAamp.cs" />
|
||||
<Compile Include="GUI\BFRES\BoneVisualAnims\BoneVisualAnimEditor.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
@ -1153,16 +1146,12 @@
|
|||
<DependentUpon>OdysseyCostumeLoader.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GUI\SMO\MarioCostumeEditor.cs" />
|
||||
<Compile Include="GUI\AAMP\AampV1Editor.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI\AAMP\AampV2Editor.cs">
|
||||
<Compile Include="GUI\AAMP\AampEditor.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI\AAMP\EditBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI\AAMP\EditBox.Designer.cs" />
|
||||
<Compile Include="GUI\BFRES\BfresEditor.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
@ -1563,8 +1552,8 @@
|
|||
<None Include="Resources\InjectTexErrored.dds" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="GUI\AAMP\AampEditor.resx">
|
||||
<DependentUpon>AampEditor.cs</DependentUpon>
|
||||
<EmbeddedResource Include="GUI\AAMP\AampEditorBase.resx">
|
||||
<DependentUpon>AampEditorBase.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GUI\AAMP\EditBox.resx" />
|
||||
<EmbeddedResource Include="GUI\Advanced Editor\TextureViewer.resx">
|
||||
|
|
|
@ -1,202 +1,234 @@
|
|||
using ByamlExt.Byaml;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Syroot.BinaryData;
|
||||
using EditorCore;
|
||||
using Toolbox.Library.Forms;
|
||||
using AampLibraryCSharp;
|
||||
using Syroot.Maths;
|
||||
using Toolbox.Library;
|
||||
using ByamlExt;
|
||||
using Toolbox.Library.Forms;
|
||||
|
||||
namespace FirstPlugin.Forms
|
||||
{
|
||||
public partial class AampEditorBase : STUserControl, IFIleEditor
|
||||
public partial class AampEditor : AampEditorBase
|
||||
{
|
||||
public AAMP AampFile;
|
||||
|
||||
public List<IFileFormat> GetFileFormats()
|
||||
public AampEditor(AAMP aamp, bool IsSaveDialog) : base(aamp, IsSaveDialog)
|
||||
{
|
||||
return new List<IFileFormat>() { AampFile };
|
||||
treeView1.Nodes.Add(aamp.FileName);
|
||||
LoadFile(aamp.aampFile, treeView1.Nodes[0]);
|
||||
}
|
||||
|
||||
public AampEditorBase(AAMP aamp, bool IsSaveDialog)
|
||||
public void LoadFile(AampFile aampFile, TreeNode parentNode)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
treeView1.BackColor = FormThemes.BaseTheme.FormBackColor;
|
||||
treeView1.ForeColor = FormThemes.BaseTheme.FormForeColor;
|
||||
|
||||
AampFile = aamp;
|
||||
|
||||
if (AampFile.aampFileV1 != null)
|
||||
{
|
||||
Text = $"{AampFile.FileName} Type [{AampFile.aampFileV1.EffectType}]";
|
||||
}
|
||||
else
|
||||
{
|
||||
Text = $"{AampFile.FileName} Type [{AampFile.aampFileV2.EffectType}]";
|
||||
}
|
||||
|
||||
STContextMenuStrip contextMenuStrip1 = new STContextMenuStrip();
|
||||
contextMenuStrip1.Items.Add(new ToolStripMenuItem("Save", null, saveAsToolStripMenuItem_Click, Keys.Control | Keys.I));
|
||||
contextMenuStrip1.Items.Add(new ToolStripSeparator());
|
||||
contextMenuStrip1.Items.Add(new ToolStripMenuItem("Export as Yaml", null, ToYamlAction, Keys.Control | Keys.A));
|
||||
contextMenuStrip1.Items.Add(new ToolStripMenuItem("Open as Yaml", null, OpenYamlEditorAction, Keys.Control | Keys.A));
|
||||
|
||||
this.treeView1.ContextMenuStrip = contextMenuStrip1;
|
||||
|
||||
LoadChildNodes(aampFile.RootNode, parentNode);
|
||||
}
|
||||
|
||||
private void OpenYamlEditorAction(object sender, EventArgs e)
|
||||
public override void TreeView_AfterSelect()
|
||||
{
|
||||
string yaml = "";
|
||||
var node = treeView1.SelectedNode;
|
||||
|
||||
if (AampFile.aampFileV1 != null)
|
||||
yaml = AampYamlConverter.ToYaml(AampFile.aampFileV1);
|
||||
else
|
||||
yaml = AampYamlConverter.ToYaml(AampFile.aampFileV2);
|
||||
|
||||
STForm form = new STForm();
|
||||
form.Text = "YAML Text Editor";
|
||||
var panel = new STPanel() { Dock = DockStyle.Fill, };
|
||||
form.AddControl(panel);
|
||||
var editor = new TextEditor() { Dock = DockStyle.Fill, };
|
||||
editor.FillEditor(yaml);
|
||||
editor.IsYAML = true;
|
||||
panel.Controls.Add(editor);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (node.Tag != null)
|
||||
{
|
||||
|
||||
if (node.Tag is ParamObject) {
|
||||
LoadObjectDataList((ParamObject)node.Tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ToYamlAction(object sender, EventArgs e)
|
||||
public override void AddParamEntry(TreeNode parentNode)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = "YAML|*.yaml;";
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
if (parentNode.Tag != null && parentNode.Tag is ParamObject)
|
||||
{
|
||||
string yaml = "";
|
||||
ParamEntry entry = new ParamEntry();
|
||||
entry.ParamType = ParamType.Float;
|
||||
entry.HashString = "NewEntry";
|
||||
entry.Value = 0;
|
||||
|
||||
if (AampFile.aampFileV1 != null)
|
||||
yaml = AampYamlConverter.ToYaml(AampFile.aampFileV1);
|
||||
else
|
||||
yaml = AampYamlConverter.ToYaml(AampFile.aampFileV2);
|
||||
ListViewItem item = new ListViewItem();
|
||||
SetListItemParamObject(entry, item);
|
||||
|
||||
File.WriteAllText(sfd.FileName, yaml);
|
||||
OpenNewParamEditor(entry,(ParamObject)parentNode.Tag, item);
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyNode_Click(object sender, EventArgs e)
|
||||
public override void RenameParamEntry(ListViewItem SelectedItem)
|
||||
{
|
||||
Clipboard.SetText(treeView1.SelectedNode.Text);
|
||||
}
|
||||
|
||||
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sav = new SaveFileDialog() { FileName = AampFile.FileName, Filter = "Parameter Archive | *.aamp" };
|
||||
if (sav.ShowDialog() == DialogResult.OK)
|
||||
if (SelectedItem.Tag != null && SelectedItem.Tag is ParamEntry)
|
||||
{
|
||||
Toolbox.Library.IO.STFileSaver.SaveFileFormat(AampFile, sav.FileName);
|
||||
RenameDialog dialog = new RenameDialog();
|
||||
dialog.SetString(SelectedItem.Text);
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string NewString = dialog.textBox1.Text;
|
||||
|
||||
((ParamEntry)SelectedItem.Tag).HashString = NewString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void editValueNodeMenuItem_Click(object sender, EventArgs e)
|
||||
public override void OnEditorClick(ListViewItem SelectedItem)
|
||||
{
|
||||
if (listViewCustom1.SelectedItems.Count <= 0)
|
||||
return;
|
||||
|
||||
OnEditorClick(listViewCustom1.SelectedItems[0]);
|
||||
if (SelectedItem.Tag != null && SelectedItem.Tag is ParamEntry)
|
||||
{
|
||||
OpenEditor((ParamEntry)SelectedItem.Tag, SelectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetValues()
|
||||
private void LoadObjectDataList(ParamObject paramObj)
|
||||
{
|
||||
if (treeView1.SelectedNode == null)
|
||||
return;
|
||||
|
||||
listViewCustom1.Items.Clear();
|
||||
|
||||
var targetNodeCollection = treeView1.SelectedNode.Nodes;
|
||||
|
||||
dynamic target = treeView1.SelectedNode.Tag;
|
||||
}
|
||||
|
||||
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) {
|
||||
ResetValues();
|
||||
TreeView_AfterSelect();
|
||||
}
|
||||
|
||||
private void addNodeToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
if (treeView1.SelectedNode == null)
|
||||
return;
|
||||
|
||||
AddParamEntry(treeView1.SelectedNode);
|
||||
}
|
||||
|
||||
public virtual void OnEditorClick(ListViewItem SelectedItem) { }
|
||||
public virtual void TreeView_AfterSelect() { }
|
||||
public virtual void AddParamEntry(TreeNode parent) { }
|
||||
public virtual void RenameParamEntry(ListViewItem SelectedItem) { }
|
||||
public virtual void OnEntryDeletion(object target, TreeNode parent) { }
|
||||
|
||||
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listViewCustom1.SelectedItems.Count <= 0 && treeView1.SelectedNode != null)
|
||||
return;
|
||||
|
||||
var result = MessageBox.Show("Are you sure you want to remove this entry? This cannot be undone!",
|
||||
$"Entry {listViewCustom1.SelectedItems[0].Text}", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
foreach (var entry in paramObj.paramEntries)
|
||||
{
|
||||
OnEntryDeletion(listViewCustom1.SelectedItems[0].Tag, treeView1.SelectedNode);
|
||||
|
||||
int index = listViewCustom1.Items.IndexOf(listViewCustom1.SelectedItems[0]);
|
||||
listViewCustom1.Items.RemoveAt(index);
|
||||
ListViewItem item = new ListViewItem(entry.HashString);
|
||||
SetListItemParamObject(entry, item);
|
||||
listViewCustom1.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void renameToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
if (listViewCustom1.SelectedItems.Count <= 0)
|
||||
return;
|
||||
private void SetListItemParamObject(ParamEntry entry, ListViewItem item)
|
||||
{
|
||||
item.SubItems.Clear();
|
||||
item.Text = entry.HashString;
|
||||
item.Tag = entry;
|
||||
item.UseItemStyleForSubItems = false;
|
||||
item.SubItems.Add(entry.ParamType.ToString());
|
||||
string ValueText = "";
|
||||
|
||||
RenameParamEntry(listViewCustom1.SelectedItems[0]);
|
||||
System.Drawing.Color color = System.Drawing.Color.Empty;
|
||||
|
||||
switch (entry.ParamType)
|
||||
{
|
||||
case ParamType.Boolean:
|
||||
case ParamType.Float:
|
||||
case ParamType.Int:
|
||||
case ParamType.Uint:
|
||||
ValueText = $"{entry.Value}";
|
||||
break;
|
||||
case ParamType.String64:
|
||||
case ParamType.String32:
|
||||
case ParamType.String256:
|
||||
case ParamType.StringRef:
|
||||
ValueText = $"{((AampLibraryCSharp.StringEntry)entry.Value).ToString()}";
|
||||
break;
|
||||
case ParamType.Vector2F:
|
||||
var vec2 = (Vector2F)entry.Value;
|
||||
ValueText = $"{vec2.X} {vec2.Y}";
|
||||
break;
|
||||
case ParamType.Vector3F:
|
||||
var vec3 = (Vector3F)entry.Value;
|
||||
ValueText = $"{vec3.X} {vec3.Y} {vec3.Z}";
|
||||
break;
|
||||
case ParamType.Vector4F:
|
||||
var vec4 = (Vector4F)entry.Value;
|
||||
ValueText = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}";
|
||||
break;
|
||||
case ParamType.Color4F:
|
||||
var col = (Vector4F)entry.Value;
|
||||
ValueText = $"{col.X} {col.Y} {col.Z} {col.W}";
|
||||
|
||||
int ImageIndex = Images.Count;
|
||||
|
||||
color = System.Drawing.Color.FromArgb(
|
||||
EditBox.FloatToIntClamp(col.W),
|
||||
EditBox.FloatToIntClamp(col.X),
|
||||
EditBox.FloatToIntClamp(col.Y),
|
||||
EditBox.FloatToIntClamp(col.Z));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
item.SubItems.Add(ValueText);
|
||||
|
||||
if (color != System.Drawing.Color.Empty)
|
||||
item.SubItems[2].BackColor = color;
|
||||
}
|
||||
|
||||
private void deleteNodeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
public override void OnEntryDeletion(object obj, TreeNode objNode)
|
||||
{
|
||||
if (treeView1.SelectedNode == null)
|
||||
if (obj is ParamEntry)
|
||||
{
|
||||
return;
|
||||
var paramObjectParent = (ParamObject)objNode.Tag;
|
||||
|
||||
var entryList = new List<ParamEntry>();
|
||||
for (int i = 0; i < paramObjectParent.paramEntries.Length; i++)
|
||||
entryList.Add(paramObjectParent.paramEntries[i]);
|
||||
|
||||
entryList.Remove((ParamEntry)obj);
|
||||
|
||||
paramObjectParent.paramEntries = entryList.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private void contentContainer_Paint(object sender, PaintEventArgs e)
|
||||
public void LoadChildNodes(ParamList paramList, TreeNode parentNode)
|
||||
{
|
||||
TreeNode newNode = new TreeNode(paramList.HashString);
|
||||
newNode.Tag = paramList;
|
||||
|
||||
parentNode.Nodes.Add(newNode);
|
||||
|
||||
//Add lists and objects if exits
|
||||
if (paramList.childParams.Length > 0)
|
||||
newNode.Nodes.Add("list", "Lists {}");
|
||||
if (paramList.paramObjects.Length > 0)
|
||||
newNode.Nodes.Add("obj", "Objects {}");
|
||||
|
||||
//Add child nodes
|
||||
foreach (var child in paramList.childParams)
|
||||
LoadChildNodes(child, newNode.Nodes["list"]);
|
||||
|
||||
//Add object nodes
|
||||
foreach (var obj in paramList.paramObjects)
|
||||
SetObjNode(obj, newNode.Nodes["obj"]);
|
||||
}
|
||||
|
||||
private void listViewCustom1_MouseClick(object sender, MouseEventArgs e)
|
||||
List<Bitmap> Images = new List<Bitmap>();
|
||||
|
||||
void SetObjNode(ParamObject paramObj, TreeNode parentNode)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
string name = paramObj.HashString;
|
||||
|
||||
var objNode = new TreeNode(name);
|
||||
objNode.Tag = paramObj;
|
||||
parentNode.Nodes.Add(objNode);
|
||||
}
|
||||
|
||||
private void OpenNewParamEditor(ParamEntry entry, ParamObject paramObject, ListViewItem SelectedItem)
|
||||
{
|
||||
EditBox editor = new EditBox();
|
||||
editor.LoadEntry(entry);
|
||||
editor.ToggleNameEditing(true);
|
||||
|
||||
if (editor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Point pt = listViewCustom1.PointToScreen(e.Location);
|
||||
stContextMenuStrip1.Show(pt);
|
||||
editor.SaveEntry();
|
||||
SetListItemParamObject(entry, SelectedItem);
|
||||
listViewCustom1.Items.Add(SelectedItem);
|
||||
|
||||
var entryList = new List<ParamEntry>();
|
||||
for (int i = 0; i < paramObject.paramEntries.Length; i++)
|
||||
entryList.Add(paramObject.paramEntries[i]);
|
||||
|
||||
entryList.Add(entry);
|
||||
paramObject.paramEntries = entryList.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private void stContextMenuStrip1_Opening(object sender, CancelEventArgs e)
|
||||
private void OpenEditor(ParamEntry entry, ListViewItem SelectedItem)
|
||||
{
|
||||
EditBox editor = new EditBox();
|
||||
editor.LoadEntry(entry);
|
||||
editor.ToggleNameEditing(true);
|
||||
|
||||
if (editor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
editor.SaveEntry();
|
||||
SetListItemParamObject(entry, SelectedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@
|
|||
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.stPanel1 = new Toolbox.Library.Forms.STPanel();
|
||||
this.stTabControl1 = new Toolbox.Library.Forms.STTabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.stPanel2 = new Toolbox.Library.Forms.STPanel();
|
||||
this.addItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.renameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -49,6 +53,9 @@
|
|||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
this.stPanel1.SuspendLayout();
|
||||
this.stTabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
this.stContextMenuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -58,7 +65,7 @@
|
|||
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.treeView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.treeView1.Name = "treeView1";
|
||||
this.treeView1.Size = new System.Drawing.Size(183, 398);
|
||||
this.treeView1.Size = new System.Drawing.Size(217, 462);
|
||||
this.treeView1.TabIndex = 0;
|
||||
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
|
||||
//
|
||||
|
@ -88,10 +95,11 @@
|
|||
this.columnHeader3});
|
||||
this.listViewCustom1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.listViewCustom1.FullRowSelect = true;
|
||||
this.listViewCustom1.HideSelection = false;
|
||||
this.listViewCustom1.Location = new System.Drawing.Point(0, 0);
|
||||
this.listViewCustom1.Name = "listViewCustom1";
|
||||
this.listViewCustom1.OwnerDraw = true;
|
||||
this.listViewCustom1.Size = new System.Drawing.Size(362, 398);
|
||||
this.listViewCustom1.Size = new System.Drawing.Size(432, 462);
|
||||
this.listViewCustom1.TabIndex = 0;
|
||||
this.listViewCustom1.UseCompatibleStateImageBehavior = false;
|
||||
this.listViewCustom1.View = System.Windows.Forms.View.Details;
|
||||
|
@ -110,12 +118,12 @@
|
|||
// columnHeader3
|
||||
//
|
||||
this.columnHeader3.Text = "Data";
|
||||
this.columnHeader3.Width = 155;
|
||||
this.columnHeader3.Width = 225;
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer1.Location = new System.Drawing.Point(3, 3);
|
||||
this.splitContainer1.Name = "splitContainer1";
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
|
@ -125,19 +133,61 @@
|
|||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.listViewCustom1);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(549, 398);
|
||||
this.splitContainer1.SplitterDistance = 183;
|
||||
this.splitContainer1.Size = new System.Drawing.Size(653, 462);
|
||||
this.splitContainer1.SplitterDistance = 217;
|
||||
this.splitContainer1.TabIndex = 14;
|
||||
//
|
||||
// stPanel1
|
||||
//
|
||||
this.stPanel1.Controls.Add(this.splitContainer1);
|
||||
this.stPanel1.Controls.Add(this.stTabControl1);
|
||||
this.stPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.stPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.stPanel1.Name = "stPanel1";
|
||||
this.stPanel1.Size = new System.Drawing.Size(549, 398);
|
||||
this.stPanel1.Size = new System.Drawing.Size(667, 497);
|
||||
this.stPanel1.TabIndex = 15;
|
||||
//
|
||||
// stTabControl1
|
||||
//
|
||||
this.stTabControl1.Controls.Add(this.tabPage1);
|
||||
this.stTabControl1.Controls.Add(this.tabPage2);
|
||||
this.stTabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.stTabControl1.Location = new System.Drawing.Point(0, 0);
|
||||
this.stTabControl1.myBackColor = System.Drawing.Color.Empty;
|
||||
this.stTabControl1.Name = "stTabControl1";
|
||||
this.stTabControl1.SelectedIndex = 0;
|
||||
this.stTabControl1.Size = new System.Drawing.Size(667, 497);
|
||||
this.stTabControl1.TabIndex = 15;
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.splitContainer1);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 25);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(659, 468);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "Editor";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.stPanel2);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 25);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(659, 468);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "Text Editor";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// stPanel2
|
||||
//
|
||||
this.stPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.stPanel2.Location = new System.Drawing.Point(3, 3);
|
||||
this.stPanel2.Name = "stPanel2";
|
||||
this.stPanel2.Size = new System.Drawing.Size(653, 462);
|
||||
this.stPanel2.TabIndex = 0;
|
||||
//
|
||||
// addItemToolStripMenuItem
|
||||
//
|
||||
this.addItemToolStripMenuItem.Name = "addItemToolStripMenuItem";
|
||||
|
@ -183,12 +233,15 @@
|
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.stPanel1);
|
||||
this.Name = "AampEditorBase";
|
||||
this.Size = new System.Drawing.Size(549, 398);
|
||||
this.Size = new System.Drawing.Size(667, 497);
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
this.stPanel1.ResumeLayout(false);
|
||||
this.stTabControl1.ResumeLayout(false);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
this.stContextMenuStrip1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
|
@ -211,5 +264,9 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem renameToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
|
||||
private Toolbox.Library.Forms.STContextMenuStrip stContextMenuStrip1;
|
||||
private Toolbox.Library.Forms.STTabControl stTabControl1;
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
private Toolbox.Library.Forms.STPanel stPanel2;
|
||||
}
|
||||
}
|
220
File_Format_Library/GUI/AAMP/AampEditorBase.cs
Normal file
220
File_Format_Library/GUI/AAMP/AampEditorBase.cs
Normal file
|
@ -0,0 +1,220 @@
|
|||
using ByamlExt.Byaml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Syroot.BinaryData;
|
||||
using EditorCore;
|
||||
using Toolbox.Library.Forms;
|
||||
using Toolbox.Library;
|
||||
using ByamlExt;
|
||||
|
||||
namespace FirstPlugin.Forms
|
||||
{
|
||||
public partial class AampEditorBase : STUserControl, IFIleEditor
|
||||
{
|
||||
public AAMP AampFile;
|
||||
|
||||
public List<IFileFormat> GetFileFormats()
|
||||
{
|
||||
return new List<IFileFormat>() { AampFile };
|
||||
}
|
||||
|
||||
private TextEditor textEditor;
|
||||
public AampEditorBase(AAMP aamp, bool IsSaveDialog)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
treeView1.BackColor = FormThemes.BaseTheme.FormBackColor;
|
||||
treeView1.ForeColor = FormThemes.BaseTheme.FormForeColor;
|
||||
stTabControl1.myBackColor = FormThemes.BaseTheme.FormBackColor;
|
||||
|
||||
AampFile = aamp;
|
||||
Text = $"{AampFile.FileName} Type [{AampFile.aampFile.EffectType}]";
|
||||
|
||||
STContextMenuStrip contextMenuStrip1 = new STContextMenuStrip();
|
||||
contextMenuStrip1.Items.Add(new ToolStripMenuItem("Save", null, saveAsToolStripMenuItem_Click, Keys.Control | Keys.I));
|
||||
contextMenuStrip1.Items.Add(new ToolStripSeparator());
|
||||
contextMenuStrip1.Items.Add(new ToolStripMenuItem("Export as Yaml", null, ToYamlAction, Keys.Control | Keys.A));
|
||||
contextMenuStrip1.Items.Add(new ToolStripMenuItem("Open as Yaml", null, OpenYamlEditorAction, Keys.Control | Keys.A));
|
||||
|
||||
this.treeView1.ContextMenuStrip = contextMenuStrip1;
|
||||
|
||||
textEditor = new TextEditor();
|
||||
textEditor.Dock = DockStyle.Fill;
|
||||
textEditor.ClearContextMenus();
|
||||
textEditor.AddContextMenu("Decompile", TextEditorToYaml);
|
||||
textEditor.AddContextMenu("Compile", TextEditorFromYaml);
|
||||
stPanel2.Controls.Add(textEditor);
|
||||
}
|
||||
|
||||
private void TextEditorToYaml(object sender, EventArgs e)
|
||||
{
|
||||
if (AampFile == null) return;
|
||||
|
||||
textEditor.FillEditor(AampFile.ConvertToString());
|
||||
textEditor.IsYAML = true;
|
||||
}
|
||||
|
||||
private void TextEditorFromYaml(object sender, EventArgs e)
|
||||
{
|
||||
if (AampFile == null) return;
|
||||
|
||||
var text = textEditor.GetText();
|
||||
if (text != string.Empty) {
|
||||
try
|
||||
{
|
||||
AampFile.ConvertFromString(text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Aamp failed to convert! " + ex.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.Show("Aamp converted successfully!");
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenYamlEditorAction(object sender, EventArgs e)
|
||||
{
|
||||
string yaml = AampLibraryCSharp.YamlConverter.ToYaml(AampFile.aampFile);
|
||||
|
||||
STForm form = new STForm();
|
||||
form.Text = "YAML Text Editor";
|
||||
var panel = new STPanel() { Dock = DockStyle.Fill, };
|
||||
form.AddControl(panel);
|
||||
var editor = new TextEditor() { Dock = DockStyle.Fill, };
|
||||
editor.FillEditor(yaml);
|
||||
editor.IsYAML = true;
|
||||
panel.Controls.Add(editor);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ToYamlAction(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = "YAML|*.yaml;";
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string yaml = AampLibraryCSharp.YamlConverter.ToYaml(AampFile.aampFile);
|
||||
|
||||
File.WriteAllText(sfd.FileName, yaml);
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyNode_Click(object sender, EventArgs e)
|
||||
{
|
||||
Clipboard.SetText(treeView1.SelectedNode.Text);
|
||||
}
|
||||
|
||||
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sav = new SaveFileDialog() { FileName = AampFile.FileName, Filter = "Parameter Archive | *.aamp" };
|
||||
if (sav.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Toolbox.Library.IO.STFileSaver.SaveFileFormat(AampFile, sav.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void editValueNodeMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listViewCustom1.SelectedItems.Count <= 0)
|
||||
return;
|
||||
|
||||
OnEditorClick(listViewCustom1.SelectedItems[0]);
|
||||
}
|
||||
|
||||
private void ResetValues()
|
||||
{
|
||||
if (treeView1.SelectedNode == null)
|
||||
return;
|
||||
|
||||
listViewCustom1.Items.Clear();
|
||||
|
||||
var targetNodeCollection = treeView1.SelectedNode.Nodes;
|
||||
|
||||
dynamic target = treeView1.SelectedNode.Tag;
|
||||
}
|
||||
|
||||
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) {
|
||||
ResetValues();
|
||||
TreeView_AfterSelect();
|
||||
}
|
||||
|
||||
private void addNodeToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
if (treeView1.SelectedNode == null)
|
||||
return;
|
||||
|
||||
AddParamEntry(treeView1.SelectedNode);
|
||||
}
|
||||
|
||||
public virtual void OnEditorClick(ListViewItem SelectedItem) { }
|
||||
public virtual void TreeView_AfterSelect() { }
|
||||
public virtual void AddParamEntry(TreeNode parent) { }
|
||||
public virtual void RenameParamEntry(ListViewItem SelectedItem) { }
|
||||
public virtual void OnEntryDeletion(object target, TreeNode parent) { }
|
||||
|
||||
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listViewCustom1.SelectedItems.Count <= 0 && treeView1.SelectedNode != null)
|
||||
return;
|
||||
|
||||
var result = MessageBox.Show("Are you sure you want to remove this entry? This cannot be undone!",
|
||||
$"Entry {listViewCustom1.SelectedItems[0].Text}", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
OnEntryDeletion(listViewCustom1.SelectedItems[0].Tag, treeView1.SelectedNode);
|
||||
|
||||
int index = listViewCustom1.Items.IndexOf(listViewCustom1.SelectedItems[0]);
|
||||
listViewCustom1.Items.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
private void renameToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
if (listViewCustom1.SelectedItems.Count <= 0)
|
||||
return;
|
||||
|
||||
RenameParamEntry(listViewCustom1.SelectedItems[0]);
|
||||
}
|
||||
|
||||
private void deleteNodeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void contentContainer_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void listViewCustom1_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
Point pt = listViewCustom1.PointToScreen(e.Location);
|
||||
stContextMenuStrip1.Show(pt);
|
||||
}
|
||||
}
|
||||
|
||||
private void stContextMenuStrip1_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,235 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AampV1Library;
|
||||
using Syroot.Maths;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.Forms;
|
||||
|
||||
namespace FirstPlugin.Forms
|
||||
{
|
||||
public partial class AampV1Editor : AampEditorBase
|
||||
{
|
||||
public AampV1Editor(AAMP aamp, bool IsSaveDialog) : base(aamp, IsSaveDialog)
|
||||
{
|
||||
treeView1.Nodes.Add(aamp.FileName);
|
||||
LoadFile(aamp.aampFileV1, treeView1.Nodes[0]);
|
||||
}
|
||||
|
||||
public void LoadFile(AampFile aampFile, TreeNode parentNode)
|
||||
{
|
||||
LoadChildNodes(aampFile.RootNode, parentNode);
|
||||
}
|
||||
|
||||
public override void TreeView_AfterSelect()
|
||||
{
|
||||
var node = treeView1.SelectedNode;
|
||||
|
||||
if (node.Tag != null)
|
||||
{
|
||||
if (node.Tag is ParamObject) {
|
||||
LoadObjectDataList((ParamObject)node.Tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddParamEntry(TreeNode parentNode)
|
||||
{
|
||||
if (parentNode.Tag != null && parentNode.Tag is ParamObject)
|
||||
{
|
||||
ParamEntry entry = new ParamEntry();
|
||||
entry.ParamType = ParamType.Float;
|
||||
entry.HashString = "NewEntry";
|
||||
entry.Value = 0;
|
||||
|
||||
ListViewItem item = new ListViewItem();
|
||||
SetListItemParamObject(entry, item);
|
||||
|
||||
OpenNewParamEditor(entry,(ParamObject)parentNode.Tag, item);
|
||||
}
|
||||
}
|
||||
|
||||
public override void RenameParamEntry(ListViewItem SelectedItem)
|
||||
{
|
||||
if (SelectedItem.Tag != null && SelectedItem.Tag is ParamEntry)
|
||||
{
|
||||
RenameDialog dialog = new RenameDialog();
|
||||
dialog.SetString(SelectedItem.Text);
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string NewString = dialog.textBox1.Text;
|
||||
|
||||
((ParamEntry)SelectedItem.Tag).HashString = NewString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEditorClick(ListViewItem SelectedItem)
|
||||
{
|
||||
if (SelectedItem.Tag != null && SelectedItem.Tag is ParamEntry)
|
||||
{
|
||||
OpenEditor((ParamEntry)SelectedItem.Tag, SelectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadObjectDataList(ParamObject paramObj)
|
||||
{
|
||||
listViewCustom1.Items.Clear();
|
||||
foreach (var entry in paramObj.paramEntries)
|
||||
{
|
||||
ListViewItem item = new ListViewItem(entry.HashString);
|
||||
SetListItemParamObject(entry, item);
|
||||
listViewCustom1.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetListItemParamObject(ParamEntry entry, ListViewItem item)
|
||||
{
|
||||
item.SubItems.Clear();
|
||||
item.Text = entry.HashString;
|
||||
item.Tag = entry;
|
||||
item.UseItemStyleForSubItems = false;
|
||||
item.SubItems.Add(entry.ParamType.ToString());
|
||||
string ValueText = "";
|
||||
|
||||
System.Drawing.Color color = System.Drawing.Color.Empty;
|
||||
|
||||
switch (entry.ParamType)
|
||||
{
|
||||
case ParamType.Boolean:
|
||||
case ParamType.Float:
|
||||
case ParamType.Int:
|
||||
case ParamType.Uint:
|
||||
ValueText = $"{entry.Value}";
|
||||
break;
|
||||
case ParamType.String64:
|
||||
case ParamType.String32:
|
||||
case ParamType.String256:
|
||||
case ParamType.StringRef:
|
||||
ValueText = $"{((AampCommon.StringEntry)entry.Value).ToString()}";
|
||||
break;
|
||||
case ParamType.Vector2F:
|
||||
var vec2 = (Vector2F)entry.Value;
|
||||
ValueText = $"{vec2.X} {vec2.Y}";
|
||||
break;
|
||||
case ParamType.Vector3F:
|
||||
var vec3 = (Vector3F)entry.Value;
|
||||
ValueText = $"{vec3.X} {vec3.Y} {vec3.Z}";
|
||||
break;
|
||||
case ParamType.Vector4F:
|
||||
var vec4 = (Vector4F)entry.Value;
|
||||
ValueText = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}";
|
||||
break;
|
||||
case ParamType.Color4F:
|
||||
var col = (Vector4F)entry.Value;
|
||||
ValueText = $"{col.X} {col.Y} {col.Z} {col.W}";
|
||||
|
||||
int ImageIndex = Images.Count;
|
||||
|
||||
color = System.Drawing.Color.FromArgb(
|
||||
EditBox.FloatToIntClamp(col.W),
|
||||
EditBox.FloatToIntClamp(col.X),
|
||||
EditBox.FloatToIntClamp(col.Y),
|
||||
EditBox.FloatToIntClamp(col.Z));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
item.SubItems.Add(ValueText);
|
||||
|
||||
if (color != System.Drawing.Color.Empty)
|
||||
item.SubItems[2].BackColor = color;
|
||||
}
|
||||
|
||||
public override void OnEntryDeletion(object obj, TreeNode objNode)
|
||||
{
|
||||
if (obj is ParamEntry)
|
||||
{
|
||||
var paramObjectParent = (ParamObject)objNode.Tag;
|
||||
|
||||
var entryList = new List<ParamEntry>();
|
||||
for (int i = 0; i < paramObjectParent.paramEntries.Length; i++)
|
||||
entryList.Add(paramObjectParent.paramEntries[i]);
|
||||
|
||||
entryList.Remove((ParamEntry)obj);
|
||||
|
||||
paramObjectParent.paramEntries = entryList.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadChildNodes(ParamList paramList, TreeNode parentNode)
|
||||
{
|
||||
TreeNode newNode = new TreeNode(paramList.HashString);
|
||||
newNode.Tag = paramList;
|
||||
|
||||
parentNode.Nodes.Add(newNode);
|
||||
|
||||
//Add lists and objects if exits
|
||||
if (paramList.childParams.Length > 0)
|
||||
newNode.Nodes.Add("list", "Lists {}");
|
||||
if (paramList.paramObjects.Length > 0)
|
||||
newNode.Nodes.Add("obj", "Objects {}");
|
||||
|
||||
//Add child nodes
|
||||
foreach (var child in paramList.childParams)
|
||||
LoadChildNodes(child, newNode.Nodes["list"]);
|
||||
|
||||
//Add object nodes
|
||||
foreach (var obj in paramList.paramObjects)
|
||||
SetObjNode(obj, newNode.Nodes["obj"]);
|
||||
}
|
||||
|
||||
List<Bitmap> Images = new List<Bitmap>();
|
||||
|
||||
void SetObjNode(ParamObject paramObj, TreeNode parentNode)
|
||||
{
|
||||
string name = paramObj.HashString;
|
||||
string groupName = paramObj.GroupHashString;
|
||||
|
||||
var objNode = new TreeNode(name);
|
||||
objNode.Tag = paramObj;
|
||||
parentNode.Nodes.Add(objNode);
|
||||
}
|
||||
|
||||
private void OpenNewParamEditor(ParamEntry entry, ParamObject paramObject, ListViewItem SelectedItem)
|
||||
{
|
||||
EditBox editor = new EditBox();
|
||||
editor.LoadEntry(entry);
|
||||
editor.ToggleNameEditing(true);
|
||||
|
||||
if (editor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
editor.SaveEntry();
|
||||
SetListItemParamObject(entry, SelectedItem);
|
||||
listViewCustom1.Items.Add(SelectedItem);
|
||||
|
||||
var entryList = new List<ParamEntry>();
|
||||
for (int i = 0; i < paramObject.paramEntries.Length; i++)
|
||||
entryList.Add(paramObject.paramEntries[i]);
|
||||
|
||||
entryList.Add(entry);
|
||||
paramObject.paramEntries = entryList.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenEditor(ParamEntry entry, ListViewItem SelectedItem)
|
||||
{
|
||||
EditBox editor = new EditBox();
|
||||
editor.LoadEntry(entry);
|
||||
editor.ToggleNameEditing(true);
|
||||
|
||||
if (editor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
editor.SaveEntry();
|
||||
SetListItemParamObject(entry, SelectedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,236 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AampV2Library;
|
||||
using Syroot.Maths;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.Forms;
|
||||
|
||||
namespace FirstPlugin.Forms
|
||||
{
|
||||
public partial class AampV2Editor : AampEditorBase
|
||||
{
|
||||
public AampV2Editor(AAMP aamp, bool IsSaveDialog) : base(aamp, IsSaveDialog)
|
||||
{
|
||||
treeView1.Nodes.Add(aamp.FileName);
|
||||
LoadFile(aamp.aampFileV2, treeView1.Nodes[0]);
|
||||
}
|
||||
|
||||
public void LoadFile(AampFile aampFile, TreeNode parentNode)
|
||||
{
|
||||
LoadChildNodes(aampFile.RootNode, parentNode);
|
||||
}
|
||||
|
||||
public override void TreeView_AfterSelect()
|
||||
{
|
||||
var node = treeView1.SelectedNode;
|
||||
|
||||
if (node.Tag != null)
|
||||
{
|
||||
if (node.Tag is ParamObject)
|
||||
{
|
||||
LoadObjectDataList((ParamObject)node.Tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddParamEntry(TreeNode parentNode)
|
||||
{
|
||||
if (parentNode.Tag != null && parentNode.Tag is ParamObject)
|
||||
{
|
||||
ParamEntry entry = new ParamEntry();
|
||||
entry.ParamType = ParamType.Float;
|
||||
entry.HashString = "NewEntry";
|
||||
entry.Value = 0;
|
||||
|
||||
ListViewItem item = new ListViewItem();
|
||||
SetListItemParamObject(entry, item);
|
||||
|
||||
OpenNewParamEditor(entry, (ParamObject)parentNode.Tag, item);
|
||||
}
|
||||
}
|
||||
|
||||
public override void RenameParamEntry(ListViewItem SelectedItem)
|
||||
{
|
||||
if (SelectedItem.Tag != null && SelectedItem.Tag is ParamEntry)
|
||||
{
|
||||
RenameDialog dialog = new RenameDialog();
|
||||
dialog.SetString(SelectedItem.Text);
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string NewString = dialog.textBox1.Text;
|
||||
|
||||
((ParamEntry)SelectedItem.Tag).HashString = NewString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEditorClick(ListViewItem SelectedItem)
|
||||
{
|
||||
if (SelectedItem.Tag != null && SelectedItem.Tag is ParamEntry)
|
||||
{
|
||||
OpenEditor((ParamEntry)SelectedItem.Tag, SelectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadObjectDataList(ParamObject paramObj)
|
||||
{
|
||||
listViewCustom1.Items.Clear();
|
||||
foreach (var entry in paramObj.paramEntries)
|
||||
{
|
||||
ListViewItem item = new ListViewItem(entry.HashString);
|
||||
SetListItemParamObject(entry, item);
|
||||
listViewCustom1.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetListItemParamObject(ParamEntry entry, ListViewItem item)
|
||||
{
|
||||
item.SubItems.Clear();
|
||||
item.Text = entry.HashString;
|
||||
item.Tag = entry;
|
||||
item.UseItemStyleForSubItems = false;
|
||||
item.SubItems.Add(entry.ParamType.ToString());
|
||||
string ValueText = "";
|
||||
|
||||
System.Drawing.Color color = System.Drawing.Color.Empty;
|
||||
|
||||
switch (entry.ParamType)
|
||||
{
|
||||
case ParamType.Boolean:
|
||||
case ParamType.Float:
|
||||
case ParamType.Int:
|
||||
case ParamType.Uint:
|
||||
ValueText = $"{entry.Value}";
|
||||
break;
|
||||
case ParamType.String64:
|
||||
case ParamType.String32:
|
||||
case ParamType.String256:
|
||||
case ParamType.StringRef:
|
||||
ValueText = $"{((AampCommon.StringEntry)entry.Value).ToString()}";
|
||||
|
||||
break;
|
||||
case ParamType.Vector2F:
|
||||
var vec2 = (Vector2F)entry.Value;
|
||||
ValueText = $"{vec2.X} {vec2.Y}";
|
||||
break;
|
||||
case ParamType.Vector3F:
|
||||
var vec3 = (Vector3F)entry.Value;
|
||||
ValueText = $"{vec3.X} {vec3.Y} {vec3.Z}";
|
||||
break;
|
||||
case ParamType.Vector4F:
|
||||
var vec4 = (Vector4F)entry.Value;
|
||||
ValueText = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}";
|
||||
break;
|
||||
case ParamType.Color4F:
|
||||
var col = (Vector4F)entry.Value;
|
||||
ValueText = $"{col.X} {col.Y} {col.Z} {col.W}";
|
||||
|
||||
int ImageIndex = Images.Count;
|
||||
|
||||
color = System.Drawing.Color.FromArgb(
|
||||
EditBox.FloatToIntClamp(col.W),
|
||||
EditBox.FloatToIntClamp(col.X),
|
||||
EditBox.FloatToIntClamp(col.Y),
|
||||
EditBox.FloatToIntClamp(col.Z));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
item.SubItems.Add(ValueText);
|
||||
|
||||
if (color != System.Drawing.Color.Empty)
|
||||
item.SubItems[2].BackColor = color;
|
||||
}
|
||||
|
||||
public override void OnEntryDeletion(object obj, TreeNode objNode)
|
||||
{
|
||||
if (obj is ParamEntry)
|
||||
{
|
||||
var paramObjectParent = (ParamObject)objNode.Tag;
|
||||
|
||||
var entryList = new List<ParamEntry>();
|
||||
for (int i = 0; i < paramObjectParent.paramEntries.Length; i++)
|
||||
entryList.Add(paramObjectParent.paramEntries[i]);
|
||||
|
||||
entryList.Remove((ParamEntry)obj);
|
||||
|
||||
paramObjectParent.paramEntries = entryList.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadChildNodes(ParamList paramList, TreeNode parentNode)
|
||||
{
|
||||
TreeNode newNode = new TreeNode(paramList.HashString);
|
||||
newNode.Tag = paramList;
|
||||
|
||||
parentNode.Nodes.Add(newNode);
|
||||
|
||||
//Add lists and objects if exits
|
||||
if (paramList.childParams.Length > 0)
|
||||
newNode.Nodes.Add("list", "Lists {}");
|
||||
if (paramList.paramObjects.Length > 0)
|
||||
newNode.Nodes.Add("obj", "Objects {}");
|
||||
|
||||
//Add child nodes
|
||||
foreach (var child in paramList.childParams)
|
||||
LoadChildNodes(child, newNode.Nodes["list"]);
|
||||
|
||||
//Add object nodes
|
||||
foreach (var obj in paramList.paramObjects)
|
||||
SetObjNode(obj, newNode.Nodes["obj"]);
|
||||
}
|
||||
|
||||
List<Bitmap> Images = new List<Bitmap>();
|
||||
|
||||
void SetObjNode(ParamObject paramObj, TreeNode parentNode)
|
||||
{
|
||||
string name = paramObj.HashString;
|
||||
|
||||
var objNode = new TreeNode(name);
|
||||
objNode.Tag = paramObj;
|
||||
parentNode.Nodes.Add(objNode);
|
||||
}
|
||||
|
||||
private void OpenNewParamEditor(ParamEntry entry, ParamObject paramObject, ListViewItem SelectedItem)
|
||||
{
|
||||
EditBox editor = new EditBox();
|
||||
editor.LoadEntry(entry);
|
||||
editor.ToggleNameEditing(true);
|
||||
|
||||
if (editor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
editor.SaveEntry();
|
||||
SetListItemParamObject(entry, SelectedItem);
|
||||
listViewCustom1.Items.Add(SelectedItem);
|
||||
|
||||
var entryList = new List<ParamEntry>();
|
||||
for (int i = 0; i < paramObject.paramEntries.Length; i++)
|
||||
entryList.Add(paramObject.paramEntries[i]);
|
||||
|
||||
entryList.Add(entry);
|
||||
paramObject.paramEntries = entryList.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenEditor(ParamEntry entry, ListViewItem SelectedItem)
|
||||
{
|
||||
EditBox editor = new EditBox();
|
||||
editor.LoadEntry(entry);
|
||||
editor.ToggleNameEditing(true);
|
||||
|
||||
if (editor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
editor.SaveEntry();
|
||||
SetListItemParamObject(entry, SelectedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
File_Format_Library/GUI/AAMP/EditBox.Designer.cs
generated
133
File_Format_Library/GUI/AAMP/EditBox.Designer.cs
generated
|
@ -1,133 +0,0 @@
|
|||
namespace FirstPlugin.Forms
|
||||
{
|
||||
partial class EditBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.nameTB = new System.Windows.Forms.TextBox();
|
||||
this.typeCB = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.dataTB = new System.Windows.Forms.TextBox();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTB
|
||||
//
|
||||
this.nameTB.Enabled = false;
|
||||
this.nameTB.Location = new System.Drawing.Point(76, 12);
|
||||
this.nameTB.Name = "nameTB";
|
||||
this.nameTB.Size = new System.Drawing.Size(220, 20);
|
||||
this.nameTB.TabIndex = 0;
|
||||
//
|
||||
// typeCB
|
||||
//
|
||||
this.typeCB.FormattingEnabled = true;
|
||||
this.typeCB.Location = new System.Drawing.Point(76, 38);
|
||||
this.typeCB.Name = "typeCB";
|
||||
this.typeCB.Size = new System.Drawing.Size(220, 21);
|
||||
this.typeCB.TabIndex = 1;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 15);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(38, 13);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "Name:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 41);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(34, 13);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Type:";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button1.Location = new System.Drawing.Point(275, 187);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 5;
|
||||
this.button1.Text = "Save";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// dataTB
|
||||
//
|
||||
this.dataTB.Location = new System.Drawing.Point(12, 74);
|
||||
this.dataTB.Multiline = true;
|
||||
this.dataTB.Name = "dataTB";
|
||||
this.dataTB.Size = new System.Drawing.Size(346, 107);
|
||||
this.dataTB.TabIndex = 6;
|
||||
this.dataTB.TextChanged += new System.EventHandler(this.dataTB_TextChanged);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Location = new System.Drawing.Point(302, 12);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(56, 50);
|
||||
this.pictureBox1.TabIndex = 7;
|
||||
this.pictureBox1.TabStop = false;
|
||||
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
|
||||
//
|
||||
// EditBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(362, 216);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.dataTB);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.typeCB);
|
||||
this.Controls.Add(this.nameTB);
|
||||
this.Name = "EditBox";
|
||||
this.Text = "EditBox";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox nameTB;
|
||||
private System.Windows.Forms.ComboBox typeCB;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.TextBox dataTB;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
}
|
||||
}
|
|
@ -7,8 +7,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AampV1Library;
|
||||
using Aampv2 = AampV2Library;
|
||||
using AampLibraryCSharp;
|
||||
using Syroot.Maths;
|
||||
|
||||
namespace FirstPlugin.Forms
|
||||
|
@ -26,39 +25,6 @@ namespace FirstPlugin.Forms
|
|||
}
|
||||
|
||||
ParamEntry paramEntry;
|
||||
Aampv2.ParamEntry paramEntryV2;
|
||||
|
||||
public void LoadEntry(Aampv2.ParamEntry entry)
|
||||
{
|
||||
typeCB.Items.Clear();
|
||||
|
||||
foreach (var type in Enum.GetValues(typeof(AampV2Library.ParamType)).Cast<AampV2Library.ParamType>())
|
||||
typeCB.Items.Add(type);
|
||||
|
||||
paramEntryV2 = entry;
|
||||
nameTB.Text = entry.HashString;
|
||||
typeCB.SelectedItem = entry.ParamType;
|
||||
|
||||
dataTB.Text = entry.Value.ToString();
|
||||
|
||||
switch (entry.ParamType)
|
||||
{
|
||||
case AampV2Library.ParamType.Vector2F:
|
||||
var vec2 = (Vector2F)entry.Value;
|
||||
dataTB.Text = $"{vec2.X} {vec2.Y}";
|
||||
break;
|
||||
case AampV2Library.ParamType.Vector3F:
|
||||
var vec3 = (Vector3F)entry.Value;
|
||||
dataTB.Text = $"{vec3.X} {vec3.Y} {vec3.Z}";
|
||||
break;
|
||||
case AampV2Library.ParamType.Vector4F:
|
||||
case AampV2Library.ParamType.Color4F:
|
||||
var vec4 = (Vector4F)entry.Value;
|
||||
dataTB.Text = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadEntry(ParamEntry entry)
|
||||
{
|
||||
typeCB.Items.Clear();
|
||||
|
@ -87,6 +53,18 @@ namespace FirstPlugin.Forms
|
|||
var vec4 = (Vector4F)entry.Value;
|
||||
dataTB.Text = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}";
|
||||
break;
|
||||
case ParamType.BufferBinary:
|
||||
dataTB.Text = string.Join(",", (byte[])entry.Value);
|
||||
break;
|
||||
case ParamType.BufferFloat:
|
||||
dataTB.Text = string.Join(",", (float[])entry.Value);
|
||||
break;
|
||||
case ParamType.BufferInt:
|
||||
dataTB.Text = string.Join(",", (int[])entry.Value);
|
||||
break;
|
||||
case ParamType.BufferUint:
|
||||
dataTB.Text = string.Join(",", (uint[])entry.Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,43 +94,69 @@ namespace FirstPlugin.Forms
|
|||
int.TryParse(dataTB.Text, out valueInt);
|
||||
paramEntry.Value = valueInt;
|
||||
break;
|
||||
case ParamType.BufferUint:
|
||||
{
|
||||
var strings = dataTB.Text.Split(',');
|
||||
var array = new uint[strings.Length];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
array[i] = uint.Parse(strings[i]);
|
||||
paramEntry.Value = array;
|
||||
}
|
||||
break;
|
||||
case ParamType.BufferInt:
|
||||
{
|
||||
var strings = dataTB.Text.Split(',');
|
||||
var array = new int[strings.Length];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
array[i] = int.Parse(strings[i]);
|
||||
paramEntry.Value = array;
|
||||
}
|
||||
break;
|
||||
case ParamType.BufferFloat:
|
||||
{
|
||||
var strings = dataTB.Text.Split(',');
|
||||
var array = new float[strings.Length];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
array[i] = float.Parse(strings[i]);
|
||||
paramEntry.Value = array;
|
||||
}
|
||||
break;
|
||||
case ParamType.BufferBinary:
|
||||
{
|
||||
var strings = dataTB.Text.Split(',');
|
||||
var array = new byte[strings.Length];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
array[i] = byte.Parse(strings[i]);
|
||||
paramEntry.Value = array;
|
||||
}
|
||||
break;
|
||||
case ParamType.Vector2F:
|
||||
var values2F = dataTB.Text.Split(' ');
|
||||
if (values2F.Length != 2)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (values2F.Length == 2) {
|
||||
float x, y;
|
||||
float.TryParse(values2F[0], out x);
|
||||
float.TryParse(values2F[1], out y);
|
||||
paramEntry.Value = new Vector2F(x, y);
|
||||
}
|
||||
else
|
||||
throw new Exception("Invalid amount of values. Type requires 2 values.");
|
||||
break;
|
||||
case ParamType.Vector3F:
|
||||
var values3F = dataTB.Text.Split(' ');
|
||||
if (values3F.Length != 3)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (values3F.Length == 3) {
|
||||
float x, y, z;
|
||||
float.TryParse(values3F[0], out x);
|
||||
float.TryParse(values3F[1], out y);
|
||||
float.TryParse(values3F[2], out z);
|
||||
paramEntry.Value = new Vector3F(x, y, z);
|
||||
}
|
||||
else
|
||||
throw new Exception("Invalid amount of values. Type requires 3 values.");
|
||||
break;
|
||||
case ParamType.Vector4F:
|
||||
case ParamType.Color4F:
|
||||
var values = dataTB.Text.Split(' ');
|
||||
if (values.Length != 4)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
if (values.Length == 4)
|
||||
{
|
||||
float x, y, z, w;
|
||||
float.TryParse(values[0], out x);
|
||||
|
@ -161,6 +165,8 @@ namespace FirstPlugin.Forms
|
|||
float.TryParse(values[3], out w);
|
||||
paramEntry.Value = new Vector4F(x, y, z, w);
|
||||
}
|
||||
else
|
||||
throw new Exception("Invalid amount of values. Type requires 4 values.");
|
||||
break;
|
||||
case ParamType.Uint:
|
||||
uint valueUInt = 0;
|
||||
|
@ -171,114 +177,19 @@ namespace FirstPlugin.Forms
|
|||
case ParamType.String32:
|
||||
case ParamType.String256:
|
||||
case ParamType.StringRef:
|
||||
paramEntry.Value = new AampCommon.StringEntry(dataTB.Text);
|
||||
paramEntry.Value = new AampLibraryCSharp.StringEntry(dataTB.Text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
paramEntryV2.ParamType = (AampV2Library.ParamType)typeCB.SelectedItem;
|
||||
|
||||
if (nameTB.Enabled)
|
||||
paramEntryV2.HashString = nameTB.Text;
|
||||
|
||||
switch (paramEntryV2.ParamType)
|
||||
{
|
||||
case AampV2Library.ParamType.Boolean:
|
||||
bool value = false;
|
||||
bool.TryParse(dataTB.Text, out value);
|
||||
paramEntryV2.Value = value;
|
||||
break;
|
||||
case AampV2Library.ParamType.Float:
|
||||
float valueF = 0;
|
||||
float.TryParse(dataTB.Text, out valueF);
|
||||
paramEntryV2.Value = valueF;
|
||||
break;
|
||||
case AampV2Library.ParamType.Int:
|
||||
int valueInt = 0;
|
||||
int.TryParse(dataTB.Text, out valueInt);
|
||||
paramEntryV2.Value = valueInt;
|
||||
break;
|
||||
case AampV2Library.ParamType.Vector2F:
|
||||
var values2F = dataTB.Text.Split(' ');
|
||||
if (values2F.Length != 2)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
float x, y;
|
||||
float.TryParse(values2F[0], out x);
|
||||
float.TryParse(values2F[1], out y);
|
||||
paramEntryV2.Value = new Vector2F(x, y);
|
||||
}
|
||||
break;
|
||||
case AampV2Library.ParamType.Vector3F:
|
||||
var values3F = dataTB.Text.Split(' ');
|
||||
if (values3F.Length != 3)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
float x, y, z;
|
||||
float.TryParse(values3F[0], out x);
|
||||
float.TryParse(values3F[1], out y);
|
||||
float.TryParse(values3F[2], out z);
|
||||
paramEntryV2.Value = new Vector3F(x, y, z);
|
||||
}
|
||||
break;
|
||||
case AampV2Library.ParamType.Vector4F:
|
||||
case AampV2Library.ParamType.Color4F:
|
||||
var values = dataTB.Text.Split(' ');
|
||||
if (values.Length != 4)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
float x, y, z, w;
|
||||
float.TryParse(values[0], out x);
|
||||
float.TryParse(values[1], out y);
|
||||
float.TryParse(values[2], out z);
|
||||
float.TryParse(values[3], out w);
|
||||
paramEntryV2.Value = new Vector4F(x, y, z, w);
|
||||
}
|
||||
break;
|
||||
case AampV2Library.ParamType.Uint:
|
||||
uint valueUInt = 0;
|
||||
uint.TryParse(dataTB.Text, out valueUInt);
|
||||
paramEntryV2.Value = valueUInt;
|
||||
break;
|
||||
case AampV2Library.ParamType.String64:
|
||||
case AampV2Library.ParamType.String32:
|
||||
case AampV2Library.ParamType.String256:
|
||||
case AampV2Library.ParamType.StringRef:
|
||||
paramEntryV2.Value = new AampCommon.StringEntry(dataTB.Text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dataTB_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (paramEntry != null)
|
||||
switch (paramEntry.ParamType)
|
||||
{
|
||||
switch (paramEntry.ParamType)
|
||||
{
|
||||
case ParamType.Color4F:
|
||||
UpdatePictureboxColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (paramEntryV2.ParamType)
|
||||
{
|
||||
case AampV2Library.ParamType.Color4F:
|
||||
UpdatePictureboxColor();
|
||||
break;
|
||||
}
|
||||
case ParamType.Color4F:
|
||||
UpdatePictureboxColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,24 +241,145 @@ namespace FirstPlugin.Forms
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paramEntryV2.ParamType == AampV2Library.ParamType.Color4F)
|
||||
{
|
||||
ColorDialog dlg = new ColorDialog();
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
paramEntryV2.Value = new Vector4F(
|
||||
dlg.Color.R / 255.0f,
|
||||
dlg.Color.G / 255.0f,
|
||||
dlg.Color.B / 255.0f,
|
||||
dlg.Color.A / 255.0f);
|
||||
|
||||
var vec4 = (Vector4F)paramEntryV2.Value;
|
||||
dataTB.Text = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.nameTB = new System.Windows.Forms.TextBox();
|
||||
this.typeCB = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.dataTB = new System.Windows.Forms.TextBox();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTB
|
||||
//
|
||||
this.nameTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.nameTB.Enabled = false;
|
||||
this.nameTB.Location = new System.Drawing.Point(76, 12);
|
||||
this.nameTB.Name = "nameTB";
|
||||
this.nameTB.Size = new System.Drawing.Size(220, 20);
|
||||
this.nameTB.TabIndex = 0;
|
||||
//
|
||||
// typeCB
|
||||
//
|
||||
this.typeCB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.typeCB.FormattingEnabled = true;
|
||||
this.typeCB.Location = new System.Drawing.Point(76, 38);
|
||||
this.typeCB.Name = "typeCB";
|
||||
this.typeCB.Size = new System.Drawing.Size(220, 21);
|
||||
this.typeCB.TabIndex = 1;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 15);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(38, 13);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "Name:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 41);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(34, 13);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Type:";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button1.Location = new System.Drawing.Point(275, 187);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 5;
|
||||
this.button1.Text = "Save";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// dataTB
|
||||
//
|
||||
this.dataTB.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dataTB.Location = new System.Drawing.Point(12, 74);
|
||||
this.dataTB.Multiline = true;
|
||||
this.dataTB.Name = "dataTB";
|
||||
this.dataTB.Size = new System.Drawing.Size(346, 107);
|
||||
this.dataTB.TabIndex = 6;
|
||||
this.dataTB.TextChanged += new System.EventHandler(this.dataTB_TextChanged);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pictureBox1.Location = new System.Drawing.Point(302, 12);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(56, 50);
|
||||
this.pictureBox1.TabIndex = 7;
|
||||
this.pictureBox1.TabStop = false;
|
||||
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
|
||||
//
|
||||
// EditBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(362, 216);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.dataTB);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.typeCB);
|
||||
this.Controls.Add(this.nameTB);
|
||||
this.Name = "EditBox";
|
||||
this.Text = "EditBox";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox nameTB;
|
||||
private System.Windows.Forms.ComboBox typeCB;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.TextBox dataTB;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
}
|
||||
}
|
||||
|
|
109
File_Format_Library/GUI/Byaml/ByamlEditor.Designer.cs
generated
109
File_Format_Library/GUI/Byaml/ByamlEditor.Designer.cs
generated
|
@ -35,11 +35,11 @@
|
|||
this.editValueNodeMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.deleteNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exportJsonToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.importFromXmlToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.importFromXmlToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.stPanel1 = new Toolbox.Library.Forms.STPanel();
|
||||
this.stTabControl1 = new Toolbox.Library.Forms.STTabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
|
@ -50,11 +50,9 @@
|
|||
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.stPanel4 = new Toolbox.Library.Forms.STPanel();
|
||||
this.stPanel3 = new Toolbox.Library.Forms.STPanel();
|
||||
this.btnToXml = new Toolbox.Library.Forms.STButton();
|
||||
this.stPanel2 = new Toolbox.Library.Forms.STPanel();
|
||||
this.btnXmlToByaml = new Toolbox.Library.Forms.STButton();
|
||||
this.stMenuStrip1 = new Toolbox.Library.Forms.STMenuStrip();
|
||||
this.stContextMenuStrip1 = new Toolbox.Library.Forms.STContextMenuStrip(this.components);
|
||||
this.addItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -62,7 +60,7 @@
|
|||
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.copyDataAsTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.stPanel4 = new Toolbox.Library.Forms.STPanel();
|
||||
this.chkShiftJISEncoding = new Toolbox.Library.Forms.STCheckBox();
|
||||
this.contextMenuStrip1.SuspendLayout();
|
||||
this.stPanel1.SuspendLayout();
|
||||
this.stTabControl1.SuspendLayout();
|
||||
|
@ -83,11 +81,11 @@
|
|||
this.editValueNodeMenuItem,
|
||||
this.deleteNodeToolStripMenuItem,
|
||||
this.exportJsonToolStripMenuItem,
|
||||
this.importFromXmlToolStripMenuItem,
|
||||
this.toolStripSeparator1,
|
||||
this.saveAsToolStripMenuItem,
|
||||
this.saveToolStripMenuItem,
|
||||
this.toolStripSeparator2,
|
||||
this.importFromXmlToolStripMenuItem});
|
||||
this.toolStripSeparator2});
|
||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
this.contextMenuStrip1.Size = new System.Drawing.Size(170, 192);
|
||||
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuOpening);
|
||||
|
@ -124,9 +122,16 @@
|
|||
//
|
||||
this.exportJsonToolStripMenuItem.Name = "exportJsonToolStripMenuItem";
|
||||
this.exportJsonToolStripMenuItem.Size = new System.Drawing.Size(169, 22);
|
||||
this.exportJsonToolStripMenuItem.Text = "Export as xml";
|
||||
this.exportJsonToolStripMenuItem.Text = "Export";
|
||||
this.exportJsonToolStripMenuItem.Click += new System.EventHandler(this.exportJsonToolStripMenuItem_Click);
|
||||
//
|
||||
// importFromXmlToolStripMenuItem
|
||||
//
|
||||
this.importFromXmlToolStripMenuItem.Name = "importFromXmlToolStripMenuItem";
|
||||
this.importFromXmlToolStripMenuItem.Size = new System.Drawing.Size(169, 22);
|
||||
this.importFromXmlToolStripMenuItem.Text = "Import";
|
||||
this.importFromXmlToolStripMenuItem.Click += new System.EventHandler(this.importFromXmlToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
|
@ -152,17 +157,10 @@
|
|||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
this.toolStripSeparator2.Size = new System.Drawing.Size(166, 6);
|
||||
//
|
||||
// importFromXmlToolStripMenuItem
|
||||
//
|
||||
this.importFromXmlToolStripMenuItem.Name = "importFromXmlToolStripMenuItem";
|
||||
this.importFromXmlToolStripMenuItem.Size = new System.Drawing.Size(169, 22);
|
||||
this.importFromXmlToolStripMenuItem.Text = "Import from xml";
|
||||
this.importFromXmlToolStripMenuItem.Click += new System.EventHandler(this.importFromXmlToolStripMenuItem_Click);
|
||||
//
|
||||
// stPanel1
|
||||
//
|
||||
this.stPanel1.Controls.Add(this.chkShiftJISEncoding);
|
||||
this.stPanel1.Controls.Add(this.stTabControl1);
|
||||
this.stPanel1.Controls.Add(this.stMenuStrip1);
|
||||
this.stPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.stPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.stPanel1.Name = "stPanel1";
|
||||
|
@ -176,11 +174,11 @@
|
|||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.stTabControl1.Controls.Add(this.tabPage1);
|
||||
this.stTabControl1.Controls.Add(this.tabPage2);
|
||||
this.stTabControl1.Location = new System.Drawing.Point(0, 27);
|
||||
this.stTabControl1.Location = new System.Drawing.Point(0, 20);
|
||||
this.stTabControl1.myBackColor = System.Drawing.Color.Empty;
|
||||
this.stTabControl1.Name = "stTabControl1";
|
||||
this.stTabControl1.SelectedIndex = 0;
|
||||
this.stTabControl1.Size = new System.Drawing.Size(549, 368);
|
||||
this.stTabControl1.Size = new System.Drawing.Size(549, 378);
|
||||
this.stTabControl1.TabIndex = 15;
|
||||
//
|
||||
// tabPage1
|
||||
|
@ -189,7 +187,7 @@
|
|||
this.tabPage1.Location = new System.Drawing.Point(4, 25);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(541, 339);
|
||||
this.tabPage1.Size = new System.Drawing.Size(541, 349);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "Editor";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
|
@ -207,7 +205,7 @@
|
|||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.listViewCustom1);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(535, 333);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(535, 343);
|
||||
this.splitContainer1.SplitterDistance = 178;
|
||||
this.splitContainer1.TabIndex = 14;
|
||||
//
|
||||
|
@ -218,10 +216,11 @@
|
|||
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.treeView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.treeView1.Name = "treeView1";
|
||||
this.treeView1.Size = new System.Drawing.Size(178, 333);
|
||||
this.treeView1.Size = new System.Drawing.Size(178, 343);
|
||||
this.treeView1.TabIndex = 0;
|
||||
this.treeView1.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.BeforeExpand);
|
||||
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
|
||||
this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_MouseClick);
|
||||
//
|
||||
// listViewCustom1
|
||||
//
|
||||
|
@ -236,7 +235,7 @@
|
|||
this.listViewCustom1.Location = new System.Drawing.Point(0, 0);
|
||||
this.listViewCustom1.Name = "listViewCustom1";
|
||||
this.listViewCustom1.OwnerDraw = true;
|
||||
this.listViewCustom1.Size = new System.Drawing.Size(353, 333);
|
||||
this.listViewCustom1.Size = new System.Drawing.Size(353, 343);
|
||||
this.listViewCustom1.TabIndex = 0;
|
||||
this.listViewCustom1.UseCompatibleStateImageBehavior = false;
|
||||
this.listViewCustom1.View = System.Windows.Forms.View.Details;
|
||||
|
@ -261,17 +260,23 @@
|
|||
//
|
||||
this.tabPage2.Controls.Add(this.stPanel4);
|
||||
this.tabPage2.Controls.Add(this.stPanel3);
|
||||
this.tabPage2.Controls.Add(this.btnToXml);
|
||||
this.tabPage2.Controls.Add(this.stPanel2);
|
||||
this.tabPage2.Controls.Add(this.btnXmlToByaml);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 25);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(541, 339);
|
||||
this.tabPage2.Size = new System.Drawing.Size(541, 369);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "XML Editor";
|
||||
this.tabPage2.Text = "Text Editor";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// stPanel4
|
||||
//
|
||||
this.stPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.stPanel4.Location = new System.Drawing.Point(3, 3);
|
||||
this.stPanel4.Name = "stPanel4";
|
||||
this.stPanel4.Size = new System.Drawing.Size(535, 363);
|
||||
this.stPanel4.TabIndex = 4;
|
||||
//
|
||||
// stPanel3
|
||||
//
|
||||
this.stPanel3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
|
@ -282,17 +287,6 @@
|
|||
this.stPanel3.Size = new System.Drawing.Size(0, 0);
|
||||
this.stPanel3.TabIndex = 3;
|
||||
//
|
||||
// btnToXml
|
||||
//
|
||||
this.btnToXml.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnToXml.Location = new System.Drawing.Point(15, 6);
|
||||
this.btnToXml.Name = "btnToXml";
|
||||
this.btnToXml.Size = new System.Drawing.Size(107, 23);
|
||||
this.btnToXml.TabIndex = 2;
|
||||
this.btnToXml.Text = "Generate";
|
||||
this.btnToXml.UseVisualStyleBackColor = false;
|
||||
this.btnToXml.Click += new System.EventHandler(this.btnToXml_Click);
|
||||
//
|
||||
// stPanel2
|
||||
//
|
||||
this.stPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
|
@ -303,26 +297,6 @@
|
|||
this.stPanel2.Size = new System.Drawing.Size(0, 0);
|
||||
this.stPanel2.TabIndex = 1;
|
||||
//
|
||||
// btnXmlToByaml
|
||||
//
|
||||
this.btnXmlToByaml.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnXmlToByaml.Location = new System.Drawing.Point(128, 6);
|
||||
this.btnXmlToByaml.Name = "btnXmlToByaml";
|
||||
this.btnXmlToByaml.Size = new System.Drawing.Size(107, 23);
|
||||
this.btnXmlToByaml.TabIndex = 0;
|
||||
this.btnXmlToByaml.Text = "Compile";
|
||||
this.btnXmlToByaml.UseVisualStyleBackColor = false;
|
||||
this.btnXmlToByaml.Click += new System.EventHandler(this.btnXmlToByaml_Click);
|
||||
//
|
||||
// stMenuStrip1
|
||||
//
|
||||
this.stMenuStrip1.HighlightSelectedTab = false;
|
||||
this.stMenuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.stMenuStrip1.Name = "stMenuStrip1";
|
||||
this.stMenuStrip1.Size = new System.Drawing.Size(549, 24);
|
||||
this.stMenuStrip1.TabIndex = 16;
|
||||
this.stMenuStrip1.Text = "stMenuStrip1";
|
||||
//
|
||||
// stContextMenuStrip1
|
||||
//
|
||||
this.stContextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
|
@ -377,15 +351,16 @@
|
|||
this.copyDataAsTextToolStripMenuItem.Text = "Copy data as text";
|
||||
this.copyDataAsTextToolStripMenuItem.Click += new System.EventHandler(this.copyDataAsTextToolStripMenuItem_Click);
|
||||
//
|
||||
// stPanel4
|
||||
// chkShiftJISEncoding
|
||||
//
|
||||
this.stPanel4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.stPanel4.Location = new System.Drawing.Point(15, 35);
|
||||
this.stPanel4.Name = "stPanel4";
|
||||
this.stPanel4.Size = new System.Drawing.Size(520, 298);
|
||||
this.stPanel4.TabIndex = 4;
|
||||
this.chkShiftJISEncoding.AutoSize = true;
|
||||
this.chkShiftJISEncoding.Location = new System.Drawing.Point(7, 3);
|
||||
this.chkShiftJISEncoding.Name = "chkShiftJISEncoding";
|
||||
this.chkShiftJISEncoding.Size = new System.Drawing.Size(135, 17);
|
||||
this.chkShiftJISEncoding.TabIndex = 1;
|
||||
this.chkShiftJISEncoding.Text = "Use Shift JIS Encoding";
|
||||
this.chkShiftJISEncoding.UseVisualStyleBackColor = true;
|
||||
this.chkShiftJISEncoding.CheckedChanged += new System.EventHandler(this.chkShiftJISEncoding_CheckedChanged);
|
||||
//
|
||||
// ByamlEditor
|
||||
//
|
||||
|
@ -438,13 +413,11 @@
|
|||
private Toolbox.Library.Forms.STTabControl stTabControl1;
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
private Toolbox.Library.Forms.STButton btnXmlToByaml;
|
||||
private Toolbox.Library.Forms.STPanel stPanel2;
|
||||
private Toolbox.Library.Forms.STButton btnToXml;
|
||||
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem copyDataAsTextToolStripMenuItem;
|
||||
private Toolbox.Library.Forms.STPanel stPanel3;
|
||||
private Toolbox.Library.Forms.STMenuStrip stMenuStrip1;
|
||||
private Toolbox.Library.Forms.STPanel stPanel4;
|
||||
private Toolbox.Library.Forms.STCheckBox chkShiftJISEncoding;
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ using Toolbox.Library.Forms;
|
|||
using Toolbox.Library;
|
||||
using ByamlExt;
|
||||
using FirstPlugin.Forms;
|
||||
using ByamlExt.Byaml;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
|
@ -22,7 +23,7 @@ namespace FirstPlugin
|
|||
//Added as an editor form for saving data back via other plugins
|
||||
public partial class ByamlEditor : UserControl, IFIleEditor
|
||||
{
|
||||
public IFileFormat FileFormat;
|
||||
public BYAML FileFormat;
|
||||
|
||||
public List<IFileFormat> GetFileFormats()
|
||||
{
|
||||
|
@ -30,14 +31,19 @@ namespace FirstPlugin
|
|||
}
|
||||
|
||||
public ByteOrder byteOrder;
|
||||
public dynamic byml;
|
||||
public dynamic byml
|
||||
{
|
||||
get { return FileFormat.BymlData.RootNode; }
|
||||
set { FileFormat.BymlData.RootNode = value; }
|
||||
}
|
||||
|
||||
public string FileName = "";
|
||||
bool pathSupport;
|
||||
ushort bymlVer;
|
||||
|
||||
bool useMuunt = true;
|
||||
|
||||
private TextEditor xmlEditor;
|
||||
private TextEditor textEditor;
|
||||
|
||||
public ByamlEditor()
|
||||
{
|
||||
|
@ -55,6 +61,7 @@ namespace FirstPlugin
|
|||
|
||||
private void Reload()
|
||||
{
|
||||
chkShiftJISEncoding.Checked = BymlFileData.Encoding == Encoding.GetEncoding("shift_jis");
|
||||
treeView1.BackColor = FormThemes.BaseTheme.FormBackColor;
|
||||
treeView1.ForeColor = FormThemes.BaseTheme.FormForeColor;
|
||||
treeView1.Nodes.Clear();
|
||||
|
@ -91,10 +98,13 @@ namespace FirstPlugin
|
|||
if (byml == null) return;
|
||||
ParseBymlFirstNode();
|
||||
|
||||
xmlEditor = new TextEditor();
|
||||
stPanel4.Controls.Add(xmlEditor);
|
||||
xmlEditor.Dock = DockStyle.Fill;
|
||||
xmlEditor.IsXML = true;
|
||||
stPanel4.Controls.Clear();
|
||||
|
||||
textEditor = new TextEditor();
|
||||
textEditor.ClearContextMenus();
|
||||
textEditor.AddContextMenu("Decompile", TextEditorToYaml);
|
||||
textEditor.AddContextMenu("Compile", TextEditorFromYaml);
|
||||
stPanel4.Controls.Add(textEditor);
|
||||
}
|
||||
|
||||
void ParseBymlFirstNode()
|
||||
|
@ -105,7 +115,7 @@ namespace FirstPlugin
|
|||
treeView1.SelectedNode = root;
|
||||
|
||||
//the first node should always be a dictionary node
|
||||
if (byml is Dictionary<string, dynamic>)
|
||||
if (byml is IDictionary<string, dynamic>)
|
||||
{
|
||||
parseDictNode(byml, root.Nodes);
|
||||
}
|
||||
|
@ -169,7 +179,7 @@ namespace FirstPlugin
|
|||
{
|
||||
foreach (string k in node.Keys)
|
||||
{
|
||||
if ((node[k] is Dictionary<string, dynamic>) ||
|
||||
if ((node[k] is IDictionary<string, dynamic>) ||
|
||||
(node[k] is List<dynamic>) ||
|
||||
(node[k] is List<ByamlPathPoint>))
|
||||
{
|
||||
|
@ -206,7 +216,7 @@ namespace FirstPlugin
|
|||
int index = 0;
|
||||
foreach (dynamic k in list)
|
||||
{
|
||||
if ((k is Dictionary<string, dynamic>) ||
|
||||
if ((k is IDictionary<string, dynamic>) ||
|
||||
(k is List<dynamic>) ||
|
||||
(k is List<ByamlPathPoint>))
|
||||
{
|
||||
|
@ -403,10 +413,20 @@ namespace FirstPlugin
|
|||
|
||||
private void exportJsonToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sav = new SaveFileDialog() { Filter = "Xml file | *.xml" };
|
||||
SaveFileDialog sav = new SaveFileDialog() { Filter = TextFilter };
|
||||
sav.FileName = Path.GetFileNameWithoutExtension(FileName);
|
||||
sav.DefaultExt = ".yaml";
|
||||
if (sav.ShowDialog() != DialogResult.OK) return;
|
||||
File.WriteAllText(sav.FileName,
|
||||
XmlConverter.ToXml(new BymlFileData { Version = bymlVer, byteOrder = byteOrder, SupportPaths = pathSupport, RootNode = byml }));
|
||||
|
||||
string ext = Utils.GetExtension(sav.FileName);
|
||||
if (ext == ".xml") {
|
||||
File.WriteAllText(sav.FileName, XmlByamlConverter.ToXML(FileFormat.BymlData));
|
||||
}
|
||||
else {
|
||||
File.WriteAllText(sav.FileName, YamlByamlConverter.ToYaml(FileFormat.BymlData));
|
||||
}
|
||||
|
||||
MessageBox.Show("Byaml converted successfully!");
|
||||
}
|
||||
|
||||
public static void ImportFromJson()
|
||||
|
@ -424,6 +444,18 @@ namespace FirstPlugin
|
|||
}
|
||||
}
|
||||
|
||||
private static string TextFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Supported Formats|*.yaml;*.xml;|" +
|
||||
"YAML |*.yaml|" +
|
||||
"XML |*.xml|" +
|
||||
"All files(*.*)|*.*";
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
static bool SupportPaths()
|
||||
{
|
||||
return MessageBox.Show("Does this game support paths ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes;
|
||||
|
@ -570,15 +602,17 @@ namespace FirstPlugin
|
|||
return;
|
||||
|
||||
dynamic targetNode = treeView1.SelectedNode.Tag;
|
||||
dynamic target = listViewCustom1.SelectedItems[0].Tag;
|
||||
if (targetNode is IDictionary<string, dynamic>)
|
||||
((IDictionary<string, dynamic>)targetNode).Remove(listViewCustom1.SelectedItems[0].Text);
|
||||
if (targetNode is IList<dynamic>)
|
||||
((IList<dynamic>)targetNode).Remove(target);
|
||||
foreach (ListViewItem item in listViewCustom1.SelectedItems)
|
||||
{
|
||||
dynamic target = item.Tag;
|
||||
if (targetNode is IDictionary<string, dynamic>)
|
||||
((IDictionary<string, dynamic>)targetNode).Remove(item.Text);
|
||||
if (targetNode is IList<dynamic>)
|
||||
((IList<dynamic>)targetNode).Remove(target);
|
||||
|
||||
int index = listViewCustom1.Items.IndexOf(listViewCustom1.SelectedItems[0]);
|
||||
|
||||
listViewCustom1.Items.RemoveAt(index);
|
||||
int index = listViewCustom1.Items.IndexOf(item);
|
||||
listViewCustom1.Items.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
private void renameToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -638,13 +672,14 @@ namespace FirstPlugin
|
|||
target = treeView1.SelectedNode.Parent.Tag;
|
||||
targetNode = treeView1.SelectedNode.Parent.Nodes;
|
||||
}
|
||||
|
||||
int index = targetNode.IndexOf(treeView1.SelectedNode);
|
||||
if (target is Dictionary<string, dynamic>)
|
||||
{
|
||||
target.Remove(((Dictionary<string, dynamic>)target).Keys.ToArray()[index]);
|
||||
}
|
||||
else
|
||||
target.RemoveAt(targetNode.IndexOf(treeView1.SelectedNode));
|
||||
|
||||
if (target is IDictionary<string, dynamic>)
|
||||
target.Remove(((Dictionary<string, dynamic>)target).ElementAt(index).Key);
|
||||
if (target is IList<dynamic>)
|
||||
target.RemoveAt(index);
|
||||
|
||||
targetNode.RemoveAt(index);
|
||||
}
|
||||
|
||||
|
@ -658,12 +693,19 @@ namespace FirstPlugin
|
|||
private void importFromXmlToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog openFile = new OpenFileDialog();
|
||||
openFile.Filter = "xml file |*.xml| every file | *.*";
|
||||
openFile.Filter = TextFilter;
|
||||
if (openFile.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
StreamReader t = new StreamReader(new FileStream(openFile.FileName, FileMode.Open), UnicodeEncoding.Unicode);
|
||||
string ext = Utils.GetExtension(openFile.FileName);
|
||||
if (ext == ".xml") {
|
||||
StreamReader t = new StreamReader(new FileStream(openFile.FileName, FileMode.Open));
|
||||
FileFormat.BymlData = XmlByamlConverter.FromXML(t.ReadToEnd());
|
||||
}
|
||||
else {
|
||||
StreamReader t = new StreamReader(new FileStream(openFile.FileName, FileMode.Open));
|
||||
FileFormat.BymlData = YamlByamlConverter.FromYaml(t.ReadToEnd());
|
||||
}
|
||||
treeView1.Nodes.Clear();
|
||||
byml = XmlConverter.ToByml(t.ReadToEnd()).RootNode;
|
||||
ParseBymlFirstNode();
|
||||
}
|
||||
|
||||
|
@ -681,30 +723,28 @@ namespace FirstPlugin
|
|||
}
|
||||
}
|
||||
|
||||
private void btnToXml_Click(object sender, EventArgs e)
|
||||
private void TextEditorToYaml(object sender, EventArgs e)
|
||||
{
|
||||
xmlEditor.FillEditor(XmlConverter.ToXml(new BymlFileData {
|
||||
Version = bymlVer,
|
||||
byteOrder = byteOrder,
|
||||
SupportPaths = pathSupport,
|
||||
RootNode = byml
|
||||
}));
|
||||
var format = (IConvertableTextFormat)FileFormat;
|
||||
textEditor.FillEditor(((IConvertableTextFormat)FileFormat).ConvertToString());
|
||||
|
||||
if (format.TextFileType == TextFileType.Xml)
|
||||
textEditor.IsXML = true;
|
||||
else
|
||||
textEditor.IsYAML = true;
|
||||
}
|
||||
|
||||
private void btnXmlToByaml_Click(object sender, EventArgs e)
|
||||
private void TextEditorFromYaml(object sender, EventArgs e)
|
||||
{
|
||||
string editorText = xmlEditor.GetText();
|
||||
string editorText = textEditor.GetText();
|
||||
if (editorText == string.Empty)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
byte[] TextData = Encoding.Unicode.GetBytes(xmlEditor.GetText());
|
||||
StreamReader t = new StreamReader(new MemoryStream(TextData), Encoding.GetEncoding(932));
|
||||
byml = XmlConverter.ToByml(t.ReadToEnd()).RootNode;
|
||||
|
||||
if (FileFormat != null)
|
||||
((BYAML)FileFormat).UpdateByamlRoot(byml);
|
||||
if (FileFormat != null) {
|
||||
FileFormat.ConvertFromString(textEditor.GetText());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -717,5 +757,25 @@ namespace FirstPlugin
|
|||
|
||||
MessageBox.Show("Byaml converted successfully!");
|
||||
}
|
||||
|
||||
private void treeView1_MouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
treeView1.SelectedNode = e.Node;
|
||||
}
|
||||
}
|
||||
|
||||
private void chkShiftJISEncoding_CheckedChanged(object sender, EventArgs e) {
|
||||
if (FileFormat == null) return;
|
||||
|
||||
if (chkShiftJISEncoding.Checked)
|
||||
FileFormat.ReloadEncoding(Encoding.GetEncoding("shift_jis"));
|
||||
else
|
||||
FileFormat.ReloadEncoding(Encoding.UTF8);
|
||||
|
||||
treeView1.Nodes.Clear();
|
||||
ParseBymlFirstNode();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -120,9 +120,6 @@
|
|||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="stMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>339, 17</value>
|
||||
</metadata>
|
||||
<metadata name="stContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>172, 17</value>
|
||||
</metadata>
|
||||
|
|
|
@ -10,11 +10,10 @@ using FirstPlugin.Turbo.CourseMuuntStructs;
|
|||
using GL_EditorFramework.EditorDrawables;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using aampv1 = AampV1Library;
|
||||
using aampv2 = AampV2Library;
|
||||
using Toolbox.Library.Rendering;
|
||||
using Toolbox.Library.IO;
|
||||
using FirstPlugin.Turbo;
|
||||
using AampLibraryCSharp;
|
||||
|
||||
namespace FirstPlugin.Forms
|
||||
{
|
||||
|
@ -121,14 +120,7 @@ namespace FirstPlugin.Forms
|
|||
}
|
||||
|
||||
foreach (AAMP aamp in scene.ParameterArchives)
|
||||
{
|
||||
if (aamp.aampFileV1 != null)
|
||||
LoadParameters(aamp.aampFileV1);
|
||||
else if (aamp.aampFileV2 != null)
|
||||
LoadParameters(aamp.aampFileV2);
|
||||
else
|
||||
throw new Exception("Failed to load parameter file " + aamp.FileName);
|
||||
}
|
||||
LoadParameters(aamp.aampFile);
|
||||
|
||||
viewport.AddDrawable(new GL_EditorFramework.EditorDrawables.SingleObject(new OpenTK.Vector3(0)));
|
||||
|
||||
|
@ -230,7 +222,7 @@ namespace FirstPlugin.Forms
|
|||
|
||||
ProbeLighting probeLightingConfig;
|
||||
|
||||
private void LoadParameters(aampv1.AampFile aamp)
|
||||
private void LoadParameters(AampFile aamp)
|
||||
{
|
||||
if (aamp.EffectType == "Probe Data")
|
||||
{
|
||||
|
@ -295,7 +287,7 @@ namespace FirstPlugin.Forms
|
|||
}
|
||||
}
|
||||
|
||||
private void LoadDataBuffer(aampv1.ParamEntry[] paramEntries, ProbeLighting.Entry probeEntry)
|
||||
private void LoadDataBuffer(ParamEntry[] paramEntries, ProbeLighting.Entry probeEntry)
|
||||
{
|
||||
foreach (var entry in paramEntries)
|
||||
{
|
||||
|
@ -307,13 +299,13 @@ namespace FirstPlugin.Forms
|
|||
probeEntry.MaxShDataNum = (uint)entry.Value;
|
||||
if (entry.HashString == "data_buffer")
|
||||
{
|
||||
if (entry.ParamType == aampv1.ParamType.BufferFloat)
|
||||
if (entry.ParamType == ParamType.BufferFloat)
|
||||
probeEntry.DataBuffer = (float[])entry.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadIndexBuffer(aampv1.ParamEntry[] paramEntries, ProbeLighting.Entry probeEntry)
|
||||
private void LoadIndexBuffer(ParamEntry[] paramEntries, ProbeLighting.Entry probeEntry)
|
||||
{
|
||||
foreach (var entry in paramEntries)
|
||||
{
|
||||
|
@ -325,7 +317,7 @@ namespace FirstPlugin.Forms
|
|||
probeEntry.MaxIndexNum = (uint)entry.Value;
|
||||
if (entry.HashString == "index_buffer")
|
||||
{
|
||||
if (entry.ParamType == aampv1.ParamType.BufferUint)
|
||||
if (entry.ParamType == ParamType.BufferUint)
|
||||
probeEntry.IndexBuffer = (uint[])entry.Value;
|
||||
|
||||
//Experimental, just fill in indices
|
||||
|
@ -339,7 +331,7 @@ namespace FirstPlugin.Forms
|
|||
}
|
||||
}
|
||||
|
||||
private ProbeLighting.Grid LoadGridData(aampv1.ParamEntry[] paramEntries)
|
||||
private ProbeLighting.Grid LoadGridData(ParamEntry[] paramEntries)
|
||||
{
|
||||
ProbeLighting.Grid grid = new ProbeLighting.Grid();
|
||||
|
||||
|
@ -365,11 +357,6 @@ namespace FirstPlugin.Forms
|
|||
return grid;
|
||||
}
|
||||
|
||||
private void LoadParameters(aampv2.AampFile aamp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void AddPathDrawable(string Name, IEnumerable<BasePathPoint> Groups, Color color, bool CanConnect = true)
|
||||
{
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Toolbox.Library.IO
|
|||
|
||||
public class ZSTD
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,12 @@ namespace Toolbox.Library.IO
|
|||
|
||||
using (var reader = new FileReader(stream, true))
|
||||
{
|
||||
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
|
||||
reader.Position = 0;
|
||||
reader.SetByteOrder(true);
|
||||
uint chunkSize = reader.ReadUInt32();
|
||||
if (chunkSize == 256)
|
||||
reader.SetByteOrder(false);
|
||||
|
||||
uint chunkCount = reader.ReadUInt32();
|
||||
uint decompressedSize = reader.ReadUInt32();
|
||||
if (reader.BaseStream.Length > 8 + (chunkCount * 4) + 128)
|
||||
|
@ -58,7 +61,7 @@ namespace Toolbox.Library.IO
|
|||
ushort magic = reader.ReadUInt16();
|
||||
|
||||
reader.Position = 0;
|
||||
if (magic == 0x78da)
|
||||
if (magic == 0x78da || magic == 0xda78)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
@ -74,10 +77,13 @@ namespace Toolbox.Library.IO
|
|||
{
|
||||
using (var reader = new FileReader(stream, true))
|
||||
{
|
||||
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
|
||||
reader.SetByteOrder(true);
|
||||
uint chunkSize = reader.ReadUInt32();
|
||||
if (chunkSize == 256)
|
||||
reader.SetByteOrder(false);
|
||||
|
||||
try
|
||||
{
|
||||
uint chunkSize = reader.ReadUInt32();
|
||||
uint chunkCount = reader.ReadUInt32();
|
||||
uint decompressedSize = reader.ReadUInt32();
|
||||
uint[] chunkSizes = reader.ReadUInt32s((int)chunkCount); //Not very sure about this
|
||||
|
@ -106,6 +112,7 @@ namespace Toolbox.Library.IO
|
|||
else //If the magic check fails, seek back 2. This shouldn't happen, but just incase
|
||||
reader.Seek(-2);
|
||||
}
|
||||
|
||||
//Return the decompressed stream with all chunks combined
|
||||
return new MemoryStream(Utils.CombineByteArray(DecompressedChunks.ToArray()));
|
||||
}
|
||||
|
@ -360,12 +367,12 @@ namespace Toolbox.Library.IO
|
|||
op_len = op_len_ext;
|
||||
if (op_ofs >= 2)
|
||||
{
|
||||
Loop1(ref flag, ref op_len, ref chunk, ref data, ref output);
|
||||
Loop1(ref flag, ref op_len, ref chunk, ref data, ref output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loop2(ref flag, ref op_len, ref data, ref output, ref chunk);
|
||||
Loop2(ref flag, ref op_len, ref data, ref output, ref chunk);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,13 +104,13 @@ namespace Toolbox.Library
|
|||
|
||||
private bool CheckSupport()
|
||||
{
|
||||
string ext = Utils.GetExtension(filePath);
|
||||
/* string ext = Utils.GetExtension(filePath);
|
||||
foreach (var format in FileManager.GetFileFormats())
|
||||
{
|
||||
for (int i = 0; i < format.Extension.Length; i++)
|
||||
if (format.Extension[i].Contains(ext))
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
return false;
|
||||
|
||||
|
|
|
@ -71,6 +71,8 @@ namespace Toolbox.Library.Forms
|
|||
if (ClearPlaylist)
|
||||
audioListView.Items.Clear();
|
||||
|
||||
AudioFileFormats.Add(fileFormat);
|
||||
|
||||
AudioFile file = new AudioFile();
|
||||
file.Title = fileFormat.FileName;
|
||||
|
||||
|
@ -82,11 +84,6 @@ namespace Toolbox.Library.Forms
|
|||
file.Artist = mp3.Artist;
|
||||
}
|
||||
|
||||
AudioFileFormats.Add(fileFormat);
|
||||
|
||||
|
||||
audioListView.AddObject(file);
|
||||
|
||||
AudioChannel audioChannel = new AudioChannel();
|
||||
audioChannel.Name = $"Channel [0]";
|
||||
file.Channels.Add(audioChannel);
|
||||
|
@ -101,8 +98,12 @@ namespace Toolbox.Library.Forms
|
|||
|
||||
}
|
||||
};
|
||||
audioListView.UpdateObject(file);
|
||||
|
||||
audioListView.AddObject(file);
|
||||
// audioListView.UpdateObject(file);
|
||||
|
||||
if (audioListView.Items.Count != 0)
|
||||
audioListView.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
public void LoadFile(AudioData audioData, IFileFormat fileFormat, bool ClearPlaylist = false)
|
||||
|
|
|
@ -83,11 +83,11 @@ namespace Toolbox.Library.Forms
|
|||
}
|
||||
|
||||
AudioFileFormats.Add(fileFormat);
|
||||
audioListView.AddObject(file);
|
||||
|
||||
AudioChannel audioChannel = new AudioChannel();
|
||||
audioChannel.Name = $"Channel [0]";
|
||||
file.Channels.Add(audioChannel);
|
||||
|
||||
audioChannel.audioPlayer.Open(source, activeDevice);
|
||||
|
||||
audioChannel.audioPlayer.PlaybackStopped += (s, args) =>
|
||||
|
@ -99,6 +99,8 @@ namespace Toolbox.Library.Forms
|
|||
|
||||
}
|
||||
};
|
||||
|
||||
audioListView.AddObject(file);
|
||||
audioListView.UpdateObject(file);
|
||||
|
||||
}
|
||||
|
|
|
@ -94,7 +94,6 @@ namespace Toolbox.Library.Forms
|
|||
}
|
||||
|
||||
SelectNode(FileRoot);
|
||||
|
||||
for (int i = 0; i < FileRoot.FileNodes.Count; i++)
|
||||
{
|
||||
if (FileRoot.FileNodes[i].Item1.OpenFileFormatOnLoad)
|
||||
|
|
|
@ -41,39 +41,9 @@ namespace Toolbox.Library.Forms
|
|||
{
|
||||
scintilla1.Lexer = Lexer.Xml;
|
||||
|
||||
// Enable folding
|
||||
scintilla1.SetProperty("fold", "1");
|
||||
scintilla1.SetProperty("fold.compact", "1");
|
||||
UpdateFolderMarkings();
|
||||
scintilla1.SetProperty("fold.html", "1");
|
||||
|
||||
scintilla1.Margins[0].Width = 20;
|
||||
|
||||
// Use Margin 2 for fold markers
|
||||
scintilla1.Margins[2].Type = MarginType.Symbol;
|
||||
scintilla1.Margins[2].Mask = Marker.MaskFolders;
|
||||
scintilla1.Margins[2].Sensitive = true;
|
||||
scintilla1.Margins[2].Width = 20;
|
||||
|
||||
// Reset folder markers
|
||||
for (int i = Marker.FolderEnd; i <= Marker.FolderOpen; i++)
|
||||
{
|
||||
scintilla1.Markers[i].SetForeColor(BACK_COLOR);
|
||||
scintilla1.Markers[i].SetBackColor(Color.Gray);
|
||||
}
|
||||
|
||||
// Style the folder markers
|
||||
scintilla1.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus;
|
||||
// scintilla1.Markers[Marker.Folder].SetBackColor(FormThemes.BaseTheme.TextEditorBackColor);
|
||||
scintilla1.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus;
|
||||
scintilla1.Markers[Marker.FolderEnd].Symbol = MarkerSymbol.BoxPlusConnected;
|
||||
// scintilla1.Markers[Marker.FolderEnd].SetBackColor(FormThemes.BaseTheme.TextEditorBackColor);
|
||||
scintilla1.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner;
|
||||
scintilla1.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected;
|
||||
scintilla1.Markers[Marker.FolderSub].Symbol = MarkerSymbol.VLine;
|
||||
scintilla1.Markers[Marker.FolderTail].Symbol = MarkerSymbol.LCorner;
|
||||
|
||||
scintilla1.AutomaticFold = AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change;
|
||||
|
||||
scintilla1.Styles[Style.Xml.XmlStart].ForeColor = Color.FromArgb(128, 128, 128);
|
||||
scintilla1.Styles[Style.Xml.XmlEnd].ForeColor = Color.FromArgb(128, 128, 128);
|
||||
scintilla1.Styles[Style.Xml.Default].ForeColor = Color.FromArgb(180, 180, 180);
|
||||
|
@ -116,6 +86,11 @@ namespace Toolbox.Library.Forms
|
|||
scintilla1.Styles[Style.Json.StringEol].BackColor = Color.Pink;
|
||||
scintilla1.Styles[Style.Json.Operator].ForeColor = Color.Purple;
|
||||
scintilla1.Lexer = Lexer.Json;
|
||||
|
||||
UpdateFolderMarkings();
|
||||
|
||||
scintilla1.SetFoldMarginColor(true, BACK_COLOR);
|
||||
scintilla1.SetFoldMarginHighlightColor(true, BACK_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,28 +110,61 @@ namespace Toolbox.Library.Forms
|
|||
{
|
||||
scintilla1.Lexer = (Lexer)48;
|
||||
|
||||
scintilla1.Styles[Style.Xml.XmlStart].ForeColor = Color.FromArgb(86, 156, 214);
|
||||
scintilla1.Styles[Style.Xml.XmlEnd].ForeColor = Color.FromArgb(86, 156, 214);
|
||||
scintilla1.Styles[Style.Xml.Default].ForeColor = Color.FromArgb(214, 157, 133);
|
||||
scintilla1.Styles[Style.Xml.Comment].ForeColor = Color.FromArgb(87, 166, 74);
|
||||
scintilla1.Styles[Style.Xml.Number].ForeColor = Color.FromArgb(214, 157, 133);
|
||||
scintilla1.Styles[Style.Json.Default].ForeColor = Color.FromArgb(214, 157, 133);
|
||||
scintilla1.Styles[Style.Json.BlockComment].ForeColor = Color.FromArgb(87, 166, 74); // Green
|
||||
scintilla1.Styles[Style.Json.LineComment].ForeColor = Color.FromArgb(87, 166, 74); // Green
|
||||
scintilla1.Styles[Style.Json.Number].ForeColor = Color.FromArgb(214, 157, 133);
|
||||
scintilla1.Styles[Style.Json.PropertyName].ForeColor = Color.FromArgb(214, 157, 133);
|
||||
scintilla1.Styles[Style.Json.String].ForeColor = Color.FromArgb(86, 156, 214);
|
||||
scintilla1.Styles[Style.Json.StringEol].BackColor = Color.FromArgb(214, 157, 133);
|
||||
scintilla1.Styles[Style.Json.Operator].ForeColor = Color.FromArgb(180, 180, 180);
|
||||
scintilla1.Styles[Style.Json.Keyword].ForeColor = Color.FromArgb(146, 202, 244);
|
||||
scintilla1.Styles[Style.Json.EscapeSequence].ForeColor = Color.FromArgb(146, 202, 244);
|
||||
|
||||
UpdateFolderMarkings();
|
||||
|
||||
scintilla1.Styles[Style.Xml.DoubleString].ForeColor = Color.FromArgb(180, 180, 180);
|
||||
scintilla1.Styles[Style.Xml.SingleString].ForeColor = Color.FromArgb(180, 180, 180);
|
||||
scintilla1.Styles[Style.Xml.Tag].ForeColor = Color.FromArgb(214, 157, 133);
|
||||
scintilla1.Styles[Style.Xml.TagEnd].ForeColor = Color.FromArgb(86, 156, 214);
|
||||
scintilla1.Styles[Style.Xml.TagUnknown].ForeColor = Color.FromArgb(86, 156, 214);
|
||||
scintilla1.Styles[Style.Xml.Attribute].ForeColor = Color.FromArgb(86, 156, 214);
|
||||
scintilla1.Styles[Style.Xml.AttributeUnknown].ForeColor = Color.FromArgb(86, 156, 214);
|
||||
scintilla1.Styles[Style.Xml.CData].ForeColor = Color.FromArgb(214, 157, 133);
|
||||
|
||||
scintilla1.SetKeywords(1, "!aamp !io");
|
||||
scintilla1.SetKeywords(4, "!color !vec2 !vec3 !vec4 !str32 !str64 !str128 !str256 !obj");
|
||||
// scintilla1.SetKeywords(0, "!aamp !io True False");
|
||||
// scintilla1.SetKeywords(1, "!color !vec2 !vec3 !vec4 !str32 !str64 !str128 !str256 !obj");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateFolderMarkings()
|
||||
{
|
||||
// Enable folding
|
||||
scintilla1.SetProperty("fold", "1");
|
||||
scintilla1.SetProperty("fold.compact", "1");
|
||||
|
||||
scintilla1.Margins[0].Width = 20;
|
||||
|
||||
// Use Margin 2 for fold markers
|
||||
scintilla1.Margins[2].Type = MarginType.Symbol;
|
||||
scintilla1.Margins[2].Mask = Marker.MaskFolders;
|
||||
scintilla1.Margins[2].Sensitive = true;
|
||||
scintilla1.Margins[2].Width = 20;
|
||||
|
||||
// Reset folder markers
|
||||
for (int i = Marker.FolderEnd; i <= Marker.FolderOpen; i++)
|
||||
{
|
||||
scintilla1.Markers[i].SetForeColor(BACK_COLOR);
|
||||
scintilla1.Markers[i].SetBackColor(Color.Gray);
|
||||
}
|
||||
|
||||
scintilla1.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus;
|
||||
scintilla1.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus;
|
||||
scintilla1.Markers[Marker.FolderEnd].Symbol = MarkerSymbol.BoxPlusConnected;
|
||||
scintilla1.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner;
|
||||
scintilla1.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected;
|
||||
scintilla1.Markers[Marker.FolderSub].Symbol = MarkerSymbol.VLine;
|
||||
scintilla1.Markers[Marker.FolderTail].Symbol = MarkerSymbol.LCorner;
|
||||
|
||||
scintilla1.AutomaticFold = AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change;
|
||||
|
||||
scintilla1.SetFoldMarginColor(true, BACK_COLOR);
|
||||
scintilla1.SetFoldMarginHighlightColor(true, BACK_COLOR);
|
||||
|
||||
}
|
||||
|
||||
public static Color IntToColor(int rgb)
|
||||
{
|
||||
return Color.FromArgb(255, (byte)(rgb >> 16), (byte)(rgb >> 8), (byte)rgb);
|
||||
|
@ -197,6 +205,11 @@ namespace Toolbox.Library.Forms
|
|||
stContextMenuStrip1.Items.Add(text, null, handler);
|
||||
}
|
||||
|
||||
public void ClearContextMenus()
|
||||
{
|
||||
stContextMenuStrip1.Items.Clear();
|
||||
}
|
||||
|
||||
public string GetText()
|
||||
{
|
||||
return scintilla1.Text;
|
||||
|
@ -227,6 +240,8 @@ namespace Toolbox.Library.Forms
|
|||
scintilla1.SetSelectionForeColor(true, FormThemes.BaseTheme.FormForeColor);
|
||||
|
||||
scintilla1.SetWhitespaceBackColor(true, Color.FromArgb(50,50,50));
|
||||
scintilla1.WrapMode = WrapMode.Word;
|
||||
wordWrapToolStripMenuItem.Checked = true;
|
||||
|
||||
scintilla1.Margins[0].Type = MarginType.Number;
|
||||
scintilla1.Margins[0].Width = 35;
|
||||
|
|
|
@ -254,6 +254,7 @@ namespace Toolbox.Library
|
|||
v.uv0 = new Vector2(v.uv0.X, 1 - v.uv0.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public void FlipUvsHorizontal()
|
||||
{
|
||||
foreach (Vertex v in vertices)
|
||||
|
@ -261,6 +262,7 @@ namespace Toolbox.Library
|
|||
v.uv0 = new Vector2(1 - v.uv0.X, v.uv0.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public void TransformUVs(Vector2 Translate, Vector2 Scale, int Index)
|
||||
{
|
||||
foreach (Vertex v in vertices)
|
||||
|
@ -551,12 +553,10 @@ namespace Toolbox.Library
|
|||
return;
|
||||
|
||||
Vector3[] normals = new Vector3[vertices.Count];
|
||||
|
||||
for (int i = 0; i < normals.Length; i++)
|
||||
normals[i] = new Vector3(0, 0, 0);
|
||||
|
||||
List<int> f = GetFaces();
|
||||
|
||||
for (int i = 0; i < f.Count; i += 3)
|
||||
{
|
||||
Vertex v1 = vertices[f[i]];
|
||||
|
|
|
@ -215,6 +215,14 @@ namespace Toolbox.Library.IO
|
|||
return new Syroot.IOExtension.Half(ReadUInt16());
|
||||
}
|
||||
|
||||
public Quaternion ReadQuaternion(bool invert = false)
|
||||
{
|
||||
var quat = new Quaternion(
|
||||
ReadSingle(), ReadSingle(),
|
||||
ReadSingle(), ReadSingle());
|
||||
return invert ? quat.Inverted() : quat;
|
||||
}
|
||||
|
||||
public Matrix4 ReadMatrix4(bool SwapRows = false)
|
||||
{
|
||||
Matrix4 mat4 = new Matrix4();
|
||||
|
|
|
@ -19,6 +19,11 @@ namespace Toolbox.Library.IO
|
|||
{
|
||||
}
|
||||
|
||||
public FileWriter(Stream stream, Encoding encoding, bool leaveOpen = false)
|
||||
: base(stream, encoding, leaveOpen)
|
||||
{
|
||||
}
|
||||
|
||||
public FileWriter(string fileName)
|
||||
: this(new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||
{
|
||||
|
|
|
@ -67,6 +67,19 @@ namespace Toolbox.Library
|
|||
return new Vector3(x, y, z) * -1;
|
||||
}
|
||||
|
||||
public static Quaternion FromEulerAngles(Vector3 rotation)
|
||||
{
|
||||
Quaternion xRotation = Quaternion.FromAxisAngle(Vector3.UnitX, rotation.X);
|
||||
Quaternion yRotation = Quaternion.FromAxisAngle(Vector3.UnitY, rotation.Y);
|
||||
Quaternion zRotation = Quaternion.FromAxisAngle(Vector3.UnitZ, rotation.Z);
|
||||
Quaternion q = (zRotation * yRotation * xRotation);
|
||||
|
||||
if (q.W < 0)
|
||||
q *= -1;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
public static float Clamp(float v, float min, float max)
|
||||
{
|
||||
if (v < min) return min;
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
Toolbox/Lib/AampLibraryCSharp.pdb
Normal file
BIN
Toolbox/Lib/AampLibraryCSharp.pdb
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -360,15 +360,6 @@
|
|||
<Content Include="Gl_EditorFramework.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\AampCommon.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\AampV1Library.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\AampV2Library.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\aamp_hashed_names.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
Loading…
Reference in a new issue