feat: bring back examine window

This commit is contained in:
Anna 2021-02-01 14:37:08 -05:00
parent 7bb76768aa
commit 48617c9357
3 changed files with 41 additions and 20 deletions

View File

@ -18,7 +18,8 @@ namespace PeepingTom {
IntPtr rciPtr;
try {
rciPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 83 7B 30 00 74 47");
// got this by checking what accesses rciData below
rciPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("48 89 5C 24 ?? 57 48 83 EC 40 BA ?? ?? ?? ?? 48 8B D9 E8 ?? ?? ?? ?? 48 8B F8 48 85 C0 74 16");
} catch (KeyNotFoundException) {
rciPtr = IntPtr.Zero;
}
@ -48,17 +49,28 @@ namespace PeepingTom {
var framework = this.Plugin.Interface.Framework.Address.BaseAddress;
// NOTES LAST UPDATED: 5.41
// offsets and stuff come from the beginning of case 0x2c (around line 621 in IDA)
// if 29f8 ever changes, I'd just scan for it in old binary and find what it is in the new binary at the same spot
// 40 55 53 57 41 54 41 55 41 56 48 8D 6C 24 ??
var getListPtr = FollowPtrChain(framework, new[] { 0x29f8, 0, 0x110 });
var getList = Marshal.GetDelegateForFunctionPointer<GetListDelegate>(getListPtr);
var list = getList(Marshal.ReadIntPtr(framework + 0x29f8));
var rciData = Marshal.ReadIntPtr(list + 0x188);
var rciData = Marshal.ReadIntPtr(list + 0x198);
Marshal.WriteInt32(rciData + 0x28, actor.ActorId);
Marshal.WriteInt32(rciData + 0x2c, actor.ActorId);
Marshal.WriteInt32(rciData + 0x30, actor.ActorId);
unsafe {
// offsets at sig E8 ?? ?? ?? ?? 33 C0 EB 4C
// this is called at the end of the 2c case
var raw = (int*) rciData;
*(raw + 10) = actor.ActorId;
*(raw + 11) = actor.ActorId;
*(raw + 12) = actor.ActorId;
*(raw + 13) = -536870912;
*(raw + 311) = 0;
}
this._requestCharInfo(rciData);
}
}
}

View File

@ -7,6 +7,7 @@
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<AssemblyName>PeepingTom</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\target.wav" />

View File

