mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 12:44:16 +01:00
fix: give some feedback for plugin installs
This commit is contained in:
parent
67aa0f5ee5
commit
b7a298e22a
1 changed files with 36 additions and 14 deletions
|
|
@ -26,6 +26,9 @@ namespace Dalamud.Plugin
|
||||||
private bool errorModalDrawing = true;
|
private bool errorModalDrawing = true;
|
||||||
private bool errorModalOnNextFrame = false;
|
private bool errorModalOnNextFrame = false;
|
||||||
|
|
||||||
|
private bool updateComplete = false;
|
||||||
|
private int updatePluginCount = 0;
|
||||||
|
|
||||||
private enum PluginInstallStatus {
|
private enum PluginInstallStatus {
|
||||||
None,
|
None,
|
||||||
InProgress,
|
InProgress,
|
||||||
|
|
@ -63,9 +66,11 @@ namespace Dalamud.Plugin
|
||||||
public void UpdatePlugins() {
|
public void UpdatePlugins() {
|
||||||
Log.Information("Starting plugin update...");
|
Log.Information("Starting plugin update...");
|
||||||
|
|
||||||
|
var updatedCount = 0;
|
||||||
|
this.installStatus = PluginInstallStatus.Success;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var pluginsDirectory = new DirectoryInfo(this.pluginDirectory);
|
var pluginsDirectory = new DirectoryInfo(this.pluginDirectory);
|
||||||
this.installStatus = PluginInstallStatus.Success;
|
|
||||||
foreach (var installed in pluginsDirectory.GetDirectories()) {
|
foreach (var installed in pluginsDirectory.GetDirectories()) {
|
||||||
var versions = installed.GetDirectories();
|
var versions = installed.GetDirectories();
|
||||||
|
|
||||||
|
|
@ -114,7 +119,13 @@ namespace Dalamud.Plugin
|
||||||
Log.Error(ex, "Plugin disable failed");
|
Log.Error(ex, "Plugin disable failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallPlugin(remoteInfo);
|
var installSuccess = InstallPlugin(remoteInfo);
|
||||||
|
|
||||||
|
if (installSuccess) {
|
||||||
|
updatedCount++;
|
||||||
|
} else {
|
||||||
|
Log.Error("InstallPlugin failed.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.Information("Up to date: {0}", remoteInfo.InternalName);
|
Log.Information("Up to date: {0}", remoteInfo.InternalName);
|
||||||
}
|
}
|
||||||
|
|
@ -126,10 +137,13 @@ namespace Dalamud.Plugin
|
||||||
this.installStatus = PluginInstallStatus.Fail;
|
this.installStatus = PluginInstallStatus.Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.updatePluginCount = updatedCount;
|
||||||
|
this.updateComplete = true;
|
||||||
|
|
||||||
Log.Information("Plugin update OK.");
|
Log.Information("Plugin update OK.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InstallPlugin(PluginDefinition definition) {
|
private bool InstallPlugin(PluginDefinition definition) {
|
||||||
try {
|
try {
|
||||||
var outputDir = new DirectoryInfo(Path.Combine(this.pluginDirectory, definition.InternalName, definition.AssemblyVersion));
|
var outputDir = new DirectoryInfo(Path.Combine(this.pluginDirectory, definition.InternalName, definition.AssemblyVersion));
|
||||||
var dllFile = new FileInfo(Path.Combine(outputDir.FullName, $"{definition.InternalName}.dll"));
|
var dllFile = new FileInfo(Path.Combine(outputDir.FullName, $"{definition.InternalName}.dll"));
|
||||||
|
|
@ -140,7 +154,7 @@ namespace Dalamud.Plugin
|
||||||
disabledFile.Delete();
|
disabledFile.Delete();
|
||||||
|
|
||||||
this.installStatus = this.manager.LoadPluginFromAssembly(dllFile, false) ? PluginInstallStatus.Success : PluginInstallStatus.Fail;
|
this.installStatus = this.manager.LoadPluginFromAssembly(dllFile, false) ? PluginInstallStatus.Success : PluginInstallStatus.Fail;
|
||||||
return;
|
return this.installStatus == PluginInstallStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputDir.Exists)
|
if (outputDir.Exists)
|
||||||
|
|
@ -161,6 +175,8 @@ namespace Dalamud.Plugin
|
||||||
Log.Error(e, "Plugin download failed hard.");
|
Log.Error(e, "Plugin download failed hard.");
|
||||||
this.installStatus = PluginInstallStatus.Fail;
|
this.installStatus = PluginInstallStatus.Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.installStatus == PluginInstallStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Draw() {
|
public bool Draw() {
|
||||||
|
|
@ -261,18 +277,24 @@ namespace Dalamud.Plugin
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
||||||
if (this.installStatus == PluginInstallStatus.InProgress) {
|
if (this.installStatus == PluginInstallStatus.InProgress) {
|
||||||
ImGui.Button("In progress...");
|
ImGui.Button("Updating...");
|
||||||
} else {
|
} else {
|
||||||
if (ImGui.Button("Update plugins"))
|
if (this.updateComplete) {
|
||||||
{
|
ImGui.Button(this.updatePluginCount == 0
|
||||||
this.installStatus = PluginInstallStatus.InProgress;
|
? "No updates found!"
|
||||||
|
: $"{this.updatePluginCount} plugins updated!");
|
||||||
|
} else {
|
||||||
|
if (ImGui.Button("Update plugins"))
|
||||||
|
{
|
||||||
|
this.installStatus = PluginInstallStatus.InProgress;
|
||||||
|
|
||||||
Task.Run(() => UpdatePlugins()).ContinueWith(t => {
|
Task.Run(UpdatePlugins).ContinueWith(t => {
|
||||||
this.installStatus =
|
this.installStatus =
|
||||||
t.IsFaulted ? PluginInstallStatus.Fail : this.installStatus;
|
t.IsFaulted ? PluginInstallStatus.Fail : this.installStatus;
|
||||||
this.errorModalDrawing = this.installStatus == PluginInstallStatus.Fail;
|
this.errorModalDrawing = this.installStatus == PluginInstallStatus.Fail;
|
||||||
this.errorModalOnNextFrame = this.installStatus == PluginInstallStatus.Fail;
|
this.errorModalOnNextFrame = this.installStatus == PluginInstallStatus.Fail;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue