This commit is contained in:
goat 2020-12-13 21:15:59 +01:00
commit f8e5728985
6 changed files with 57 additions and 23 deletions

View file

@ -34,6 +34,7 @@ namespace Dalamud
public bool ToggleUiHideDuringGpose { get; set; } = true;
public bool PrintPluginsWelcomeMsg { get; set; } = true;
public bool AutoUpdatePlugins { get; set; } = false;
[JsonIgnore]
public string ConfigPath;

View file

@ -212,20 +212,34 @@ namespace Dalamud.Game {
this.dalamud.Configuration.Save();
}
try {
var hasNeedsUpdate = this.dalamud.PluginRepository.UpdatePlugins(true).UpdatedPlugins.Count != 0;
Task.Run(() => this.dalamud.PluginRepository.UpdatePlugins(!this.dalamud.Configuration.AutoUpdatePlugins)).ContinueWith(t => {
if (t.IsFaulted) {
Log.Error(t.Exception, Loc.Localize("DalamudPluginUpdateCheckFail", "Could not check for plugin updates."));
} else {
var updatedPlugins = t.Result.UpdatedPlugins;
if (hasNeedsUpdate) {
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
});
if (updatedPlugins.Count != 0) {
if (this.dalamud.Configuration.AutoUpdatePlugins) {
this.dalamud.Framework.Gui.Chat.Print(string.Format(Loc.Localize("DalamudPluginUpdateSuccessful", "Auto-update:")));
foreach (var plugin in updatedPlugins) {
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;
}

View file

@ -56,7 +56,7 @@ namespace Dalamud.Game.ClientState.Structs
// public const int ??? = 6371; // 0x18E3 DifficultyRank
// public const int ??? = 6385; // 0x18F1 AgroFlags
// public const int ??? = 6406; // 0x1906 CombatFlags
public const int UIStatusEffects = 6488; // 0x1958 DefaultStatusEffectOffset
public const int UIStatusEffects = 6616; // 0x1958 DefaultStatusEffectOffset
// public const int ??? = 6880; // 0x1AE0 IsCasting1
// public const int ??? = 6882; // 0x1AE2 IsCasting2
// public const int ??? = 6884; // 0x1AE4 CastingID

View file

@ -33,6 +33,7 @@ namespace Dalamud.Interface
this.thirdRepoList = this.dalamud.Configuration.ThirdRepoList;
this.printPluginsWelcomeMsg = this.dalamud.Configuration.PrintPluginsWelcomeMsg;
this.autoUpdatePlugins = this.dalamud.Configuration.AutoUpdatePlugins;
this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray();
try {
@ -91,6 +92,7 @@ namespace Dalamud.Interface
private List<ThirdRepoSetting> thirdRepoList;
private bool printPluginsWelcomeMsg;
private bool autoUpdatePlugins;
private string thirdRepoTempUrl = string.Empty;
@ -139,6 +141,9 @@ namespace Dalamud.Interface
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.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();
}
@ -296,6 +301,7 @@ namespace Dalamud.Interface
this.dalamud.Configuration.ThirdRepoList = this.thirdRepoList;
this.dalamud.Configuration.PrintPluginsWelcomeMsg = this.printPluginsWelcomeMsg;
this.dalamud.Configuration.AutoUpdatePlugins = this.autoUpdatePlugins;
this.dalamud.Configuration.Save();
}

View file

@ -91,13 +91,13 @@ namespace Dalamud.Plugin
ImGui.Text(Loc.Localize("InstallerHint", "This window allows you install and remove in-game plugins.\nThey are made by third-party developers."));
ImGui.SameLine(ImGui.GetWindowWidth() - ((250 + 90 + ImGui.CalcTextSize(Loc.Localize("PluginSort", "Sort By")).X) * ImGui.GetIO().FontGlobalScale));
ImGui.SameLine(ImGui.GetWindowWidth() - ((250 + 20 + ImGui.CalcTextSize(Loc.Localize("SortDownloadCounts", "Download Count")).X + ImGui.CalcTextSize(Loc.Localize("PluginSort", "Sort By")).X) * ImGui.GetIO().FontGlobalScale));
ImGui.SetNextItemWidth(240 * ImGui.GetIO().FontGlobalScale);
ImGui.InputTextWithHint("###XPlPluginInstaller_Search", Loc.Localize("InstallerSearch", "Search"), ref this.searchText, 100);
ImGui.SameLine();
ImGui.SetNextItemWidth(80 * ImGui.GetIO().FontGlobalScale);
ImGui.SetNextItemWidth(10 + (ImGui.CalcTextSize(Loc.Localize("SortDownloadCounts", "Download Count")).X) * ImGui.GetIO().FontGlobalScale);
if (ImGui.BeginCombo(Loc.Localize("PluginSort", "Sort By"), this.filterText, ImGuiComboFlags.NoArrowButton)) {
if (ImGui.Selectable(Loc.Localize("SortAlphabetical", "Alphabetical"))) {
this.sortKind = PluginSortKind.Alphabetical;
@ -372,13 +372,19 @@ namespace Dalamud.Plugin
ImGui.Text($"{command.Key} → {command.Value.HelpMessage}");
}
if (!installedPlugin.IsRaw && ImGui.Button(Loc.Localize("InstallerDisable", "Disable"))) {
try {
this.dalamud.PluginManager.DisablePlugin(installedPlugin.Definition);
} catch (Exception exception) {
Log.Error(exception, "Could not disable plugin.");
this.errorModalDrawing = true;
this.errorModalOnNextFrame = true;
ImGui.NewLine();
if (!installedPlugin.IsRaw) {
ImGui.SameLine();
if (ImGui.Button(Loc.Localize("InstallerDisable", "Disable"))) {
try {
this.dalamud.PluginManager.DisablePlugin(installedPlugin.Definition);
} catch (Exception exception) {
Log.Error(exception, "Could not disable plugin.");
this.errorModalDrawing = true;
this.errorModalOnNextFrame = true;
}
}
}
@ -404,7 +410,8 @@ namespace Dalamud.Plugin
ImGui.TextColored(new Vector4(0.5f, 0.5f, 0.5f, 1.0f), $" v{pluginDefinition.AssemblyVersion}");
if(installedPlugin.IsRaw) {
ImGui.TextColored(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), "To update or disable this plugin, please remove it from the devPlugins folder.");
ImGui.SameLine();
ImGui.TextColored(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), " To update or disable this plugin, please remove it from the devPlugins folder.");
}
}

View file

@ -140,6 +140,8 @@ namespace Dalamud.Plugin
internal class PluginUpdateStatus {
public string InternalName { get; set; }
public string Name { get; set; }
public string Version { get; set; }
public bool WasUpdated { get; set; }
}
@ -244,11 +246,15 @@ namespace Dalamud.Plugin
updatedList.Add(new PluginUpdateStatus {
InternalName = remoteInfo.InternalName,
Name = remoteInfo.Name,
Version = testingAvailable ? remoteInfo.TestingAssemblyVersion : remoteInfo.AssemblyVersion,
WasUpdated = installSuccess
});
} else {
updatedList.Add(new PluginUpdateStatus {
InternalName = remoteInfo.InternalName,
Name = remoteInfo.Name,
Version = testingAvailable ? remoteInfo.TestingAssemblyVersion : remoteInfo.AssemblyVersion,
WasUpdated = true
});
}