private void LoadRightPacks(string filePath) { #region Behavior Packs //////////////////// //Behavior packs//// //////////////////// string[] subDirectories; rightListGroup[0].Clear(); try { subDirectories = Directory.GetDirectories(System.IO.Path.Combine(filePath, "development_behavior_packs")); for (int i = 0; i < subDirectories.Length; i++) { string filePathAppended = System.IO.Path.Combine(subDirectories[i], "manifest.json"); if (File.Exists(filePathAppended)) { string contents = File.ReadAllText(filePathAppended); PackEntry newEntry = Newtonsoft.Json.JsonConvert.DeserializeObject <PackEntry>(contents); newEntry.filePath = filePathAppended; newEntry.iconPath = System.IO.Path.Combine(subDirectories[i], "pack_icon.png"); newEntry.loadIcon(); rightListGroup[0].Add(newEntry); } } } catch (Exception) { } #endregion #region Resource Packs //////////////////// //Resource packs//// //////////////////// rightListGroup[1].Clear(); try { subDirectories = Directory.GetDirectories(System.IO.Path.Combine(filePath, "development_resource_packs")); for (int i = 0; i < subDirectories.Length; i++) { string filePathAppended = System.IO.Path.Combine(subDirectories[i], "manifest.json"); if (File.Exists(filePathAppended)) { string contents = File.ReadAllText(filePathAppended); PackEntry newEntry = Newtonsoft.Json.JsonConvert.DeserializeObject <PackEntry>(contents); newEntry.filePath = filePathAppended; newEntry.iconPath = System.IO.Path.Combine(subDirectories[i], "pack_icon.png"); newEntry.loadIcon(); rightListGroup[1].Add(newEntry); } } } catch (Exception) { } #endregion #region Worlds //////////////////// //Worlds//////////// //////////////////// rightListGroup[2].Clear(); try { subDirectories = Directory.GetDirectories(System.IO.Path.Combine(filePath, "minecraftWorlds")); for (int i = 0; i < subDirectories.Length; i++) { string filePathAppended = System.IO.Path.Combine(subDirectories[i], "levelname.txt"); if (File.Exists(filePathAppended)) { string contents = File.ReadAllText(filePathAppended); PackEntry newEntry = new PackEntry(); newEntry.header.name = contents; newEntry.filePath = filePathAppended; newEntry.iconPath = System.IO.Path.Combine(subDirectories[i], "world_icon.jpeg"); newEntry.loadIcon(); rightListGroup[2].Add(newEntry); } } } catch (Exception) { } #endregion #region Uncategorized //////////////////// //Uncategorized///// //////////////////// rightListGroup[3].Clear(); try { subDirectories = Directory.GetDirectories(filePath); for (int i = 0; i < subDirectories.Length; i++) { string filePathAppended = System.IO.Path.Combine(subDirectories[i], "manifest.json"); if (File.Exists(filePathAppended)) { string contents = File.ReadAllText(filePathAppended); PackEntry newEntry = Newtonsoft.Json.JsonConvert.DeserializeObject <PackEntry>(contents); newEntry.filePath = filePathAppended; newEntry.iconPath = System.IO.Path.Combine(subDirectories[i], "pack_icon.png"); newEntry.loadIcon(); rightListGroup[3].Add(newEntry); } } } catch (Exception) { } #endregion }
private void LoadLeftPacks(string filePath) { #region Behavior Packs //////////////////// //Behavior packs//// //////////////////// string[] subDirectories; leftListGroup[0].Clear(); try { subDirectories = Directory.GetDirectories(System.IO.Path.Combine(filePath, "development_behavior_packs")); for (int i = 0; i < subDirectories.Length; i++) { string filePathAppended = System.IO.Path.Combine(subDirectories[i], "manifest.json"); if (File.Exists(filePathAppended)) { string contents = File.ReadAllText(filePathAppended); PackEntry newEntry = Newtonsoft.Json.JsonConvert.DeserializeObject <PackEntry>(contents); newEntry.filePath = filePathAppended; newEntry.iconPath = System.IO.Path.Combine(subDirectories[i], "pack_icon.png"); newEntry.loadIcon(); //Handing name/desc stored in lang files if (newEntry.header.name == "pack.name") { filePathAppended = System.IO.Path.Combine(subDirectories[i], "texts/en_US.lang"); if (File.Exists(filePathAppended)) { string[] langLines = File.ReadAllLines(filePathAppended); for (int j = 0; j < langLines.Length; j++) { string[] stringSeparators = new string[] { "=" }; string[] splitLine = langLines[i].Split(stringSeparators, StringSplitOptions.None); if (splitLine[0] == "pack.name" && splitLine.Length > 1) { newEntry.header.name = splitLine[1]; } } } } leftListGroup[0].Add(newEntry); } } } catch (Exception) { } #endregion #region Resource Packs //////////////////// //Resource packs//// //////////////////// leftListGroup[1].Clear(); try { subDirectories = Directory.GetDirectories(System.IO.Path.Combine(filePath, "development_resource_packs")); for (int i = 0; i < subDirectories.Length; i++) { string filePathAppended = System.IO.Path.Combine(subDirectories[i], "manifest.json"); if (File.Exists(filePathAppended)) { string contents = File.ReadAllText(filePathAppended); PackEntry newEntry = Newtonsoft.Json.JsonConvert.DeserializeObject <PackEntry>(contents); newEntry.filePath = filePathAppended; newEntry.iconPath = System.IO.Path.Combine(subDirectories[i], "pack_icon.png"); newEntry.loadIcon(); leftListGroup[1].Add(newEntry); } } } catch (Exception) { } #endregion #region Worlds //////////////////// //Worlds//////////// //////////////////// leftListGroup[2].Clear(); try { subDirectories = Directory.GetDirectories(System.IO.Path.Combine(filePath, "minecraftWorlds")); for (int i = 0; i < subDirectories.Length; i++) { string filePathAppended = System.IO.Path.Combine(subDirectories[i], "levelname.txt"); if (File.Exists(filePathAppended)) { string contents = File.ReadAllText(filePathAppended); PackEntry newEntry = new PackEntry(); newEntry.header.name = contents; newEntry.filePath = filePathAppended; newEntry.iconPath = System.IO.Path.Combine(subDirectories[i], "world_icon.jpeg"); newEntry.loadIcon(); leftListGroup[2].Add(newEntry); } } } catch (Exception) { } #endregion #region Uncategorized //////////////////// //Uncategorized///// //////////////////// leftListGroup[3].Clear(); try { subDirectories = Directory.GetDirectories(filePath); for (int i = 0; i < subDirectories.Length; i++) { string filePathAppended = System.IO.Path.Combine(subDirectories[i], "manifest.json"); if (File.Exists(filePathAppended)) { string contents = File.ReadAllText(filePathAppended); PackEntry newEntry = Newtonsoft.Json.JsonConvert.DeserializeObject <PackEntry>(contents); newEntry.filePath = filePathAppended; newEntry.iconPath = System.IO.Path.Combine(subDirectories[i], "pack_icon.png"); newEntry.loadIcon(); leftListGroup[3].Add(newEntry); } } } catch (Exception) { } #endregion }