Skip to content

Commit

Permalink
Add option to replace native UI
Browse files Browse the repository at this point in the history
  • Loading branch information
sourpuh committed Nov 30, 2024
1 parent a701307 commit b979616
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 33 deletions.
2 changes: 1 addition & 1 deletion WaymarkStudio/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<WaymarkPreset> SavedPresets { get; set; } = [];

public void Save()
Expand Down
21 changes: 9 additions & 12 deletions WaymarkStudio/FieldMarkerAddon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,31 @@ namespace WaymarkStudio;
public unsafe class FieldMarkerAddon : IDisposable
{
private readonly Hook<AgentFieldMarker.Delegates.Show>? show;
private readonly Hook<AgentFieldMarker.Delegates.Hide>? hide;

int lastHover = -1;

public FieldMarkerAddon()
{
//show ??= Plugin.Hooker.HookFromAddress<AgentFieldMarker.Delegates.Show>((nint)AgentFieldMarker.Instance()->VirtualTable->Show, OnShow);
//hide ??= Plugin.Hooker.HookFromAddress<AgentFieldMarker.Delegates.Hide>((nint)AgentFieldMarker.Instance()->VirtualTable->Hide, OnHide);
show ??= Plugin.Hooker.HookFromAddress<AgentFieldMarker.Delegates.Show>((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)
{
Expand Down
11 changes: 2 additions & 9 deletions WaymarkStudio/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.Event;
using Lumina.Excel.Sheets;
using System;
using WaymarkStudio.Windows;


Expand Down Expand Up @@ -91,15 +90,9 @@ private void OnCommand(string command, string args)

private void OnTerritoryChange(ushort mapId)
{
try
{
TerritoryType territory = DataManager.GetExcelSheet<TerritoryType>().GetRow(mapId);
if (DataManager.GetExcelSheet<TerritoryType>().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)
{
Expand Down
16 changes: 5 additions & 11 deletions WaymarkStudio/Windows/ConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
*/
}
}

0 comments on commit b979616

Please sign in to comment.