fix: possibly empty error message

This commit is contained in:
goat 2020-06-08 22:36:32 +02:00
parent ccb6632310
commit c0fd954230
3 changed files with 28 additions and 20 deletions

View file

@ -107,6 +107,12 @@ namespace Dalamud {
this.LocalizationManager.SetupWithUiCulture(); this.LocalizationManager.SetupWithUiCulture();
} }
var pluginDir = this.StartInfo.PluginDirectory;
if (this.Configuration.DoPluginTest)
pluginDir = Path.Combine(pluginDir, "..", "testPlugins");
this.PluginRepository = new PluginRepository(this, pluginDir, this.StartInfo.GameVersion);
if (Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") != "True") { if (Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") != "True") {
try try
{ {
@ -139,14 +145,8 @@ namespace Dalamud {
this.BotManager.Start(); this.BotManager.Start();
try { try {
var pluginDir = this.StartInfo.PluginDirectory;
if (this.Configuration.DoPluginTest)
pluginDir = Path.Combine(pluginDir, "..", "testPlugins");
this.PluginManager = new PluginManager(this, pluginDir, this.StartInfo.DefaultPluginDirectory); this.PluginManager = new PluginManager(this, pluginDir, this.StartInfo.DefaultPluginDirectory);
this.PluginManager.LoadPlugins(); this.PluginManager.LoadPlugins();
this.PluginRepository = new PluginRepository(this, pluginDir, this.StartInfo.GameVersion);
} }
catch (Exception ex) catch (Exception ex)
{ {

View file

@ -27,7 +27,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 List<PluginRepository.PluginUpdateStatus> updatedPlugins;
private enum PluginInstallStatus { private enum PluginInstallStatus {
None, None,
@ -82,13 +82,13 @@ namespace Dalamud.Plugin
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;
label = this.updatedInternalName != null && label = this.updatedPlugins != null &&
this.updatedInternalName.Any(x => x.InternalName == pluginDefinition.InternalName && x.WasUpdated) this.updatedPlugins.Any(x => x.InternalName == pluginDefinition.InternalName && x.WasUpdated)
? Loc.Localize("InstallerUpdated", " (updated)") ? Loc.Localize("InstallerUpdated", " (updated)")
: label; : label;
label = this.updatedInternalName != null && label = this.updatedPlugins != null &&
this.updatedInternalName.Any(x => x.InternalName == pluginDefinition.InternalName && x.WasUpdated == false) this.updatedPlugins.Any(x => x.InternalName == pluginDefinition.InternalName && x.WasUpdated == false)
? Loc.Localize("InstallerUpdateFailed", " (update failed)") ? Loc.Localize("InstallerUpdateFailed", " (update failed)")
: label; : label;
@ -190,8 +190,8 @@ namespace Dalamud.Plugin
} }
if (t.Result.UpdatedPlugins != null) { if (t.Result.UpdatedPlugins != null) {
this.updatePluginCount = t.Result.UpdatedPlugins.Length; this.updatePluginCount = t.Result.UpdatedPlugins.Count;
this.updatedInternalName = t.Result.UpdatedPlugins; this.updatedPlugins = t.Result.UpdatedPlugins;
} }
this.errorModalDrawing = this.installStatus == PluginInstallStatus.Fail; this.errorModalDrawing = this.installStatus == PluginInstallStatus.Fail;
@ -215,12 +215,20 @@ namespace Dalamud.Plugin
var message = Loc.Localize("InstallerErrorHint", var message = Loc.Localize("InstallerErrorHint",
"The plugin installer ran into an issue or the plugin is incompatible.\nPlease restart the game and report this error on our discord."); "The plugin installer ran into an issue or the plugin is incompatible.\nPlease restart the game and report this error on our discord.");
if (this.updatedInternalName != null) { if (this.updatedPlugins != null) {
var extraInfoMessage = Loc.Localize("InstallerErrorPluginInfo", "\n\nThe following plugins caused these issues:\n\n{0}\nYou may try removing these plugins manually and reinstalling them."); if (this.updatedPlugins.Any(x => x.WasUpdated == false))
var insert = this.updatedInternalName.Where(x => x.WasUpdated == false).Aggregate(string.Empty, (current, pluginUpdateStatus) => current + $"* {pluginUpdateStatus.InternalName}\n"); {
var extraInfoMessage = Loc.Localize("InstallerErrorPluginInfo",
"\n\nThe following plugins caused these issues:\n\n{0}\nYou may try removing these plugins manually and reinstalling them.");
var insert = this.updatedPlugins.Where(x => x.WasUpdated == false)
.Aggregate(string.Empty,
(current, pluginUpdateStatus) =>
current + $"* {pluginUpdateStatus.InternalName}\n");
extraInfoMessage = string.Format(extraInfoMessage, insert); extraInfoMessage = string.Format(extraInfoMessage, insert);
message += extraInfoMessage; message += extraInfoMessage;
} }
}
ImGui.Text(message); ImGui.Text(message);

View file

@ -119,7 +119,7 @@ namespace Dalamud.Plugin
public bool WasUpdated { get; set; } public bool WasUpdated { get; set; }
} }
public (bool Success, PluginUpdateStatus[] UpdatedPlugins) UpdatePlugins(bool dryRun = false) public (bool Success, List<PluginUpdateStatus> UpdatedPlugins) UpdatePlugins(bool dryRun = false)
{ {
Log.Information("Starting plugin update... dry:{0}", dryRun); Log.Information("Starting plugin update... dry:{0}", dryRun);
@ -233,7 +233,7 @@ namespace Dalamud.Plugin
Log.Information("Plugin update OK."); Log.Information("Plugin update OK.");
return (!hasError, updatedList.ToArray()); return (!hasError, updatedList);
} }
} }
} }