public bool CheckboxLabeled(string label, bool value, string tooltip = null, bool enabled = true) { GUIPlus.SetEnabledColor(enabled); var previous = value; CheckboxLabeled(label, ref value, tooltip); GUIPlus.ResetColor(); return(enabled ? value : previous); }
public bool Label(string label, TipSignal?tooltip = null, GameFont?font = null, Color?color = null, bool highlight = false) { GUIPlus.SetFont(font); GUIPlus.SetColor(color); var rect = GetRect(Text.CalcHeight(label, ColumnWidth)); Widgets.Label(rect, label); GUIPlus.DrawTooltip(rect, tooltip, highlight); Gap(verticalSpacing); GUIPlus.ResetColor(); GUIPlus.ResetFont(); return(Widgets.ButtonInvisible(rect)); }
public void RangeSlider(RangeOption range, bool enabled = true) { GUIPlus.SetEnabledColor(enabled); var grid = GetRect(Text.LineHeight).GetHGrid(ElementPadding, LabelWidth, ValueWidth, -1f); GUIPlus.DrawText(grid[1], range.Label); GUIPlus.DrawText(grid[2], range.ToString()); var value = Mathf.RoundToInt(Widgets.HorizontalSlider(grid[3], range.Value, range.Min, range.Max, true)); if (enabled) { range.Value = value; } GUIPlus.DrawTooltip(grid[0], range.Tooltip, true); Gap(verticalSpacing); GUIPlus.ResetColor(); }
public static void OnGUI(Rect inRect, IInspectPane pane) { Theme.CheckFontChange(); var model = PawnModel.Selected; pane.RecentHeight = Theme.InspectPaneHeight.Value - 35f; if (model == null) { return; } if (!pane.AnythingSelected) { return; } var rect = inRect.ContractedBy(12f); rect.yMin -= 4f; rect.yMax += 6f; try { GUI.BeginGroup(rect.ExpandedBy(1f)); var lineEndWidth = 0f; if (pane.ShouldShowSelectNextInCellButton) { var selectOverlappingNextRect = new Rect(rect.width - ButtonSize, 0f, ButtonSize, ButtonSize); if (Widgets.ButtonImage(selectOverlappingNextRect, Textures.SelectOverlappingNext)) { pane.SelectNextInCell(); } lineEndWidth += ButtonSize; TooltipHandler.TipRegion(selectOverlappingNextRect, "SelectNextInSquareTip".Translate(KeyBindingDefOf.SelectNextInCell.MainKeyLabel)); } DrawButtons(rect, ref lineEndWidth); var previousAnchor = Text.Anchor; Text.Anchor = TextAnchor.UpperLeft; GUIPlus.SetFont(GameFont.Medium); GUIPlus.SetColor(model.FactionRelationColor); var labelRect = new Rect(0f, 0f, rect.width - lineEndWidth, Text.LineHeight); var label = model.Name; Widgets.Label(labelRect, label); if (Widgets.ButtonInvisible(labelRect)) { ToggleSocialTab(); } GUIPlus.ResetFont(); GUIPlus.ResetColor(); Text.Anchor = previousAnchor; GUIPlus.DrawTooltip(labelRect, model.BioTooltip, false); if (!pane.ShouldShowPaneContents) { return; } var contentRect = rect.AtZero(); contentRect.yMin += 26f; DrawContent(contentRect, model, null); } catch (Exception exception) { Mod.HandleError(exception); } finally { GUI.EndGroup(); } }
private static void DrawButtons(Rect rect, ref float lineEndWidth) { if (Find.Selector.NumSelected != 1) { return; } var selected = Find.Selector.SingleSelectedThing; if (selected == null) { return; } lineEndWidth += ButtonSize; Widgets.InfoCardButton(rect.width - lineEndWidth, 0f, selected); if (!(selected is Pawn pawn) || !PlayerControlled(pawn)) { return; } if (pawn.playerSettings.UsesConfigurableHostilityResponse) { lineEndWidth += ButtonSize; HostilityResponseModeUtility.DrawResponseButton(new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize), pawn, false); lineEndWidth += GUIPlus.SmallPadding; } lineEndWidth += ButtonSize; var careRect = new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize); MedicalCareUtility.MedicalCareSelectButton(careRect, pawn); GUIPlus.DrawTooltip(careRect, new TipSignal(() => Lang.Get("InspectPane.MedicalCare", pawn.KindLabel, pawn.playerSettings.medCare.GetLabel()), GUIPlus.TooltipId), true); lineEndWidth += GUIPlus.SmallPadding; if (!pawn.IsColonist) { return; } lineEndWidth += ButtonSize; var canDoctor = !pawn.WorkTypeIsDisabled(WorkTypeDefOf.Doctor); var canDoctorPriority = (pawn.workSettings == null) || (pawn.workSettings?.GetPriority(WorkTypeDefOf.Doctor) > 0); var selfTendRect = new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize); var selfTendTip = "SelfTendTip".Translate(Faction.OfPlayer.def.pawnsPlural, 0.7f.ToStringPercent()).CapitalizeFirst(); if (!canDoctor) { selfTendTip += "\n\n" + "MessageCannotSelfTendEver".Translate(pawn.LabelShort, pawn); } else if (!canDoctorPriority) { selfTendTip += "\n\n" + "MessageSelfTendUnsatisfied".Translate(pawn.LabelShort, pawn); } GUIPlus.SetFont(GameFont.Tiny); var selfTend = pawn.playerSettings.selfTend; selfTend = GUIPlus.DrawToggle(selfTendRect, selfTend, new TipSignal(() => selfTendTip, GUIPlus.TooltipId), canDoctor, Textures.SelfTendOnIcon, Textures.SelfTendOffIcon); if (selfTend != pawn.playerSettings.selfTend) { Mod_Multiplayer.SetSelfTend(pawn, selfTend); } GUIPlus.ResetFont(); lineEndWidth += GUIPlus.SmallPadding; }
public void BoolToggle(BoolOption option, bool enabled = true) { GUIPlus.SetEnabledColor(enabled); option.Value = CheckboxLabeled(option.Label, option.Value, option.Tooltip, enabled); GUIPlus.ResetColor(); }
public void RangeSliderEntry(RangeOption range, ref string text, int id, bool enabled = true) { GUIPlus.SetEnabledColor(enabled); var grid = GetRect(Text.LineHeight).GetHGrid(ElementPadding, LabelWidth, ValueWidth, -1f); GUIPlus.DrawText(grid[1], range.Label); var entryName = "RangeSliderEntry_Text" + id; var isFocused = GUI.GetNameOfFocusedControl() == entryName; if (!isFocused) { text = range.Value.ToString(); } GUI.SetNextControlName(entryName); var newText = Widgets.TextField(grid[2], text, 5, RangeSliderEntryRegex); if (enabled) { text = newText; } var textValue = text.ToInt(); if (textValue.HasValue) { if (textValue.Value < range.Min) { range.Value = range.Min; } else if (textValue.Value > range.Max) { range.Value = range.Max; } else { range.Value = textValue.Value; } } var sliderName = "RangeSliderEntry_Slider" + id; GUI.SetNextControlName(sliderName); var sliderValue = Mathf.RoundToInt(Widgets.HorizontalSlider(grid[3], range.Value, range.Min, range.Max, true)); if (enabled && (range.Value != sliderValue)) { range.Value = sliderValue; text = range.Value.ToString(); } if (Widgets.ButtonInvisible(grid[3])) { GUI.FocusControl(sliderName); } GUIPlus.DrawTooltip(grid[0], range.Tooltip, true); Gap(verticalSpacing); GUIPlus.ResetColor(); }