diff --git a/Dalamud/Game/Gui/ContextMenus/ContextMenu.cs b/Dalamud/Game/Gui/ContextMenus/ContextMenu.cs
index 5c9d1223f..ca60f0632 100644
--- a/Dalamud/Game/Gui/ContextMenus/ContextMenu.cs
+++ b/Dalamud/Game/Gui/ContextMenus/ContextMenu.cs
@@ -11,7 +11,6 @@ using Dalamud.Memory;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
-using Serilog;
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
@@ -86,18 +85,6 @@ namespace Dalamud.Game.Gui.ContextMenus
private ContextMenuAddressResolver Address { get; set; }
- ///
- /// Enable this subsystem.
- ///
- public void Enable()
- {
- this.contextMenuOpeningHook.Enable();
- this.contextMenuOpenedHook.Enable();
- this.contextMenuItemSelectedHook.Enable();
- this.subContextMenuOpeningHook.Enable();
- this.subContextMenuOpenedHook.Enable();
- }
-
///
void IDisposable.Dispose()
{
@@ -108,6 +95,18 @@ namespace Dalamud.Game.Gui.ContextMenus
this.contextMenuOpeningHook.Disable();
}
+ ///
+ /// Enable this subsystem.
+ ///
+ internal void Enable()
+ {
+ this.contextMenuOpeningHook.Enable();
+ this.contextMenuOpenedHook.Enable();
+ this.contextMenuItemSelectedHook.Enable();
+ this.subContextMenuOpeningHook.Enable();
+ this.subContextMenuOpenedHook.Enable();
+ }
+
private static unsafe bool IsInventoryContext(AgentContextInterface* agentContextInterface)
{
return agentContextInterface == AgentInventoryContext.Instance();
@@ -129,8 +128,6 @@ namespace Dalamud.Game.Gui.ContextMenus
private unsafe bool ContextMenuOpenedDetour(AddonContextMenu* addonContextMenu, int atkValueCount, AtkValue* atkValues)
{
- Log.Information("Poop " + Marshal.PtrToStringUTF8(new IntPtr(((AtkUnitBase*)addonContextMenu)->Name)));
-
try
{
this.ContextMenuOpenedImplementation(addonContextMenu, ref atkValueCount, ref atkValues);
diff --git a/Dalamud/Game/Gui/ContextMenus/OpenSubContextMenuItem.cs b/Dalamud/Game/Gui/ContextMenus/OpenSubContextMenuItem.cs
index 8e7258b4f..92dd0f3c3 100644
--- a/Dalamud/Game/Gui/ContextMenus/OpenSubContextMenuItem.cs
+++ b/Dalamud/Game/Gui/ContextMenus/OpenSubContextMenuItem.cs
@@ -1,4 +1,6 @@
-using Dalamud.Game.Text.SeStringHandling;
+using Dalamud.Game.Text;
+using Dalamud.Game.Text.SeStringHandling;
+using Dalamud.Game.Text.SeStringHandling.Payloads;
namespace Dalamud.Game.Gui.ContextMenus
{
@@ -13,7 +15,7 @@ namespace Dalamud.Game.Gui.ContextMenus
/// The name of the item.
/// The action that will be called when the item is selected.
internal OpenSubContextMenuItem(SeString name, ContextMenuOpenedDelegate opened)
- : base(name)
+ : base(new SeString().Append(new UIForegroundPayload(539)).Append($"{SeIconChar.BoxedLetterD.ToIconString()} ").Append(new UIForegroundPayload(0)).Append(name))
{
this.Opened = opened;
this.Indicator = ContextMenuItemIndicator.Next;
diff --git a/Dalamud/Game/Internal/DalamudAtkTweaks.cs b/Dalamud/Game/Internal/DalamudAtkTweaks.cs
index 2acba47a6..a39cbe998 100644
--- a/Dalamud/Game/Internal/DalamudAtkTweaks.cs
+++ b/Dalamud/Game/Internal/DalamudAtkTweaks.cs
@@ -1,9 +1,10 @@
using System;
using System.Runtime.InteropServices;
-using System.Text;
using CheapLoc;
using Dalamud.Configuration.Internal;
+using Dalamud.Data;
+using Dalamud.Game.Gui.ContextMenus;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
@@ -11,6 +12,7 @@ using Dalamud.Hooking;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Windowing;
using FFXIVClientStructs.FFXIV.Component.GUI;
+using Lumina.Excel.GeneratedSheets;
using Serilog;
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
@@ -31,6 +33,9 @@ namespace Dalamud.Game.Internal
private readonly Hook hookAtkUnitBaseReceiveGlobalEvent;
+ private readonly string locDalamudPlugins;
+ private readonly string locDalamudSettings;
+
///
/// Initializes a new instance of the class.
///
@@ -53,6 +58,12 @@ namespace Dalamud.Game.Internal
var atkUnitBaseReceiveGlobalEventAddress = sigScanner.ScanText("48 89 5C 24 ?? 48 89 7C 24 ?? 55 41 56 41 57 48 8B EC 48 83 EC 50 44 0F B7 F2 ");
this.hookAtkUnitBaseReceiveGlobalEvent = new Hook(atkUnitBaseReceiveGlobalEventAddress, this.AtkUnitBaseReceiveGlobalEventDetour);
+
+ this.locDalamudPlugins = Loc.Localize("SystemMenuPlugins", "Dalamud Plugins");
+ this.locDalamudSettings = Loc.Localize("SystemMenuSettings", "Dalamud Settings");
+
+ var contextMenu = Service.Get();
+ contextMenu.ContextMenuOpened += this.ContextMenuOnContextMenuOpened;
}
private delegate void AgentHudOpenSystemMenuPrototype(void* thisPtr, AtkValue* atkValueArgs, uint menuSize);
@@ -75,6 +86,27 @@ namespace Dalamud.Game.Internal
this.hookAtkUnitBaseReceiveGlobalEvent.Enable();
}
+ private void ContextMenuOnContextMenuOpened(ContextMenuOpenedArgs args)
+ {
+ var systemText = Service.Get().GetExcelSheet()!.GetRow(1059)!.Text.RawString; // "System"
+ var configuration = Service.Get();
+
+ if (args.Title == systemText && configuration.DoButtonsSystemMenu)
+ {
+ var dalamudInterface = Service.Get();
+
+ args.Items.Insert(0, new CustomContextMenuItem(this.locDalamudSettings, selectedArgs =>
+ {
+ dalamudInterface.ToggleSettingsWindow();
+ }));
+
+ args.Items.Insert(0, new CustomContextMenuItem(this.locDalamudPlugins, selectedArgs =>
+ {
+ dalamudInterface.TogglePluginInstallerWindow();
+ }));
+ }
+ }
+
private IntPtr AtkUnitBaseReceiveGlobalEventDetour(AtkUnitBase* thisPtr, ushort cmd, uint a3, IntPtr a4, uint* arg)
{
// Log.Information("{0}: cmd#{1} a3#{2} - HasAnyFocus:{3}", Marshal.PtrToStringAnsi(new IntPtr(thisPtr->Name)), cmd, a3, WindowSystem.HasAnyWindowSystemFocus);
@@ -150,11 +182,11 @@ namespace Dalamud.Game.Internal
var strPlugins = new SeString().Append(new UIForegroundPayload(color))
.Append($"{SeIconChar.BoxedLetterD.ToIconString()} ")
.Append(new UIForegroundPayload(0))
- .Append(Loc.Localize("SystemMenuPlugins", "Dalamud Plugins")).Encode();
+ .Append(this.locDalamudPlugins).Encode();
var strSettings = new SeString().Append(new UIForegroundPayload(color))
.Append($"{SeIconChar.BoxedLetterD.ToIconString()} ")
.Append(new UIForegroundPayload(0))
- .Append(Loc.Localize("SystemMenuSettings", "Dalamud Settings")).Encode();
+ .Append(this.locDalamudSettings).Encode();
// do this the most terrible way possible since im lazy
var bytes = stackalloc byte[strPlugins.Length + 1];
@@ -229,6 +261,8 @@ namespace Dalamud.Game.Internal
this.hookAgentHudOpenSystemMenu.Dispose();
this.hookUiModuleRequestMainCommand.Dispose();
this.hookAtkUnitBaseReceiveGlobalEvent.Dispose();
+
+ Service.Get().ContextMenuOpened -= this.ContextMenuOnContextMenuOpened;
}
this.disposed = true;