update 14
This commit is contained in:
1 parent
e0ddd32744
commit
da592f9860
15 files changed
+261
-286
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Plugin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Waypoints;
|
||||
|
||||
[Serializable]
|
||||
public class Configuration : IPluginConfiguration
|
||||
{
|
||||
public int Version { get; set; } = 0;
|
||||
|
||||
public Dictionary<string, (uint, uint, Vector3)> Waypoints = new();
|
||||
|
||||
[NonSerialized]
|
||||
private IDalamudPluginInterface? PluginInterface;
|
||||
|
||||
public void Initialize(IDalamudPluginInterface pluginInterface)
|
||||
{
|
||||
PluginInterface = pluginInterface;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
PluginInterface!.SavePluginConfig(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Waypoints;
|
||||
|
||||
public class MainWindow : Window, IDisposable
|
||||
{
|
||||
private string newName = string.Empty;
|
||||
|
||||
public MainWindow()
|
||||
: base("Waypoints")
|
||||
{
|
||||
SizeConstraints = new WindowSizeConstraints
|
||||
{
|
||||
MinimumSize = new Vector2(375, 330),
|
||||
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
|
||||
};
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
ImGui.InputText("", ref newName, 128);
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Add Waypoint"))
|
||||
{
|
||||
if (newName.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Plugin.Configuration.Waypoints.Add(newName, (Utils.CurrentTerritoryId(), Utils.CurrentMapId(), Utils.CurrentPosition() ?? Vector3.Zero));
|
||||
Plugin.Configuration.Save();
|
||||
Plugin.WotsitIpc.Update();
|
||||
newName = string.Empty;
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.Text("Waypoints");
|
||||
foreach (var kvp in Plugin.Configuration.Waypoints)
|
||||
{
|
||||
if (ImGui.Button(kvp.Key))
|
||||
{
|
||||
Utils.OpenMapAt(kvp.Value.Item1, kvp.Value.Item2, kvp.Value.Item3);
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button($"Delete##{kvp.Key}"))
|
||||
{
|
||||
Plugin.Configuration.Waypoints.Remove(kvp.Key);
|
||||
Plugin.Configuration.Save();
|
||||
Plugin.WotsitIpc.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
|
||||
namespace Waypoints;
|
||||
|
||||
public sealed class Plugin : IDalamudPlugin
|
||||
{
|
||||
[PluginService] public static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
|
||||
[PluginService] public static IClientState ClientState { get; private set; } = null!;
|
||||
[PluginService] public static IObjectTable ObjectTable { get; private set; } = null!;
|
||||
public static Configuration Configuration { get; private set; } = null!;
|
||||
public readonly WindowSystem WindowSystem = new("Waypoints");
|
||||
public static WotsitIpc WotsitIpc { get; private set; } = null!;
|
||||
public static MainWindow MainWindow { get; private set; } = null!;
|
||||
|
||||
public Plugin()
|
||||
{
|
||||
Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||
Configuration.Initialize(PluginInterface);
|
||||
|
||||
WotsitIpc = new();
|
||||
|
||||
MainWindow = new();
|
||||
WindowSystem.AddWindow(MainWindow);
|
||||
PluginInterface.UiBuilder.Draw += WindowSystem.Draw;
|
||||
PluginInterface.UiBuilder.OpenMainUi += MainWindow.Toggle;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Configuration.Save();
|
||||
WindowSystem.RemoveAllWindows();
|
||||
WotsitIpc.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Waypoints
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
public static unsafe uint CurrentTerritoryId()
|
||||
{
|
||||
return AgentMap.Instance()->CurrentTerritoryId;
|
||||
}
|
||||
|
||||
public static unsafe uint CurrentMapId()
|
||||
{
|
||||
return AgentMap.Instance()->CurrentMapId;
|
||||
}
|
||||
|
||||
public static Vector3? CurrentPosition()
|
||||
{
|
||||
return Plugin.ObjectTable.LocalPlayer?.Position;
|
||||
}
|
||||
|
||||
public static unsafe void OpenMapAt(uint territoryId, uint mapId, Vector3 position)
|
||||
{
|
||||
AgentMap.Instance()->SetFlagMapMarker(territoryId, mapId, position);
|
||||
AgentMap.Instance()->OpenMap(mapId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Dalamud.NET.Sdk/14.0.1">
|
||||
<PropertyGroup>
|
||||
<Version>0.0.0.1</Version>
|
||||
<PackageProjectUrl>https://github.com/goatcorp/SamplePlugin</PackageProjectUrl>
|
||||
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"Author": "SuspiciousActivity",
|
||||
"Name": "Waypoints",
|
||||
"Punchline": "Save Waypoints and access them using Wotsit.",
|
||||
"Description": "Save Waypoints and access them using Wotsit.",
|
||||
"ApplicableVersion": "any",
|
||||
"Tags": [
|
||||
"waypoint",
|
||||
"wotsit"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Timers;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
|
||||
namespace Waypoints
|
||||
{
|
||||
public class WotsitIpc
|
||||
{
|
||||
private ICallGateSubscriber<string, string, string, uint, string> _registerWithSearch;
|
||||
private ICallGateSubscriber<string, bool> _invoke;
|
||||
private ICallGateSubscriber<string, bool> _unregisterAll;
|
||||
private Timer _timer;
|
||||
|
||||
private Dictionary<string, (uint, uint, Vector3)> _map = new();
|
||||
|
||||
public WotsitIpc()
|
||||
{
|
||||
_registerWithSearch = Plugin.PluginInterface.GetIpcSubscriber<string, string, string, uint, string>("FA.RegisterWithSearch");
|
||||
_unregisterAll = Plugin.PluginInterface.GetIpcSubscriber<string, bool>("FA.UnregisterAll");
|
||||
|
||||
_invoke = Plugin.PluginInterface.GetIpcSubscriber<string, bool>("FA.Invoke");
|
||||
_invoke.Subscribe(Invoke);
|
||||
_timer = new Timer(5000);
|
||||
_timer.Elapsed += (sender, e) => RetryInit();
|
||||
if (!Update())
|
||||
{
|
||||
_timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void RetryInit()
|
||||
{
|
||||
_registerWithSearch = Plugin.PluginInterface.GetIpcSubscriber<string, string, string, uint, string>("FA.RegisterWithSearch");
|
||||
_unregisterAll = Plugin.PluginInterface.GetIpcSubscriber<string, bool>("FA.UnregisterAll");
|
||||
|
||||
_invoke = Plugin.PluginInterface.GetIpcSubscriber<string, bool>("FA.Invoke");
|
||||
_invoke.Subscribe(Invoke);
|
||||
if (Update())
|
||||
{
|
||||
_timer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
UnregisterAll();
|
||||
}
|
||||
|
||||
public bool Update()
|
||||
{
|
||||
_map.Clear();
|
||||
if (!UnregisterAll())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var kvp in Plugin.Configuration.Waypoints)
|
||||
{
|
||||
string guid = _registerWithSearch.InvokeFunc(
|
||||
Plugin.PluginInterface.InternalName,
|
||||
$"Waypoint: {kvp.Key}",
|
||||
$"Waypoint: {kvp.Key}",
|
||||
66472
|
||||
);
|
||||
|
||||
_map.Add(guid, (kvp.Value.Item1, kvp.Value.Item2, kvp.Value.Item3));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Invoke(string guid)
|
||||
{
|
||||
if (!_map.TryGetValue(guid, out var value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Utils.OpenMapAt(value.Item1, value.Item2, value.Item3);
|
||||
}
|
||||
|
||||
public bool UnregisterAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
_unregisterAll.InvokeFunc(Plugin.PluginInterface.InternalName);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"version": 1,
|
||||
"dependencies": {
|
||||
"net10.0-windows7.0": {
|
||||
"DalamudPackager": {
|
||||
"type": "Direct",
|
||||
"requested": "[14.0.1, )",
|
||||
"resolved": "14.0.1",
|
||||
"contentHash": "y0WWyUE6dhpGdolK3iKgwys05/nZaVf4ZPtIjpLhJBZvHxkkiE23zYRo7K7uqAgoK/QvK5cqF6l3VG5AbgC6KA=="
|
||||
},
|
||||
"DotNet.ReproducibleBuilds": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.2.39, )",
|
||||
"resolved": "1.2.39",
|
||||
"contentHash": "fcFN01tDTIQqDuTwr1jUQK/geofiwjG5DycJQOnC72i1SsLAk1ELe+apBOuZ11UMQG8YKFZG1FgvjZPbqHyatg=="
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user