using System; using System.Collections.Generic; using System.Linq; using HUD_Manager.Structs; using Newtonsoft.Json; namespace HUD_Manager.Configuration { [Serializable] public class SavedLayout { public Dictionary Elements { get; } public Dictionary Windows { get; } // public Dictionary> Positions { get; private set; } public Guid Parent { get; set; } = Guid.Empty; public string Name { get; set; } [JsonConstructor] public SavedLayout(string name, Dictionary elements, Dictionary windows, Guid parent) { this.Name = name; this.Elements = elements; this.Windows = windows; this.Parent = parent; } public SavedLayout(string name, Layout hud, Dictionary windows) { this.Name = name; this.Elements = hud.ToDictionary(); this.Windows = windows; } public SavedLayout(string name, Layout hud) { this.Name = name; this.Elements = hud.ToDictionary(); this.Windows = new Dictionary(); } public Layout ToLayout() { var elements = this.Elements.Values.ToList(); while (elements.Count < Hud.InMemoryLayoutElements) { elements.Add(new Element(new RawElement())); } return new Layout { elements = elements.Select(elem => new RawElement(elem)).ToArray(), }; } } }