-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
279 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,74 @@ | ||
using System; | ||
using XivCommon.Functions.ContextMenu; | ||
using Dalamud.Logging; | ||
using System.Threading.Tasks; | ||
using Dalamud.ContextMenu; | ||
using Dalamud.Game.Text.SeStringHandling; | ||
using Dalamud.Game.Text.SeStringHandling.Payloads; | ||
|
||
namespace MoveFurniture { | ||
public unsafe class ContextMenuHousing : IDisposable { | ||
ContextMenu ContextMenu = null!; | ||
namespace MoveFurniture; | ||
public unsafe class ContextMenuHousing : IDisposable | ||
{ | ||
DalamudContextMenu ContextMenu = null!; | ||
|
||
AwaitingTarget waiting = new(); | ||
GameObjectContextMenuItem? contextMenuItem; | ||
AwaitingTarget waiting = new(); | ||
|
||
public void Toggle() { | ||
ContextMenu = Service.Common.Functions.ContextMenu; | ||
ContextMenu.OpenContextMenu += OnOpenContextMenu; | ||
} | ||
public void Toggle() | ||
{ | ||
ContextMenu = new DalamudContextMenu(); | ||
contextMenuItem = new GameObjectContextMenuItem(new SeString(new TextPayload("Target Item")), SetFurnitureActive, false); | ||
ContextMenu.OnOpenGameObjectContextMenu += OnOpenContextMenu; | ||
} | ||
|
||
public void Dispose() { | ||
if (ContextMenu != null) | ||
ContextMenu.OpenContextMenu -= OnOpenContextMenu; | ||
} | ||
public void Dispose() | ||
{ | ||
if (ContextMenu != null) | ||
ContextMenu.OnOpenGameObjectContextMenu -= OnOpenContextMenu; | ||
} | ||
|
||
private void OnOpenContextMenu(ContextMenuOpenArgs args) { | ||
if (args.ParentAddonName is "HousingGoods" && args.Items.Count < 3) // To make sure it doenst appear in the Stored tab | ||
args.Items.Add(new NormalContextMenuItem("Target Item", SetFurnitureActive)); | ||
} | ||
private void OnOpenContextMenu(GameObjectContextMenuOpenArgs args) | ||
{ | ||
|
||
private void SetFurnitureActive(ContextMenuItemSelectedArgs args) { | ||
if (Service.Memory.HousingStructure->Mode == HousingLayoutMode.Rotate && Service.Memory.HousingStructure->State == ItemState.SoftSelect) { | ||
Service.Memory.SelectItem((IntPtr)Service.Memory.HousingStructure, (IntPtr)Service.Memory.HousingStructure->ActiveItem); | ||
} else if (Service.Memory.HousingStructure->Mode == HousingLayoutMode.Move && Service.Memory.HousingStructure->State == ItemState.SoftSelect) { | ||
if (Service.Configuration.UseAltTarget) { | ||
Service.Memory.HousingStructure->State = ItemState.Active; | ||
Service.Memory.HousingStructure->State2 = ItemState2.Active; | ||
} else { | ||
// 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) | ||
waiting.waitingRetarget(this); | ||
PluginLog.Debug($"Finished"); | ||
} | ||
} | ||
} | ||
if (args.ParentAddonName is "HousingGoods" && contextMenuItem != null) // To make sure it doenst appear in the Stored tab | ||
args.AddCustomItem(contextMenuItem); | ||
} | ||
|
||
public void TargetItem() { | ||
private void SetFurnitureActive(GameObjectContextMenuItemSelectedArgs args) | ||
{ | ||
if (Service.Memory.HousingStructure->Mode == HousingLayoutMode.Rotate && Service.Memory.HousingStructure->State == ItemState.SoftSelect) | ||
{ | ||
Service.Memory.SelectItem((IntPtr)Service.Memory.HousingStructure, (IntPtr)Service.Memory.HousingStructure->ActiveItem); | ||
} | ||
else if (Service.Memory.HousingStructure->Mode == HousingLayoutMode.Move && Service.Memory.HousingStructure->State == ItemState.SoftSelect) | ||
{ | ||
if (Service.Configuration.UseAltTarget) | ||
{ | ||
Service.Memory.HousingStructure->State = ItemState.Active; | ||
Service.Memory.HousingStructure->State2 = ItemState2.Active; | ||
} | ||
else | ||
{ | ||
// 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) | ||
waiting.waitingRetarget(this); | ||
PluginLog.Debug($"Finished"); | ||
} | ||
} | ||
} | ||
|
||
public class AwaitingTarget { | ||
public async void waitingRetarget(ContextMenuHousing contextMenuHousing) { | ||
await Task.Delay(60); | ||
contextMenuHousing.TargetItem(); | ||
} | ||
public void TargetItem() | ||
{ | ||
Service.Memory.SelectItem((IntPtr)Service.Memory.HousingStructure, (IntPtr)Service.Memory.HousingStructure->ActiveItem); | ||
} | ||
} | ||
|
||
public class AwaitingTarget | ||
{ | ||
public async void waitingRetarget(ContextMenuHousing contextMenuHousing) | ||
{ | ||
await Task.Delay(60); | ||
contextMenuHousing.TargetItem(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.