2021-03-08 15:03:11 +00:00
|
|
|
|
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<ElementKind, Element> Elements { get; }
|
2021-03-17 17:36:40 +00:00
|
|
|
|
public Dictionary<string, Window> Windows { get; }
|
|
|
|
|
// public Dictionary<string, Vector2<short>> Positions { get; private set; }
|
2021-03-10 19:08:28 +00:00
|
|
|
|
public Guid Parent { get; set; } = Guid.Empty;
|
2021-03-08 15:03:11 +00:00
|
|
|
|
|
2021-03-10 19:08:28 +00:00
|
|
|
|
public string Name { get; set; }
|
2021-03-08 15:03:11 +00:00
|
|
|
|
|
|
|
|
|
[JsonConstructor]
|
2021-03-17 17:36:40 +00:00
|
|
|
|
public SavedLayout(string name, Dictionary<ElementKind, Element> elements, Dictionary<string, Window> windows, Guid parent) {
|
2021-03-08 15:03:11 +00:00
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Elements = elements;
|
2021-03-17 17:36:40 +00:00
|
|
|
|
this.Windows = windows;
|
2021-03-10 19:08:28 +00:00
|
|
|
|
this.Parent = parent;
|
2021-03-08 15:03:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 17:36:40 +00:00
|
|
|
|
public SavedLayout(string name, Layout hud, Dictionary<string, Window> windows) {
|
2021-03-08 15:03:11 +00:00
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Elements = hud.ToDictionary();
|
2021-03-17 17:36:40 +00:00
|
|
|
|
this.Windows = windows;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SavedLayout(string name, Layout hud) {
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.Elements = hud.ToDictionary();
|
|
|
|
|
this.Windows = new Dictionary<string, Window>();
|
2021-03-08 15:03:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Layout ToLayout() {
|
|
|
|
|
var elements = this.Elements.Values.ToList();
|
|
|
|
|
|
2021-03-10 19:13:19 +00:00
|
|
|
|
while (elements.Count < Hud.InMemoryLayoutElements) {
|
2021-03-10 19:08:28 +00:00
|
|
|
|
elements.Add(new Element(new RawElement()));
|
2021-03-08 15:03:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Layout {
|
2021-03-10 19:08:28 +00:00
|
|
|
|
elements = elements.Select(elem => new RawElement(elem)).ToArray(),
|
2021-03-08 15:03:11 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|