@ -17,6 +17,7 @@ namespace PeepingTom {
private Optional<Actor> PreviousFocus { get; set; } = new();
private bool _wantsOpen;
public bool WantsOpen {
get => this._wantsOpen;
set => this._wantsOpen = value;
@ -25,6 +26,7 @@ namespace PeepingTom {
public bool Visible { get; private set; }
private bool _settingsOpen;
public bool SettingsOpen {
get => this._settingsOpen;
set => this._settingsOpen = value;
@ -199,11 +201,11 @@ namespace PeepingTom {
this.Plugin.Config.Save();
}
// bool openExamine = this.plugin.Config.OpenExamine;
// if (ImGui.Checkbox("Open examine window on Alt-click", ref openExamine)) {
// this.plugin.Config.OpenExamine = openExamine;
// this.plugin.Config.Save();
// }
var openExamine = this.Plugin.Config.OpenExamine;
if (ImGui.Checkbox("Open examine window on Alt-click", ref openExamine)) {
this.Plugin.Config.OpenExamine = openExamine;
this.Plugin.Config.Save();
}
ImGui.EndTabItem();
}
@ -240,6 +242,7 @@ namespace PeepingTom {
} else {
name = "Invalid device";
}
if (ImGui.BeginCombo("Output device", name)) {
if (ImGui.Selectable("Default")) {
this.Plugin.Config.SoundDevice = -1;
@ -362,7 +365,7 @@ namespace PeepingTom {
.Cast<PlayerCharacter>();
foreach (var actor in actors) {
var payload = new PlayerPayload(this.Plugin.Interface.Data, actor.Name, actor.HomeWorld.Id);
Payload[] payloads = { payload };
Payload[] payloads = {payload};
this.Plugin.Interface.Framework.Gui.Chat.PrintChat(new XivChatEntry {
MessageBytes = new SeString(payloads).Encode()
});
@ -375,7 +378,7 @@ namespace PeepingTom {
if (target != null) {
var payload = new PlayerPayload(this.Plugin.Interface.Data, target.Name, target.HomeWorld.Id);
Payload[] payloads = { payload };
Payload[] payloads = {payload};
this.Plugin.Interface.Framework.Gui.Chat.PrintChat(new XivChatEntry {
MessageBytes = new SeString(payloads).Encode()
});
@ -407,6 +410,7 @@ namespace PeepingTom {
dict.Add(actor.ActorId, actor);
}
actors = dict;
}
@ -414,9 +418,11 @@ namespace PeepingTom {
if (!this.Plugin.Config.AllowMovement) {
flags |= ImGuiWindowFlags.NoMove;
}
if (!this.Plugin.Config.AllowResize) {
flags |= ImGuiWindowFlags.NoResize;
}
ImGui.SetNextWindowSize(new Vector2(290, 195), ImGuiCond.FirstUseEver);
if (!ImGui.Begin(this.Plugin.Name, ref this._wantsOpen, flags)) {
return;
@ -425,11 +431,7 @@ namespace PeepingTom {
{
ImGui.Text("Targeting you");
ImGui.SameLine();
// if (this.plugin.Config.OpenExamine) {
// HelpMarker("Click to link, Alt-click to examine, or right click to target.");
// } else {
HelpMarker("Click to link or right click to target.");
// }
HelpMarker(this.Plugin.Config.OpenExamine ? "Click to link, Alt-click to examine, or right click to target." : "Click to link or right click to target.");
var height = ImGui.GetContentRegionAvail().Y;
height -= ImGui.GetStyle().ItemSpacing.Y;
@ -449,6 +451,7 @@ namespace PeepingTom {
actors?.TryGetValue(targeter.ActorId, out actor);
this.AddEntry(targeter, actor, ref anyHovered);
}
if (this.Plugin.Config.KeepHistory) {
// get a list of the previous targeters that aren't currently targeting
var previous = (previousTargeters ?? new List<Targeter>())
@ -461,8 +464,10 @@ namespace PeepingTom {
this.AddEntry(oldTargeter, actor, ref anyHovered, ImGuiSelectableFlags.Disabled);
}
}
ImGui.ListBoxFooter();
}
if (this.Plugin.Config.FocusTargetOnHover && !anyHovered && this.PreviousFocus.Get(out var previousFocus)) {
if (previousFocus == null) {
this.Plugin.Interface.ClientState.Targets.SetFocusTarget(null);
@ -471,8 +476,10 @@ namespace PeepingTom {
// either target the actor if still present or target nothing
this.Plugin.Interface.ClientState.Targets.SetFocusTarget(actor);
}
this.PreviousFocus = new Optional<Actor>();
}
ImGui.End();
}
}
@ -508,11 +515,12 @@ namespace PeepingTom {
if (!this.PreviousFocus.Present) {
this.PreviousFocus = new Optional<Actor>(this.Plugin.Interface.ClientState.Targets.FocusTarget);
}
this.Plugin.Interface.ClientState.Targets.SetFocusTarget(actor);
}
if (left) {
if (false && this.Plugin.Config.OpenExamine && ImGui.GetIO().KeyAlt) {
if (this.Plugin.Config.OpenExamine && ImGui.GetIO().KeyAlt) {
if (actor != null) {
this.Plugin.GameFunctions.OpenExamineWindow(actor);
} else {
@ -527,7 +535,7 @@ namespace PeepingTom {
}
} else {
var payload = new PlayerPayload(this.Plugin.Interface.Data, targeter.Name, targeter.HomeWorld.Id);
Payload[] payloads = { payload };
Payload[] payloads = {payload};
this.Plugin.Interface.Framework.Gui.Chat.PrintChat(new XivChatEntry {
MessageBytes = new SeString(payloads).Encode(),
});