From e3e7329fe359d4a2b8423f13920dad152d1883b7 Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Wed, 19 Jun 2024 18:43:25 -0700 Subject: [PATCH] Add tooltip for when going above 100% iterations --- Craftimizer/Configuration.cs | 2 +- Craftimizer/Windows/MacroEditor.cs | 8 ++++---- Craftimizer/Windows/RecipeNote.cs | 10 +++++++++- Craftimizer/Windows/SynthHelper.cs | 10 +++++----- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Craftimizer/Configuration.cs b/Craftimizer/Configuration.cs index da14910..d6e35cf 100644 --- a/Craftimizer/Configuration.cs +++ b/Craftimizer/Configuration.cs @@ -137,7 +137,7 @@ public partial class Configuration : IPluginConfiguration } [JsonSerializable(typeof(Configuration))] - internal partial class JsonContext : JsonSerializerContext { } + internal sealed partial class JsonContext : JsonSerializerContext { } public void Save() { diff --git a/Craftimizer/Windows/MacroEditor.cs b/Craftimizer/Windows/MacroEditor.cs index 909f823..7a8c081 100644 --- a/Craftimizer/Windows/MacroEditor.cs +++ b/Craftimizer/Windows/MacroEditor.cs @@ -1253,17 +1253,17 @@ public sealed class MacroEditor : Window, IDisposable { var percentWidth = ImGui.CalcTextSize("100%").X; var progressWidth = availSpace - percentWidth - spacing; - var fraction = Math.Clamp((float)solver.ProgressValue / solver.ProgressMax, 0, 1); + var fraction = (float)solver.ProgressValue / solver.ProgressMax; var progressColors = Colors.GetSolverProgressColors(solver.ProgressStage); using (ImRaii.PushColor(ImGuiCol.FrameBg, progressColors.Background)) using (ImRaii.PushColor(ImGuiCol.PlotHistogram, progressColors.Foreground)) - ImGui.ProgressBar(fraction, new(progressWidth, ImGui.GetFrameHeight()), string.Empty); + ImGui.ProgressBar(Math.Clamp(fraction, 0, 1), new(progressWidth, ImGui.GetFrameHeight()), string.Empty); if (ImGui.IsItemHovered()) - ImGuiUtils.Tooltip($"Solver Progress: {solver.ProgressValue} / {solver.ProgressMax}"); + RecipeNote.DrawSolverTooltip(solver); ImGui.SameLine(0, spacing); ImGui.AlignTextToFramePadding(); - ImGuiUtils.TextRight($"{fraction * 100:0}%", percentWidth); + ImGuiUtils.TextRight($"{fraction * 100:N0}%", percentWidth); } DrawMacroActions(availSpace); } diff --git a/Craftimizer/Windows/RecipeNote.cs b/Craftimizer/Windows/RecipeNote.cs index 1ba55df..e1ded2e 100644 --- a/Craftimizer/Windows/RecipeNote.cs +++ b/Craftimizer/Windows/RecipeNote.cs @@ -735,6 +735,14 @@ public sealed unsafe class RecipeNote : Window, IDisposable public Action>? MacroEditorSetter; } + public static void DrawSolverTooltip(Solver.Solver solver) + { + var tooltip = $"Solver Progress: {solver.ProgressValue:N0} / {solver.ProgressMax:N0}"; + if (solver.ProgressValue > solver.ProgressMax) + tooltip += $"\n\nThis is taking longer than expected. Check to see if your gear stats are good and the solver settings are adequate."; + ImGuiUtils.TooltipWrapped(tooltip); + } + private void DrawMacro(in MacroTaskState state, float panelWidth) { var panelTitle = state.Type switch @@ -812,7 +820,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable ImGui.ColorConvertFloat4ToU32(progressColors.Background), ImGui.ColorConvertFloat4ToU32(progressColors.Foreground)); if (ImGui.IsItemHovered()) - ImGuiUtils.Tooltip($"Solver Progress: {solver.ProgressValue} / {solver.ProgressMax}"); + DrawSolverTooltip(solver); ImGui.SameLine(0, spacing); diff --git a/Craftimizer/Windows/SynthHelper.cs b/Craftimizer/Windows/SynthHelper.cs index 4723efe..3b47284 100644 --- a/Craftimizer/Windows/SynthHelper.cs +++ b/Craftimizer/Windows/SynthHelper.cs @@ -411,17 +411,17 @@ public sealed unsafe class SynthHelper : Window, IDisposable var percentWidth = ImGui.CalcTextSize("100%").X; var progressWidth = availSpace - percentWidth - spacing; - var fraction = Math.Clamp((float)solver.ProgressValue / solver.ProgressMax, 0, 1); + var fraction = (float)solver.ProgressValue / solver.ProgressMax; var progressColors = Colors.GetSolverProgressColors(solver.ProgressStage); - + using (ImRaii.PushColor(ImGuiCol.FrameBg, progressColors.Background)) using (ImRaii.PushColor(ImGuiCol.PlotHistogram, progressColors.Foreground)) - ImGui.ProgressBar(fraction, new(progressWidth, ImGui.GetFrameHeight()), string.Empty); + ImGui.ProgressBar(Math.Clamp(fraction, 0, 1), new(progressWidth, ImGui.GetFrameHeight()), string.Empty); if (ImGui.IsItemHovered()) - ImGuiUtils.Tooltip($"Solver Progress: {solver.ProgressValue} / {solver.ProgressMax}"); + RecipeNote.DrawSolverTooltip(solver); ImGui.SameLine(0, spacing); ImGui.AlignTextToFramePadding(); - ImGuiUtils.TextRight($"{fraction * 100:0}%", percentWidth); + ImGuiUtils.TextRight($"{fraction * 100:N0}%", percentWidth); } private void DrawMacroActions()