fix: clean up the new swap system

This commit is contained in:
Anna 2020-09-02 22:24:34 -04:00
parent 315f617ead
commit 803938564a
3 changed files with 269 additions and 220 deletions

View File

@ -21,6 +21,7 @@ namespace HudSwap {
public HudSlot StagingSlot { get; set; } = HudSlot.Four;
[Obsolete("Superceded by HudConditionMatches")]
public Guid DefaultLayout { get; set; } = Guid.Empty;
#pragma warning disable CA1051 // Do not declare visible instance fields
@ -111,23 +112,28 @@ namespace HudSwap {
}
if (this.JobLayouts.Count != 0) {
foreach (var jobLayout in this.JobLayouts)
foreach (var jobLayout in this.JobLayouts) {
this.HudConditionMatches.Add(new HudConditionMatch() {
ClassJob = jobLayout.Key,
Status = JobsCombatOnly ? Status.InCombat : default,
LayoutId = jobLayout.Value
});
}
this.JobLayouts.Clear();
}
if (this.StatusLayouts.Count != 0) {
foreach (var statusLayout in this.StatusLayouts) {
var match = new HudConditionMatch() {Status = statusLayout.Key, LayoutId = statusLayout.Value};
if (HighPriorityJobs)
var match = new HudConditionMatch() {
Status = statusLayout.Key,
LayoutId = statusLayout.Value
};
if (this.HighPriorityJobs) {
this.HudConditionMatches.Add(match);
else
} else {
this.HudConditionMatches.Insert(0, match);
}
}
this.StatusLayouts.Clear();

View File

@ -1,4 +1,5 @@
using Dalamud.Game.ClientState.Actors.Types;
using Dalamud.Interface;
using Dalamud.Plugin;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
@ -42,6 +43,7 @@ namespace HudSwap {
private int editingConditionIndex = -1;
private HudConditionMatch editingCondition;
private bool scrollToAdd = false;
private static bool configErrorOpen = true;
public static void ConfigError() {
@ -59,184 +61,196 @@ namespace HudSwap {
return;
}
PlayerCharacter player = this.pi.ClientState.LocalPlayer;
ImGui.SetNextWindowSize(new Vector2(500, 450), ImGuiCond.FirstUseEver);
if (ImGui.Begin("HudSwap", ref this._settingsVisible, ImGuiWindowFlags.AlwaysAutoResize)) {
if (ImGui.BeginTabBar("##hudswap-tabs")) {
if (!this.plugin.Config.UnderstandsRisks) {
if (ImGui.BeginTabItem("About")) {
ImGui.TextColored(new Vector4(1f, 0f, 0f, 1f), "Read this first");
ImGui.Separator();
ImGui.PushTextWrapPos(ImGui.GetFontSize() * 20f);
ImGui.Text("HudSwap will use the configured staging slot as its own slot to make changes to. This means the staging slot will be overwritten whenever any swap happens.");
ImGui.Spacing();
ImGui.Text("Any HUD layout changes you make while HudSwap is enabled may potentially be lost, no matter what slot. If you want to make changes to your HUD layout, TURN OFF HudSwap first.");
ImGui.Spacing();
ImGui.Text("When editing or making a new layout, to be completely safe, turn off swaps, set up your layout, import the layout into HudSwap, then turn on swaps.");
ImGui.Spacing();
ImGui.Text("If you are a new user, HudSwap auto-imported your existing layouts on startup.");
ImGui.Spacing();
ImGui.Text("Finally, HudSwap is beta software. Back up your character data before using this plugin. You may lose some to all of your HUD layouts while testing this plugin.");
ImGui.Separator();
ImGui.Text("If you have read all of the above and are okay with continuing, check the box below to enable HudSwap. You only need to do this once.");
ImGui.PopTextWrapPos();
bool understandsRisks = this.plugin.Config.UnderstandsRisks;
if (ImGui.Checkbox("I understand", ref understandsRisks)) {
this.plugin.Config.UnderstandsRisks = understandsRisks;
this.plugin.Config.Save();
}
ImGui.EndTabItem();
}
ImGui.EndTabBar();
ImGui.End();
return;
}
if (ImGui.BeginTabItem("Layouts")) {
ImGui.Text("Saved layouts");
if (this.plugin.Config.Layouts2.Count == 0) {
ImGui.Text("None saved!");
} else {
if (ImGui.ListBoxHeader("##saved-layouts")) {
foreach (KeyValuePair<Guid, Layout> entry in this.plugin.Config.Layouts2) {
if (ImGui.Selectable($"{entry.Value.Name}##{entry.Key}", this.selectedLayout == entry.Key)) {
this.selectedLayout = entry.Key;
this.renameName = entry.Value.Name;
}
}
ImGui.ListBoxFooter();
}
ImGui.Text("Copy onto slot...");
foreach (HudSlot slot in Enum.GetValues(typeof(HudSlot))) {
string buttonName = $"{(int)slot + 1}##copy";
if (ImGui.Button(buttonName) && this.selectedLayout != null) {
Layout layout = this.plugin.Config.Layouts2[this.selectedLayout];
this.plugin.Hud.WriteLayout(slot, layout.Hud.ToArray());
}
ImGui.SameLine();
}
if (ImGui.Button("Delete") && this.selectedLayout != null) {
this.plugin.Config.Layouts2.Remove(this.selectedLayout);
this.plugin.Config.HudConditionMatches.RemoveAll(m => m.LayoutId == this.selectedLayout);
this.selectedLayout = Guid.Empty;
this.renameName = "";
this.plugin.Config.Save();
}
ImGui.SameLine();
if (ImGui.Button("Copy to clipboard") && this.selectedLayout != null) {
if (this.plugin.Config.Layouts2.TryGetValue(this.selectedLayout, out Layout layout)) {
SharedLayout shared = new SharedLayout(layout);
string json = JsonConvert.SerializeObject(shared);
ImGui.SetClipboardText(json);
}
}
ImGui.InputText("##rename-input", ref this.renameName, 100);
ImGui.SameLine();
if (ImGui.Button("Rename") && this.renameName.Length != 0 && this.selectedLayout != null) {
Layout layout = this.plugin.Config.Layouts2[this.selectedLayout];
Layout newLayout = new Layout(this.renameName, layout.Hud, layout.Positions);
this.plugin.Config.Layouts2[this.selectedLayout] = newLayout;
this.plugin.Config.Save();
}
}
if (!ImGui.Begin(this.plugin.Name, ref this._settingsVisible)) {
return;
}
if (ImGui.BeginTabBar("##hudswap-tabs")) {
if (!this.plugin.Config.UnderstandsRisks) {
if (ImGui.BeginTabItem("About")) {
ImGui.TextColored(new Vector4(1f, 0f, 0f, 1f), "Read this first");
ImGui.Separator();
ImGui.Text("Import");
ImGui.InputText("Imported layout name", ref this.importName, 100);
bool importPositions = this.plugin.Config.ImportPositions;
if (ImGui.Checkbox("Import window positions", ref importPositions)) {
this.plugin.Config.ImportPositions = importPositions;
this.plugin.Config.Save();
}
ImGui.SameLine();
HelpMarker("If this is checked, the position of the chat box and the map will be saved with the imported layout.");
foreach (HudSlot slot in Enum.GetValues(typeof(HudSlot))) {
string buttonName = $"{(int)slot + 1}##import";
if (ImGui.Button(buttonName) && this.importName.Length != 0) {
this.ImportSlot(this.importName, slot);
this.importName = "";
}
ImGui.SameLine();
}
if (ImGui.Button("Clipboard") && this.importName.Length != 0) {
SharedLayout shared = null;
try {
shared = (SharedLayout)JsonConvert.DeserializeObject(ImGui.GetClipboardText(), typeof(SharedLayout));
#pragma warning disable CA1031 // Do not catch general exception types
} catch (Exception) {
#pragma warning restore CA1031 // Do not catch general exception types
}
if (shared != null) {
byte[] layout = shared.Layout();
if (layout != null) {
this.Import(this.importName, layout, shared.Positions);
this.importName = "";
}
}
}
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Swaps")) {
bool enabled = this.plugin.Config.SwapsEnabled;
if (ImGui.Checkbox("Enable swaps", ref enabled)) {
this.plugin.Config.SwapsEnabled = enabled;
this.plugin.Config.Save();
}
ImGui.Text("Note: Disable swaps when editing your HUD.");
ImGui.PushTextWrapPos(ImGui.GetFontSize() * 20f);
ImGui.Text("HudSwap will use the configured staging slot as its own slot to make changes to. This means the staging slot will be overwritten whenever any swap happens.");
ImGui.Spacing();
string staging = ((int)this.plugin.Config.StagingSlot + 1).ToString();
if (ImGui.BeginCombo("Staging slot", staging)) {
foreach (HudSlot slot in Enum.GetValues(typeof(HudSlot))) {
if (ImGui.Selectable(((int)slot + 1).ToString())) {
this.plugin.Config.StagingSlot = slot;
this.plugin.Config.Save();
}
}
ImGui.EndCombo();
}
ImGui.SameLine();
HelpMarker("The staging slot is the HUD layout slot that will be used as your HUD layout. All changes will be written to this slot when swaps are enabled.");
ImGui.Text("Any HUD layout changes you make while HudSwap is enabled may potentially be lost, no matter what slot. If you want to make changes to your HUD layout, TURN OFF HudSwap first.");
ImGui.Spacing();
ImGui.Text("When editing or making a new layout, to be completely safe, turn off swaps, set up your layout, import the layout into HudSwap, then turn on swaps.");
ImGui.Spacing();
ImGui.Text("If you are a new user, HudSwap auto-imported your existing layouts on startup.");
ImGui.Spacing();
ImGui.Text("Finally, HudSwap is beta software. Back up your character data before using this plugin. You may lose some to all of your HUD layouts while testing this plugin.");
ImGui.Separator();
if (this.plugin.Config.Layouts2.Count == 0) {
ImGui.Text("Create at least one layout to begin setting up swaps.");
} else {
ImGui.Text("Add conditions below for when to swap.\nThe topmost condition in the list has priority.");
this.DrawConditionsTable();
ImGui.Text("If you have read all of the above and are okay with continuing, check the box below to enable HudSwap. You only need to do this once.");
ImGui.PopTextWrapPos();
bool understandsRisks = this.plugin.Config.UnderstandsRisks;
if (ImGui.Checkbox("I understand", ref understandsRisks)) {
this.plugin.Config.UnderstandsRisks = understandsRisks;
this.plugin.Config.Save();
}
ImGui.EndTabItem();
}
ImGui.EndTabBar();
ImGui.End();
return;
}
ImGui.End();
if (ImGui.BeginTabItem("Layouts")) {
ImGui.Text("Saved layouts");
if (this.plugin.Config.Layouts2.Count == 0) {
ImGui.Text("None saved!");
} else {
ImGui.PushItemWidth(-1);
if (ImGui.ListBoxHeader("##saved-layouts")) {
foreach (KeyValuePair<Guid, Layout> entry in this.plugin.Config.Layouts2) {
if (ImGui.Selectable($"{entry.Value.Name}##{entry.Key}", this.selectedLayout == entry.Key)) {
this.selectedLayout = entry.Key;
this.renameName = entry.Value.Name;
}
}
ImGui.ListBoxFooter();
}
ImGui.PopItemWidth();
ImGui.Text("Copy onto slot...");
foreach (HudSlot slot in Enum.GetValues(typeof(HudSlot))) {
string buttonName = $"{(int)slot + 1}##copy";
if (ImGui.Button(buttonName) && this.selectedLayout != null) {
Layout layout = this.plugin.Config.Layouts2[this.selectedLayout];
this.plugin.Hud.WriteLayout(slot, layout.Hud.ToArray());
}
ImGui.SameLine();
}
if (ImGui.Button("Delete") && this.selectedLayout != null) {
this.plugin.Config.Layouts2.Remove(this.selectedLayout);
this.plugin.Config.HudConditionMatches.RemoveAll(m => m.LayoutId == this.selectedLayout);
this.selectedLayout = Guid.Empty;
this.renameName = "";
this.plugin.Config.Save();
}
ImGui.SameLine();
if (ImGui.Button("Copy to clipboard") && this.selectedLayout != null) {
if (this.plugin.Config.Layouts2.TryGetValue(this.selectedLayout, out Layout layout)) {
SharedLayout shared = new SharedLayout(layout);
string json = JsonConvert.SerializeObject(shared);
ImGui.SetClipboardText(json);
}
}
ImGui.InputText("##rename-input", ref this.renameName, 100);
ImGui.SameLine();
if (ImGui.Button("Rename") && this.renameName.Length != 0 && this.selectedLayout != null) {
Layout layout = this.plugin.Config.Layouts2[this.selectedLayout];
Layout newLayout = new Layout(this.renameName, layout.Hud, layout.Positions);
this.plugin.Config.Layouts2[this.selectedLayout] = newLayout;
this.plugin.Config.Save();
}
}
ImGui.Separator();
ImGui.Text("Import");
ImGui.InputText("Imported layout name", ref this.importName, 100);
bool importPositions = this.plugin.Config.ImportPositions;
if (ImGui.Checkbox("Import window positions", ref importPositions)) {
this.plugin.Config.ImportPositions = importPositions;
this.plugin.Config.Save();
}
ImGui.SameLine();
HelpMarker("If this is checked, the position of the chat box and the map will be saved with the imported layout.");
foreach (HudSlot slot in Enum.GetValues(typeof(HudSlot))) {
string buttonName = $"{(int)slot + 1}##import";
if (ImGui.Button(buttonName) && this.importName.Length != 0) {
this.ImportSlot(this.importName, slot);
this.importName = "";
}
ImGui.SameLine();
}
if (ImGui.Button("Clipboard") && this.importName.Length != 0) {
SharedLayout shared = null;
try {
shared = (SharedLayout)JsonConvert.DeserializeObject(ImGui.GetClipboardText(), typeof(SharedLayout));
#pragma warning disable CA1031 // Do not catch general exception types
} catch (Exception) {
#pragma warning restore CA1031 // Do not catch general exception types
}
if (shared != null) {
byte[] layout = shared.Layout();
if (layout != null) {
this.Import(this.importName, layout, shared.Positions);
this.importName = "";
}
}
}
ImGui.EndTabItem();
}
if (ImGui.BeginTabItem("Swaps")) {
bool enabled = this.plugin.Config.SwapsEnabled;
if (ImGui.Checkbox("Enable swaps", ref enabled)) {
this.plugin.Config.SwapsEnabled = enabled;
this.plugin.Config.Save();
}
ImGui.Text("Note: Disable swaps when editing your HUD.");
ImGui.Spacing();
string staging = ((int)this.plugin.Config.StagingSlot + 1).ToString();
if (ImGui.BeginCombo("Staging slot", staging)) {
foreach (HudSlot slot in Enum.GetValues(typeof(HudSlot))) {
if (ImGui.Selectable(((int)slot + 1).ToString())) {
this.plugin.Config.StagingSlot = slot;
this.plugin.Config.Save();
}
}
ImGui.EndCombo();
}
ImGui.SameLine();
HelpMarker("The staging slot is the HUD layout slot that will be used as your HUD layout. All changes will be written to this slot when swaps are enabled.");
ImGui.Separator();
if (this.plugin.Config.Layouts2.Count == 0) {
ImGui.Text("Create at least one layout to begin setting up swaps.");
} else {
ImGui.Text("Add swap conditions below.\nThe first condition that is satisfied will be the layout that is used.");
ImGui.Separator();
this.DrawConditionsTable();
}
ImGui.EndTabItem();
}
ImGui.EndTabBar();
}
ImGui.End();
}
private void DrawConditionsTable()
{
private void DrawConditionsTable() {
ImGui.PushFont(UiBuilder.IconFont);
float height = ImGui.GetContentRegionAvail().Y - ImGui.CalcTextSize(FontAwesomeIcon.Plus.ToIconString()).Y - ImGui.GetStyle().ItemSpacing.Y - ImGui.GetStyle().ItemInnerSpacing.Y * 2;
ImGui.PopFont();
if (!ImGui.BeginChild("##conditions-table", new Vector2(-1, height))) {
return;
}
ImGui.Columns(4);
var conditions = new List<HudConditionMatch>(plugin.Config.HudConditionMatches);
if (this.editingConditionIndex == conditions.Count)
var conditions = new List<HudConditionMatch>(this.plugin.Config.HudConditionMatches);
if (this.editingConditionIndex == conditions.Count) {
conditions.Add(new HudConditionMatch());
}
ImGui.Text("Job");
ImGui.NextColumn();
@ -257,39 +271,70 @@ namespace HudSwap {
int action = 0; // 0 for delete, otherwise move.
foreach (var item in conditions.Select((cond, i) => new { cond, i })) {
if (this.editingConditionIndex == item.i) {
ImGui.PushItemWidth(-1);
if (ImGui.BeginCombo("##condition-edit-job", this.editingCondition.ClassJob ?? "Any")) {
if (ImGui.Selectable("Any##condition-edit-job"))
if (ImGui.Selectable("Any##condition-edit-job")) {
this.editingCondition.ClassJob = null;
foreach (ClassJob job in this.pi.Data.GetExcelSheet<ClassJob>().ToList())
if (ImGui.Selectable($"{job.Abbreviation}##condition-edit-job"))
}
foreach (ClassJob job in this.pi.Data.GetExcelSheet<ClassJob>().Skip(1)) {
if (ImGui.Selectable($"{job.Abbreviation}##condition-edit-job")) {
this.editingCondition.ClassJob = job.Abbreviation;
}
}
ImGui.EndCombo();
}
ImGui.PopItemWidth();
ImGui.NextColumn();
ImGui.PushItemWidth(-1);
if (ImGui.BeginCombo("##condition-edit-status", this.editingCondition.Status?.Name() ?? "Any")) {
if (ImGui.Selectable("Any##condition-edit-status"))
if (ImGui.Selectable("Any##condition-edit-status")) {
this.editingCondition.Status = null;
foreach (Status status in Enum.GetValues(typeof(Status)))
if (ImGui.Selectable($"{status.Name()}##condition-edit-status"))
}
foreach (Status status in Enum.GetValues(typeof(Status))) {
if (ImGui.Selectable($"{status.Name()}##condition-edit-status")) {
this.editingCondition.Status = status;
}
}
ImGui.EndCombo();
}
ImGui.PopItemWidth();
ImGui.NextColumn();
if (ImGui.BeginCombo("##condition-edit-layout", this.editingCondition.LayoutId == Guid.Empty ? string.Empty : this.plugin.Config.Layouts2[this.editingCondition.LayoutId].Name)) {
if (ImGui.Selectable("##condition-edit-layout-empty"))
this.editingCondition.LayoutId = Guid.Empty;
foreach (var layout in this.plugin.Config.Layouts2)
if (ImGui.Selectable($"{layout.Value.Name}##condition-edit-layout"))
ImGui.PushItemWidth(-1);
string comboPreview = this.editingCondition.LayoutId == Guid.Empty ? string.Empty : this.plugin.Config.Layouts2[this.editingCondition.LayoutId].Name;
if (ImGui.BeginCombo("##condition-edit-layout", comboPreview)) {
foreach (var layout in this.plugin.Config.Layouts2) {
if (ImGui.Selectable($"{layout.Value.Name}##condition-edit-layout-{layout.Key}")) {
this.editingCondition.LayoutId = layout.Key;
}
}
ImGui.EndCombo();
}
ImGui.PopItemWidth();
ImGui.NextColumn();
if (this.editingCondition.LayoutId != Guid.Empty)
if (ImGui.Button("Confirm##condition-edit"))
if (this.editingCondition.LayoutId != Guid.Empty) {
if (IconButton(FontAwesomeIcon.Check, "condition-edit")) {
addCondition = true;
}
ImGui.SameLine();
}
if (IconButton(FontAwesomeIcon.Times, "condition-stop")) {
this.editingConditionIndex = -1;
}
if (this.scrollToAdd) {
this.scrollToAdd = false;
ImGui.SetScrollHereY();
}
} else {
ImGui.Text(item.cond.ClassJob ?? string.Empty);
ImGui.NextColumn();
@ -297,25 +342,28 @@ namespace HudSwap {
ImGui.Text(item.cond.Status?.Name() ?? string.Empty);
ImGui.NextColumn();
ImGui.Text(this.plugin.Config.Layouts2[item.cond.LayoutId].Name);
this.plugin.Config.Layouts2.TryGetValue(item.cond.LayoutId, out Layout condLayout);
ImGui.Text(condLayout?.Name ?? string.Empty);
ImGui.NextColumn();
if (ImGui.Button($"E##{item.i}")) {
if (IconButton(FontAwesomeIcon.PencilAlt, $"{item.i}")) {
this.editingConditionIndex = item.i;
this.editingCondition = item.cond;
}
ImGui.SameLine();
if (ImGui.Button($"D##{item.i}"))
if (IconButton(FontAwesomeIcon.Trash, $"{item.i}")) {
actionedItemIndex = item.i;
}
ImGui.SameLine();
if (ImGui.Button($"↑##{item.i}")) {
if (IconButton(FontAwesomeIcon.ArrowUp, $"{item.i}")) {
actionedItemIndex = item.i;
action = -1;
}
ImGui.SameLine();
if (ImGui.Button($"↓##{item.i}")) {
if (IconButton(FontAwesomeIcon.ArrowDown, $"{item.i}")) {
actionedItemIndex = item.i;
action = 1;
}
@ -324,19 +372,25 @@ namespace HudSwap {
ImGui.NextColumn();
}
ImGui.Columns();
ImGui.Columns(1);
ImGui.Separator();
if (ImGui.Button("Add##condition")) {
ImGui.EndChild();
if (IconButton(FontAwesomeIcon.Plus, "condition")) {
this.editingConditionIndex = this.plugin.Config.HudConditionMatches.Count;
this.editingCondition = new HudConditionMatch();
this.scrollToAdd = true;
}
bool recalculate = false;
if (addCondition) {
if (this.editingConditionIndex == this.plugin.Config.HudConditionMatches.Count)
recalculate = true;
if (this.editingConditionIndex == this.plugin.Config.HudConditionMatches.Count) {
this.plugin.Config.HudConditionMatches.Add(this.editingCondition);
else {
} else {
this.plugin.Config.HudConditionMatches.RemoveAt(this.editingConditionIndex);
this.plugin.Config.HudConditionMatches.Insert(this.editingConditionIndex, this.editingCondition);
}
@ -345,9 +399,10 @@ namespace HudSwap {
}
if (actionedItemIndex >= 0) {
if (action == 0)
recalculate = true;
if (action == 0) {
this.plugin.Config.HudConditionMatches.RemoveAt(actionedItemIndex);
else {
} else {
if (actionedItemIndex + action >= 0 && actionedItemIndex + action < this.plugin.Config.HudConditionMatches.Count) {
// Move the condition.
var c = this.plugin.Config.HudConditionMatches[actionedItemIndex];
@ -357,6 +412,21 @@ namespace HudSwap {
}
this.plugin.Config.Save();
}
if (recalculate) {
PlayerCharacter player = this.pi.ClientState.LocalPlayer;
if (player != null && this.plugin.Config.SwapsEnabled) {
this.plugin.Statuses.Update(player);
this.plugin.Statuses.SetHudLayout(null);
}
}
}
private static bool IconButton(FontAwesomeIcon icon, string append = "") {
ImGui.PushFont(UiBuilder.IconFont);
bool button = ImGui.Button($"{icon.ToIconString()}##{append}");
ImGui.PopFont();
return button;
}
private static void HelpMarker(string text) {
@ -370,41 +440,10 @@ namespace HudSwap {
}
}
private string LayoutNameOrDefault(Guid key) {
if (this.plugin.Config.Layouts2.TryGetValue(key, out Layout layout)) {
return layout.Name;
} else {
return "";
}
}
public void Draw() {
this.DrawSettings();
}
private bool LayoutBox(string name, Guid currentLayout, out Guid newLayout) {
newLayout = Guid.Empty;
bool updated = false;
ImGui.Text(name);
ImGui.NextColumn();
if (ImGui.BeginCombo($"##{name}-layout", this.LayoutNameOrDefault(currentLayout))) {
if (ImGui.Selectable("Not set")) {
updated = true;
}
ImGui.Separator();
foreach (KeyValuePair<Guid, Layout> entry in this.plugin.Config.Layouts2) {
if (ImGui.Selectable(entry.Value.Name)) {
updated = true;
newLayout = entry.Key;
}
}
ImGui.EndCombo();
}
ImGui.NextColumn();
return updated;
}
private Dictionary<string, Vector2<short>> GetPositions() {
Dictionary<string, Vector2<short>> positions = new Dictionary<string, Vector2<short>>();

View File

@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
// TODO: Zone swaps?
@ -57,11 +58,12 @@ namespace HudSwap {
foreach (var match in this.plugin.Config.HudConditionMatches) {
if ((!match.Status.HasValue || this.condition[match.Status.Value]) &&
(match.ClassJob == null || this.job.Abbreviation == match.ClassJob))
(match.ClassJob == null || this.job.Abbreviation == match.ClassJob)) {
return match.LayoutId;
}
}
return this.plugin.Config.DefaultLayout;
return Guid.Empty;
}
public void SetHudLayout(PlayerCharacter player, bool update = false) {
@ -92,11 +94,13 @@ namespace HudSwap {
/// </summary>
public string ClassJob { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public Status? Status { get; set; }
public Guid LayoutId { get; set; }
}
// Note: Changing the names of these is a breaking change
public enum Status {
InCombat = ConditionFlag.InCombat,
WeaponDrawn = ConditionFlag.None,