public static void Dialog_Checkbox(this Listing_Standard list, string desc, ref bool forBool, bool addGap = true) { var label = desc.SafeTranslate(); var indent = 24 + "_".GetWidthCached(); var height = Math.Max(Text.LineHeight, Text.CalcHeight(label, list.ColumnWidth - indent)); var rect = list.GetRect(height); rect.xMin += inset; var oldValue = forBool; var butRect = rect; butRect.xMin += 24f; if (Widgets.ButtonInvisible(butRect, false)) { forBool = !forBool; } if (forBool != oldValue) { SoundDefOf.RadioButtonClicked.PlayOneShotOnCamera(null); } Widgets.Checkbox(new Vector2(rect.x, rect.y - 1f), ref forBool); var curX = GetterSetters.curXByRef(list); GetterSetters.curXByRef(list) = curX + indent; var anchor = Text.Anchor; Text.Anchor = TextAnchor.UpperLeft; rect.xMin += indent; var color = GUI.color; GUI.color = contentColor; Widgets.Label(rect, label); GUI.color = color; Text.Anchor = anchor; GetterSetters.curXByRef(list) = curX; if (addGap) { list.Gap(2 * list.verticalSpacing); } }
public static bool Dialog_RadioButton(this Listing_Standard list, bool active, string desc) { var label = desc.SafeTranslate(); var indent = 24 + "_".GetWidthCached(); var height = Math.Max(Text.LineHeight, Text.CalcHeight(label, list.ColumnWidth - indent)); var rect = list.GetRect(height); rect.xMin += inset; var line = new Rect(rect); var result = Widgets.RadioButton(line.xMin, line.yMin, active); var curX = GetterSetters.curXByRef(list); GetterSetters.curXByRef(list) = curX + indent; var anchor = Text.Anchor; Text.Anchor = TextAnchor.UpperLeft; line.xMin += indent; var color = GUI.color; GUI.color = contentColor; Widgets.Label(line, label); GUI.color = color; Text.Anchor = anchor; GetterSetters.curXByRef(list) = curX; result |= Widgets.ButtonInvisible(rect, false); if (result && !active) { SoundDefOf.RadioButtonClicked.PlayOneShotOnCamera(null); } list.Gap(list.verticalSpacing * 2); return(result); }