mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat: plugin testing stuff
This commit is contained in:
parent
cf08eaee87
commit
a9fa629e0b
4 changed files with 32 additions and 31 deletions
|
|
@ -75,8 +75,10 @@ namespace Dalamud.Injector {
|
||||||
|
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
#if !DEBUG
|
||||||
// Inject exception handler
|
// Inject exception handler
|
||||||
NativeInject(process);
|
NativeInject(process);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Inject(Process process, DalamudStartInfo info) {
|
private static void Inject(Process process, DalamudStartInfo info) {
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ namespace Dalamud {
|
||||||
this.PluginManager = new PluginManager(this, this.StartInfo.PluginDirectory, this.StartInfo.DefaultPluginDirectory);
|
this.PluginManager = new PluginManager(this, this.StartInfo.PluginDirectory, this.StartInfo.DefaultPluginDirectory);
|
||||||
this.PluginManager.LoadPlugins();
|
this.PluginManager.LoadPlugins();
|
||||||
|
|
||||||
this.PluginRepository = new PluginRepository(PluginManager, this.StartInfo.PluginDirectory, this.StartInfo.GameVersion);
|
this.PluginRepository = new PluginRepository(this, this.StartInfo.PluginDirectory, this.StartInfo.GameVersion);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -296,7 +296,7 @@ namespace Dalamud {
|
||||||
{
|
{
|
||||||
if (ImGui.MenuItem("Open Plugin installer"))
|
if (ImGui.MenuItem("Open Plugin installer"))
|
||||||
{
|
{
|
||||||
this.pluginWindow = new PluginInstallerWindow(this.PluginManager, this.PluginRepository, this.StartInfo.GameVersion);
|
this.pluginWindow = new PluginInstallerWindow(this, this.StartInfo.GameVersion);
|
||||||
this.isImguiDrawPluginWindow = true;
|
this.isImguiDrawPluginWindow = true;
|
||||||
}
|
}
|
||||||
if (ImGui.MenuItem("Open Plugin Stats")) {
|
if (ImGui.MenuItem("Open Plugin Stats")) {
|
||||||
|
|
@ -725,7 +725,7 @@ namespace Dalamud {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnOpenInstallerCommand(string command, string arguments) {
|
private void OnOpenInstallerCommand(string command, string arguments) {
|
||||||
this.pluginWindow = new PluginInstallerWindow(this.PluginManager, PluginRepository, this.StartInfo.GameVersion);
|
this.pluginWindow = new PluginInstallerWindow(this, this.StartInfo.GameVersion);
|
||||||
this.isImguiDrawPluginWindow = true;
|
this.isImguiDrawPluginWindow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,7 @@ using Serilog;
|
||||||
namespace Dalamud.Plugin
|
namespace Dalamud.Plugin
|
||||||
{
|
{
|
||||||
internal class PluginInstallerWindow {
|
internal class PluginInstallerWindow {
|
||||||
private const string PluginRepoBaseUrl = "https://goaaats.github.io/DalamudPlugins/";
|
private readonly Dalamud dalamud;
|
||||||
|
|
||||||
private PluginManager manager;
|
|
||||||
private PluginRepository repository;
|
|
||||||
private string gameVersion;
|
private string gameVersion;
|
||||||
|
|
||||||
private bool errorModalDrawing = true;
|
private bool errorModalDrawing = true;
|
||||||
|
|
@ -41,10 +38,11 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
private PluginInstallStatus installStatus = PluginInstallStatus.None;
|
private PluginInstallStatus installStatus = PluginInstallStatus.None;
|
||||||
|
|
||||||
public PluginInstallerWindow(PluginManager manager, PluginRepository repository, string gameVersion) {
|
public PluginInstallerWindow(Dalamud dalamud, string gameVersion) {
|
||||||
this.manager = manager;
|
this.dalamud = dalamud;
|
||||||
this.repository = repository;
|
|
||||||
this.gameVersion = gameVersion;
|
this.gameVersion = gameVersion;
|
||||||
|
|
||||||
|
this.dalamud.PluginRepository.ReloadPluginMaster();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Draw() {
|
public bool Draw() {
|
||||||
|
|
@ -52,7 +50,7 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
ImGui.SetNextWindowSize(new Vector2(750, 520));
|
ImGui.SetNextWindowSize(new Vector2(750, 520));
|
||||||
|
|
||||||
ImGui.Begin(Loc.Localize("InstallerHeader", "Plugin Installer"), ref windowOpen,
|
ImGui.Begin(Loc.Localize("InstallerHeader", "Plugin Installer") + (this.dalamud.Configuration.DoPluginTest ? " (TESTING)" : string.Empty) + "###XlPluginInstaller", ref windowOpen,
|
||||||
ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar);
|
ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar);
|
||||||
|
|
||||||
ImGui.Text(Loc.Localize("InstallerHint", "This window allows you install and remove in-game plugins.\nThey are made by third-party developers."));
|
ImGui.Text(Loc.Localize("InstallerHint", "This window allows you install and remove in-game plugins.\nThey are made by third-party developers."));
|
||||||
|
|
@ -62,14 +60,14 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(1, 3));
|
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(1, 3));
|
||||||
|
|
||||||
if (this.repository.State == PluginRepository.InitializationState.InProgress) {
|
if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.InProgress) {
|
||||||
ImGui.Text(Loc.Localize("InstallerLoading", "Loading plugins..."));
|
ImGui.Text(Loc.Localize("InstallerLoading", "Loading plugins..."));
|
||||||
} else if (this.repository.State == PluginRepository.InitializationState.Fail) {
|
} else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Fail) {
|
||||||
ImGui.Text(Loc.Localize("InstallerDownloadFailed", "Download failed."));
|
ImGui.Text(Loc.Localize("InstallerDownloadFailed", "Download failed."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var pluginDefinition in this.repository.PluginMaster) {
|
foreach (var pluginDefinition in this.dalamud.PluginRepository.PluginMaster) {
|
||||||
if (pluginDefinition.ApplicableVersion != this.gameVersion &&
|
if (pluginDefinition.ApplicableVersion != this.gameVersion &&
|
||||||
pluginDefinition.ApplicableVersion != "any")
|
pluginDefinition.ApplicableVersion != "any")
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -79,7 +77,7 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
ImGui.PushID(pluginDefinition.InternalName + pluginDefinition.AssemblyVersion);
|
ImGui.PushID(pluginDefinition.InternalName + pluginDefinition.AssemblyVersion);
|
||||||
|
|
||||||
var isInstalled = this.manager.Plugins.Where(x => x.Definition != null).Any(
|
var isInstalled = this.dalamud.PluginManager.Plugins.Where(x => x.Definition != null).Any(
|
||||||
x => x.Definition.InternalName == pluginDefinition.InternalName);
|
x => x.Definition.InternalName == pluginDefinition.InternalName);
|
||||||
|
|
||||||
var label = isInstalled ? Loc.Localize("InstallerInstalled", " (installed)") : string.Empty;
|
var label = isInstalled ? Loc.Localize("InstallerInstalled", " (installed)") : string.Empty;
|
||||||
|
|
@ -109,7 +107,7 @@ namespace Dalamud.Plugin
|
||||||
if (ImGui.Button($"Install v{pluginDefinition.AssemblyVersion}")) {
|
if (ImGui.Button($"Install v{pluginDefinition.AssemblyVersion}")) {
|
||||||
this.installStatus = PluginInstallStatus.InProgress;
|
this.installStatus = PluginInstallStatus.InProgress;
|
||||||
|
|
||||||
Task.Run(() => this.repository.InstallPlugin(pluginDefinition)).ContinueWith(t => {
|
Task.Run(() => this.dalamud.PluginRepository.InstallPlugin(pluginDefinition)).ContinueWith(t => {
|
||||||
this.installStatus =
|
this.installStatus =
|
||||||
t.Result ? PluginInstallStatus.Success : PluginInstallStatus.Fail;
|
t.Result ? PluginInstallStatus.Success : PluginInstallStatus.Fail;
|
||||||
this.installStatus =
|
this.installStatus =
|
||||||
|
|
@ -121,13 +119,13 @@ namespace Dalamud.Plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var installedPlugin = this.manager.Plugins.Where(x => x.Definition != null).First(
|
var installedPlugin = this.dalamud.PluginManager.Plugins.Where(x => x.Definition != null).First(
|
||||||
x => x.Definition.InternalName ==
|
x => x.Definition.InternalName ==
|
||||||
pluginDefinition.InternalName);
|
pluginDefinition.InternalName);
|
||||||
|
|
||||||
if (ImGui.Button(Loc.Localize("InstallerDisable", "Disable")))
|
if (ImGui.Button(Loc.Localize("InstallerDisable", "Disable")))
|
||||||
try {
|
try {
|
||||||
this.manager.DisablePlugin(installedPlugin.Definition);
|
this.dalamud.PluginManager.DisablePlugin(installedPlugin.Definition);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
Log.Error(exception, "Could not disable plugin.");
|
Log.Error(exception, "Could not disable plugin.");
|
||||||
this.errorModalDrawing = true;
|
this.errorModalDrawing = true;
|
||||||
|
|
@ -180,7 +178,7 @@ namespace Dalamud.Plugin
|
||||||
{
|
{
|
||||||
this.installStatus = PluginInstallStatus.InProgress;
|
this.installStatus = PluginInstallStatus.InProgress;
|
||||||
|
|
||||||
Task.Run(() => this.repository.UpdatePlugins()).ContinueWith(t => {
|
Task.Run(() => this.dalamud.PluginRepository.UpdatePlugins()).ContinueWith(t => {
|
||||||
this.installStatus =
|
this.installStatus =
|
||||||
t.Result.Success ? PluginInstallStatus.Success : PluginInstallStatus.Fail;
|
t.Result.Success ? PluginInstallStatus.Success : PluginInstallStatus.Fail;
|
||||||
this.installStatus =
|
this.installStatus =
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ namespace Dalamud.Plugin
|
||||||
{
|
{
|
||||||
internal class PluginRepository
|
internal class PluginRepository
|
||||||
{
|
{
|
||||||
private const string PluginRepoBaseUrl = "https://goatcorp.github.io/DalamudPlugins/";
|
private const string PluginRepoBaseUrl = "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/";
|
||||||
|
|
||||||
private PluginManager manager;
|
private readonly Dalamud dalamud;
|
||||||
private string pluginDirectory;
|
private string pluginDirectory;
|
||||||
public ReadOnlyCollection<PluginDefinition> PluginMaster;
|
public ReadOnlyCollection<PluginDefinition> PluginMaster;
|
||||||
|
|
||||||
|
|
@ -29,31 +29,32 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
public InitializationState State { get; private set; }
|
public InitializationState State { get; private set; }
|
||||||
|
|
||||||
public PluginRepository(PluginManager manager, string pluginDirectory, string gameVersion)
|
public PluginRepository(Dalamud dalamud, string pluginDirectory, string gameVersion)
|
||||||
{
|
{
|
||||||
this.manager = manager;
|
this.dalamud = dalamud;
|
||||||
this.pluginDirectory = pluginDirectory;
|
this.pluginDirectory = pluginDirectory;
|
||||||
|
|
||||||
State = InitializationState.InProgress;
|
State = InitializationState.InProgress;
|
||||||
Task.Run(CachePluginMaster).ContinueWith(t => {
|
Task.Run(ReloadPluginMaster).ContinueWith(t => {
|
||||||
if (t.IsFaulted)
|
if (t.IsFaulted)
|
||||||
State = InitializationState.Fail;
|
State = InitializationState.Fail;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CachePluginMaster()
|
public void ReloadPluginMaster()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var client = new WebClient();
|
using var client = new WebClient();
|
||||||
|
|
||||||
var data = client.DownloadString(PluginRepoBaseUrl + "pluginmaster.json");
|
var data = client.DownloadString(PluginRepoBaseUrl + (this.dalamud.Configuration.DoPluginTest ? "testing/" : "master/") + "pluginmaster.json");
|
||||||
|
|
||||||
this.PluginMaster = JsonConvert.DeserializeObject<ReadOnlyCollection<PluginDefinition>>(data);
|
this.PluginMaster = JsonConvert.DeserializeObject<ReadOnlyCollection<PluginDefinition>>(data);
|
||||||
|
|
||||||
State = InitializationState.Success;
|
State = InitializationState.Success;
|
||||||
}
|
}
|
||||||
catch {
|
catch(Exception ex) {
|
||||||
|
Log.Error(ex, "Could not download PluginMaster");
|
||||||
State = InitializationState.Fail;
|
State = InitializationState.Fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +72,7 @@ namespace Dalamud.Plugin
|
||||||
if (disabledFile.Exists)
|
if (disabledFile.Exists)
|
||||||
disabledFile.Delete();
|
disabledFile.Delete();
|
||||||
|
|
||||||
return this.manager.LoadPluginFromAssembly(dllFile, false);
|
return this.dalamud.PluginManager.LoadPluginFromAssembly(dllFile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dllFile.Exists && !enableAfterInstall) {
|
if (dllFile.Exists && !enableAfterInstall) {
|
||||||
|
|
@ -100,7 +101,7 @@ namespace Dalamud.Plugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.manager.LoadPluginFromAssembly(dllFile, false);
|
return this.dalamud.PluginManager.LoadPluginFromAssembly(dllFile, false);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -165,7 +166,7 @@ namespace Dalamud.Plugin
|
||||||
if (!dryRun)
|
if (!dryRun)
|
||||||
{
|
{
|
||||||
var wasEnabled =
|
var wasEnabled =
|
||||||
this.manager.Plugins.Where(x => x.Definition != null).Any(
|
this.dalamud.PluginManager.Plugins.Where(x => x.Definition != null).Any(
|
||||||
x => x.Definition.InternalName == info.InternalName); ;
|
x => x.Definition.InternalName == info.InternalName); ;
|
||||||
|
|
||||||
Log.Verbose("wasEnabled: {0}", wasEnabled);
|
Log.Verbose("wasEnabled: {0}", wasEnabled);
|
||||||
|
|
@ -173,7 +174,7 @@ namespace Dalamud.Plugin
|
||||||
// Try to disable plugin if it is loaded
|
// Try to disable plugin if it is loaded
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.manager.DisablePlugin(info);
|
this.dalamud.PluginManager.DisablePlugin(info);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue