diff --git a/WaymarkStudio/Configuration.cs b/WaymarkStudio/Configuration.cs index 511f911..54b677c 100644 --- a/WaymarkStudio/Configuration.cs +++ b/WaymarkStudio/Configuration.cs @@ -20,7 +20,7 @@ public class Configuration : IPluginConfiguration public bool SnapXZToGrid = true; public bool PlaceRealIfPossible = false; public bool ShareAcrossDifficulties = true; - + public bool ReplaceNativeUi = true; public List SavedPresets { get; set; } = []; public void Save() diff --git a/WaymarkStudio/FieldMarkerAddon.cs b/WaymarkStudio/FieldMarkerAddon.cs index 4a854cf..dff2584 100644 --- a/WaymarkStudio/FieldMarkerAddon.cs +++ b/WaymarkStudio/FieldMarkerAddon.cs @@ -13,34 +13,31 @@ namespace WaymarkStudio; public unsafe class FieldMarkerAddon : IDisposable { private readonly Hook? show; - private readonly Hook? hide; int lastHover = -1; public FieldMarkerAddon() { - //show ??= Plugin.Hooker.HookFromAddress((nint)AgentFieldMarker.Instance()->VirtualTable->Show, OnShow); - //hide ??= Plugin.Hooker.HookFromAddress((nint)AgentFieldMarker.Instance()->VirtualTable->Hide, OnHide); + show ??= Plugin.Hooker.HookFromAddress((nint)AgentFieldMarker.Instance()->VirtualTable->Show, OnShow); + show.Enable(); Plugin.AddonLifecycle.RegisterListener(AddonEvent.PostDraw, "FieldMarker", AddonPostDraw); } public void Dispose() { - //show?.Dispose(); - //hide?.Dispose(); + show?.Disable(); + show?.Dispose(); + Plugin.AddonLifecycle.UnregisterListener(AddonPostDraw); } public void OnShow(AgentFieldMarker* thisPtr) { - Plugin.Chat.Print("show"); - if (thisPtr == null) - return; - } - public void OnHide(AgentFieldMarker* thisPtr) - { - Plugin.Chat.Print("hide"); if (thisPtr == null) return; + if (Plugin.Config.ReplaceNativeUi) + Plugin.StudioWindow.Toggle(); + else + show!.Original(thisPtr); } public void AddonPostDraw(AddonEvent type, AddonArgs args) { diff --git a/WaymarkStudio/Plugin.cs b/WaymarkStudio/Plugin.cs index da07773..88dfa39 100644 --- a/WaymarkStudio/Plugin.cs +++ b/WaymarkStudio/Plugin.cs @@ -6,7 +6,6 @@ using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Game.Event; using Lumina.Excel.Sheets; -using System; using WaymarkStudio.Windows; @@ -91,15 +90,9 @@ private void OnCommand(string command, string args) private void OnTerritoryChange(ushort mapId) { - try - { - TerritoryType territory = DataManager.GetExcelSheet().GetRow(mapId); + if (DataManager.GetExcelSheet().TryGetRow(mapId, out var territory)) WaymarkManager.OnTerritoryChange(territory); - } - catch (ArgumentOutOfRangeException e) - { - Log.Error(e.ToString()); - } + #if DEBUG if (EventFramework.GetCurrentContentType() == FFXIVClientStructs.FFXIV.Client.Game.Event.ContentType.Party) { diff --git a/WaymarkStudio/Windows/ConfigWindow.cs b/WaymarkStudio/Windows/ConfigWindow.cs index 23c273f..12f16fe 100644 --- a/WaymarkStudio/Windows/ConfigWindow.cs +++ b/WaymarkStudio/Windows/ConfigWindow.cs @@ -20,18 +20,12 @@ public void Dispose() { } public override void Draw() { - ImGui.Text("Did you think there would be something here?"); - /* - if (ImGui.BeginTable("ConfigTable", 1, ImGuiTableFlags.BordersOuter | ImGuiTableFlags.NoHostExtendX | ImGuiTableFlags.SizingFixedSame)) + bool needSave = false; + needSave |= ImGui.Checkbox("Replace Native Waymarks UI", ref Configuration.ReplaceNativeUi); + // needSave |= ImGui.Checkbox("Share Criterion Normal and Savage Presets", ref Configuration.ShareAcrossDifficulties); + if (needSave) { - ImGui.TableNextRow(); - ImGui.TableNextColumn(); - - if (ImGui.Checkbox("Share Criterion Normal and Savage Presets", ref Configuration.ShareAcrossDifficulties)) - { - } - ImGui.EndTable(); + Configuration.Save(); } - */ } }