diff --git a/Dalamud/Game/ChatHandlers.cs b/Dalamud/Game/ChatHandlers.cs index 7215568aa..91467bfc9 100644 --- a/Dalamud/Game/ChatHandlers.cs +++ b/Dalamud/Game/ChatHandlers.cs @@ -292,7 +292,7 @@ namespace Dalamud.Game this.hasAutoUpdatedPlugins = true; - Task.Run(() => pluginManager.UpdatePluginsAsync(!this.configuration.AutoUpdatePlugins)).ContinueWith(task => + Task.Run(() => pluginManager.UpdatePluginsAsync(true, !this.configuration.AutoUpdatePlugins)).ContinueWith(task => { if (task.IsFaulted) { @@ -301,7 +301,7 @@ namespace Dalamud.Game } var updatedPlugins = task.Result; - if (updatedPlugins != null && updatedPlugins.Any()) + if (updatedPlugins.Any()) { if (this.configuration.AutoUpdatePlugins) { diff --git a/Dalamud/Interface/Components/ImGuiComponents.ToggleSwitch.cs b/Dalamud/Interface/Components/ImGuiComponents.ToggleSwitch.cs index 83c238c06..bdf14b430 100644 --- a/Dalamud/Interface/Components/ImGuiComponents.ToggleSwitch.cs +++ b/Dalamud/Interface/Components/ImGuiComponents.ToggleSwitch.cs @@ -36,10 +36,10 @@ namespace Dalamud.Interface.Components } if (ImGui.IsItemHovered()) - drawList.AddRectFilled(p, new Vector2(p.X + width, p.Y + height), ImGui.GetColorU32(v ? colors[(int)ImGuiCol.ButtonActive] : new Vector4(0.78f, 0.78f, 0.78f, 1.0f)), height * 0.5f); + drawList.AddRectFilled(p, new Vector2(p.X + width, p.Y + height), ImGui.GetColorU32(!v ? colors[(int)ImGuiCol.ButtonActive] : new Vector4(0.78f, 0.78f, 0.78f, 1.0f)), height * 0.5f); else - drawList.AddRectFilled(p, new Vector2(p.X + width, p.Y + height), ImGui.GetColorU32(v ? colors[(int)ImGuiCol.Button] : new Vector4(0.55f, 0.55f, 0.55f, 1.0f)), height * 0.50f); - drawList.AddCircleFilled(new Vector2(p.X + radius + ((v ? 1 : 0) * (width - (radius * 2.0f))), p.Y + radius), radius - 1.5f, ImGui.ColorConvertFloat4ToU32(new Vector4(255, 255, 255, 255))); + drawList.AddRectFilled(p, new Vector2(p.X + width, p.Y + height), ImGui.GetColorU32(!v ? colors[(int)ImGuiCol.Button] * 0.6f : new Vector4(0.35f, 0.35f, 0.35f, 1.0f)), height * 0.50f); + drawList.AddCircleFilled(new Vector2(p.X + radius + ((v ? 1 : 0) * (width - (radius * 2.0f))), p.Y + radius), radius - 1.5f, ImGui.ColorConvertFloat4ToU32(new Vector4(1, 1, 1, 1))); return changed; } @@ -60,13 +60,12 @@ namespace Dalamud.Interface.Components var radius = height * 0.50f; // TODO: animate - // TODO: dim colors ImGui.InvisibleButton(id, new Vector2(width, height)); var dimFactor = 0.5f; drawList.AddRectFilled(p, new Vector2(p.X + width, p.Y + height), ImGui.GetColorU32(v ? colors[(int)ImGuiCol.Button] * dimFactor : new Vector4(0.55f, 0.55f, 0.55f, 1.0f) * dimFactor), height * 0.50f); - drawList.AddCircleFilled(new Vector2(p.X + radius + ((v ? 1 : 0) * (width - (radius * 2.0f))), p.Y + radius), radius - 1.5f, ImGui.ColorConvertFloat4ToU32(new Vector4(255, 255, 255, 255) * dimFactor)); + drawList.AddCircleFilled(new Vector2(p.X + radius + ((v ? 1 : 0) * (width - (radius * 2.0f))), p.Y + radius), radius - 1.5f, ImGui.ColorConvertFloat4ToU32(new Vector4(1, 1, 1, 1) * dimFactor)); } } } diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index ad4a2d41a..5d6f59a08 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -14,6 +14,7 @@ using Dalamud.Game.Command; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; using Dalamud.Interface.Internal.Notifications; +using Dalamud.Interface.Style; using Dalamud.Interface.Windowing; using Dalamud.Logging.Internal; using Dalamud.Plugin; @@ -420,7 +421,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller this.updateStatus = OperationStatus.InProgress; this.loadingIndicatorKind = LoadingIndicatorKind.UpdatingAll; - Task.Run(() => pluginManager.UpdatePluginsAsync()) + Task.Run(() => pluginManager.UpdatePluginsAsync(true, false)) .ContinueWith(task => { this.updateStatus = OperationStatus.Complete; @@ -1816,6 +1817,8 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller var isLoadedAndUnloadable = plugin.State == PluginState.Loaded || plugin.State == PluginState.DependencyResolutionFailed; + StyleModelV1.DalamudStandard.Push(); + if (plugin.State == PluginState.UnloadError) { ImGuiComponents.DisabledButton(FontAwesomeIcon.Frown); @@ -1886,6 +1889,8 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller } } + StyleModelV1.DalamudStandard.Pop(); + ImGui.SameLine(); ImGuiHelpers.ScaledDummy(15, 0); diff --git a/Dalamud/Interface/Style/StyleModel.cs b/Dalamud/Interface/Style/StyleModel.cs index 978ef78dc..a66a8ff81 100644 --- a/Dalamud/Interface/Style/StyleModel.cs +++ b/Dalamud/Interface/Style/StyleModel.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; - +using System.Numerics; using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; using Dalamud.Utility; +using ImGuiNET; using Newtonsoft.Json; using Serilog; @@ -15,6 +16,10 @@ namespace Dalamud.Interface.Style /// public abstract class StyleModel { + private static int NumPushedStyles = 0; + private static int NumPushedColors = 0; + private static bool HasPushedOnce = false; + /// /// Gets or sets the name of the style model. /// @@ -84,7 +89,7 @@ namespace Dalamud.Interface.Style configuration.SavedStyles = new List(); configuration.SavedStyles.AddRange(configuration.SavedStylesOld); - Log.Information("Transferred {0} styles", configuration.SavedStyles.Count); + Log.Information("Transferred {NumStyles} styles", configuration.SavedStyles.Count); configuration.SavedStylesOld = null; configuration.Save(); @@ -123,6 +128,60 @@ namespace Dalamud.Interface.Style /// /// Pop this style model from the ImGui style/color stack. /// - public abstract void Pop(); + public void Pop() + { + if (!HasPushedOnce) + throw new InvalidOperationException("Wasn't pushed at least once."); + + ImGui.PopStyleVar(NumPushedStyles); + ImGui.PopStyleColor(NumPushedColors); + } + + /// + /// Push a style var. + /// + /// Style kind. + /// Style var. + protected void PushStyleHelper(ImGuiStyleVar style, float arg) + { + ImGui.PushStyleVar(style, arg); + + if (!HasPushedOnce) + NumPushedStyles++; + } + + /// + /// Push a style var. + /// + /// Style kind. + /// Style var. + protected void PushStyleHelper(ImGuiStyleVar style, Vector2 arg) + { + ImGui.PushStyleVar(style, arg); + + if (!HasPushedOnce) + NumPushedStyles++; + } + + /// + /// Push a style color. + /// + /// Color kind. + /// Color value. + protected void PushColorHelper(ImGuiCol color, Vector4 value) + { + ImGui.PushStyleColor(color, value); + + if (!HasPushedOnce) + NumPushedColors++; + } + + /// + /// Indicate that you have pushed. + /// + protected void DonePushing() + { + HasPushedOnce = true; + } } } diff --git a/Dalamud/Interface/Style/StyleModelV1.cs b/Dalamud/Interface/Style/StyleModelV1.cs index 0d10387c4..54aff8f84 100644 --- a/Dalamud/Interface/Style/StyleModelV1.cs +++ b/Dalamud/Interface/Style/StyleModelV1.cs @@ -487,13 +487,41 @@ namespace Dalamud.Interface.Style /// public override void Push() { - throw new NotImplementedException(); - } + this.PushStyleHelper(ImGuiStyleVar.Alpha, this.Alpha); + this.PushStyleHelper(ImGuiStyleVar.WindowPadding, this.WindowPadding); + this.PushStyleHelper(ImGuiStyleVar.WindowRounding, this.WindowRounding); + this.PushStyleHelper(ImGuiStyleVar.WindowBorderSize, this.WindowBorderSize); + this.PushStyleHelper(ImGuiStyleVar.WindowTitleAlign, this.WindowTitleAlign); + this.PushStyleHelper(ImGuiStyleVar.ChildRounding, this.ChildRounding); + this.PushStyleHelper(ImGuiStyleVar.ChildBorderSize, this.ChildBorderSize); + this.PushStyleHelper(ImGuiStyleVar.PopupRounding, this.PopupRounding); + this.PushStyleHelper(ImGuiStyleVar.PopupBorderSize, this.PopupBorderSize); + this.PushStyleHelper(ImGuiStyleVar.FramePadding, this.FramePadding); + this.PushStyleHelper(ImGuiStyleVar.FrameRounding, this.FrameRounding); + this.PushStyleHelper(ImGuiStyleVar.FrameBorderSize, this.FrameBorderSize); + this.PushStyleHelper(ImGuiStyleVar.ItemSpacing, this.ItemSpacing); + this.PushStyleHelper(ImGuiStyleVar.ItemInnerSpacing, this.ItemInnerSpacing); + this.PushStyleHelper(ImGuiStyleVar.CellPadding, this.CellPadding); + this.PushStyleHelper(ImGuiStyleVar.IndentSpacing, this.IndentSpacing); + this.PushStyleHelper(ImGuiStyleVar.ScrollbarSize, this.ScrollbarSize); + this.PushStyleHelper(ImGuiStyleVar.ScrollbarRounding, this.ScrollbarRounding); + this.PushStyleHelper(ImGuiStyleVar.GrabMinSize, this.GrabMinSize); + this.PushStyleHelper(ImGuiStyleVar.GrabRounding, this.GrabRounding); + this.PushStyleHelper(ImGuiStyleVar.TabRounding, this.TabRounding); + this.PushStyleHelper(ImGuiStyleVar.ButtonTextAlign, this.ButtonTextAlign); + this.PushStyleHelper(ImGuiStyleVar.SelectableTextAlign, this.SelectableTextAlign); - /// - public override void Pop() - { - throw new NotImplementedException(); + foreach (var imGuiCol in Enum.GetValues()) + { + if (imGuiCol == ImGuiCol.COUNT) + { + continue; + } + + this.PushColorHelper(imGuiCol, this.Colors[imGuiCol.ToString()]); + } + + this.DonePushing(); } } } diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index 22dcbed7a..e8232d386 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -884,7 +884,7 @@ internal partial class PluginManager : IDisposable, IServiceType /// /// Perform a dry run, don't install anything. /// Success or failure and a list of updated plugin metadata. - public async Task> UpdatePluginsAsync(bool dryRun = false) + public async Task> UpdatePluginsAsync(bool ignoreDisabled, bool dryRun) { Log.Information("Starting plugin update"); @@ -897,6 +897,9 @@ internal partial class PluginManager : IDisposable, IServiceType if (plugin.InstalledPlugin.IsDev) continue; + if (plugin.InstalledPlugin.Manifest.Disabled && ignoreDisabled) + continue; + var result = await this.UpdateSinglePluginAsync(plugin, false, dryRun); if (result != null) updatedList.Add(result);