refactor: move to net5

This commit is contained in:
Anna 2021-08-24 01:17:42 -04:00
parent 04f598f44c
commit fd2fe8db78
16 changed files with 146 additions and 133 deletions

View File

@ -8,13 +8,13 @@ namespace RoleplayersToolbox {
internal Commands(Plugin plugin) { internal Commands(Plugin plugin) {
this.Plugin = plugin; this.Plugin = plugin;
this.Plugin.Interface.CommandManager.AddHandler("/rptools", new CommandInfo(this.OnCommand) { this.Plugin.CommandManager.AddHandler("/rptools", new CommandInfo(this.OnCommand) {
HelpMessage = "Open The Roleplayer's Toolbox", HelpMessage = "Open The Roleplayer's Toolbox",
}); });
} }
public void Dispose() { public void Dispose() {
this.Plugin.Interface.CommandManager.RemoveHandler("/rptools"); this.Plugin.CommandManager.RemoveHandler("/rptools");
} }
private void OnCommand(string command, string arguments) { private void OnCommand(string command, string arguments) {

View File

@ -1,18 +0,0 @@
using Dalamud.Plugin;
namespace RoleplayersToolbox {
// ReSharper disable once UnusedType.Global
public class DalamudPlugin : IDalamudPlugin {
public string Name => "The Roleplayer's Toolbox";
private Plugin Plugin { get; set; } = null!;
public void Initialize(DalamudPluginInterface pluginInterface) {
this.Plugin = new Plugin(pluginInterface);
}
public void Dispose() {
this.Plugin.Dispose();
}
}
}

View File

@ -1,3 +0,0 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ILMerge/>
</Weavers>

View File

@ -1,6 +1,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.IoC;
using Dalamud.Logging;
using Dalamud.Plugin; using Dalamud.Plugin;
using Lumina; using Lumina;
using RoleplayersToolbox.Tools; using RoleplayersToolbox.Tools;
@ -14,8 +23,39 @@ using RoleplayersToolbox.Tools.Illegal.EmoteSnap;
#endif #endif
namespace RoleplayersToolbox { namespace RoleplayersToolbox {
internal class Plugin : IDisposable { internal class Plugin : IDalamudPlugin {
internal DalamudPluginInterface Interface { get; } public string Name => "The Roleplayer's Toolbox";
[PluginService]
internal DalamudPluginInterface Interface { get; init; } = null!;
[PluginService]
internal ChatGui ChatGui { get; init; } = null!;
[PluginService]
internal ClientState ClientState { get; init; } = null!;
[PluginService]
internal CommandManager CommandManager { get; init; } = null!;
[PluginService]
internal DataManager DataManager { get; init; } = null!;
[PluginService]
internal Framework Framework { get; init; } = null!;
[PluginService]
internal GameGui GameGui { get; init; } = null!;
[PluginService]
internal ObjectTable ObjectTable { get; init; } = null!;
[PluginService]
internal SeStringManager SeStringManager { get; init; } = null!;
[PluginService]
internal SigScanner SigScanner { get; init; } = null!;
internal GameData? GameData { get; } internal GameData? GameData { get; }
internal Configuration Config { get; } internal Configuration Config { get; }
internal XivCommonBase Common { get; } internal XivCommonBase Common { get; }
@ -23,14 +63,13 @@ namespace RoleplayersToolbox {
internal PluginUi Ui { get; } internal PluginUi Ui { get; }
private Commands Commands { get; } private Commands Commands { get; }
public Plugin(DalamudPluginInterface pluginInterface) { public Plugin() {
this.Interface = pluginInterface; this.GameData = (GameData?) this.DataManager
this.GameData = (GameData?) this.Interface.Data
.GetType() .GetType()
.GetField("gameData", BindingFlags.Instance | BindingFlags.NonPublic) .GetField("gameData", BindingFlags.Instance | BindingFlags.NonPublic)
?.GetValue(this.Interface.Data); ?.GetValue(this.DataManager);
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration(); this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
this.Common = new XivCommonBase(pluginInterface, Hooks.ContextMenu | Hooks.PartyFinderListings); this.Common = new XivCommonBase(Hooks.ContextMenu | Hooks.PartyFinderListings);
this.Tools.Add(new HousingTool(this)); this.Tools.Add(new HousingTool(this));
this.Tools.Add(new TargetingTool(this)); this.Tools.Add(new TargetingTool(this));

View File

@ -1,11 +1,11 @@
using System; using System;
using System.Numerics; using System.Numerics;
using Dalamud.Plugin; using Dalamud.Logging;
using ImGuiNET; using ImGuiNET;
namespace RoleplayersToolbox { namespace RoleplayersToolbox {
internal class PluginUi : IDisposable { internal class PluginUi : IDisposable {
internal Plugin Plugin { get; } private Plugin Plugin { get; }
private bool _showInterface; private bool _showInterface;
@ -17,16 +17,16 @@ namespace RoleplayersToolbox {
internal PluginUi(Plugin plugin) { internal PluginUi(Plugin plugin) {
this.Plugin = plugin; this.Plugin = plugin;
this.Plugin.Interface.UiBuilder.OnBuildUi += this.Draw; this.Plugin.Interface.UiBuilder.Draw += this.Draw;
this.Plugin.Interface.UiBuilder.OnOpenConfigUi += this.OpenConfig; this.Plugin.Interface.UiBuilder.OpenConfigUi += this.OpenConfig;
} }
public void Dispose() { public void Dispose() {
this.Plugin.Interface.UiBuilder.OnOpenConfigUi -= this.OpenConfig; this.Plugin.Interface.UiBuilder.OpenConfigUi -= this.OpenConfig;
this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw; this.Plugin.Interface.UiBuilder.Draw -= this.Draw;
} }
private void OpenConfig(object? sender = null, object? args = null) { private void OpenConfig() {
this.ShowInterface = true; this.ShowInterface = true;
} }

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net48</TargetFramework> <TargetFramework>net5-windows</TargetFramework>
<Version>0.3.0</Version> <Version>0.3.0</Version>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -51,10 +51,8 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DalamudPackager" Version="1.2.1"/> <PackageReference Include="DalamudPackager" Version="2.1.0" />
<PackageReference Include="F23.StringSimilarity" Version="4.1.0"/> <PackageReference Include="F23.StringSimilarity" Version="4.1.0" />
<PackageReference Include="Fody" Version="6.5.1" PrivateAssets="all"/> <PackageReference Include="XivCommon" Version="3.0.1" />
<PackageReference Include="ILMerge.Fody" Version="1.16.0" PrivateAssets="all"/>
<PackageReference Include="XivCommon" Version="2.2.0-alpha.1"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -20,11 +20,11 @@ namespace RoleplayersToolbox {
private DataManager Data { get; } private DataManager Data { get; }
internal Teleport(Plugin plugin) { internal Teleport(Plugin plugin) {
this.Data = plugin.Interface.Data; this.Data = plugin.DataManager;
plugin.Interface.TargetModuleScanner.TryGetStaticAddressFromSig(Signatures.TelepoAddress, out this._telepo); plugin.SigScanner.TryGetStaticAddressFromSig(Signatures.TelepoAddress, out this._telepo);
if (plugin.Interface.TargetModuleScanner.TryScanText(Signatures.Teleport, out var teleportPtr)) { if (plugin.SigScanner.TryScanText(Signatures.Teleport, out var teleportPtr)) {
this._teleport = Marshal.GetDelegateForFunctionPointer<TeleportDelegate>(teleportPtr); this._teleport = Marshal.GetDelegateForFunctionPointer<TeleportDelegate>(teleportPtr);
} }
} }
@ -34,7 +34,7 @@ namespace RoleplayersToolbox {
return; return;
} }
var aetheryte = this.Data.GetExcelSheet<Aetheryte>().FirstOrDefault(aeth => aeth.IsAetheryte && aeth.Territory.Row == area.CityStateTerritoryType()); var aetheryte = this.Data.GetExcelSheet<Aetheryte>()!.FirstOrDefault(aeth => aeth.IsAetheryte && aeth.Territory.Row == area.CityStateTerritoryType());
if (aetheryte == null) { if (aetheryte == null) {
return; return;
} }

View File

@ -53,7 +53,7 @@ namespace RoleplayersToolbox.Tools.Housing {
var hash = bookmark.GetHashCode().ToString(); var hash = bookmark.GetHashCode().ToString();
if (ImGui.TreeNode($"{bookmark.Name}##{hash}")) { if (ImGui.TreeNode($"{bookmark.Name}##{hash}")) {
var worldName = this.Plugin.Interface.Data.GetExcelSheet<World>().GetRow(bookmark.WorldId)?.Name; var worldName = this.Plugin.DataManager.GetExcelSheet<World>()!.GetRow(bookmark.WorldId)?.Name;
ImGui.TextUnformatted($"{worldName}/{bookmark.Area.Name()}/W{bookmark.Ward}/P{bookmark.Plot}"); ImGui.TextUnformatted($"{worldName}/{bookmark.Area.Name()}/W{bookmark.Ward}/P{bookmark.Plot}");
if (Util.IconButton(FontAwesomeIcon.MapMarkerAlt, hash)) { if (Util.IconButton(FontAwesomeIcon.MapMarkerAlt, hash)) {
@ -67,7 +67,7 @@ namespace RoleplayersToolbox.Tools.Housing {
if (Util.IconButton(FontAwesomeIcon.Route, hash)) { if (Util.IconButton(FontAwesomeIcon.Route, hash)) {
this.Tool.Destination = new DestinationInfo( this.Tool.Destination = new DestinationInfo(
this.Tool.Info, this.Tool.Info,
this.Plugin.Interface.Data.GetExcelSheet<World>().GetRow(bookmark.WorldId), this.Plugin.DataManager.GetExcelSheet<World>()!.GetRow(bookmark.WorldId),
bookmark.Area, bookmark.Area,
bookmark.Ward, bookmark.Ward,
bookmark.Plot bookmark.Plot
@ -153,11 +153,11 @@ namespace RoleplayersToolbox.Tools.Housing {
var world = bookmark.WorldId == 0 var world = bookmark.WorldId == 0
? null ? null
: this.Plugin.Interface.Data.GetExcelSheet<World>().GetRow(bookmark.WorldId); : this.Plugin.DataManager.GetExcelSheet<World>()!.GetRow(bookmark.WorldId);
if (ImGui.BeginCombo("World", world?.Name?.ToString() ?? string.Empty)) { if (ImGui.BeginCombo("World", world?.Name?.ToString() ?? string.Empty)) {
var dataCentre = this.Plugin.Interface.ClientState.LocalPlayer?.HomeWorld?.GameData?.DataCenter?.Row; var dataCentre = this.Plugin.ClientState.LocalPlayer?.HomeWorld?.GameData?.DataCenter?.Row;
foreach (var availWorld in this.Plugin.Interface.Data.GetExcelSheet<World>()) { foreach (var availWorld in this.Plugin.DataManager.GetExcelSheet<World>()!) {
if (availWorld.DataCenter.Row != dataCentre || !availWorld.IsPublic) { if (availWorld.DataCenter.Row != dataCentre || !availWorld.IsPublic) {
continue; continue;
} }

View File

@ -28,7 +28,7 @@ namespace RoleplayersToolbox.Tools.Housing {
}; };
public static TerritoryType CityState(this HousingArea area, DataManager data) { public static TerritoryType CityState(this HousingArea area, DataManager data) {
return data.GetExcelSheet<TerritoryType>().GetRow(area.CityStateTerritoryType()); return data.GetExcelSheet<TerritoryType>()!.GetRow(area.CityStateTerritoryType())!;
} }
public static bool CanWorldTravel(this HousingArea area) { public static bool CanWorldTravel(this HousingArea area) {

View File

@ -27,7 +27,7 @@ namespace RoleplayersToolbox.Tools.Housing {
internal HousingAethernet? GetClosest(HousingArea area, uint plot) { internal HousingAethernet? GetClosest(HousingArea area, uint plot) {
if (Overrides.TryGetValue(area, out var overridePlots)) { if (Overrides.TryGetValue(area, out var overridePlots)) {
if (overridePlots.TryGetValue(plot, out var overrideId)) { if (overridePlots.TryGetValue(plot, out var overrideId)) {
var overrideAethernet = this.Data.GetExcelSheet<HousingAethernet>().GetRow(overrideId); var overrideAethernet = this.Data.GetExcelSheet<HousingAethernet>()!.GetRow(overrideId);
if (overrideAethernet != null) { if (overrideAethernet != null) {
return overrideAethernet; return overrideAethernet;
} }

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Dalamud.Data; using Dalamud.Data;
using Dalamud.Plugin; using Dalamud.Logging;
using Lumina; using Lumina;
using Lumina.Data.Files; using Lumina.Data.Files;
using Lumina.Data.Parsing.Layer; using Lumina.Data.Parsing.Layer;
@ -15,14 +15,14 @@ namespace RoleplayersToolbox.Tools.Housing {
internal HousingDistances Distances { get; } internal HousingDistances Distances { get; }
internal HousingInfo(Plugin plugin) { internal HousingInfo(Plugin plugin) {
this.Data = plugin.Interface.Data; this.Data = plugin.DataManager;
this.GameData = plugin.GameData; this.GameData = plugin.GameData;
this.Distances = this.PrecalculateClosest(); this.Distances = this.PrecalculateClosest();
} }
private HousingAethernet? CalculateClosest(HousingArea area, uint plot) { private HousingAethernet? CalculateClosest(HousingArea area, uint plot) {
// subtract 1 from the subrow because Lumina is zero-indexed even though the sheet isn't // subtract 1 from the subrow because Lumina is zero-indexed even though the sheet isn't
var info = this.Data.GetExcelSheet<HousingMapMarkerInfo>().GetRow((uint) area, plot - 1); var info = this.Data.GetExcelSheet<HousingMapMarkerInfo>()!.GetRow((uint) area, plot - 1);
if (info == null) { if (info == null) {
return null; return null;
} }
@ -30,7 +30,7 @@ namespace RoleplayersToolbox.Tools.Housing {
var (x, y, z) = (info.X, info.Y, info.Z); var (x, y, z) = (info.X, info.Y, info.Z);
(HousingAethernet aethernet, double distance)? shortest = null; (HousingAethernet aethernet, double distance)? shortest = null;
foreach (var aethernet in this.Data.GetExcelSheet<HousingAethernet>()) { foreach (var aethernet in this.Data.GetExcelSheet<HousingAethernet>()!) {
if (aethernet.TerritoryType.Row != (uint) area) { if (aethernet.TerritoryType.Row != (uint) area) {
continue; continue;
} }
@ -79,7 +79,7 @@ namespace RoleplayersToolbox.Tools.Housing {
return new HousingDistances(this.Data, allClosest); return new HousingDistances(this.Data, allClosest);
} }
internal LgbFile? GetLgbFromPath(string path) { private LgbFile? GetLgbFromPath(string path) {
if (this.GameData == null) { if (this.GameData == null) {
return null; return null;
} }
@ -92,18 +92,18 @@ namespace RoleplayersToolbox.Tools.Housing {
} }
} }
internal LgbFile? GetLgbFromArea(HousingArea area) { private LgbFile? GetLgbFromArea(HousingArea area) {
var territory = this.Data.GetExcelSheet<TerritoryType>().GetRow((uint) area); var territory = this.Data.GetExcelSheet<TerritoryType>()!.GetRow((uint) area);
if (territory == null) { if (territory == null) {
return null; return null;
} }
var path = territory.Bg.ToString(); var path = territory.Bg.ToString();
path = path.Substring(0, path.LastIndexOf('/')); path = path[..path.LastIndexOf('/')];
return this.GetLgbFromPath($"bg/{path}/planmap.lgb"); return this.GetLgbFromPath($"bg/{path}/planmap.lgb");
} }
internal void LoadObjectsFromFile(LgbFile lgb) { private void LoadObjectsFromFile(LgbFile lgb) {
foreach (var layer in lgb.Layers) { foreach (var layer in lgb.Layers) {
foreach (var obj in layer.InstanceObjects) { foreach (var obj in layer.InstanceObjects) {
this.LgbObjects[obj.InstanceId] = obj; this.LgbObjects[obj.InstanceId] = obj;
@ -120,7 +120,7 @@ namespace RoleplayersToolbox.Tools.Housing {
this.LoadObjectsFromFile(lgb); this.LoadObjectsFromFile(lgb);
} }
internal void LoadObjectsFromArea(HousingArea area) { private void LoadObjectsFromArea(HousingArea area) {
var lgb = this.GetLgbFromArea(area); var lgb = this.GetLgbFromArea(area);
if (lgb == null) { if (lgb == null) {
return; return;

View File

@ -2,8 +2,8 @@
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Dalamud.Game;
using Dalamud.Game.Command; using Dalamud.Game.Command;
using Dalamud.Game.Internal;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Game.Text.SeStringHandling.Payloads;
using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI;
@ -73,26 +73,26 @@ namespace RoleplayersToolbox.Tools.Housing {
this.BookmarksUi = new BookmarksUi(plugin, this, this.Config); this.BookmarksUi = new BookmarksUi(plugin, this, this.Config);
this.Teleport = new Teleport(plugin); this.Teleport = new Teleport(plugin);
if (this.Plugin.Interface.TargetModuleScanner.TryScanText(Signatures.AddonMapHide, out var addonMapHidePtr)) { if (this.Plugin.SigScanner.TryScanText(Signatures.AddonMapHide, out var addonMapHidePtr)) {
this._addonMapHide = Marshal.GetDelegateForFunctionPointer<AddonMapHideDelegate>(addonMapHidePtr); this._addonMapHide = Marshal.GetDelegateForFunctionPointer<AddonMapHideDelegate>(addonMapHidePtr);
} }
this.Plugin.Interface.TargetModuleScanner.TryGetStaticAddressFromSig(Signatures.HousingPointer, out this._housingPointer); this.Plugin.SigScanner.TryGetStaticAddressFromSig(Signatures.HousingPointer, out this._housingPointer);
this.Plugin.Common.Functions.ContextMenu.OpenContextMenu += this.OnContextMenu; this.Plugin.Common.Functions.ContextMenu.OpenContextMenu += this.OnContextMenu;
this.Plugin.Interface.Framework.OnUpdateEvent += this.OnFramework; this.Plugin.Framework.Update += this.OnFramework;
this.Plugin.Interface.CommandManager.AddHandler("/route", new CommandInfo(this.OnRouteCommand) { this.Plugin.CommandManager.AddHandler("/route", new CommandInfo(this.OnRouteCommand) {
HelpMessage = "Extract housing information from the given text and open the routing window", HelpMessage = "Extract housing information from the given text and open the routing window",
}); });
this.Plugin.Interface.CommandManager.AddHandler("/bookmarks", new CommandInfo(this.OnBookmarksCommand) { this.Plugin.CommandManager.AddHandler("/bookmarks", new CommandInfo(this.OnBookmarksCommand) {
HelpMessage = "Toggles the housing bookmarks window", HelpMessage = "Toggles the housing bookmarks window",
}); });
} }
public void Dispose() { public void Dispose() {
this.Plugin.Interface.CommandManager.RemoveHandler("/bookmarks"); this.Plugin.CommandManager.RemoveHandler("/bookmarks");
this.Plugin.Interface.CommandManager.RemoveHandler("/route"); this.Plugin.CommandManager.RemoveHandler("/route");
this.Plugin.Interface.Framework.OnUpdateEvent -= this.OnFramework; this.Plugin.Framework.Update -= this.OnFramework;
this.Plugin.Common.Functions.ContextMenu.OpenContextMenu -= this.OnContextMenu; this.Plugin.Common.Functions.ContextMenu.OpenContextMenu -= this.OnContextMenu;
} }
@ -137,9 +137,9 @@ namespace RoleplayersToolbox.Tools.Housing {
var world = this.Destination.World; var world = this.Destination.World;
if (ImGui.BeginCombo("World", world?.Name?.ToString() ?? string.Empty)) { if (ImGui.BeginCombo("World", world?.Name?.ToString() ?? string.Empty)) {
var dataCentre = this.Plugin.Interface.ClientState.LocalPlayer?.HomeWorld?.GameData?.DataCenter?.Row; var dataCentre = this.Plugin.ClientState.LocalPlayer?.HomeWorld?.GameData?.DataCenter?.Row;
foreach (var availWorld in this.Plugin.Interface.Data.GetExcelSheet<World>()) { foreach (var availWorld in this.Plugin.DataManager.GetExcelSheet<World>()!) {
if (availWorld.DataCenter.Row != dataCentre || !availWorld.IsPublic) { if (availWorld.DataCenter.Row != dataCentre || !availWorld.IsPublic) {
continue; continue;
} }
@ -189,11 +189,11 @@ namespace RoleplayersToolbox.Tools.Housing {
ImGui.SameLine(); ImGui.SameLine();
var destArea = this.Destination.Area.Value; var destArea = this.Destination.Area.Value;
if (!destArea.CanWorldTravel() && this.Destination?.World != null && this.Destination?.World != this.Plugin.Interface.ClientState.LocalPlayer?.CurrentWorld?.GameData) { if (!destArea.CanWorldTravel() && this.Destination?.World != null && this.Destination?.World != this.Plugin.ClientState.LocalPlayer?.CurrentWorld?.GameData) {
destArea = HousingArea.Mist; destArea = HousingArea.Mist;
} }
var name = destArea.CityState(this.Plugin.Interface.Data).PlaceName.Value.Name; var name = destArea.CityState(this.Plugin.DataManager).PlaceName.Value!.Name;
if (ImGui.Button($"Teleport to {name}")) { if (ImGui.Button($"Teleport to {name}")) {
this.Teleport.TeleportToHousingArea(destArea); this.Teleport.TeleportToHousingArea(destArea);
} }
@ -207,12 +207,12 @@ namespace RoleplayersToolbox.Tools.Housing {
} }
private void OnRouteCommand(string command, string arguments) { private void OnRouteCommand(string command, string arguments) {
var player = this.Plugin.Interface.ClientState.LocalPlayer; var player = this.Plugin.ClientState.LocalPlayer;
if (player == null) { if (player == null) {
return; return;
} }
this.Destination = InfoExtractor.Extract(arguments, player.HomeWorld.GameData.DataCenter.Row, this.Plugin.Interface.Data, this.Info); this.Destination = InfoExtractor.Extract(arguments, player.HomeWorld.GameData.DataCenter.Row, this.Plugin.DataManager, this.Info);
} }
private void OnBookmarksCommand(string command, string arguments) { private void OnBookmarksCommand(string command, string arguments) {
@ -237,7 +237,7 @@ namespace RoleplayersToolbox.Tools.Housing {
} }
this.ClearFlag(); this.ClearFlag();
this.Destination = InfoExtractor.Extract(listing.Description.TextValue, listing.World.Value.DataCenter.Row, this.Plugin.Interface.Data, this.Info); this.Destination = InfoExtractor.Extract(listing.Description.TextValue, listing.World.Value.DataCenter.Row, this.Plugin.DataManager, this.Info);
} }
private void AddBookmark(ContextMenuItemSelectedArgs args) { private void AddBookmark(ContextMenuItemSelectedArgs args) {
@ -246,7 +246,7 @@ namespace RoleplayersToolbox.Tools.Housing {
return; return;
} }
var dest = InfoExtractor.Extract(listing.Description.TextValue, listing.World.Value.DataCenter.Row, this.Plugin.Interface.Data, this.Info); var dest = InfoExtractor.Extract(listing.Description.TextValue, listing.World.Value.DataCenter.Row, this.Plugin.DataManager, this.Info);
this.BookmarksUi.Editing = (new Bookmark(string.Empty) { this.BookmarksUi.Editing = (new Bookmark(string.Empty) {
WorldId = dest.World?.RowId ?? 0, WorldId = dest.World?.RowId ?? 0,
Area = dest.Area ?? 0, Area = dest.Area ?? 0,
@ -269,12 +269,12 @@ namespace RoleplayersToolbox.Tools.Housing {
return; return;
} }
var info = this.Plugin.Interface.Data.GetExcelSheet<HousingMapMarkerInfo>().GetRow((uint) destination.Area!.Value, (uint) destination.Plot! - 1); var info = this.Plugin.DataManager.GetExcelSheet<HousingMapMarkerInfo>()!.GetRow((uint) destination.Area!.Value, (uint) destination.Plot! - 1);
if (info == null) { if (info == null) {
return; return;
} }
var player = this.Plugin.Interface.ClientState.LocalPlayer; var player = this.Plugin.ClientState.LocalPlayer;
if (player == null) { if (player == null) {
return; return;
} }
@ -285,7 +285,7 @@ namespace RoleplayersToolbox.Tools.Housing {
} }
// ensure in correct zone // ensure in correct zone
if (this.Plugin.Interface.ClientState.TerritoryType != (ushort) destination.Area) { if (this.Plugin.ClientState.TerritoryType != (ushort) destination.Area) {
return; return;
} }
@ -326,9 +326,9 @@ namespace RoleplayersToolbox.Tools.Housing {
} }
private void CloseMap() { private void CloseMap() {
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName("AreaMap", 1); var addon = this.Plugin.GameGui.GetAddonByName("AreaMap", 1);
if (addon != null) { if (addon != IntPtr.Zero) {
this._addonMapHide?.Invoke(addon.Address); this._addonMapHide?.Invoke(addon);
} }
} }
@ -341,7 +341,7 @@ namespace RoleplayersToolbox.Tools.Housing {
} }
internal void FlagHouseOnMap(HousingArea area, uint plot) { internal void FlagHouseOnMap(HousingArea area, uint plot) {
var info = this.Plugin.Interface.Data.GetExcelSheet<HousingMapMarkerInfo>().GetRow((uint) area, plot - 1); var info = this.Plugin.DataManager.GetExcelSheet<HousingMapMarkerInfo>()!.GetRow((uint) area, plot - 1);
if (info == null) { if (info == null) {
return; return;
} }
@ -354,25 +354,24 @@ namespace RoleplayersToolbox.Tools.Housing {
} }
var mapLink = new MapLinkPayload( var mapLink = new MapLinkPayload(
this.Plugin.Interface.Data,
terr.RowId, terr.RowId,
map!.RowId, map!.RowId,
(int) (info.X * 1_000f), (int) (info.X * 1_000f),
(int) (info.Z * 1_000f) (int) (info.Z * 1_000f)
); );
this.Plugin.Interface.Framework.Gui.OpenMapWithMapLink(mapLink); this.Plugin.GameGui.OpenMapWithMapLink(mapLink);
} }
private unsafe void HighlightResidentialTeleport() { private unsafe void HighlightResidentialTeleport() {
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName("HousingSelectBlock", 1); var addon = this.Plugin.GameGui.GetAddonByName("HousingSelectBlock", 1);
if (addon == null) { if (addon == IntPtr.Zero) {
return; return;
} }
var shouldSet = false; var shouldSet = false;
var player = this.Plugin.Interface.ClientState.LocalPlayer; var player = this.Plugin.ClientState.LocalPlayer;
if (player != null && this.Destination?.World != null) { if (player != null && this.Destination?.World != null) {
shouldSet = player.CurrentWorld.GameData == this.Destination.World; shouldSet = player.CurrentWorld.GameData == this.Destination.World;
} }
@ -380,11 +379,11 @@ namespace RoleplayersToolbox.Tools.Housing {
if (this.Destination?.Area == null) { if (this.Destination?.Area == null) {
shouldSet = false; shouldSet = false;
} else { } else {
var currentArea = this.Plugin.Interface.ClientState.TerritoryType; var currentArea = this.Plugin.ClientState.TerritoryType;
shouldSet = shouldSet && (currentArea == (ushort) this.Destination.Area || currentArea == this.Destination.Area.Value.CityStateTerritoryType()); shouldSet = shouldSet && (currentArea == (ushort) this.Destination.Area || currentArea == this.Destination.Area.Value.CityStateTerritoryType());
} }
var unit = (AtkUnitBase*) addon.Address; var unit = (AtkUnitBase*) addon;
var uld = unit->UldManager; var uld = unit->UldManager;
if (uld.NodeListCount < 1) { if (uld.NodeListCount < 1) {
return; return;
@ -411,18 +410,18 @@ namespace RoleplayersToolbox.Tools.Housing {
} }
var textNode = (AtkTextNode*) radioUld.NodeList[3]; var textNode = (AtkTextNode*) radioUld.NodeList[3];
var text = Util.ReadSeString((IntPtr) textNode->NodeText.StringPtr, this.Plugin.Interface.SeStringManager); var text = Util.ReadSeString((IntPtr) textNode->NodeText.StringPtr, this.Plugin.SeStringManager);
HighlightIf(radioButton, shouldSet && text.TextValue == $"{this.Destination?.Ward}"); HighlightIf(radioButton, shouldSet && text.TextValue == $"{this.Destination?.Ward}");
} while ((radioButton = radioButton->PrevSiblingNode) != null); } while ((radioButton = radioButton->PrevSiblingNode) != null);
} }
private unsafe void HighlightSelectString() { private unsafe void HighlightSelectString() {
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName("SelectString", 1); var addon = this.Plugin.GameGui.GetAddonByName("SelectString", 1);
if (addon == null) { if (addon == IntPtr.Zero) {
return; return;
} }
var select = (AddonSelectString*) addon.Address; var select = (AddonSelectString*) addon;
var list = select->PopupMenu.List; var list = select->PopupMenu.List;
if (list == null) { if (list == null) {
return; return;
@ -434,7 +433,7 @@ namespace RoleplayersToolbox.Tools.Housing {
private bool ShouldHighlight(SeString str) { private bool ShouldHighlight(SeString str) {
var text = str.TextValue; var text = str.TextValue;
var sameWorld = this.Destination?.World == this.Plugin.Interface.ClientState.LocalPlayer?.CurrentWorld?.GameData; var sameWorld = this.Destination?.World == this.Plugin.ClientState.LocalPlayer?.CurrentWorld?.GameData;
if (!sameWorld && this.Destination?.World != null) { if (!sameWorld && this.Destination?.World != null) {
return text == " Visit Another World Server."; return text == " Visit Another World Server.";
} }
@ -446,7 +445,7 @@ namespace RoleplayersToolbox.Tools.Housing {
} }
// ReSharper disable once InvertIf // ReSharper disable once InvertIf
if (this.Destination?.Ward != null && this.Plugin.Interface.ClientState.TerritoryType == this.Destination?.Area?.CityStateTerritoryType()) { if (this.Destination?.Ward != null && this.Plugin.ClientState.TerritoryType == this.Destination?.Area?.CityStateTerritoryType()) {
switch (text) { switch (text) {
case " Residential District Aethernet.": case " Residential District Aethernet.":
case "Go to specified ward. (Review Tabs)": case "Go to specified ward. (Review Tabs)":
@ -461,7 +460,7 @@ namespace RoleplayersToolbox.Tools.Housing {
for (var i = 0; i < list->ListLength; i++) { for (var i = 0; i < list->ListLength; i++) {
var item = list->ItemRendererList + i; var item = list->ItemRendererList + i;
var button = item->AtkComponentListItemRenderer->AtkComponentButton; var button = item->AtkComponentListItemRenderer->AtkComponentButton;
var buttonText = Util.ReadSeString((IntPtr) button.ButtonTextNode->NodeText.StringPtr, this.Plugin.Interface.SeStringManager); var buttonText = Util.ReadSeString((IntPtr) button.ButtonTextNode->NodeText.StringPtr, this.Plugin.SeStringManager);
var component = (AtkComponentBase*) item->AtkComponentListItemRenderer; var component = (AtkComponentBase*) item->AtkComponentListItemRenderer;
@ -470,19 +469,19 @@ namespace RoleplayersToolbox.Tools.Housing {
} }
private unsafe void HighlightWorldTravel() { private unsafe void HighlightWorldTravel() {
var player = this.Plugin.Interface.ClientState.LocalPlayer; var player = this.Plugin.ClientState.LocalPlayer;
if (player == null) { if (player == null) {
return; return;
} }
var world = this.Destination?.World; var world = this.Destination?.World;
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName("WorldTravelSelect", 1); var addon = this.Plugin.GameGui.GetAddonByName("WorldTravelSelect", 1);
if (addon == null) { if (addon == IntPtr.Zero) {
return; return;
} }
var unit = (AtkUnitBase*) addon.Address; var unit = (AtkUnitBase*) addon;
var root = unit->RootNode; var root = unit->RootNode;
if (root == null) { if (root == null) {
return; return;
@ -507,7 +506,7 @@ namespace RoleplayersToolbox.Tools.Housing {
var comp = (AtkComponentNode*) prev; var comp = (AtkComponentNode*) prev;
var res = comp->Component->UldManager.RootNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode; var res = comp->Component->UldManager.RootNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode;
var text = (AtkTextNode*) res->ChildNode; var text = (AtkTextNode*) res->ChildNode;
var str = Util.ReadSeString((IntPtr) text->NodeText.StringPtr, this.Plugin.Interface.SeStringManager); var str = Util.ReadSeString((IntPtr) text->NodeText.StringPtr, this.Plugin.SeStringManager);
HighlightIf(&text->AtkResNode, str.TextValue == world?.Name?.ToString()); HighlightIf(&text->AtkResNode, str.TextValue == world?.Name?.ToString());
} while ((prev = prev->PrevSiblingNode) != null); } while ((prev = prev->PrevSiblingNode) != null);
} }

View File

@ -47,7 +47,7 @@ namespace RoleplayersToolbox.Tools.Housing {
private static World? FindWorld(string source, uint dataCentre, DataManager data) { private static World? FindWorld(string source, uint dataCentre, DataManager data) {
var words = NonWord.Split(source).Where(word => word.ToLowerInvariant() != "gg").ToArray(); var words = NonWord.Split(source).Where(word => word.ToLowerInvariant() != "gg").ToArray();
var mostSimilar = data.Excel.GetSheet<World>() var mostSimilar = data.Excel.GetSheet<World>()!
.Where(world => world.DataCenter.Row == dataCentre) .Where(world => world.DataCenter.Row == dataCentre)
.SelectMany(world => { .SelectMany(world => {
var name = world.Name.ToString().ToLowerInvariant(); var name = world.Name.ToString().ToLowerInvariant();

View File

@ -32,26 +32,26 @@ namespace RoleplayersToolbox.Tools.Illegal.Emote {
internal EmoteTool(Plugin plugin) { internal EmoteTool(Plugin plugin) {
this.Plugin = plugin; this.Plugin = plugin;
this.Plugin.Interface.CommandManager.AddHandler("/emoteid", new CommandInfo(this.EmoteIdCommand) { this.Plugin.CommandManager.AddHandler("/emoteid", new CommandInfo(this.EmoteIdCommand) {
HelpMessage = "Run the emote with the given ID if it is unlocked", HelpMessage = "Run the emote with the given ID if it is unlocked",
}); });
if (this.Plugin.Interface.TargetModuleScanner.TryScanText(Signatures.SetActionOnHotbar, out var setPtr)) { if (this.Plugin.SigScanner.TryScanText(Signatures.SetActionOnHotbar, out var setPtr)) {
this.SetActionOnHotbarHook = new Hook<SetActionOnHotbarDelegate>(setPtr, new SetActionOnHotbarDelegate(this.SetActionOnHotbarDetour)); this.SetActionOnHotbarHook = new Hook<SetActionOnHotbarDelegate>(setPtr, this.SetActionOnHotbarDetour);
this.SetActionOnHotbarHook.Enable(); this.SetActionOnHotbarHook.Enable();
} }
if (this.Plugin.Interface.TargetModuleScanner.TryScanText(Signatures.RunEmote, out var runEmotePtr)) { if (this.Plugin.SigScanner.TryScanText(Signatures.RunEmote, out var runEmotePtr)) {
this.RunEmoteFunction = Marshal.GetDelegateForFunctionPointer<RunEmoteDelegate>(runEmotePtr); this.RunEmoteFunction = Marshal.GetDelegateForFunctionPointer<RunEmoteDelegate>(runEmotePtr);
} }
this.Plugin.Interface.TargetModuleScanner.TryGetStaticAddressFromSig(Signatures.RunEmoteFirstArg, out this._runEmoteFirstArg); this.Plugin.SigScanner.TryGetStaticAddressFromSig(Signatures.RunEmoteFirstArg, out this._runEmoteFirstArg);
this.Plugin.Interface.TargetModuleScanner.TryGetStaticAddressFromSig(Signatures.RunEmoteThirdArg, out this._runEmoteThirdArg); this.Plugin.SigScanner.TryGetStaticAddressFromSig(Signatures.RunEmoteThirdArg, out this._runEmoteThirdArg);
} }
public void Dispose() { public void Dispose() {
this.SetActionOnHotbarHook?.Dispose(); this.SetActionOnHotbarHook?.Dispose();
this.Plugin.Interface.CommandManager.RemoveHandler("/emoteid"); this.Plugin.CommandManager.RemoveHandler("/emoteid");
} }
public override void DrawSettings(ref bool anyChanged) { public override void DrawSettings(ref bool anyChanged) {

View File

@ -23,18 +23,18 @@ namespace RoleplayersToolbox.Tools.Illegal.EmoteSnap {
this.Plugin = plugin; this.Plugin = plugin;
this.Config = this.Plugin.Config.Tools.EmoteSnap; this.Config = this.Plugin.Config.Tools.EmoteSnap;
if (this.Plugin.Interface.TargetModuleScanner.TryScanText(Signatures.ShouldSnap, out var snapPtr)) { if (this.Plugin.SigScanner.TryScanText(Signatures.ShouldSnap, out var snapPtr)) {
this.ShouldSnapHook = new Hook<ShouldSnapDelegate>(snapPtr, new ShouldSnapDelegate(this.ShouldSnapDetour)); this.ShouldSnapHook = new Hook<ShouldSnapDelegate>(snapPtr, this.ShouldSnapDetour);
this.ShouldSnapHook.Enable(); this.ShouldSnapHook.Enable();
} }
this.Plugin.Interface.CommandManager.AddHandler("/dozesnap", new CommandInfo(this.OnCommand) { this.Plugin.CommandManager.AddHandler("/dozesnap", new CommandInfo(this.OnCommand) {
HelpMessage = "Toggle snapping for the /doze emote", HelpMessage = "Toggle snapping for the /doze emote",
}); });
} }
public void Dispose() { public void Dispose() {
this.Plugin.Interface.CommandManager.RemoveHandler("/dozesnap"); this.Plugin.CommandManager.RemoveHandler("/dozesnap");
this.ShouldSnapHook?.Dispose(); this.ShouldSnapHook?.Dispose();
} }
@ -55,7 +55,7 @@ namespace RoleplayersToolbox.Tools.Illegal.EmoteSnap {
this.Config.DisableDozeSnap ^= true; this.Config.DisableDozeSnap ^= true;
var status = this.Config.DisableDozeSnap ? "off" : "on"; var status = this.Config.DisableDozeSnap ? "off" : "on";
this.Plugin.Interface.Framework.Gui.Chat.Print($"/doze snap toggled {status}."); this.Plugin.ChatGui.Print($"/doze snap toggled {status}.");
} }
} }
} }

View File

@ -1,7 +1,5 @@
using System; using System;
using System.Runtime.InteropServices; using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Actors;
using Dalamud.Game.ClientState.Structs;
using Dalamud.Hooking; using Dalamud.Hooking;
using ImGuiNET; using ImGuiNET;
@ -24,17 +22,17 @@ namespace RoleplayersToolbox.Tools.Targeting {
this.Plugin = plugin; this.Plugin = plugin;
this.Config = this.Plugin.Config.Tools.Targeting; this.Config = this.Plugin.Config.Tools.Targeting;
if (this.Plugin.Interface.TargetModuleScanner.TryScanText(Signatures.LeftClickTarget, out var leftClickPtr)) { if (this.Plugin.SigScanner.TryScanText(Signatures.LeftClickTarget, out var leftClickPtr)) {
unsafe { unsafe {
this.LeftClickHook = new Hook<ClickTargetDelegate>(leftClickPtr, new ClickTargetDelegate(this.LeftClickDetour)); this.LeftClickHook = new Hook<ClickTargetDelegate>(leftClickPtr, this.LeftClickDetour);
} }
this.LeftClickHook.Enable(); this.LeftClickHook.Enable();
} }
if (this.Plugin.Interface.TargetModuleScanner.TryScanText(Signatures.RightClickTarget, out var rightClickPtr)) { if (this.Plugin.SigScanner.TryScanText(Signatures.RightClickTarget, out var rightClickPtr)) {
unsafe { unsafe {
this.RightClickHook = new Hook<ClickTargetDelegate>(rightClickPtr, new ClickTargetDelegate(this.RightClickDetour)); this.RightClickHook = new Hook<ClickTargetDelegate>(rightClickPtr, this.RightClickDetour);
} }
this.RightClickHook.Enable(); this.RightClickHook.Enable();
@ -64,9 +62,9 @@ namespace RoleplayersToolbox.Tools.Targeting {
} }
if (this.Config.LeftClickExamine) { if (this.Config.LeftClickExamine) {
var actorStruct = Marshal.PtrToStructure<Actor>((IntPtr) clickedOn); var obj = this.Plugin.ObjectTable.CreateObjectReference((IntPtr) clickedOn);
if (actorStruct.ObjectKind == ObjectKind.Player) { if (obj != null && obj.ObjectKind == ObjectKind.Player) {
this.Plugin.Common.Functions.Examine.OpenExamineWindow(actorStruct.ActorId); this.Plugin.Common.Functions.Examine.OpenExamineWindow(obj.ObjectId);
// tell game current target was left-clicked // tell game current target was left-clicked
return this.LeftClickHook!.Original(a1, target, a3); return this.LeftClickHook!.Original(a1, target, a3);
} }
@ -93,9 +91,9 @@ namespace RoleplayersToolbox.Tools.Targeting {
goto Original; goto Original;
} }
var actorStruct = Marshal.PtrToStructure<Actor>((IntPtr) clickedOn); var obj = this.Plugin.ObjectTable.CreateObjectReference((IntPtr) clickedOn);
if (actorStruct.ObjectKind == ObjectKind.Player) { if (obj != null && obj.ObjectKind == ObjectKind.Player) {
this.Plugin.Common.Functions.Examine.OpenExamineWindow(actorStruct.ActorId); this.Plugin.Common.Functions.Examine.OpenExamineWindow(obj.ObjectId);
// tell game nothing was right-clicked // tell game nothing was right-clicked
return this.RightClickHook!.Original(a1, null, a3); return this.RightClickHook!.Original(a1, null, a3);
} }