Skip to content

Commit 21c92f7

Browse files
DaleStanshpaass
authored andcommitted
Add a tooltip for the net production checkbox too.
1 parent 7323cf5 commit 21c92f7

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

Yafc.UI/ImGui/ImGuiUtils.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,9 @@ public static bool CloseDropdown(this ImGui gui) {
387387
/// Draws a row with a (?) help icon at its right side, and a tooltip when the user hovers over the icon.
388388
/// </summary>
389389
/// <param name="tooltip">The tooltip that should be displayed when the user hovers over the (?) icon.</param>
390-
public static IDisposable EnterRowWithHelpIcon(this ImGui gui, string tooltip) => new RowWithHelpIcon(gui, tooltip);
390+
/// <param name="rightJustify">If <see langword="true"/>, the default, the help icon will be as far right as possible.
391+
/// If false, it will be still be drawn at the right end of the row, but as far left as possible.</param>
392+
public static IDisposable EnterRowWithHelpIcon(this ImGui gui, string tooltip, bool rightJustify = true) => new RowWithHelpIcon(gui, tooltip, rightJustify);
391393

392394
/// <summary>
393395
/// 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 {
399401
private readonly float helpCenterX;
400402
private readonly ImGui.Context group;
401403

402-
public RowWithHelpIcon(ImGui gui, string tooltip) {
404+
public RowWithHelpIcon(ImGui gui, string tooltip, bool rightJustify) {
403405
this.gui = gui;
404406
this.tooltip = tooltip;
405407
row = gui.EnterRow(); // using (gui.EnterRow()) {
406-
gui.allocator = RectAllocator.RightRow;
407-
helpCenterX = gui.AllocateRect(1, 1).Center.X;
408-
group = gui.EnterGroup(new Padding(), RectAllocator.RemainingRow); // using (gui.EnterGroup(...)) { // Required to produce the expected spacing/padding behavior.
409-
gui.allocator = RectAllocator.LeftRow;
408+
if (rightJustify) {
409+
gui.allocator = RectAllocator.RightRow;
410+
helpCenterX = gui.AllocateRect(1, 1).Center.X;
411+
group = gui.EnterGroup(new Padding(), RectAllocator.RemainingRow); // using (gui.EnterGroup(...)) { // Required to produce the expected spacing/padding behavior.
412+
gui.allocator = RectAllocator.LeftRow;
413+
}
410414
}
411415

412416
public void Dispose() {
413-
group.Dispose(); // end using block for EnterGroup
414-
Rect rect = Rect.Square(helpCenterX, gui.lastRect.Center.Y, 1.25f);
417+
Rect rect;
418+
if (helpCenterX != 0) { // if (rightJustify)
419+
group.Dispose(); // end using block for EnterGroup
420+
rect = Rect.Square(helpCenterX, gui.lastRect.Center.Y, 1.25f);
421+
}
422+
else {
423+
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.
424+
rect = Rect.Square(rect.Center, 1.25f); // Get a vertically-centered rect that's actually 1.25 x 1.25.
425+
}
415426
gui.DrawIcon(rect, Icon.Help, SchemeColor.BackgroundText);
416427
gui.BuildButton(rect, SchemeColor.None, SchemeColor.Grey).WithTooltip(gui, tooltip, rect);
417428
row.Dispose(); // end using block for EnterRow

Yafc/Windows/WelcomeScreen.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ protected override void BuildContents(ImGui gui) {
142142
gui.BuildText("In-game objects language:");
143143
}
144144

145-
using (gui.EnterRow()) {
145+
using (gui.EnterRowWithHelpIcon("""
146+
If checked, YAFC will only suggest production or consumption recipes that have a net production or consumption of that item or fluid.
147+
For example, kovarex enrichment will not be suggested when adding recipes that produce U-238 or consume U-235.
148+
""", false)) {
146149
gui.BuildCheckBox("Use net production/consumption when analyzing recipes", netProduction, out netProduction);
147150
}
148151

0 commit comments

Comments
 (0)