feat: handle more objects for mod detection
This commit is contained in:
parent
4aac060cb4
commit
42e4bcd4dd
|
@ -5,6 +5,7 @@ namespace Screenie;
|
||||||
internal class PenumbraIpc {
|
internal class PenumbraIpc {
|
||||||
private Plugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
private FuncSubscriber<string> GetModDirectorySubscriber { get; }
|
private FuncSubscriber<string> GetModDirectorySubscriber { get; }
|
||||||
|
private ParamsFuncSubscriber<ushort, IReadOnlyDictionary<string, string[]>?[]> GetGameObjectResourcePathsSubscriber { get; }
|
||||||
private FuncSubscriber<IReadOnlyDictionary<ushort, IReadOnlyDictionary<string, string[]>>> GetPlayerResourcePathsSubscriber { get; }
|
private FuncSubscriber<IReadOnlyDictionary<ushort, IReadOnlyDictionary<string, string[]>>> GetPlayerResourcePathsSubscriber { get; }
|
||||||
private FuncSubscriber<IList<(string, string)>> GetModsSubscriber { get; }
|
private FuncSubscriber<IList<(string, string)>> GetModsSubscriber { get; }
|
||||||
|
|
||||||
|
@ -12,6 +13,7 @@ internal class PenumbraIpc {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
|
|
||||||
this.GetModDirectorySubscriber = Penumbra.Api.Ipc.GetModDirectory.Subscriber(this.Plugin.Interface);
|
this.GetModDirectorySubscriber = Penumbra.Api.Ipc.GetModDirectory.Subscriber(this.Plugin.Interface);
|
||||||
|
this.GetGameObjectResourcePathsSubscriber = Penumbra.Api.Ipc.GetGameObjectResourcePaths.Subscriber(this.Plugin.Interface);
|
||||||
this.GetPlayerResourcePathsSubscriber = Penumbra.Api.Ipc.GetPlayerResourcePaths.Subscriber(this.Plugin.Interface);
|
this.GetPlayerResourcePathsSubscriber = Penumbra.Api.Ipc.GetPlayerResourcePaths.Subscriber(this.Plugin.Interface);
|
||||||
this.GetModsSubscriber = Penumbra.Api.Ipc.GetMods.Subscriber(this.Plugin.Interface);
|
this.GetModsSubscriber = Penumbra.Api.Ipc.GetMods.Subscriber(this.Plugin.Interface);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +26,14 @@ internal class PenumbraIpc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal IReadOnlyDictionary<string, string[]>?[]? GetGameObjectResourcePaths(params ushort[] objects) {
|
||||||
|
try {
|
||||||
|
return this.GetGameObjectResourcePathsSubscriber.Invoke(objects);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal IReadOnlyDictionary<ushort, IReadOnlyDictionary<string, string[]>>? GetPlayerResourcePaths() {
|
internal IReadOnlyDictionary<ushort, IReadOnlyDictionary<string, string[]>>? GetPlayerResourcePaths() {
|
||||||
try {
|
try {
|
||||||
return this.GetPlayerResourcePathsSubscriber.Invoke();
|
return this.GetPlayerResourcePathsSubscriber.Invoke();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using Dalamud.Game.ClientState.Objects.Enums;
|
||||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game.Housing;
|
using FFXIVClientStructs.FFXIV.Client.Game.Housing;
|
||||||
|
@ -11,6 +12,7 @@ using Lumina.Excel.GeneratedSheets;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Screenie.Util;
|
using Screenie.Util;
|
||||||
using Map = Lumina.Excel.GeneratedSheets.Map;
|
using Map = Lumina.Excel.GeneratedSheets.Map;
|
||||||
|
using ObjectKind = Dalamud.Game.ClientState.Objects.Enums.ObjectKind;
|
||||||
|
|
||||||
namespace Screenie;
|
namespace Screenie;
|
||||||
|
|
||||||
|
@ -95,8 +97,29 @@ public class ScreenshotMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
var timeUtc = DateTime.UtcNow;
|
var timeUtc = DateTime.UtcNow;
|
||||||
|
// var relevantModObjects = new List<Dalamud.Game.ClientState.Objects.Types.GameObject>();
|
||||||
|
var relevantModObjects = new List<ushort>();
|
||||||
var visible = plugin.ObjectTable
|
var visible = plugin.ObjectTable
|
||||||
.Where(obj => obj is PlayerCharacter)
|
.Where(obj => {
|
||||||
|
// pull a sneaky and populate the relevantModObjects list here
|
||||||
|
if (
|
||||||
|
obj.ObjectKind is
|
||||||
|
ObjectKind.Player
|
||||||
|
or ObjectKind.Companion
|
||||||
|
or ObjectKind.BattleNpc
|
||||||
|
or ObjectKind.EventNpc
|
||||||
|
or ObjectKind.MountType
|
||||||
|
or ObjectKind.Retainer
|
||||||
|
) {
|
||||||
|
if (obj.ObjectId > ushort.MaxValue) {
|
||||||
|
Plugin.Log.Warning($"cannot pass object with id {obj.ObjectId} to Penumbra: too large");
|
||||||
|
} else {
|
||||||
|
relevantModObjects.Add((ushort) obj.ObjectId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj is PlayerCharacter;
|
||||||
|
})
|
||||||
.Cast<PlayerCharacter>()
|
.Cast<PlayerCharacter>()
|
||||||
.Where(chara => {
|
.Where(chara => {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -114,12 +137,19 @@ public class ScreenshotMetadata {
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var modDir = plugin.Penumbra.GetModDirectory();
|
var modDir = plugin.Penumbra.GetModDirectory();
|
||||||
var paths = plugin.Penumbra.GetPlayerResourcePaths();
|
var paths = plugin.Penumbra.GetGameObjectResourcePaths([.. relevantModObjects]);
|
||||||
var mods = plugin.Penumbra.GetMods();
|
var mods = plugin.Penumbra.GetMods();
|
||||||
var modsInUse = new HashSet<PenumbraMod>();
|
var modsInUse = new HashSet<PenumbraMod>();
|
||||||
if (modDir != null && paths != null && mods != null) {
|
if (modDir != null && paths != null && mods != null) {
|
||||||
var baseUri = new Uri($"{Path.TrimEndingDirectorySeparator(modDir)}/");
|
var baseUri = new Uri($"{Path.TrimEndingDirectorySeparator(modDir)}/");
|
||||||
foreach (var dict in paths.Values) {
|
var enumerable = paths
|
||||||
|
.Where(p => p != null)
|
||||||
|
.SelectMany(p => p!.Values);
|
||||||
|
foreach (var dict in paths) {
|
||||||
|
if (dict == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var path in dict.Keys) {
|
foreach (var path in dict.Keys) {
|
||||||
if (!Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out var pathUri)) {
|
if (!Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out var pathUri)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue