qstcompanion v1.0.1
This commit is contained in:
parent
3e10cbbbf2
commit
44c67ab71b
79 changed files with 21148 additions and 0 deletions
|
|
@ -0,0 +1,148 @@
|
|||
using System;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace QuestionableCompanion.Services;
|
||||
|
||||
public class PartyInviteAutoAccept : IDisposable
|
||||
{
|
||||
private readonly IPluginLog log;
|
||||
|
||||
private readonly IFramework framework;
|
||||
|
||||
private readonly IGameGui gameGui;
|
||||
|
||||
private readonly IPartyList partyList;
|
||||
|
||||
private readonly Configuration configuration;
|
||||
|
||||
private bool shouldAutoAccept;
|
||||
|
||||
private DateTime autoAcceptUntil = DateTime.MinValue;
|
||||
|
||||
public PartyInviteAutoAccept(IPluginLog log, IFramework framework, IGameGui gameGui, IPartyList partyList, Configuration configuration)
|
||||
{
|
||||
this.log = log;
|
||||
this.framework = framework;
|
||||
this.gameGui = gameGui;
|
||||
this.partyList = partyList;
|
||||
this.configuration = configuration;
|
||||
framework.Update += OnFrameworkUpdate;
|
||||
log.Information("[PartyInviteAutoAccept] Initialized");
|
||||
}
|
||||
|
||||
public void EnableAutoAccept()
|
||||
{
|
||||
if (!configuration.IsHighLevelHelper && !configuration.IsQuester)
|
||||
{
|
||||
log.Debug("[PartyInviteAutoAccept] Not a helper or quester, ignoring auto-accept request");
|
||||
return;
|
||||
}
|
||||
shouldAutoAccept = true;
|
||||
autoAcceptUntil = DateTime.Now.AddSeconds(30.0);
|
||||
string role = (configuration.IsHighLevelHelper ? "Helper" : "Quester");
|
||||
log.Information("[PartyInviteAutoAccept] Auto-accept enabled for 30 seconds (" + role + ")");
|
||||
log.Information($"[PartyInviteAutoAccept] Will accept until: {autoAcceptUntil:HH:mm:ss}");
|
||||
log.Information("[PartyInviteAutoAccept] Will accept ALL party invites during this time!");
|
||||
}
|
||||
|
||||
private unsafe void OnFrameworkUpdate(IFramework framework)
|
||||
{
|
||||
if (!shouldAutoAccept)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (DateTime.Now > autoAcceptUntil)
|
||||
{
|
||||
shouldAutoAccept = false;
|
||||
log.Information("[PartyInviteAutoAccept] Auto-accept window expired");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
string[] obj = new string[6] { "SelectYesno", "SelectYesNo", "_PartyInvite", "PartyInvite", "SelectString", "_Notification" };
|
||||
nint addonPtr = IntPtr.Zero;
|
||||
string[] array = obj;
|
||||
foreach (string name in array)
|
||||
{
|
||||
addonPtr = (nint)gameGui.GetAddonByName(name);
|
||||
if (addonPtr != IntPtr.Zero)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (addonPtr == IntPtr.Zero)
|
||||
{
|
||||
if (DateTime.Now.Second % 5 != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
log.Debug($"[PartyInviteAutoAccept] Still waiting for party invite dialog... ({(autoAcceptUntil - DateTime.Now).TotalSeconds:F0}s remaining)");
|
||||
if (DateTime.Now.Second % 10 != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
log.Warning("[PartyInviteAutoAccept] === DUMPING ALL VISIBLE ADDONS ===");
|
||||
RaptureAtkUnitManager* atkStage = RaptureAtkUnitManager.Instance();
|
||||
if (atkStage != null)
|
||||
{
|
||||
AtkUnitManager* unitManager = &atkStage->AtkUnitManager;
|
||||
for (int j = 0; j < unitManager->AllLoadedUnitsList.Count; j++)
|
||||
{
|
||||
AtkUnitBase* addon = unitManager->AllLoadedUnitsList.Entries[j].Value;
|
||||
if (addon != null && addon->IsVisible)
|
||||
{
|
||||
string name2 = addon->NameString;
|
||||
log.Warning("[PartyInviteAutoAccept] Visible addon: " + name2);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Warning("[PartyInviteAutoAccept] === END ADDON DUMP ===");
|
||||
}
|
||||
else
|
||||
{
|
||||
AtkUnitBase* addon2 = (AtkUnitBase*)addonPtr;
|
||||
if (addon2 == null)
|
||||
{
|
||||
log.Warning("[PartyInviteAutoAccept] Addon pointer is null!");
|
||||
return;
|
||||
}
|
||||
if (!addon2->IsVisible)
|
||||
{
|
||||
log.Debug("[PartyInviteAutoAccept] Addon exists but not visible yet");
|
||||
return;
|
||||
}
|
||||
AtkValue* values = stackalloc AtkValue[1];
|
||||
*values = new AtkValue
|
||||
{
|
||||
Type = FFXIVClientStructs.FFXIV.Component.GUI.ValueType.Int,
|
||||
Int = 0
|
||||
};
|
||||
addon2->FireCallback(1u, values);
|
||||
AtkValue* values2 = stackalloc AtkValue[2];
|
||||
*values2 = new AtkValue
|
||||
{
|
||||
Type = FFXIVClientStructs.FFXIV.Component.GUI.ValueType.Int,
|
||||
Int = 0
|
||||
};
|
||||
values2[1] = new AtkValue
|
||||
{
|
||||
Type = FFXIVClientStructs.FFXIV.Component.GUI.ValueType.UInt,
|
||||
UInt = 0u
|
||||
};
|
||||
addon2->FireCallback(2u, values2);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error("[PartyInviteAutoAccept] Error: " + ex.Message);
|
||||
log.Error("[PartyInviteAutoAccept] Stack: " + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
framework.Update -= OnFrameworkUpdate;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue