diff --git a/src/HUDMerger/Models/HUDLayout.cs b/src/HUDMerger/Models/HUDLayout.cs deleted file mode 100644 index dfbbe55..0000000 --- a/src/HUDMerger/Models/HUDLayout.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using HUDMergerVDF; - -namespace HUDMerger.Models; - -public class HUDLayout -{ - private readonly Dictionary> Entries = new(StringComparer.OrdinalIgnoreCase); - - public HUDLayout(HUD hud) - { - void ReadFile(string filePath, Dictionary obj) - { - string[] baseFiles = obj.ContainsKey("#base") - ? obj["#base"] is List baseFilesList - ? baseFilesList.Select((baseFile) => (string)baseFile).ToArray() - : new string[] { (string)obj["#base"] } - : null; - - foreach (KeyValuePair kv in obj) - { - if (kv.Value is Dictionary header) - { - foreach (KeyValuePair hudLayoutEntry in header) - { - if (!Entries.ContainsKey(hudLayoutEntry.Key)) - { - Entries[hudLayoutEntry.Key] = new Dictionary(); - } - - Dictionary entry = Entries[hudLayoutEntry.Key]; - - if (hudLayoutEntry.Value is Dictionary properties) - { - foreach (KeyValuePair property in properties) - { - if (!entry.ContainsKey(property.Key)) - { - entry[property.Key] = property.Value; - } - } - } - } - } - } - - if (baseFiles == null) - { - return; - } - - string folderPath = Path.GetDirectoryName(filePath); - - foreach (string baseFile in baseFiles) - { - string baseFilePath = Path.Join(folderPath, baseFile); - - if (!Utilities.TestPath(baseFilePath)) - { - continue; - } - - Dictionary baseObj = Utilities.VDFTryParse(baseFilePath); - ReadFile(baseFilePath, baseObj); - } - } - - string HUDLayoutPath = Path.Join(hud.FolderPath, "scripts\\hudlayout.res"); - - Dictionary hudLayoutObj = Utilities.VDFTryParse(HUDLayoutPath); - - ReadFile(HUDLayoutPath, hudLayoutObj); - } - - public Dictionary this[string index] => Entries[index]; -}