feat: capture mods in use
This commit is contained in:
parent
282f764916
commit
b5089d00e4
12
Command.cs
12
Command.cs
|
@ -43,18 +43,6 @@ internal class Command : IDisposable {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.Plugin.Penumbra.GetPlayerResourcePaths() is { } paths) {
|
||||
foreach (var (objId, data) in paths) {
|
||||
Plugin.Log.Info($"{objId}");
|
||||
foreach (var (key, value) in data) {
|
||||
Plugin.Log.Info($" {key}");
|
||||
foreach (var str in value) {
|
||||
Plugin.Log.Info($" {str}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Task.Factory.StartNew(async () => {
|
||||
using var bitmap = bitmapOuter;
|
||||
|
||||
|
|
|
@ -3,12 +3,24 @@ using Screenie;
|
|||
|
||||
internal class PenumbraIpc {
|
||||
private Plugin Plugin { get; }
|
||||
private FuncSubscriber<string> GetModDirectorySubscriber { get; }
|
||||
private FuncSubscriber<IReadOnlyDictionary<ushort, IReadOnlyDictionary<string, string[]>>> GetPlayerResourcePathsSubscriber { get; }
|
||||
private FuncSubscriber<IList<(string, string)>> GetModsSubscriber { get; }
|
||||
|
||||
internal PenumbraIpc(Plugin plugin) {
|
||||
this.Plugin = plugin;
|
||||
|
||||
this.GetModDirectorySubscriber = Penumbra.Api.Ipc.GetModDirectory.Subscriber(this.Plugin.Interface);
|
||||
this.GetPlayerResourcePathsSubscriber = Penumbra.Api.Ipc.GetPlayerResourcePaths.Subscriber(this.Plugin.Interface);
|
||||
this.GetModsSubscriber = Penumbra.Api.Ipc.GetMods.Subscriber(this.Plugin.Interface);
|
||||
}
|
||||
|
||||
internal string? GetModDirectory() {
|
||||
try {
|
||||
return this.GetModDirectorySubscriber.Invoke();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal IReadOnlyDictionary<ushort, IReadOnlyDictionary<string, string[]>>? GetPlayerResourcePaths() {
|
||||
|
@ -18,4 +30,12 @@ internal class PenumbraIpc {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal IList<(string Directory, string Name)>? GetMods() {
|
||||
try {
|
||||
return this.GetModsSubscriber.Invoke();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,40 @@ public class ScreenshotMetadata {
|
|||
.Select(tuple => new Character(tuple.chara, tuple.screenPos, scale, offsetX, offsetY))
|
||||
.ToArray();
|
||||
|
||||
var modDir = plugin.Penumbra.GetModDirectory();
|
||||
var paths = plugin.Penumbra.GetPlayerResourcePaths();
|
||||
var mods = plugin.Penumbra.GetMods();
|
||||
var modsInUse = new List<PenumbraMod>();
|
||||
if (modDir != null && paths != null && mods != null) {
|
||||
var baseUri = new Uri($"{modDir}/");
|
||||
foreach (var dict in paths.Values) {
|
||||
foreach (var path in dict.Keys) {
|
||||
if (!Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out var pathUri)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!pathUri.IsAbsoluteUri || !baseUri.IsBaseOf(pathUri)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var modPathUntrimmed = Uri.UnescapeDataString(pathUri.Segments[baseUri.Segments.Length..][0]);
|
||||
var modPath = Path.TrimEndingDirectorySeparator(modPathUntrimmed);
|
||||
|
||||
var found = mods.FirstOrDefault(mod => string.Equals(mod.Directory, modPath, StringComparison.OrdinalIgnoreCase));
|
||||
if (found != default) {
|
||||
modsInUse.Add(new PenumbraMod {
|
||||
Name = found.Name,
|
||||
Path = found.Directory,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var mod in modsInUse) {
|
||||
Plugin.Log.Info($"{mod.Name} at {mod.Path}");
|
||||
}
|
||||
|
||||
return new ScreenshotMetadata {
|
||||
ActiveCharacter = active,
|
||||
Location = map?.PlaceName.Value?.Name.ToDalamudString().TextValue.WhitespaceToNull()
|
||||
|
@ -128,7 +162,7 @@ public class ScreenshotMetadata {
|
|||
Ward = ward,
|
||||
Plot = plot,
|
||||
VisibleCharacters = visible,
|
||||
ModsInUse = Array.Empty<PenumbraMod>(), // TODO
|
||||
ModsInUse = [.. modsInUse],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue