mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-18 22:07:44 +01:00
Merge pull request #219 from Aireil/feat_auto_update
Add an auto-updater for plugins
This commit is contained in:
commit
4a251ed190
4 changed files with 39 additions and 12 deletions
|
|
@ -32,6 +32,7 @@ namespace Dalamud
|
||||||
public bool ToggleUiHideDuringGpose { get; set; } = true;
|
public bool ToggleUiHideDuringGpose { get; set; } = true;
|
||||||
|
|
||||||
public bool PrintPluginsWelcomeMsg { get; set; } = true;
|
public bool PrintPluginsWelcomeMsg { get; set; } = true;
|
||||||
|
public bool AutoUpdatePlugins { get; set; } = false;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string ConfigPath;
|
public string ConfigPath;
|
||||||
|
|
|
||||||
|
|
@ -212,20 +212,34 @@ namespace Dalamud.Game {
|
||||||
this.dalamud.Configuration.Save();
|
this.dalamud.Configuration.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
Task.Run(() => this.dalamud.PluginRepository.UpdatePlugins(!this.dalamud.Configuration.AutoUpdatePlugins)).ContinueWith(t => {
|
||||||
var hasNeedsUpdate = this.dalamud.PluginRepository.UpdatePlugins(true).UpdatedPlugins.Count != 0;
|
if (t.IsFaulted) {
|
||||||
|
Log.Error(t.Exception, Loc.Localize("DalamudPluginUpdateCheckFail", "Could not check for plugin updates."));
|
||||||
|
} else {
|
||||||
|
var updatedPlugins = t.Result.UpdatedPlugins;
|
||||||
|
|
||||||
if (hasNeedsUpdate) {
|
if (updatedPlugins.Count != 0) {
|
||||||
this.dalamud.Framework.Gui.Chat.PrintChat(new XivChatEntry
|
if (this.dalamud.Configuration.AutoUpdatePlugins) {
|
||||||
{
|
this.dalamud.Framework.Gui.Chat.Print(string.Format(Loc.Localize("DalamudPluginUpdateSuccessful", "Auto-update:")));
|
||||||
MessageBytes = Encoding.UTF8.GetBytes(Loc.Localize("DalamudPluginUpdateRequired", "One or more of your plugins needs to be updated. Please use the /xlplugins command in-game to update them!")),
|
foreach (var plugin in updatedPlugins) {
|
||||||
Type = XivChatType.Urgent
|
if (plugin.WasUpdated) {
|
||||||
});
|
this.dalamud.Framework.Gui.Chat.Print(string.Format(Loc.Localize("DalamudPluginUpdateSuccessful", " 》 {0} updated to v{1}."), plugin.Name, plugin.Version));
|
||||||
|
} else {
|
||||||
|
this.dalamud.Framework.Gui.Chat.PrintChat(new XivChatEntry {
|
||||||
|
MessageBytes = Encoding.UTF8.GetBytes(string.Format(Loc.Localize("DalamudPluginUpdateFailed", " 》 {0} update to v{1} failed."), plugin.Name, plugin.Version)),
|
||||||
|
Type = XivChatType.Urgent
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.dalamud.Framework.Gui.Chat.PrintChat(new XivChatEntry {
|
||||||
|
MessageBytes = Encoding.UTF8.GetBytes(Loc.Localize("DalamudPluginUpdateRequired", "One or more of your plugins needs to be updated. Please use the /xlplugins command in-game to update them!")),
|
||||||
|
Type = XivChatType.Urgent
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
catch (Exception e) {
|
|
||||||
Log.Error(e, Loc.Localize("DalamudPluginUpdateCheckFail", "Could not check for plugin updates."));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.hasSeenLoadingMsg = true;
|
this.hasSeenLoadingMsg = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ namespace Dalamud.Interface
|
||||||
this.doDalamudTest = this.dalamud.Configuration.DoDalamudTest;
|
this.doDalamudTest = this.dalamud.Configuration.DoDalamudTest;
|
||||||
|
|
||||||
this.printPluginsWelcomeMsg = this.dalamud.Configuration.PrintPluginsWelcomeMsg;
|
this.printPluginsWelcomeMsg = this.dalamud.Configuration.PrintPluginsWelcomeMsg;
|
||||||
|
this.autoUpdatePlugins = this.dalamud.Configuration.AutoUpdatePlugins;
|
||||||
|
|
||||||
this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray();
|
this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray();
|
||||||
try {
|
try {
|
||||||
|
|
@ -87,6 +88,7 @@ namespace Dalamud.Interface
|
||||||
private bool doToggleUiHideDuringGpose;
|
private bool doToggleUiHideDuringGpose;
|
||||||
|
|
||||||
private bool printPluginsWelcomeMsg;
|
private bool printPluginsWelcomeMsg;
|
||||||
|
private bool autoUpdatePlugins;
|
||||||
|
|
||||||
#region Experimental
|
#region Experimental
|
||||||
|
|
||||||
|
|
@ -132,6 +134,9 @@ namespace Dalamud.Interface
|
||||||
ImGui.Checkbox(Loc.Localize("DalamudSettingsPrintPluginsWelcomeMsg", "Display loaded plugins in the welcome message"), ref this.printPluginsWelcomeMsg);
|
ImGui.Checkbox(Loc.Localize("DalamudSettingsPrintPluginsWelcomeMsg", "Display loaded plugins in the welcome message"), ref this.printPluginsWelcomeMsg);
|
||||||
ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsPrintPluginsWelcomeMsgHint", "Display loaded plugins in FFXIV chat when logging in with a character."));
|
ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsPrintPluginsWelcomeMsgHint", "Display loaded plugins in FFXIV chat when logging in with a character."));
|
||||||
|
|
||||||
|
ImGui.Checkbox(Loc.Localize("DalamudSettingsAutoUpdatePlugins", "Auto-update plugins"), ref this.autoUpdatePlugins);
|
||||||
|
ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsAutoUpdatePluginsMsgHint", "Automatically update plugins when logging in with a character."));
|
||||||
|
|
||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,6 +223,7 @@ namespace Dalamud.Interface
|
||||||
this.dalamud.Configuration.DoDalamudTest = this.doDalamudTest;
|
this.dalamud.Configuration.DoDalamudTest = this.doDalamudTest;
|
||||||
|
|
||||||
this.dalamud.Configuration.PrintPluginsWelcomeMsg = this.printPluginsWelcomeMsg;
|
this.dalamud.Configuration.PrintPluginsWelcomeMsg = this.printPluginsWelcomeMsg;
|
||||||
|
this.dalamud.Configuration.AutoUpdatePlugins = this.autoUpdatePlugins;
|
||||||
|
|
||||||
this.dalamud.Configuration.Save();
|
this.dalamud.Configuration.Save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,8 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
internal class PluginUpdateStatus {
|
internal class PluginUpdateStatus {
|
||||||
public string InternalName { get; set; }
|
public string InternalName { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Version { get; set; }
|
||||||
public bool WasUpdated { get; set; }
|
public bool WasUpdated { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -244,11 +246,15 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
updatedList.Add(new PluginUpdateStatus {
|
updatedList.Add(new PluginUpdateStatus {
|
||||||
InternalName = remoteInfo.InternalName,
|
InternalName = remoteInfo.InternalName,
|
||||||
|
Name = remoteInfo.Name,
|
||||||
|
Version = testingAvailable ? remoteInfo.TestingAssemblyVersion : remoteInfo.AssemblyVersion,
|
||||||
WasUpdated = installSuccess
|
WasUpdated = installSuccess
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
updatedList.Add(new PluginUpdateStatus {
|
updatedList.Add(new PluginUpdateStatus {
|
||||||
InternalName = remoteInfo.InternalName,
|
InternalName = remoteInfo.InternalName,
|
||||||
|
Name = remoteInfo.Name,
|
||||||
|
Version = testingAvailable ? remoteInfo.TestingAssemblyVersion : remoteInfo.AssemblyVersion,
|
||||||
WasUpdated = true
|
WasUpdated = true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue