mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 06:13:40 +01:00
Merge pull request #557 from goatcorp/autoUpdate
AutoUpdate plugins when pluginManager is ready
This commit is contained in:
commit
3985d3eadd
1 changed files with 41 additions and 25 deletions
|
|
@ -106,6 +106,7 @@ namespace Dalamud.Game
|
||||||
private readonly DalamudLinkPayload openInstallerWindowLink;
|
private readonly DalamudLinkPayload openInstallerWindowLink;
|
||||||
|
|
||||||
private bool hasSeenLoadingMsg;
|
private bool hasSeenLoadingMsg;
|
||||||
|
private bool hasAutoUpdatedPlugins;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ChatHandlers"/> class.
|
/// Initializes a new instance of the <see cref="ChatHandlers"/> class.
|
||||||
|
|
@ -181,6 +182,9 @@ namespace Dalamud.Game
|
||||||
if (clientState.LocalPlayer != null && clientState.TerritoryType == 0 && !this.hasSeenLoadingMsg)
|
if (clientState.LocalPlayer != null && clientState.TerritoryType == 0 && !this.hasSeenLoadingMsg)
|
||||||
this.PrintWelcomeMessage();
|
this.PrintWelcomeMessage();
|
||||||
|
|
||||||
|
if (!this.hasAutoUpdatedPlugins)
|
||||||
|
this.AutoUpdatePlugins();
|
||||||
|
|
||||||
#if !DEBUG && false
|
#if !DEBUG && false
|
||||||
if (!this.hasSeenLoadingMsg)
|
if (!this.hasSeenLoadingMsg)
|
||||||
return;
|
return;
|
||||||
|
|
@ -231,7 +235,6 @@ namespace Dalamud.Game
|
||||||
var configuration = Service<DalamudConfiguration>.Get();
|
var configuration = Service<DalamudConfiguration>.Get();
|
||||||
var pluginManager = Service<PluginManager>.Get();
|
var pluginManager = Service<PluginManager>.Get();
|
||||||
var dalamudInterface = Service<DalamudInterface>.Get();
|
var dalamudInterface = Service<DalamudInterface>.Get();
|
||||||
var notifications = Service<NotificationManager>.Get();
|
|
||||||
|
|
||||||
var assemblyVersion = Assembly.GetAssembly(typeof(ChatHandlers)).GetName().Version.ToString();
|
var assemblyVersion = Assembly.GetAssembly(typeof(ChatHandlers)).GetName().Version.ToString();
|
||||||
|
|
||||||
|
|
@ -261,17 +264,33 @@ namespace Dalamud.Game
|
||||||
configuration.Save();
|
configuration.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.Run(() => pluginManager.UpdatePluginsAsync(!configuration.AutoUpdatePlugins))
|
this.hasSeenLoadingMsg = true;
|
||||||
.ContinueWith(t =>
|
|
||||||
{
|
|
||||||
if (t.IsFaulted)
|
|
||||||
{
|
|
||||||
Log.Error(t.Exception, Loc.Localize("DalamudPluginUpdateCheckFail", "Could not check for plugin updates."));
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
var updatedPlugins = t.Result;
|
|
||||||
|
|
||||||
|
private void AutoUpdatePlugins()
|
||||||
|
{
|
||||||
|
var chatGui = Service<ChatGui>.Get();
|
||||||
|
var configuration = Service<DalamudConfiguration>.Get();
|
||||||
|
var pluginManager = Service<PluginManager>.Get();
|
||||||
|
var notifications = Service<NotificationManager>.Get();
|
||||||
|
|
||||||
|
if (!pluginManager.ReposReady || pluginManager.InstalledPlugins.Count == 0 || pluginManager.AvailablePlugins.Count == 0)
|
||||||
|
{
|
||||||
|
// Plugins aren't ready yet.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.hasAutoUpdatedPlugins = true;
|
||||||
|
|
||||||
|
Task.Run(() => pluginManager.UpdatePluginsAsync(!configuration.AutoUpdatePlugins)).ContinueWith(task =>
|
||||||
|
{
|
||||||
|
if (task.IsFaulted)
|
||||||
|
{
|
||||||
|
Log.Error(task.Exception, Loc.Localize("DalamudPluginUpdateCheckFail", "Could not check for plugin updates."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var updatedPlugins = task.Result;
|
||||||
if (updatedPlugins != null && updatedPlugins.Any())
|
if (updatedPlugins != null && updatedPlugins.Any())
|
||||||
{
|
{
|
||||||
if (configuration.AutoUpdatePlugins)
|
if (configuration.AutoUpdatePlugins)
|
||||||
|
|
@ -300,10 +319,7 @@ namespace Dalamud.Game
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.hasSeenLoadingMsg = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue