From d756dc0287b459db556881d30ab32bbe64d39a58 Mon Sep 17 00:00:00 2001 From: Aireil <33433913+Aireil@users.noreply.github.com> Date: Wed, 9 Dec 2020 15:02:37 +0100 Subject: [PATCH 1/4] Fix new line if no disable button --- Dalamud/Plugin/PluginInstallerWindow.cs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Dalamud/Plugin/PluginInstallerWindow.cs b/Dalamud/Plugin/PluginInstallerWindow.cs index 2ecb4b441..7ab96d310 100644 --- a/Dalamud/Plugin/PluginInstallerWindow.cs +++ b/Dalamud/Plugin/PluginInstallerWindow.cs @@ -365,13 +365,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; + } } } @@ -397,7 +403,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."); } } From 42e817032fff7ac4c8079fb40da47d5be79c00d9 Mon Sep 17 00:00:00 2001 From: Aireil <33433913+Aireil@users.noreply.github.com> Date: Thu, 10 Dec 2020 01:04:21 +0100 Subject: [PATCH 2/4] Fix the sort by size --- Dalamud/Plugin/PluginInstallerWindow.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dalamud/Plugin/PluginInstallerWindow.cs b/Dalamud/Plugin/PluginInstallerWindow.cs index 9a0206a89..e2e04225c 100644 --- a/Dalamud/Plugin/PluginInstallerWindow.cs +++ b/Dalamud/Plugin/PluginInstallerWindow.cs @@ -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; From bfb0b536c5286a8bdf8229023a061c101748a958 Mon Sep 17 00:00:00 2001 From: Aireil <33433913+Aireil@users.noreply.github.com> Date: Sun, 13 Dec 2020 04:25:25 +0100 Subject: [PATCH 3/4] Add an auto-updater for plugins --- Dalamud/Configuration/DalamudConfiguration.cs | 1 + Dalamud/Game/ChatHandlers.cs | 38 +++++++++++++------ Dalamud/Interface/DalamudSettingsWindow.cs | 6 +++ Dalamud/Plugin/PluginRepository.cs | 6 +++ 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Dalamud/Configuration/DalamudConfiguration.cs b/Dalamud/Configuration/DalamudConfiguration.cs index 5d11508f2..2edba97f2 100644 --- a/Dalamud/Configuration/DalamudConfiguration.cs +++ b/Dalamud/Configuration/DalamudConfiguration.cs @@ -32,6 +32,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; diff --git a/Dalamud/Game/ChatHandlers.cs b/Dalamud/Game/ChatHandlers.cs index 889e0e6c7..78df4ae1f 100644 --- a/Dalamud/Game/ChatHandlers.cs +++ b/Dalamud/Game/ChatHandlers.cs @@ -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; } diff --git a/Dalamud/Interface/DalamudSettingsWindow.cs b/Dalamud/Interface/DalamudSettingsWindow.cs index 29e2a8a2a..d753e4bef 100644 --- a/Dalamud/Interface/DalamudSettingsWindow.cs +++ b/Dalamud/Interface/DalamudSettingsWindow.cs @@ -30,6 +30,7 @@ namespace Dalamud.Interface this.doDalamudTest = this.dalamud.Configuration.DoDalamudTest; this.printPluginsWelcomeMsg = this.dalamud.Configuration.PrintPluginsWelcomeMsg; + this.autoUpdatePlugins = this.dalamud.Configuration.AutoUpdatePlugins; this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray(); try { @@ -87,6 +88,7 @@ namespace Dalamud.Interface private bool doToggleUiHideDuringGpose; private bool printPluginsWelcomeMsg; + private bool autoUpdatePlugins; #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.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(); } @@ -218,6 +223,7 @@ namespace Dalamud.Interface this.dalamud.Configuration.DoDalamudTest = this.doDalamudTest; this.dalamud.Configuration.PrintPluginsWelcomeMsg = this.printPluginsWelcomeMsg; + this.dalamud.Configuration.AutoUpdatePlugins = this.autoUpdatePlugins; this.dalamud.Configuration.Save(); } diff --git a/Dalamud/Plugin/PluginRepository.cs b/Dalamud/Plugin/PluginRepository.cs index d5773a9e8..8c56fb313 100644 --- a/Dalamud/Plugin/PluginRepository.cs +++ b/Dalamud/Plugin/PluginRepository.cs @@ -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 }); } From 3e87c8600bbacfdcff80eac0285b555d85cf4132 Mon Sep 17 00:00:00 2001 From: Cara Date: Mon, 14 Dec 2020 05:56:59 +1030 Subject: [PATCH 4/4] Update UiStatusEffects Offset --- Dalamud/Game/ClientState/Structs/Actor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Game/ClientState/Structs/Actor.cs b/Dalamud/Game/ClientState/Structs/Actor.cs index 10aa3be77..0ad4669dd 100644 --- a/Dalamud/Game/ClientState/Structs/Actor.cs +++ b/Dalamud/Game/ClientState/Structs/Actor.cs @@ -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