From 00cc82b6c8e8c08a9e32d785ee48375b2e1a64dd Mon Sep 17 00:00:00 2001 From: Felix Miller Date: Wed, 10 Aug 2022 23:59:27 -0400 Subject: [PATCH] Creates a method of parsing and creating Bedrock JSON Sound files --- .../Classes/IO/Sounds/SoundIO.cs | 26 +++++++++++++++++++ .../Classes/IO/Sounds/Sounds.cs | 21 +++++++++++++++ MinecraftUSkinEditor/PckStudio.csproj | 2 ++ 3 files changed, 49 insertions(+) create mode 100644 MinecraftUSkinEditor/Classes/IO/Sounds/SoundIO.cs create mode 100644 MinecraftUSkinEditor/Classes/IO/Sounds/Sounds.cs diff --git a/MinecraftUSkinEditor/Classes/IO/Sounds/SoundIO.cs b/MinecraftUSkinEditor/Classes/IO/Sounds/SoundIO.cs new file mode 100644 index 00000000..5815d356 --- /dev/null +++ b/MinecraftUSkinEditor/Classes/IO/Sounds/SoundIO.cs @@ -0,0 +1,26 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace PckStudio.Classes.IO.Sounds +{ + public class SoundIO + { + public Dictionary Read(string Filepath) + { + var jObj = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(File.ReadAllText(Filepath)); + var dict = JsonConvert.DeserializeObject>(jObj.ToString()); + + return dict; + } + + public string Serialize(Dictionary input) + { + return JsonConvert.SerializeObject(input, Formatting.Indented); + } + } +} diff --git a/MinecraftUSkinEditor/Classes/IO/Sounds/Sounds.cs b/MinecraftUSkinEditor/Classes/IO/Sounds/Sounds.cs new file mode 100644 index 00000000..a040eff3 --- /dev/null +++ b/MinecraftUSkinEditor/Classes/IO/Sounds/Sounds.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PckStudio.Classes.IO.Sounds +{ + public class Type + { + public bool replace { get; set; } + public List sounds = new List(); + } + + public class Sound + { + public string name { get; set; } + public string type { get; set; } + public bool stream { get; set; } + } +} diff --git a/MinecraftUSkinEditor/PckStudio.csproj b/MinecraftUSkinEditor/PckStudio.csproj index c1e113f4..0188da44 100644 --- a/MinecraftUSkinEditor/PckStudio.csproj +++ b/MinecraftUSkinEditor/PckStudio.csproj @@ -149,6 +149,8 @@ + +