2021-03-17 17:36:40 +00:00
|
|
|
|
using System;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
namespace HUD_Manager.Configuration {
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class Window {
|
2021-03-19 18:40:07 +00:00
|
|
|
|
public const WindowComponent AllEnabled = WindowComponent.X | WindowComponent.Y;
|
|
|
|
|
|
2021-03-17 17:36:40 +00:00
|
|
|
|
public WindowComponent Enabled { get; set; } = WindowComponent.X | WindowComponent.Y;
|
|
|
|
|
|
|
|
|
|
public Vector2<short> Position { get; set; }
|
|
|
|
|
|
2021-03-19 18:40:07 +00:00
|
|
|
|
public bool this[WindowComponent component] {
|
|
|
|
|
get => (this.Enabled & component) > 0;
|
|
|
|
|
set {
|
|
|
|
|
if (value) {
|
|
|
|
|
this.Enabled |= component;
|
|
|
|
|
} else {
|
|
|
|
|
this.Enabled &= ~component;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 17:36:40 +00:00
|
|
|
|
[JsonConstructor]
|
|
|
|
|
public Window(WindowComponent enabled, Vector2<short> position) {
|
|
|
|
|
this.Enabled = enabled;
|
|
|
|
|
this.Position = position;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Window(Vector2<short> position) {
|
|
|
|
|
this.Position = position;
|
|
|
|
|
}
|
2021-03-19 18:40:07 +00:00
|
|
|
|
|
|
|
|
|
public Window Clone() {
|
|
|
|
|
return new Window(this.Enabled, new Vector2<short>(this.Position.X, this.Position.Y));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateEnabled(Window other) {
|
|
|
|
|
if (other[WindowComponent.X]) {
|
|
|
|
|
this.Position.X = other.Position.X;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (other[WindowComponent.Y]) {
|
|
|
|
|
this.Position.Y = other.Position.Y;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-17 17:36:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Flags]
|
|
|
|
|
public enum WindowComponent {
|
2021-03-19 18:40:07 +00:00
|
|
|
|
X = 1 << 0,
|
|
|
|
|
Y = 1 << 1,
|
2021-03-17 17:36:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|