From 21c92f7589bb37f3899a0caf6560107057dcfb37 Mon Sep 17 00:00:00 2001 From: Dale McCoy <21223975+DaleStan@users.noreply.github.com> Date: Fri, 26 Jul 2024 19:11:18 -0400 Subject: [PATCH] Add a tooltip for the net production checkbox too. --- Yafc.UI/ImGui/ImGuiUtils.cs | 27 +++++++++++++++++++-------- Yafc/Windows/WelcomeScreen.cs | 5 ++++- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Yafc.UI/ImGui/ImGuiUtils.cs b/Yafc.UI/ImGui/ImGuiUtils.cs index b88f70dd..e2716458 100644 --- a/Yafc.UI/ImGui/ImGuiUtils.cs +++ b/Yafc.UI/ImGui/ImGuiUtils.cs @@ -387,7 +387,9 @@ public static bool CloseDropdown(this ImGui gui) { /// Draws a row with a (?) help icon at its right side, and a tooltip when the user hovers over the icon. /// /// The tooltip that should be displayed when the user hovers over the (?) icon. - public static IDisposable EnterRowWithHelpIcon(this ImGui gui, string tooltip) => new RowWithHelpIcon(gui, tooltip); + /// If , the default, the help icon will be as far right as possible. + /// If false, it will be still be drawn at the right end of the row, but as far left as possible. + public static IDisposable EnterRowWithHelpIcon(this ImGui gui, string tooltip, bool rightJustify = true) => new RowWithHelpIcon(gui, tooltip, rightJustify); /// /// The class that sets up and stores the state needed to build a row with a help icon. @@ -399,19 +401,28 @@ private sealed class RowWithHelpIcon : IDisposable { private readonly float helpCenterX; private readonly ImGui.Context group; - public RowWithHelpIcon(ImGui gui, string tooltip) { + public RowWithHelpIcon(ImGui gui, string tooltip, bool rightJustify) { this.gui = gui; this.tooltip = tooltip; row = gui.EnterRow(); // using (gui.EnterRow()) { - gui.allocator = RectAllocator.RightRow; - helpCenterX = gui.AllocateRect(1, 1).Center.X; - group = gui.EnterGroup(new Padding(), RectAllocator.RemainingRow); // using (gui.EnterGroup(...)) { // Required to produce the expected spacing/padding behavior. - gui.allocator = RectAllocator.LeftRow; + if (rightJustify) { + gui.allocator = RectAllocator.RightRow; + helpCenterX = gui.AllocateRect(1, 1).Center.X; + group = gui.EnterGroup(new Padding(), RectAllocator.RemainingRow); // using (gui.EnterGroup(...)) { // Required to produce the expected spacing/padding behavior. + gui.allocator = RectAllocator.LeftRow; + } } public void Dispose() { - group.Dispose(); // end using block for EnterGroup - Rect rect = Rect.Square(helpCenterX, gui.lastRect.Center.Y, 1.25f); + Rect rect; + if (helpCenterX != 0) { // if (rightJustify) + group.Dispose(); // end using block for EnterGroup + rect = Rect.Square(helpCenterX, gui.lastRect.Center.Y, 1.25f); + } + else { + rect = gui.AllocateRect(1.25f, 1.25f); // Despite requesting 1.25 x 1.25, rect will be 1.25 x RowHeight, which might be greater than 1.25. + rect = Rect.Square(rect.Center, 1.25f); // Get a vertically-centered rect that's actually 1.25 x 1.25. + } gui.DrawIcon(rect, Icon.Help, SchemeColor.BackgroundText); gui.BuildButton(rect, SchemeColor.None, SchemeColor.Grey).WithTooltip(gui, tooltip, rect); row.Dispose(); // end using block for EnterRow diff --git a/Yafc/Windows/WelcomeScreen.cs b/Yafc/Windows/WelcomeScreen.cs index 6a5bc97c..fb815834 100644 --- a/Yafc/Windows/WelcomeScreen.cs +++ b/Yafc/Windows/WelcomeScreen.cs @@ -142,7 +142,10 @@ protected override void BuildContents(ImGui gui) { gui.BuildText("In-game objects language:"); } - using (gui.EnterRow()) { + using (gui.EnterRowWithHelpIcon(""" + If checked, YAFC will only suggest production or consumption recipes that have a net production or consumption of that item or fluid. + For example, kovarex enrichment will not be suggested when adding recipes that produce U-238 or consume U-235. + """, false)) { gui.BuildCheckBox("Use net production/consumption when analyzing recipes", netProduction, out netProduction); }