private static void DeserializeXml(string inputPath, string outputPath) { Console.WriteLine($"Converting {Path.GetFileName(inputPath)} to {outputPath}.numatb..."); using (var reader = new StringReader(File.ReadAllText(inputPath))) { var matl = MatlSerialization.DeserializeMatl(reader); Ssbh.TrySaveSsbhFile(outputPath, matl); } }
public void EmptyMatl() { var source = @"<?xml version=""1.0"" encoding=""utf-16""?> <MaterialLibrary xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" />"; var reader = new StringReader(source); var matl = MatlSerialization.DeserializeMatl(reader); Assert.AreEqual(0, matl.Entries.Length); }
public void EmptyMatl() { var matl = new Matl(); var writer = new StringWriter(); MatlSerialization.SerializeMatl(writer, matl); var expected = @"<?xml version=""1.0"" encoding=""utf-16""?> <MaterialLibrary xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" />"; Assert.AreEqual(expected, writer.ToString()); }
internal void ExportMatlToXml(string outputPath) { if (CurrentMaterialCollection != null) { var matl = rnumdls.SingleOrDefault(r => r.Item1 == CurrentMaterialCollection.Name).Item2.Matl; if (matl != null) { using var writer = new StringWriter(); MatlSerialization.SerializeMatl(writer, matl); File.WriteAllText(outputPath, writer.ToString()); } } }
public void SerializeMarioC00() { var source = TestResources.ReadResourceTextFile("SsbhLib.Test.MatlSerializationTests.marioc00.xml"); var reader = new StringReader(source); var matl = MatlSerialization.DeserializeMatl(reader); var writer = new StringWriter(); MatlSerialization.SerializeMatl(writer, matl); // Test 1:1 deserialize/serialize Assert.AreEqual(source, writer.ToString()); }
private static Matl?LoadPresets() { // TODO: This may fail to read the file successfully. try { using var reader = new StringReader(File.ReadAllText("MaterialPresets/MaterialPresets.xml")); return(MatlSerialization.DeserializeMatl(reader)); } catch (Exception) { // TODO: Log the error return(null); } }
private static void SerializeMatl(string inputPath, string outputPath) { Console.WriteLine($"Converting {Path.GetFileName(inputPath)} to {outputPath}..."); if (Ssbh.TryParseSsbhFile(inputPath, out Matl matlFile)) { using (var writer = new StringWriter()) { MatlSerialization.SerializeMatl(writer, matlFile); File.WriteAllText(outputPath, writer.ToString()); } } else { Console.WriteLine("Error reading matl file"); } }
public void DeserializeMarioC00() { var source = TestResources.ReadResourceTextFile("SsbhLib.Test.MatlSerializationTests.marioc00.xml"); var reader = new StringReader(source); var matl = MatlSerialization.DeserializeMatl(reader); Assert.AreEqual(12, matl.Entries.Length); var entry = matl.Entries[5]; Assert.AreEqual("SFX_PBS_010000001800830d_opaque", entry.ShaderLabel); Assert.AreEqual("EyeRD", entry.MaterialLabel); Assert.AreEqual(20, entry.Attributes.Length); Assert.AreEqual(false, entry.Attributes[3].DataObject); }