diff --git a/Globetrotter/Globetrotter.csproj b/Globetrotter/Globetrotter.csproj
index 77d40a4..cc9b51b 100755
--- a/Globetrotter/Globetrotter.csproj
+++ b/Globetrotter/Globetrotter.csproj
@@ -2,9 +2,10 @@
1.2.0
- net48
+ net5-windows
latest
enable
+ false
@@ -29,6 +30,6 @@
-
+
diff --git a/Globetrotter/Globetrotter.yaml b/Globetrotter/Globetrotter.yaml
index 42f55e0..c8d5c7c 100644
--- a/Globetrotter/Globetrotter.yaml
+++ b/Globetrotter/Globetrotter.yaml
@@ -1,5 +1,9 @@
author: ascclemens
name: Globetrotter
+punchline: Automatically shows where treasure maps are located.
description: |-
Automatically shows where treasure maps are located.
+
+ Icon: Map by Adrien Coquet from the Noun Project
repo_url: https://git.sr.ht/~jkcclemens/Globetrotter
+icon_url: https://annaclemens.io/assets/plugins/icons/globetrotter.png
diff --git a/Globetrotter/GlobetrotterPlugin.cs b/Globetrotter/GlobetrotterPlugin.cs
index 1d2c1ff..79bbf98 100644
--- a/Globetrotter/GlobetrotterPlugin.cs
+++ b/Globetrotter/GlobetrotterPlugin.cs
@@ -1,44 +1,63 @@
using Dalamud.Game.Command;
using Dalamud.Plugin;
using System;
+using Dalamud.Data;
+using Dalamud.Game;
+using Dalamud.Game.Gui;
namespace Globetrotter {
+ // ReSharper disable once ClassNeverInstantiated.Global
public class GlobetrotterPlugin : IDalamudPlugin {
private bool _disposedValue;
public string Name => "Globetrotter";
- private DalamudPluginInterface _pi = null!;
- private Configuration _config = null!;
- private PluginUi _ui = null!;
- private TreasureMaps _maps = null!;
+ private DalamudPluginInterface Interface { get; }
+ private CommandManager CommandManager { get; }
+ internal DataManager DataManager { get; }
+ internal GameGui GameGui { get; }
+ internal SigScanner SigScanner { get; }
- public void Initialize(DalamudPluginInterface pluginInterface) {
- this._pi = pluginInterface ?? throw new ArgumentNullException(nameof(pluginInterface), "DalamudPluginInterface cannot be null");
+ internal Configuration Config { get; }
+ private PluginUi Ui { get; }
+ private TreasureMaps Maps { get; }
- this._config = this._pi.GetPluginConfig() as Configuration ?? new Configuration();
- this._config.Initialize(this._pi);
+ public GlobetrotterPlugin(
+ DalamudPluginInterface pluginInterface,
+ CommandManager commandManager,
+ DataManager dataManager,
+ GameGui gameGui,
+ SigScanner scanner
+ ) {
+ this.Interface = pluginInterface;
+ this.CommandManager = commandManager;
+ this.DataManager = dataManager;
+ this.GameGui = gameGui;
+ this.SigScanner = scanner;
- this._ui = new PluginUi(this._config);
- this._maps = new TreasureMaps(this._pi, this._config);
+ this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
+ this.Config.Initialize(this.Interface);
- this._pi.UiBuilder.OnBuildUi += this._ui.Draw;
- this._pi.UiBuilder.OnOpenConfigUi += this._ui.OpenSettings;
- this._pi.Framework.Gui.HoveredItemChanged += this._maps.OnHover;
- this._pi.CommandManager.AddHandler("/pglobetrotter", new CommandInfo(this.OnConfigCommand) {
+ this.Ui = new PluginUi(this);
+ this.Maps = new TreasureMaps(this);
+
+ this.Interface.UiBuilder.Draw += this.Ui.Draw;
+ this.Interface.UiBuilder.OpenConfigUi += this.Ui.OpenSettings;
+ this.GameGui.HoveredItemChanged += this.Maps.OnHover;
+ this.CommandManager.AddHandler("/pglobetrotter", new CommandInfo(this.OnConfigCommand) {
HelpMessage = "Show the Globetrotter config",
});
- this._pi.CommandManager.AddHandler("/tmap", new CommandInfo(this.OnCommand) {
+ this.CommandManager.AddHandler("/tmap", new CommandInfo(this.OnCommand) {
HelpMessage = "Open the map and place a flag at the location of your current treasure map",
});
}
private void OnConfigCommand(string command, string args) {
- this._ui.OpenSettings(null, null);
+ this.Ui.OpenSettings(null, null);
}
private void OnCommand(string command, string args) {
- this._maps.OpenMapLocation();
+ this.Maps.OpenMapLocation();
}
protected virtual void Dispose(bool disposing) {
@@ -47,12 +66,12 @@ namespace Globetrotter {
}
if (disposing) {
- this._pi.UiBuilder.OnBuildUi -= this._ui.Draw;
- this._pi.UiBuilder.OnOpenConfigUi -= this._ui.OpenSettings;
- this._pi.Framework.Gui.HoveredItemChanged -= this._maps.OnHover;
- this._maps.Dispose();
- this._pi.CommandManager.RemoveHandler("/pglobetrotter");
- this._pi.CommandManager.RemoveHandler("/tmap");
+ this.Interface.UiBuilder.Draw -= this.Ui.Draw;
+ this.Interface.UiBuilder.OpenConfigUi -= this.Ui.OpenSettings;
+ this.GameGui.HoveredItemChanged -= this.Maps.OnHover;
+ this.Maps.Dispose();
+ this.CommandManager.RemoveHandler("/pglobetrotter");
+ this.CommandManager.RemoveHandler("/tmap");
}
this._disposedValue = true;
diff --git a/Globetrotter/PluginUi.cs b/Globetrotter/PluginUi.cs
index 32278c6..4b1f624 100644
--- a/Globetrotter/PluginUi.cs
+++ b/Globetrotter/PluginUi.cs
@@ -4,7 +4,7 @@ using System.Numerics;
namespace Globetrotter {
internal class PluginUi {
- private Configuration Config { get; }
+ private GlobetrotterPlugin Plugin { get; }
private bool _displaySettings;
@@ -13,11 +13,11 @@ namespace Globetrotter {
set => this._displaySettings = value;
}
- public PluginUi(Configuration config) {
- this.Config = config ?? throw new ArgumentNullException(nameof(config), "Configuration cannot be null");
+ public PluginUi(GlobetrotterPlugin plugin) {
+ this.Plugin = plugin;
}
- public void OpenSettings(object sender, EventArgs e) {
+ public void OpenSettings(object? sender, EventArgs? e) {
this.DisplaySettings = true;
}
@@ -37,26 +37,26 @@ namespace Globetrotter {
ImGui.Separator();
- var showOnDecipher = this.Config.ShowOnDecipher;
+ var showOnDecipher = this.Plugin.Config.ShowOnDecipher;
if (HelpCheckbox("Show on decipher", "Open the map with a flag set after deciphering a map.", ref showOnDecipher)) {
- this.Config.ShowOnDecipher = showOnDecipher;
- this.Config.Save();
+ this.Plugin.Config.ShowOnDecipher = showOnDecipher;
+ this.Plugin.Config.Save();
}
ImGui.Separator();
- var showOnOpen = this.Config.ShowOnOpen;
+ var showOnOpen = this.Plugin.Config.ShowOnOpen;
if (HelpCheckbox("Show on open", "Open the map with a flag set instead of the normal treasure map window.", ref showOnOpen)) {
- this.Config.ShowOnOpen = showOnOpen;
- this.Config.Save();
+ this.Plugin.Config.ShowOnOpen = showOnOpen;
+ this.Plugin.Config.Save();
}
ImGui.Separator();
- var showOnHover = this.Config.ShowOnHover;
+ var showOnHover = this.Plugin.Config.ShowOnHover;
if (HelpCheckbox("Show on hover", "Open the map with a flag set when hovering over a deciphered map.", ref showOnHover)) {
- this.Config.ShowOnHover = showOnHover;
- this.Config.Save();
+ this.Plugin.Config.ShowOnHover = showOnHover;
+ this.Plugin.Config.Save();
}
ImGui.End();
diff --git a/Globetrotter/TreasureMaps.cs b/Globetrotter/TreasureMaps.cs
index 18df6f6..8677db3 100644
--- a/Globetrotter/TreasureMaps.cs
+++ b/Globetrotter/TreasureMaps.cs
@@ -1,11 +1,11 @@
using Dalamud.Hooking;
-using Dalamud.Plugin;
using Lumina.Excel.GeneratedSheets;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Dalamud.Game.Text.SeStringHandling.Payloads;
+using Dalamud.Logging;
namespace Globetrotter {
internal sealed class TreasureMaps : IDisposable {
@@ -21,7 +21,7 @@ namespace Globetrotter {
var mapToRow = new Dictionary();
- foreach (var rank in this.Interface.Data.GetExcelSheet()) {
+ foreach (var rank in this.Plugin.DataManager.GetExcelSheet()) {
var unopened = rank.ItemName.Value;
if (unopened == null) {
continue;
@@ -48,8 +48,7 @@ namespace Globetrotter {
}
}
- private DalamudPluginInterface Interface { get; }
- private Configuration Config { get; }
+ private GlobetrotterPlugin Plugin { get; }
private TreasureMapPacket? _lastMap;
private delegate char HandleActorControlSelfDelegate(long a1, long a2, IntPtr dataPtr);
@@ -59,16 +58,15 @@ namespace Globetrotter {
private readonly Hook _acsHook;
private readonly Hook _showMapHook;
- public TreasureMaps(DalamudPluginInterface pi, Configuration config) {
- this.Interface = pi ?? throw new ArgumentNullException(nameof(pi), "DalamudPluginInterface cannot be null");
- this.Config = config ?? throw new ArgumentNullException(nameof(config), "Configuration cannot be null");
+ public TreasureMaps(GlobetrotterPlugin plugin) {
+ this.Plugin = plugin;
- var acsPtr = this.Interface.TargetModuleScanner.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 48 8B D9 49 8B F8 41 0F B7 08");
- this._acsHook = new Hook(acsPtr, new HandleActorControlSelfDelegate(this.OnACS));
+ var acsPtr = this.Plugin.SigScanner.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 48 8B D9 49 8B F8 41 0F B7 08");
+ this._acsHook = new Hook(acsPtr, this.OnACS);
this._acsHook.Enable();
- var showMapPtr = this.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 40 84 FF 0F 85 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ??");
- this._showMapHook = new Hook(showMapPtr, new ShowTreasureMapDelegate(this.OnShowMap));
+ var showMapPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? 40 84 FF 0F 85 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ??");
+ this._showMapHook = new Hook(showMapPtr, this.OnShowMap);
this._showMapHook.Enable();
}
@@ -77,8 +75,8 @@ namespace Globetrotter {
this._showMapHook.Dispose();
}
- public void OnHover(object sender, ulong id) {
- if (!this.Config.ShowOnHover || this._lastMap == null || this._lastMap.EventItemId != id) {
+ public void OnHover(object? sender, ulong id) {
+ if (!this.Plugin.Config.ShowOnHover || this._lastMap == null || this._lastMap.EventItemId != id) {
return;
}
@@ -107,7 +105,7 @@ namespace Globetrotter {
}
}
- if (!this.Config.ShowOnOpen && (!this.Config.ShowOnDecipher || this._lastMap?.JustOpened != true)) {
+ if (!this.Plugin.Config.ShowOnOpen && (!this.Plugin.Config.ShowOnDecipher || this._lastMap?.JustOpened != true)) {
return true;
}
@@ -145,7 +143,7 @@ namespace Globetrotter {
return;
}
- var spot = this.Interface.Data.GetExcelSheet().GetRow(rowId, packet.SubRowId);
+ var spot = this.Plugin.DataManager.GetExcelSheet().GetRow(rowId, packet.SubRowId);
var loc = spot?.Location?.Value;
var map = loc?.Map?.Value;
@@ -155,17 +153,16 @@ namespace Globetrotter {
return;
}
- var x = ToMapCoordinate(loc.X, map.SizeFactor);
+ var x = ToMapCoordinate(loc!.X, map!.SizeFactor);
var y = ToMapCoordinate(loc.Z, map.SizeFactor);
var mapLink = new MapLinkPayload(
- this.Interface.Data,
terr.RowId,
map.RowId,
ConvertMapCoordinateToRawPosition(x, map.SizeFactor),
ConvertMapCoordinateToRawPosition(y, map.SizeFactor)
);
- this.Interface.Framework.Gui.OpenMapWithMapLink(mapLink);
+ this.Plugin.GameGui.OpenMapWithMapLink(mapLink);
if (this._lastMap != null) {
this._lastMap.JustOpened = false;
diff --git a/icon.svg b/icon.svg
new file mode 100755
index 0000000..9d7c540
--- /dev/null
+++ b/icon.svg
@@ -0,0 +1,89 @@
+
+