diff --git a/Tourist/Commands.cs b/Tourist/Commands.cs index 1d8d85b..8d80e22 100644 --- a/Tourist/Commands.cs +++ b/Tourist/Commands.cs @@ -8,13 +8,13 @@ namespace Tourist { public Commands(Plugin plugin) { this.Plugin = plugin; - this.Plugin.Interface.CommandManager.AddHandler("/tourist", new CommandInfo(this.OnCommand) { + this.Plugin.CommandManager.AddHandler("/tourist", new CommandInfo(this.OnCommand) { HelpMessage = "Opens the Tourist interface", }); } public void Dispose() { - this.Plugin.Interface.CommandManager.RemoveHandler("/tourist"); + this.Plugin.CommandManager.RemoveHandler("/tourist"); } private void OnCommand(string command, string arguments) { diff --git a/Tourist/DalamudPackager.targets b/Tourist/DalamudPackager.targets index 09c903e..e4ec530 100644 --- a/Tourist/DalamudPackager.targets +++ b/Tourist/DalamudPackager.targets @@ -5,11 +5,6 @@ OutputPath="$(OutputPath)" AssemblyName="$(AssemblyName)" VersionComponents="3" - MakeZip="true" - Include=" - Tourist.dll; - Tourist.pdb; - Tourist.json - "/> + MakeZip="true"/> diff --git a/Tourist/FodyWeavers.xml b/Tourist/FodyWeavers.xml deleted file mode 100755 index 328a52d..0000000 --- a/Tourist/FodyWeavers.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - FFXIVWeather\.Lumina - - diff --git a/Tourist/GameFunctions.cs b/Tourist/GameFunctions.cs index f5c25fc..4c65310 100644 --- a/Tourist/GameFunctions.cs +++ b/Tourist/GameFunctions.cs @@ -2,7 +2,7 @@ using System.Numerics; using System.Runtime.InteropServices; using Dalamud.Hooking; -using Dalamud.Plugin; +using Dalamud.Logging; namespace Tourist { public class GameFunctions : IDisposable { @@ -25,20 +25,20 @@ namespace Tourist { public GameFunctions(Plugin plugin) { this.Plugin = plugin; - var vistaUnlockedPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 41 8B CD E8 ?? ?? ?? ??"); - this.VistaUnlockedHook = new Hook(vistaUnlockedPtr, new VistaUnlockedDelegate(this.OnVistaUnlock)); + var vistaUnlockedPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 41 8B CD E8 ?? ?? ?? ??"); + this.VistaUnlockedHook = new Hook(vistaUnlockedPtr, this.OnVistaUnlock); this.VistaUnlockedHook.Enable(); - var maskPtr = this.Plugin.Interface.TargetModuleScanner.GetStaticAddressFromSig("8B F2 48 8D 0D ?? ?? ?? ?? 8B D3"); + var maskPtr = this.Plugin.SigScanner.GetStaticAddressFromSig("8B F2 48 8D 0D ?? ?? ?? ?? 8B D3"); this.SightseeingMaskPointer = maskPtr; - var createVfxPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? F3 0F 10 35 ?? ?? ?? ?? 48 89 43 08"); + var createVfxPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? F3 0F 10 35 ?? ?? ?? ?? 48 89 43 08"); this.CreateVfx = Marshal.GetDelegateForFunctionPointer(createVfxPtr); - var playVfxPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 8B 4B 7C 85 C9"); + var playVfxPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? 8B 4B 7C 85 C9"); this.PlayVfxInternal = Marshal.GetDelegateForFunctionPointer(playVfxPtr); - var removeVfxPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("40 53 48 83 EC 20 48 8B D9 48 8B 89 ?? ?? ?? ?? 48 85 C9 74 28 33 D2"); + var removeVfxPtr = this.Plugin.SigScanner.ScanText("40 53 48 83 EC 20 48 8B D9 48 8B 89 ?? ?? ?? ?? 48 85 C9 74 28 33 D2"); this.RemoveVfx = Marshal.GetDelegateForFunctionPointer(removeVfxPtr); } diff --git a/Tourist/Markers.cs b/Tourist/Markers.cs index 899a942..dc2bfdb 100644 --- a/Tourist/Markers.cs +++ b/Tourist/Markers.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; -using Dalamud.Game.Internal; -using Dalamud.Plugin; +using Dalamud.Game; +using Dalamud.Logging; using Lumina.Excel.GeneratedSheets; namespace Tourist { @@ -17,22 +17,22 @@ namespace Tourist { public Markers(Plugin plugin) { this.Plugin = plugin; - this.Plugin.Interface.ClientState.TerritoryChanged += this.OnTerritoryChange; - this.Plugin.Interface.Framework.OnUpdateEvent += this.OnFrameworkUpdate; + this.Plugin.ClientState.TerritoryChanged += this.OnTerritoryChange; + this.Plugin.Framework.OnUpdateEvent += this.OnFrameworkUpdate; if (this.Plugin.Config.ShowArrVistas) { - this.SpawnVfxForCurrentZone(this.Plugin.Interface.ClientState.TerritoryType); + this.SpawnVfxForCurrentZone(this.Plugin.ClientState.TerritoryType); } } public void Dispose() { - this.Plugin.Interface.Framework.OnUpdateEvent -= this.OnFrameworkUpdate; - this.Plugin.Interface.ClientState.TerritoryChanged -= this.OnTerritoryChange; + this.Plugin.Framework.OnUpdateEvent -= this.OnFrameworkUpdate; + this.Plugin.ClientState.TerritoryChanged -= this.OnTerritoryChange; this.RemoveAllVfx(); } internal void RemoveVfx(ushort index) { - var adventure = this.Plugin.Interface.Data.GetExcelSheet() + var adventure = this.Plugin.DataManager.GetExcelSheet() .Skip(index) .First(); @@ -54,7 +54,7 @@ namespace Tourist { internal void SpawnVfxForCurrentZone(ushort territory) { var row = 0; - foreach (var adventure in this.Plugin.Interface.Data.GetExcelSheet()) { + foreach (var adventure in this.Plugin.DataManager.GetExcelSheet()) { if (row >= 80) { break; } @@ -77,7 +77,7 @@ namespace Tourist { } } - private void OnTerritoryChange(object sender, ushort territory) { + private void OnTerritoryChange(object? sender, ushort territory) { if (!this.Plugin.Config.ShowArrVistas) { return; } diff --git a/Tourist/Plugin.cs b/Tourist/Plugin.cs index 9224a8c..be1e4d9 100644 --- a/Tourist/Plugin.cs +++ b/Tourist/Plugin.cs @@ -1,5 +1,11 @@ using System; using System.Reflection; +using Dalamud.Data; +using Dalamud.Game; +using Dalamud.Game.ClientState; +using Dalamud.Game.Command; +using Dalamud.Game.Gui; +using Dalamud.Game.Text.SeStringHandling; using Dalamud.Plugin; using FFXIVWeather.Lumina; @@ -8,26 +14,50 @@ namespace Tourist { public class Plugin : IDalamudPlugin { public string Name => "Tourist"; - internal DalamudPluginInterface Interface { get; private set; } = null!; - internal Configuration Config { get; private set; } = null!; - internal PluginUi Ui { get; private set; } = null!; - internal FFXIVWeatherLuminaService Weather { get; private set; } = null!; - internal GameFunctions Functions { get; private set; } = null!; - private Commands Commands { get; set; } = null!; - internal Markers Markers { get; private set; } = null!; + internal DalamudPluginInterface Interface { get; } + internal ClientState ClientState { get; } + internal CommandManager CommandManager { get; } + internal DataManager DataManager { get; } + internal Framework Framework { get; } + internal GameGui GameGui { get; } + internal SeStringManager SeStringManager { get; } + internal SigScanner SigScanner { get; } - public void Initialize(DalamudPluginInterface pluginInterface) { + internal Configuration Config { get; } + internal PluginUi Ui { get; } + internal FFXIVWeatherLuminaService Weather { get; } + internal GameFunctions Functions { get; } + private Commands Commands { get; } + internal Markers Markers { get; } + + public Plugin( + DalamudPluginInterface pluginInterface, + ClientState clientState, + CommandManager commandManager, + DataManager dataManager, + Framework framework, + GameGui gameGui, + SeStringManager seStringManager, + SigScanner sigScanner + ) { this.Interface = pluginInterface; + this.ClientState = clientState; + this.CommandManager = commandManager; + this.DataManager = dataManager; + this.Framework = framework; + this.GameGui = gameGui; + this.SeStringManager = seStringManager; + this.SigScanner = sigScanner; this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration(); this.Config.Initialise(this); - var gameDataField = this.Interface.Data.GetType().GetField("gameData", BindingFlags.Instance | BindingFlags.NonPublic); + var gameDataField = this.DataManager.GetType().GetField("gameData", BindingFlags.Instance | BindingFlags.NonPublic); if (gameDataField == null) { throw new Exception("Missing gameData field"); } - var lumina = (Lumina.GameData) gameDataField.GetValue(this.Interface.Data); + var lumina = (Lumina.GameData) gameDataField.GetValue(this.DataManager)!; this.Weather = new FFXIVWeatherLuminaService(lumina); this.Functions = new GameFunctions(this); diff --git a/Tourist/PluginUi.cs b/Tourist/PluginUi.cs index 3ddd0cf..858434d 100644 --- a/Tourist/PluginUi.cs +++ b/Tourist/PluginUi.cs @@ -18,16 +18,16 @@ namespace Tourist { public PluginUi(Plugin plugin) { this.Plugin = plugin; - this.Plugin.Interface.UiBuilder.OnBuildUi += this.Draw; - this.Plugin.Interface.UiBuilder.OnOpenConfigUi += this.OpenConfig; + this.Plugin.Interface.UiBuilder.Draw += this.Draw; + this.Plugin.Interface.UiBuilder.OpenConfigUi += this.OpenConfig; } public void Dispose() { - this.Plugin.Interface.UiBuilder.OnOpenConfigUi -= this.OpenConfig; - this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw; + this.Plugin.Interface.UiBuilder.OpenConfigUi -= this.OpenConfig; + this.Plugin.Interface.UiBuilder.Draw -= this.Draw; } - private void OpenConfig(object sender, EventArgs eventArgs) { + private void OpenConfig(object? sender, EventArgs eventArgs) { this.Show = true; } @@ -102,7 +102,7 @@ namespace Tourist { this.Plugin.Config.Save(); if (showArrVistas) { - var territory = this.Plugin.Interface.ClientState.TerritoryType; + var territory = this.Plugin.ClientState.TerritoryType; this.Plugin.Markers.SpawnVfxForCurrentZone(territory); } else { this.Plugin.Markers.RemoveAllVfx(); @@ -130,7 +130,7 @@ namespace Tourist { if (ImGui.BeginChild("tourist-adventures", new Vector2(0, 0))) { const uint first = 2162688; - var adventures = this.Plugin.Interface.Data.GetExcelSheet() + var adventures = this.Plugin.DataManager.GetExcelSheet() .Select(adventure => (idx: adventure.RowId - first, adventure)) .OrderBy(entry => this.Plugin.Config.SortMode switch { SortMode.Number => entry.idx, @@ -142,7 +142,7 @@ namespace Tourist { var lastTree = false; foreach (var (idx, adventure) in adventures) { - if (this.Plugin.Config.OnlyShowCurrentZone && adventure.Level.Value.Territory.Row != this.Plugin.Interface.ClientState.TerritoryType) { + if (this.Plugin.Config.OnlyShowCurrentZone && adventure.Level.Value.Territory.Row != this.Plugin.ClientState.TerritoryType) { continue; } @@ -194,7 +194,7 @@ namespace Tourist { ? string.Empty : $" ({(countdown.Value - DateTimeOffset.UtcNow).ToHumanReadable()})"; - var name = this.Plugin.Interface.SeStringManager.Parse(adventure.Name.RawData.ToArray()); + var name = this.Plugin.SeStringManager.Parse(adventure.Name.RawData.ToArray()); var header = ImGui.CollapsingHeader($"#{idx + 1} - {name.TextValue}{next}###adventure-{adventure.RowId}"); if (has || available) { @@ -231,7 +231,7 @@ namespace Tourist { if (Weathers.All.TryGetValue(adventure.RowId, out var weathers)) { var weatherString = string.Join(", ", weathers .OrderBy(id => id) - .Select(id => this.Plugin.Interface.Data.GetExcelSheet().GetRow(id)) + .Select(id => this.Plugin.DataManager.GetExcelSheet().GetRow(id)) .Select(weather => weather.Name)); ImGui.TextUnformatted(weatherString); } else { @@ -241,7 +241,7 @@ namespace Tourist { ImGui.Columns(); if (ImGui.Button($"Open map##{adventure.RowId}")) { - this.Plugin.Interface.OpenMapLocation(adventure); + this.Plugin.GameGui.OpenMapLocation(adventure); } } diff --git a/Tourist/Tourist.csproj b/Tourist/Tourist.csproj index 7db84c5..c0bc337 100755 --- a/Tourist/Tourist.csproj +++ b/Tourist/Tourist.csproj @@ -2,10 +2,12 @@ 1.2.3 - net48 + net5-windows latest enable true + false + true @@ -29,17 +31,11 @@ $(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.Excel.dll False - - C:\Users\Anna\AppData\Roaming\XIVLauncher\addon\Hooks\dev\System.Memory.dll - False - - + - - diff --git a/Tourist/Tourist.yaml b/Tourist/Tourist.yaml index 86b4e77..4cf23ab 100644 --- a/Tourist/Tourist.yaml +++ b/Tourist/Tourist.yaml @@ -1,5 +1,6 @@ name: Tourist author: ascclemens +punchline: Finish your sightseeing log. description: |- Tourist adds a window to assist with the sightseeing log. @@ -8,4 +9,7 @@ description: |- - Open vista locations on your map - Hide already completed or unavailable vistas - Show the command needed for each vista + + Icon: sightseeing by muhammad from the Noun Project repo_url: https://git.sr.ht/~jkcclemens/Tourist +icon_url: https://annaclemens.io/assets/plugins/icons/tourist.png diff --git a/Tourist/Util.cs b/Tourist/Util.cs index 320d93a..ad596a6 100644 --- a/Tourist/Util.cs +++ b/Tourist/Util.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Dalamud.Game.Gui; using Dalamud.Game.Text.SeStringHandling.Payloads; -using Dalamud.Plugin; using FFXIVWeather.Lumina; using Lumina.Excel.GeneratedSheets; @@ -11,7 +11,7 @@ namespace Tourist { public static class Util { private static Dictionary Availability { get; } = new(); - public static void OpenMapLocation(this DalamudPluginInterface @interface, Adventure adventure) { + public static void OpenMapLocation(this GameGui gameGui, Adventure adventure) { var loc = adventure.Level?.Value; var map = loc?.Map?.Value; var terr = map?.TerritoryType?.Value; @@ -21,14 +21,13 @@ namespace Tourist { } var mapLink = new MapLinkPayload( - @interface.Data, terr.RowId, map!.RowId, (int) (loc!.X * 1_000f), (int) (loc.Z * 1_000f) ); - @interface.Framework.Gui.OpenMapWithMapLink(mapLink); + gameGui.OpenMapWithMapLink(mapLink); } private static DateTimeOffset EorzeaTime(DateTimeOffset? at = null) { diff --git a/Tourist/Weathers.cs b/Tourist/Weathers.cs index 2077d6b..c09de1d 100644 --- a/Tourist/Weathers.cs +++ b/Tourist/Weathers.cs @@ -3,86 +3,86 @@ namespace Tourist { public static class Weathers { public static readonly IReadOnlyDictionary All = new Dictionary { - [2162688] = new uint[] {2, 1}, - [2162689] = new uint[] {1, 2}, - [2162690] = new uint[] {7, 8}, - [2162691] = new uint[] {2, 1}, - [2162692] = new uint[] {3}, - [2162693] = new uint[] {2, 1}, - [2162694] = new uint[] {4}, - [2162695] = new uint[] {2, 1}, - [2162696] = new uint[] {3}, - [2162697] = new uint[] {1, 2}, - [2162698] = new uint[] {2, 1}, - [2162699] = new uint[] {2, 1}, - [2162700] = new uint[] {1, 2}, - [2162701] = new uint[] {2, 1}, - [2162702] = new uint[] {3}, - [2162703] = new uint[] {2, 1}, - [2162704] = new uint[] {4}, - [2162705] = new uint[] {7, 8}, - [2162706] = new uint[] {3}, - [2162707] = new uint[] {2, 1}, - [2162708] = new uint[] {2, 1}, - [2162709] = new uint[] {1, 2}, - [2162710] = new uint[] {7, 8}, - [2162711] = new uint[] {1, 2}, - [2162712] = new uint[] {7, 8}, - [2162713] = new uint[] {1, 2}, - [2162714] = new uint[] {6}, - [2162715] = new uint[] {2, 1}, - [2162716] = new uint[] {1, 2}, - [2162717] = new uint[] {2, 1}, - [2162718] = new uint[] {1, 2}, - [2162719] = new uint[] {10}, - [2162720] = new uint[] {2, 1}, - [2162721] = new uint[] {3}, - [2162722] = new uint[] {1, 2}, - [2162723] = new uint[] {7, 8}, - [2162724] = new uint[] {2, 1}, - [2162725] = new uint[] {7, 8}, - [2162726] = new uint[] {7, 8}, - [2162727] = new uint[] {1, 2}, - [2162728] = new uint[] {2, 1}, - [2162729] = new uint[] {1, 2}, - [2162730] = new uint[] {9}, - [2162731] = new uint[] {10}, - [2162732] = new uint[] {1, 2}, - [2162733] = new uint[] {4}, - [2162734] = new uint[] {2, 1}, - [2162735] = new uint[] {2, 1}, - [2162736] = new uint[] {1, 2}, - [2162737] = new uint[] {3}, - [2162738] = new uint[] {1, 2}, - [2162739] = new uint[] {2, 1}, - [2162740] = new uint[] {11}, - [2162741] = new uint[] {1, 2}, - [2162742] = new uint[] {1, 2}, - [2162743] = new uint[] {2, 1}, - [2162744] = new uint[] {8}, - [2162745] = new uint[] {4}, - [2162746] = new uint[] {2, 1}, - [2162747] = new uint[] {14}, - [2162748] = new uint[] {2, 1}, - [2162749] = new uint[] {14}, - [2162750] = new uint[] {1, 2}, - [2162751] = new uint[] {2, 1}, - [2162752] = new uint[] {2, 1}, - [2162753] = new uint[] {3}, - [2162754] = new uint[] {4}, - [2162755] = new uint[] {1, 2}, - [2162756] = new uint[] {4}, - [2162757] = new uint[] {16}, - [2162758] = new uint[] {2, 1}, - [2162759] = new uint[] {1, 2}, - [2162760] = new uint[] {16, 15}, - [2162761] = new uint[] {2, 1}, - [2162762] = new uint[] {2, 1}, - [2162763] = new uint[] {1, 2}, - [2162764] = new uint[] {17}, - [2162765] = new uint[] {2, 1}, - [2162766] = new uint[] {1, 2}, - [2162767] = new uint[] {2, 1}, + [2162688] = new uint[] { 2, 1 }, + [2162689] = new uint[] { 1, 2 }, + [2162690] = new uint[] { 7, 8 }, + [2162691] = new uint[] { 2, 1 }, + [2162692] = new uint[] { 3 }, + [2162693] = new uint[] { 2, 1 }, + [2162694] = new uint[] { 4 }, + [2162695] = new uint[] { 2, 1 }, + [2162696] = new uint[] { 3 }, + [2162697] = new uint[] { 1, 2 }, + [2162698] = new uint[] { 2, 1 }, + [2162699] = new uint[] { 2, 1 }, + [2162700] = new uint[] { 1, 2 }, + [2162701] = new uint[] { 2, 1 }, + [2162702] = new uint[] { 3 }, + [2162703] = new uint[] { 2, 1 }, + [2162704] = new uint[] { 4 }, + [2162705] = new uint[] { 7, 8 }, + [2162706] = new uint[] { 3 }, + [2162707] = new uint[] { 2, 1 }, + [2162708] = new uint[] { 2, 1 }, + [2162709] = new uint[] { 1, 2 }, + [2162710] = new uint[] { 7, 8 }, + [2162711] = new uint[] { 1, 2 }, + [2162712] = new uint[] { 7, 8 }, + [2162713] = new uint[] { 1, 2 }, + [2162714] = new uint[] { 6 }, + [2162715] = new uint[] { 2, 1 }, + [2162716] = new uint[] { 1, 2 }, + [2162717] = new uint[] { 2, 1 }, + [2162718] = new uint[] { 1, 2 }, + [2162719] = new uint[] { 10 }, + [2162720] = new uint[] { 2, 1 }, + [2162721] = new uint[] { 3 }, + [2162722] = new uint[] { 1, 2 }, + [2162723] = new uint[] { 7, 8 }, + [2162724] = new uint[] { 2, 1 }, + [2162725] = new uint[] { 7, 8 }, + [2162726] = new uint[] { 7, 8 }, + [2162727] = new uint[] { 1, 2 }, + [2162728] = new uint[] { 2, 1 }, + [2162729] = new uint[] { 1, 2 }, + [2162730] = new uint[] { 9 }, + [2162731] = new uint[] { 10 }, + [2162732] = new uint[] { 1, 2 }, + [2162733] = new uint[] { 4 }, + [2162734] = new uint[] { 2, 1 }, + [2162735] = new uint[] { 2, 1 }, + [2162736] = new uint[] { 1, 2 }, + [2162737] = new uint[] { 3 }, + [2162738] = new uint[] { 1, 2 }, + [2162739] = new uint[] { 2, 1 }, + [2162740] = new uint[] { 11 }, + [2162741] = new uint[] { 1, 2 }, + [2162742] = new uint[] { 1, 2 }, + [2162743] = new uint[] { 2, 1 }, + [2162744] = new uint[] { 8 }, + [2162745] = new uint[] { 4 }, + [2162746] = new uint[] { 2, 1 }, + [2162747] = new uint[] { 14 }, + [2162748] = new uint[] { 2, 1 }, + [2162749] = new uint[] { 14 }, + [2162750] = new uint[] { 1, 2 }, + [2162751] = new uint[] { 2, 1 }, + [2162752] = new uint[] { 2, 1 }, + [2162753] = new uint[] { 3 }, + [2162754] = new uint[] { 4 }, + [2162755] = new uint[] { 1, 2 }, + [2162756] = new uint[] { 4 }, + [2162757] = new uint[] { 16 }, + [2162758] = new uint[] { 2, 1 }, + [2162759] = new uint[] { 1, 2 }, + [2162760] = new uint[] { 16, 15 }, + [2162761] = new uint[] { 2, 1 }, + [2162762] = new uint[] { 2, 1 }, + [2162763] = new uint[] { 1, 2 }, + [2162764] = new uint[] { 17 }, + [2162765] = new uint[] { 2, 1 }, + [2162766] = new uint[] { 1, 2 }, + [2162767] = new uint[] { 2, 1 }, }; } } diff --git a/icon.svg b/icon.svg new file mode 100755 index 0000000..82b7fa4 --- /dev/null +++ b/icon.svg @@ -0,0 +1,112 @@ + + + + + Sightseeing + + + + Sightseeing + + + + + + + + + + + + + + + + + + + + +