mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
feat: add "updated" label to plugin installer when a plugin was updated
This commit is contained in:
parent
75b722eae0
commit
aa84c06cd1
5 changed files with 52 additions and 23 deletions
|
|
@ -51,8 +51,8 @@ namespace Dalamud {
|
||||||
|
|
||||||
public DiscordBotManager BotManager { get; private set; }
|
public DiscordBotManager BotManager { get; private set; }
|
||||||
|
|
||||||
public PluginManager PluginManager { get; private set; }
|
internal PluginManager PluginManager { get; private set; }
|
||||||
public PluginRepository PluginRepository { get; private set; }
|
internal PluginRepository PluginRepository { get; private set; }
|
||||||
|
|
||||||
public readonly ClientState ClientState;
|
public readonly ClientState ClientState;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ namespace Dalamud.Game {
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var hasNeedsUpdate = this.dalamud.PluginRepository.UpdatePlugins(true).UpdatedCount != 0;
|
var hasNeedsUpdate = this.dalamud.PluginRepository.UpdatePlugins(true).UpdatedPlugins.Length != 0;
|
||||||
|
|
||||||
if (hasNeedsUpdate)
|
if (hasNeedsUpdate)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Plugin
|
namespace Dalamud.Plugin
|
||||||
{
|
{
|
||||||
class PluginInstallerWindow {
|
internal class PluginInstallerWindow {
|
||||||
private const string PluginRepoBaseUrl = "https://goaaats.github.io/DalamudPlugins/";
|
private const string PluginRepoBaseUrl = "https://goaaats.github.io/DalamudPlugins/";
|
||||||
|
|
||||||
private PluginManager manager;
|
private PluginManager manager;
|
||||||
|
|
@ -30,6 +30,7 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
private bool updateComplete = false;
|
private bool updateComplete = false;
|
||||||
private int updatePluginCount = 0;
|
private int updatePluginCount = 0;
|
||||||
|
private PluginRepository.PluginUpdateStatus[] updatedInternalName;
|
||||||
|
|
||||||
private enum PluginInstallStatus {
|
private enum PluginInstallStatus {
|
||||||
None,
|
None,
|
||||||
|
|
@ -81,7 +82,18 @@ namespace Dalamud.Plugin
|
||||||
var isInstalled = this.manager.Plugins.Where(x => x.Definition != null).Any(
|
var isInstalled = this.manager.Plugins.Where(x => x.Definition != null).Any(
|
||||||
x => x.Definition.InternalName == pluginDefinition.InternalName);
|
x => x.Definition.InternalName == pluginDefinition.InternalName);
|
||||||
|
|
||||||
if (ImGui.CollapsingHeader(pluginDefinition.Name + (isInstalled ? Loc.Localize("InstallerInstalled", " (installed)") : string.Empty) + "###Header" + pluginDefinition.InternalName)) {
|
var label = isInstalled ? Loc.Localize("InstallerInstalled", " (installed)") : string.Empty;
|
||||||
|
label = this.updatedInternalName != null &&
|
||||||
|
this.updatedInternalName.Any(x => x.InternalName == pluginDefinition.InternalName && x.WasUpdated)
|
||||||
|
? Loc.Localize("InstallerUpdated", " (updated)")
|
||||||
|
: label;
|
||||||
|
|
||||||
|
label = this.updatedInternalName != null &&
|
||||||
|
this.updatedInternalName.Any(x => x.InternalName == pluginDefinition.InternalName && x.WasUpdated == false)
|
||||||
|
? Loc.Localize("InstallerUpdateFailed", " (update failed)")
|
||||||
|
: label;
|
||||||
|
|
||||||
|
if (ImGui.CollapsingHeader(pluginDefinition.Name + label + "###Header" + pluginDefinition.InternalName)) {
|
||||||
ImGui.Indent();
|
ImGui.Indent();
|
||||||
|
|
||||||
ImGui.Text(pluginDefinition.Name);
|
ImGui.Text(pluginDefinition.Name);
|
||||||
|
|
@ -176,7 +188,8 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
if (this.installStatus == PluginInstallStatus.Success) {
|
if (this.installStatus == PluginInstallStatus.Success) {
|
||||||
this.updateComplete = true;
|
this.updateComplete = true;
|
||||||
this.updatePluginCount = t.Result.UpdatedCount;
|
this.updatePluginCount = t.Result.UpdatedPlugins.Length;
|
||||||
|
this.updatedInternalName = t.Result.UpdatedPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.errorModalDrawing = this.installStatus == PluginInstallStatus.Fail;
|
this.errorModalDrawing = this.installStatus == PluginInstallStatus.Fail;
|
||||||
|
|
|
||||||
|
|
@ -36,15 +36,21 @@ namespace Dalamud.Plugin
|
||||||
// This handler should only be invoked on things that fail regular lookups, but it *is* global to this appdomain
|
// This handler should only be invoked on things that fail regular lookups, but it *is* global to this appdomain
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += (object source, ResolveEventArgs e) =>
|
AppDomain.CurrentDomain.AssemblyResolve += (object source, ResolveEventArgs e) =>
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
Log.Debug($"Resolving missing assembly {e.Name}");
|
Log.Debug($"Resolving missing assembly {e.Name}");
|
||||||
// This looks weird but I'm pretty sure it's actually correct. Pretty sure. Probably.
|
// This looks weird but I'm pretty sure it's actually correct. Pretty sure. Probably.
|
||||||
var assemblyPath = Path.Combine(Path.GetDirectoryName(e.RequestingAssembly.Location), new AssemblyName(e.Name).Name + ".dll");
|
var assemblyPath = Path.Combine(Path.GetDirectoryName(e.RequestingAssembly.Location),
|
||||||
if (!File.Exists(assemblyPath))
|
new AssemblyName(e.Name).Name + ".dll");
|
||||||
{
|
if (!File.Exists(assemblyPath)) {
|
||||||
Log.Error($"Assembly not found at {assemblyPath}");
|
Log.Error($"Assembly not found at {assemblyPath}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Assembly.LoadFrom(assemblyPath);
|
return Assembly.LoadFrom(assemblyPath);
|
||||||
|
} catch(Exception ex) {
|
||||||
|
Log.Error(ex, "Could not load assembly " + e.Name);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Plugin
|
namespace Dalamud.Plugin
|
||||||
{
|
{
|
||||||
public class PluginRepository
|
internal class PluginRepository
|
||||||
{
|
{
|
||||||
private const string PluginRepoBaseUrl = "https://goatcorp.github.io/DalamudPlugins/";
|
private const string PluginRepoBaseUrl = "https://goatcorp.github.io/DalamudPlugins/";
|
||||||
|
|
||||||
|
|
@ -109,11 +109,16 @@ namespace Dalamud.Plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public (bool Success, int UpdatedCount) UpdatePlugins(bool dryRun = false)
|
internal class PluginUpdateStatus {
|
||||||
|
public string InternalName { get; set; }
|
||||||
|
public bool WasUpdated { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public (bool Success, PluginUpdateStatus[] UpdatedPlugins) UpdatePlugins(bool dryRun = false)
|
||||||
{
|
{
|
||||||
Log.Information("Starting plugin update... dry:{0}", dryRun);
|
Log.Information("Starting plugin update... dry:{0}", dryRun);
|
||||||
|
|
||||||
var updatedCount = 0;
|
var updatedList = new List<PluginUpdateStatus>();
|
||||||
var hasError = false;
|
var hasError = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -190,18 +195,23 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
var installSuccess = InstallPlugin(remoteInfo, wasEnabled);
|
var installSuccess = InstallPlugin(remoteInfo, wasEnabled);
|
||||||
|
|
||||||
if (installSuccess)
|
if (!installSuccess)
|
||||||
{
|
|
||||||
updatedCount++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Log.Error("InstallPlugin failed.");
|
Log.Error("InstallPlugin failed.");
|
||||||
hasError = true;
|
hasError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatedList.Add(new PluginUpdateStatus {
|
||||||
|
InternalName = remoteInfo.InternalName,
|
||||||
|
WasUpdated = installSuccess
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
updatedCount++;
|
updatedList.Add(new PluginUpdateStatus
|
||||||
|
{
|
||||||
|
InternalName = remoteInfo.InternalName,
|
||||||
|
WasUpdated = true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -218,7 +228,7 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
Log.Information("Plugin update OK.");
|
Log.Information("Plugin update OK.");
|
||||||
|
|
||||||
return (!hasError, updatedCount);
|
return (!hasError, updatedList.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue