Don't use Reflector to check for installed plugins

This commit is contained in:
Liza 2024-12-16 20:28:10 +01:00
parent 1bcc027639
commit 267e036743
Signed by: liza
GPG Key ID: 2C41B84815CF6445

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Components; using Dalamud.Interface.Components;
@ -19,6 +20,7 @@ internal sealed class OneTimeSetupWindow : LWindow
private static readonly IReadOnlyList<PluginInfo> RequiredPlugins = private static readonly IReadOnlyList<PluginInfo> RequiredPlugins =
[ [
new("vnavmesh", new("vnavmesh",
"vnavmesh",
""" """
vnavmesh handles the navigation within a zone, moving vnavmesh handles the navigation within a zone, moving
your character to the next quest-related objective. your character to the next quest-related objective.
@ -26,12 +28,14 @@ internal sealed class OneTimeSetupWindow : LWindow
new Uri("https://github.com/awgil/ffxiv_navmesh/"), new Uri("https://github.com/awgil/ffxiv_navmesh/"),
new Uri("https://puni.sh/api/repository/veyn")), new Uri("https://puni.sh/api/repository/veyn")),
new("Lifestream", new("Lifestream",
"Lifestream",
""" """
Used to travel to aethernet shards in cities. Used to travel to aethernet shards in cities.
""", """,
new Uri("https://github.com/NightmareXIV/Lifestream"), new Uri("https://github.com/NightmareXIV/Lifestream"),
new Uri("https://github.com/NightmareXIV/MyDalamudPlugins/raw/main/pluginmaster.json")), new Uri("https://github.com/NightmareXIV/MyDalamudPlugins/raw/main/pluginmaster.json")),
new("TextAdvance", new("TextAdvance",
"TextAdvance",
""" """
Automatically accepts and turns in quests, skips cutscenes Automatically accepts and turns in quests, skips cutscenes
and dialogue. and dialogue.
@ -45,23 +49,22 @@ internal sealed class OneTimeSetupWindow : LWindow
private readonly Configuration _configuration; private readonly Configuration _configuration;
private readonly IDalamudPluginInterface _pluginInterface; private readonly IDalamudPluginInterface _pluginInterface;
private readonly UiUtils _uiUtils; private readonly UiUtils _uiUtils;
private readonly DalamudReflector _dalamudReflector;
private readonly ILogger<OneTimeSetupWindow> _logger; private readonly ILogger<OneTimeSetupWindow> _logger;
public OneTimeSetupWindow(Configuration configuration, IDalamudPluginInterface pluginInterface, UiUtils uiUtils, public OneTimeSetupWindow(Configuration configuration, IDalamudPluginInterface pluginInterface, UiUtils uiUtils,
DalamudReflector dalamudReflector, ILogger<OneTimeSetupWindow> logger, AutomatonIpc automatonIpc) ILogger<OneTimeSetupWindow> logger, AutomatonIpc automatonIpc)
: base("Questionable Setup###QuestionableOneTimeSetup", : base("Questionable Setup###QuestionableOneTimeSetup",
ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings, true) ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings, true)
{ {
_configuration = configuration; _configuration = configuration;
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
_uiUtils = uiUtils; _uiUtils = uiUtils;
_dalamudReflector = dalamudReflector;
_logger = logger; _logger = logger;
_recommendedPlugins = _recommendedPlugins =
[ [
new("Rotation Solver Reborn", new("Rotation Solver Reborn",
"RotationSolver",
""" """
Automatically handles most combat interactions you encounter Automatically handles most combat interactions you encounter
during quests, including being interrupted by mobs. during quests, including being interrupted by mobs.
@ -70,6 +73,7 @@ internal sealed class OneTimeSetupWindow : LWindow
new Uri( new Uri(
"https://raw.githubusercontent.com/FFXIV-CombatReborn/CombatRebornRepo/main/pluginmaster.json")), "https://raw.githubusercontent.com/FFXIV-CombatReborn/CombatRebornRepo/main/pluginmaster.json")),
new PluginInfo("CBT (formerly known as Automaton)", new PluginInfo("CBT (formerly known as Automaton)",
"Automaton",
""" """
Automaton is a collection of automation-related tweaks. Automaton is a collection of automation-related tweaks.
The 'Sniper no sniping' tweak can complete snipe tasks automatically. The 'Sniper no sniping' tweak can complete snipe tasks automatically.
@ -78,6 +82,7 @@ internal sealed class OneTimeSetupWindow : LWindow
new Uri("https://puni.sh/api/repository/croizat"), new Uri("https://puni.sh/api/repository/croizat"),
[new PluginDetailInfo("'Sniper no sniping' enabled", () => automatonIpc.IsAutoSnipeEnabled)]), [new PluginDetailInfo("'Sniper no sniping' enabled", () => automatonIpc.IsAutoSnipeEnabled)]),
new("NotificationMaster", new("NotificationMaster",
"NotificationMaster",
""" """
Sends a configurable out-of-game notification if a quest Sends a configurable out-of-game notification if a quest
requires manual actions. requires manual actions.
@ -159,7 +164,7 @@ internal sealed class OneTimeSetupWindow : LWindow
private bool DrawPlugin(PluginInfo plugin, float checklistPadding) private bool DrawPlugin(PluginInfo plugin, float checklistPadding)
{ {
bool isInstalled = IsPluginInstalled(plugin.DisplayName); bool isInstalled = IsPluginInstalled(plugin);
using (ImRaii.PushId("plugin_" + plugin.DisplayName)) using (ImRaii.PushId("plugin_" + plugin.DisplayName))
{ {
_uiUtils.ChecklistItem(plugin.DisplayName, isInstalled); _uiUtils.ChecklistItem(plugin.DisplayName, isInstalled);
@ -194,13 +199,14 @@ internal sealed class OneTimeSetupWindow : LWindow
return isInstalled; return isInstalled;
} }
private bool IsPluginInstalled(string internalName) private bool IsPluginInstalled(PluginInfo pluginInfo)
{ {
return _dalamudReflector.TryGetDalamudPlugin(internalName, out _, suppressErrors: true, ignoreCache: true); return _pluginInterface.InstalledPlugins.Any(x => x.InternalName == pluginInfo.InternalName && x.IsLoaded);
} }
private sealed record PluginInfo( private sealed record PluginInfo(
string DisplayName, string DisplayName,
string InternalName,
string Details, string Details,
Uri WebsiteUri, Uri WebsiteUri,
Uri? DalamudRepositoryUri, Uri? DalamudRepositoryUri,