Skip to content

Commit

Permalink
7.0 Update [PUSH]
Browse files Browse the repository at this point in the history
  • Loading branch information
InitialDet committed Jul 13, 2024
1 parent d8c526c commit cc45dbc
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 33 deletions.
35 changes: 21 additions & 14 deletions TargetFurniture/ContextMenuHousing.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
using System;
using System.Threading.Tasks;
using Dalamud.ContextMenu;
using Dalamud.Game.Gui.ContextMenu;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;

namespace TargetFurniture;

public unsafe class ContextMenuHousing : IDisposable
{
private DalamudContextMenu _contextMenu = null!;

private GameObjectContextMenuItem? _contextMenuItem;
private MenuItem _menuItemAddConductor;

public void Dispose()
{
_contextMenu.OnOpenGameObjectContextMenu -= OnOpenContextMenu;
_contextMenu.Dispose();
Service.ContextMenu.OnMenuOpened -= OnOpenContextMenu;
}

public void Toggle()
{
_contextMenu = new DalamudContextMenu(Service.PluginInterface);
_contextMenuItem =
new GameObjectContextMenuItem(new SeString(new TextPayload("Target Item")), SetFurnitureActive);
_contextMenu.OnOpenGameObjectContextMenu += OnOpenContextMenu;
_menuItemAddConductor = new MenuItem()
{
Name = new SeString(new TextPayload("Target Item")),
PrefixChar = 'T',
OnClicked = SetFurnitureActive,
};
Service.ContextMenu.OnMenuOpened += OnOpenContextMenu;
}

private void OnOpenContextMenu(GameObjectContextMenuOpenArgs args)
private void OnOpenContextMenu(IMenuOpenedArgs args)
{
if (args.ParentAddonName is "HousingGoods" &&
_contextMenuItem != null) // To make sure it doesnt appear in the Stored tab
args.AddCustomItem(_contextMenuItem);
if (args.AddonName is "HousingGoods" &&
_menuItemAddConductor != null) // To make sure it doesnt appear in the Stored tab
args.AddMenuItem(_menuItemAddConductor);
}

private void SetFurnitureActive(GameObjectContextMenuItemSelectedArgs args)
private void SetFurnitureActive(IMenuItemClickedArgs args)
{
if (Service.Memory.HousingStructure->Mode == HousingLayoutMode.Rotate &&
Service.Memory.HousingStructure->State == ItemState.SoftSelect)
{
Service.PluginLog.Debug("1");
Service.Memory.SelectItem((IntPtr)Service.Memory.HousingStructure,
(IntPtr)Service.Memory.HousingStructure->ActiveItem);
}
Expand All @@ -51,13 +53,18 @@ private void SetFurnitureActive(GameObjectContextMenuItemSelectedArgs args)
}
else
{
Service.PluginLog.Debug("3");
// To make the item follow the cursor you need to retarget it, for reasons idk you need a small delay before the second target for it to work
TargetItem();
if (Service.Configuration.MoveToCursor)
AwaitingTarget.WaitingRetarget();
//PluginLog.Debug($"Finished");
}
}
else
{
Service.PluginLog.Debug("None");
}
}

public static void TargetItem()
Expand Down
4 changes: 2 additions & 2 deletions TargetFurniture/PluginMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ public PluginMemory()
// Pointers for housing structures.
_layoutWorldPtr =
Service.SigScanner.GetStaticAddressFromSig(
"48 8B 0D ?? ?? ?? ?? 48 85 C9 74 ?? 48 8B 49 40 E9 ?? ?? ?? ??");
"48 8B D1 48 8B 0D ?? ?? ?? ?? 48 85 C9 74 0A", 3);

// Read the pointers.
_layoutWorldPtr = Marshal.ReadIntPtr(_layoutWorldPtr);

// Select housing item.
var selectItemAddress =
Service.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 8B CE E8 ?? ?? ?? ?? 48 8B 6C 24 40 48 8B CE");
Service.SigScanner.ScanText("48 85 D2 0F 84 49 09 00 00 53 41 56 48 83 EC 48 48 89 6C 24 60 48 8B DA 48 89 74 24 70 4C 8B F1");
SelectItem = Marshal.GetDelegateForFunctionPointer<SelectItemDelegate>(selectItemAddress);
}
catch (Exception)
Expand Down
8 changes: 6 additions & 2 deletions TargetFurniture/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ public class Service
{
public const string PluginName = "Target Furniture";

[PluginService] public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] public static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
[PluginService] public static ISigScanner SigScanner { get; private set; } = null!;
[PluginService] public static ICommandManager Commands { get; private set; } = null!;
[PluginService] public static IContextMenu ContextMenu { get; private set; } = null!;
[PluginService] public static IPluginLog PluginLog { get; private set; } = null!;



public static PluginMemory Memory { get; set; } = null!;
public static Configuration Configuration { get; set; } = null!;
public static WindowSystem WindowSystem { get; } = new(PluginName);

public static void Initialize(DalamudPluginInterface pluginInterface)
public static void Initialize(IDalamudPluginInterface pluginInterface)
{
pluginInterface.Create<Service>();
}
Expand Down
2 changes: 1 addition & 1 deletion TargetFurniture/TargetFurniture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class TargetFurniture : IDalamudPlugin

private readonly ContextMenuHousing _pluginContextMenu;

public TargetFurniture(DalamudPluginInterface pluginInterface)
public TargetFurniture(IDalamudPluginInterface pluginInterface)
{
Service.Initialize(pluginInterface);
Service.Configuration = Configuration.Load();
Expand Down
7 changes: 3 additions & 4 deletions TargetFurniture/TargetFurniture.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>Det</Authors>
<Version>1.0.1.8</Version>
<Version>1.0.2.0</Version>
<Description>You can now select furnitures from the Housing Menu</Description>
<PackageProjectUrl>https://github.com/InitialDet/TargetForniture</PackageProjectUrl>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<Configurations>Release</Configurations>
<LangVersion>latest</LangVersion>
Expand Down Expand Up @@ -41,8 +41,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Dalamud.ContextMenu" Version="1.3.1"/>
<PackageReference Include="DalamudPackager" Version="2.1.12"/>
<PackageReference Include="DalamudPackager" Version="2.1.13"/>
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
Expand Down
14 changes: 4 additions & 10 deletions TargetFurniture/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
{
"version": 1,
"dependencies": {
"net7.0-windows7.0": {
"Dalamud.ContextMenu": {
"type": "Direct",
"requested": "[1.3.1, )",
"resolved": "1.3.1",
"contentHash": "ptAxut5PiLnzZ4G/KQdHJVcyklC/BF3otHJ7zYVUPiKBjsOCoF0n/6h2jK7e+8ev2Y1yAY3Wtx2GuXLFQgt9Uw=="
},
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.12, )",
"resolved": "2.1.12",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
"requested": "[2.1.13, )",
"resolved": "2.1.13",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
}
}
}
Expand Down

0 comments on commit cc45dbc

Please sign in to comment.