Compare commits

...

No commits in common. "main" and "9bf2caa17d0d95d9bce13d1865b99d258eff3cab" have entirely different histories.

8 changed files with 61 additions and 110 deletions

View File

@ -2,19 +2,20 @@
using System.Numerics;
using System.Runtime.InteropServices;
using Dalamud.Hooking;
using Dalamud.Logging;
namespace Tourist {
public class GameFunctions : IDisposable {
private delegate nint VistaUnlockedDelegate(ushort index, int a2, int a3);
private delegate IntPtr VistaUnlockedDelegate(ushort index, int a2, int a3);
private delegate nint CreateVfxDelegate(string name);
private delegate IntPtr CreateVfxDelegate(string name);
private delegate nint PlayVfxDelegate(nint vfx, float idk, int idk2);
private delegate IntPtr PlayVfxDelegate(IntPtr vfx, float idk, int idk2);
internal delegate nint RemoveVfxDelegate(nint vfx);
internal delegate IntPtr RemoveVfxDelegate(IntPtr vfx);
private Plugin Plugin { get; }
private nint SightseeingMaskPointer { get; }
private IntPtr SightseeingMaskPointer { get; }
private CreateVfxDelegate CreateVfx { get; }
private PlayVfxDelegate PlayVfxInternal { get; }
@ -24,11 +25,11 @@ namespace Tourist {
public GameFunctions(Plugin plugin) {
this.Plugin = plugin;
var vistaUnlockedPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 8B CE E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 44 8B 7C 24");
this.VistaUnlockedHook = this.Plugin.GameInteropProvider.HookFromAddress<VistaUnlockedDelegate>(vistaUnlockedPtr, this.OnVistaUnlock);
var vistaUnlockedPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 41 8B CD E8 ?? ?? ?? ??");
this.VistaUnlockedHook = new Hook<VistaUnlockedDelegate>(vistaUnlockedPtr, this.OnVistaUnlock);
this.VistaUnlockedHook.Enable();
var maskPtr = this.Plugin.SigScanner.GetStaticAddressFromSig("8B EA 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.SigScanner.ScanText("E8 ?? ?? ?? ?? F3 0F 10 35 ?? ?? ?? ?? 48 89 43 08");
@ -45,17 +46,17 @@ namespace Tourist {
this.VistaUnlockedHook.Dispose();
}
private nint OnVistaUnlock(ushort index, int a2, int a3) {
private IntPtr OnVistaUnlock(ushort index, int a2, int a3) {
try {
this.Plugin.Markers.RemoveVfx(index);
} catch (Exception ex) {
Plugin.Log.Error(ex, "Exception in vista unlock");
PluginLog.LogError(ex, "Exception in vista unlock");
}
return this.VistaUnlockedHook.Original(index, a2, a3);
}
public unsafe nint SpawnVfx(string name, Vector3 position) {
public unsafe IntPtr SpawnVfx(string name, Vector3 position) {
var vfx = this.CreateVfx(name);
var pos = (float*) (vfx + 80);
@ -74,12 +75,12 @@ namespace Tourist {
return vfx;
}
internal bool PlayVfx(nint vfx) {
return this.PlayVfxInternal(vfx, 0.0f, -1) == nint.Zero;
internal bool PlayVfx(IntPtr vfx) {
return this.PlayVfxInternal(vfx, 0.0f, -1) == IntPtr.Zero;
}
public bool HasVistaUnlocked(short index) {
if (this.SightseeingMaskPointer == nint.Zero) {
if (this.SightseeingMaskPointer == IntPtr.Zero) {
return false;
}

View File

@ -2,7 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Dalamud.Plugin.Services;
using Dalamud.Game;
using Dalamud.Logging;
using Lumina.Excel.GeneratedSheets;
namespace Tourist {
@ -10,8 +11,8 @@ namespace Tourist {
private const string MarkerPath = "bgcommon/world/common/vfx_for_live/eff/b0810_tnsk_y.avfx";
private Plugin Plugin { get; }
private Dictionary<uint, nint> Spawned { get; } = new();
private HashSet<nint> Queue { get; } = new();
private Dictionary<uint, IntPtr> Spawned { get; } = new();
private HashSet<IntPtr> Queue { get; } = new();
public Markers(Plugin plugin) {
this.Plugin = plugin;
@ -60,7 +61,7 @@ namespace Tourist {
row += 1;
if (adventure.Level.Value!.Territory.Row != territory) {
if (adventure.Level.Value.Territory.Row != territory) {
continue;
}
@ -76,7 +77,7 @@ namespace Tourist {
}
}
private void OnTerritoryChange(ushort territory) {
private void OnTerritoryChange(object? sender, ushort territory) {
if (!this.Plugin.Config.ShowArrVistas) {
return;
}
@ -85,11 +86,11 @@ namespace Tourist {
this.RemoveAllVfx();
this.SpawnVfxForCurrentZone(territory);
} catch (Exception ex) {
Plugin.Log.Error(ex, "Exception in territory change");
PluginLog.LogError(ex, "Exception in territory change");
}
}
private void OnFrameworkUpdate(IFramework framework1) {
private void OnFrameworkUpdate(Framework framework) {
foreach (var vfx in this.Queue.ToArray()) {
if (this.Plugin.Functions.PlayVfx(vfx)) {
this.Queue.Remove(vfx);

View File

@ -1,40 +1,36 @@
using Dalamud.Game;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using FFXIVWeather.Lumina;
namespace Tourist {
// ReSharper disable once ClassNeverInstantiated.Global
public class Plugin : IDalamudPlugin {
public static string Name => "Tourist";
public string Name => "Tourist";
internal DalamudPluginInterface Interface { get; }
[PluginService]
internal static IPluginLog Log { get; private set; } = null!;
internal ClientState ClientState { get; init; } = null!;
[PluginService]
internal DalamudPluginInterface Interface { get; init; }
internal CommandManager CommandManager { get; init; } = null!;
[PluginService]
internal IClientState ClientState { get; init; } = null!;
internal DataManager DataManager { get; init; } = null!;
[PluginService]
internal ICommandManager CommandManager { get; init; } = null!;
internal Framework Framework { get; init; } = null!;
[PluginService]
internal IDataManager DataManager { get; init; } = null!;
internal GameGui GameGui { get; init; } = null!;
[PluginService]
internal IFramework Framework { get; init; } = null!;
[PluginService]
internal IGameGui GameGui { get; init; } = null!;
[PluginService]
internal ISigScanner SigScanner { get; init; } = null!;
[PluginService]
internal IGameInteropProvider GameInteropProvider { get; init; } = null!;
internal SigScanner SigScanner { get; init; } = null!;
internal Configuration Config { get; }
internal PluginUi Ui { get; }

View File

@ -39,7 +39,7 @@ namespace Tourist {
return;
}
if (!ImGui.Begin(Plugin.Name, ref this._show, ImGuiWindowFlags.MenuBar)) {
if (!ImGui.Begin(this.Plugin.Name, ref this._show, ImGuiWindowFlags.MenuBar)) {
ImGui.End();
return;
}
@ -135,7 +135,7 @@ namespace Tourist {
.Select(adventure => (idx: adventure.RowId - first, adventure))
.OrderBy(entry => this.Plugin.Config.SortMode switch {
SortMode.Number => entry.idx,
SortMode.Zone => entry.adventure.Level.Value!.Map.Row,
SortMode.Zone => entry.adventure.Level.Value.Map.Row,
_ => throw new ArgumentOutOfRangeException(),
});
@ -143,7 +143,7 @@ namespace Tourist {
var lastTree = false;
foreach (var (idx, adventure) in adventures) {
if (this.Plugin.Config.OnlyShowCurrentZone && adventure.Level.Value!.Territory.Row != this.Plugin.ClientState.TerritoryType) {
if (this.Plugin.Config.OnlyShowCurrentZone && adventure.Level.Value.Territory.Row != this.Plugin.ClientState.TerritoryType) {
continue;
}
@ -160,13 +160,13 @@ namespace Tourist {
}
if (this.Plugin.Config.SortMode == SortMode.Zone) {
var map = adventure.Level.Value!.Map.Value;
var map = adventure.Level.Value.Map.Value;
if (lastMap != map) {
if (lastMap != null) {
ImGui.TreePop();
}
lastTree = ImGui.CollapsingHeader($"{map!.PlaceName.Value!.Name}");
lastTree = ImGui.CollapsingHeader($"{map.PlaceName.Value.Name}");
ImGui.TreePush();
}
@ -212,7 +212,7 @@ namespace Tourist {
ImGui.TextUnformatted("Command");
ImGui.NextColumn();
ImGui.TextUnformatted(adventure.Emote.Value?.TextCommand.Value?.Command ?? "<unk>");
ImGui.TextUnformatted(adventure.Emote.Value.TextCommand.Value.Command);
ImGui.NextColumn();
ImGui.TextUnformatted("Eorzea time");
@ -233,8 +233,6 @@ namespace Tourist {
var weatherString = string.Join(", ", weathers
.OrderBy(id => id)
.Select(id => this.Plugin.DataManager.GetExcelSheet<Weather>()!.GetRow(id))
.Where(weather => weather != null)
.Cast<Weather>()
.Select(weather => weather.Name));
ImGui.TextUnformatted(weatherString);
} else {

View File

@ -1,54 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.2.14</Version>
<TargetFramework>net7-windows</TargetFramework>
<Version>1.2.4</Version>
<TargetFramework>net5-windows</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<PropertyGroup>
<DalamudLibPath>$(AppData)\XIVLauncher\addon\Hooks\dev</DalamudLibPath>
</PropertyGroup>
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
<DalamudLibPath>$(DALAMUD_HOME)</DalamudLibPath>
</PropertyGroup>
<PropertyGroup Condition="'$(IsCI)' == 'true'">
<DalamudLibPath>$(HOME)/dalamud</DalamudLibPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dalamud">
<HintPath>$(DalamudLibPath)\Dalamud.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ImGui.NET">
<HintPath>$(DalamudLibPath)\ImGui.NET.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGui.NET.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ImGuiScene">
<HintPath>$(DalamudLibPath)\ImGuiScene.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGuiScene.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lumina">
<HintPath>$(DalamudLibPath)\Lumina.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lumina.Excel">
<HintPath>$(DalamudLibPath)\Lumina.Excel.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.Excel.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="FFXIVWeather.Lumina" Version="2.2.0" />
<PackageReference Include="DalamudPackager" Version="2.1.2"/>
<PackageReference Include="FFXIVWeather.Lumina" Version="1.2.2"/>
</ItemGroup>
<ItemGroup>
<Content Include="..\icon.png" Private="false" Link="images/icon.png" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>
</Project>

View File

@ -1,5 +1,5 @@
name: Tourist
author: Anna
author: ascclemens
punchline: Finish your sightseeing log.
description: |-
Tourist adds a window to assist with the sightseeing log.
@ -11,4 +11,4 @@ description: |-
- Show the command needed for each vista
Icon: sightseeing by muhammad from the Noun Project
repo_url: https://git.anna.lgbt/anna/Tourist
repo_url: https://git.sr.ht/~jkcclemens/Tourist

View File

@ -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.Services;
using FFXIVWeather.Lumina;
using Lumina.Excel.GeneratedSheets;
@ -11,7 +11,7 @@ namespace Tourist {
public static class Util {
private static Dictionary<uint, (DateTimeOffset start, DateTimeOffset end)> Availability { get; } = new();
public static void OpenMapLocation(this IGameGui gameGui, 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;
@ -170,7 +170,7 @@ namespace Tourist {
return true;
}
var (weather, _) = service.GetCurrentWeather(adventure.Level.Value!.Territory.Value, offset);
var (weather, _) = service.GetCurrentWeather(adventure.Level.Value.Territory.Value, offset);
return weathers.Contains(weather.RowId);
}

View File

@ -1,36 +0,0 @@
{
"version": 1,
"dependencies": {
"net7.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.12, )",
"resolved": "2.1.12",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
},
"FFXIVWeather.Lumina": {
"type": "Direct",
"requested": "[2.2.0, )",
"resolved": "2.2.0",
"contentHash": "zGYBjw7iRY3fUYuDGDaroiPES123esZ07th+H/cKsIZsfs5960B9EDjyEHxu1NlA0txKMGLbNMjINUmE4XImsg==",
"dependencies": {
"Lumina": "3.9.0",
"Lumina.Excel": "6.2.0"
}
},
"Lumina": {
"type": "Transitive",
"resolved": "3.9.0",
"contentHash": "2ADC9iN8yUHXELq3IIQAK1cvi2kp53l1CDmAnrsTwBXJ9o9anIC+X6TzFRxWuRvTVI/MEMHTjwBobGwBGc3XhQ=="
},
"Lumina.Excel": {
"type": "Transitive",
"resolved": "6.2.0",
"contentHash": "gIPr/Q4HhYDL65h/9b0srdL+Nfxk90T7aIciLnpl/QaBdc7tGRPzUmq0FU2QjErkikhrFOrb4Fp5NkQaN3DQDA==",
"dependencies": {
"Lumina": "3.9.0"
}
}
}
}
}