public void TextStyleEditor(TextStyle style, bool enabled = true) { GUIPlus.SetEnabledColor(enabled); Label(style.Label.Bold()); RangeSlider(style.Size, enabled); RangeSlider(style.Height, enabled); GUIPlus.ResetColor(); }
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); }
private void DrawThresholds(Rect rect) { if (_thresholds == null) { return; } GUIPlus.SetColor(Theme.BarThresholdColor.Value); foreach (var threshold in _thresholds.Where(threshold => threshold > 0f)) { Widgets.DrawLineVertical(Mathf.Round(rect.x + (rect.width * threshold)), rect.y, rect.height); } GUIPlus.ResetColor(); }
public static void CheckFontChange() { GUIPlus.SetFont(GameFont.Small); var isChanged = _baseFont != Text.CurFontStyle.font; GUIPlus.ResetFont(); if (!isChanged) { return; } _baseFont = Text.CurFontStyle.font; RegularTextStyle.UpdateStyle(); }
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 Finish(Rect rect, bool isPanel = false) { _average = (int)(_average == 0 ? _stopwatch.ElapsedMilliseconds : (_average + _stopwatch.ElapsedMilliseconds) / 2); if (_stopwatch.ElapsedMilliseconds > _max) { _max = _stopwatch.ElapsedMilliseconds; } if (isPanel) { GUIPlus.DrawText(rect, $"[[Max={_max},Avg={_average},Now={_stopwatch.ElapsedMilliseconds} ms]", Color.cyan, Theme.RegularTextStyle, TextAnchor.MiddleCenter); } else { Widgets.DrawBoxSolidWithOutline(rect, ColorBackground, ColorForeground); GUIPlus.DrawText(rect, $"[M={_max},A={_average},N={_stopwatch.ElapsedMilliseconds}]", Color.yellow, MiniTextStyle, TextAnchor.MiddleCenter); } }
public override void DoWindowContents(Rect inRect) { var listing = new ListingPlus(); listing.Begin(inRect); listing.Label("RimHUD has automatically deactivated due to the following error(s):".Bold()); listing.Label(_info.Message); if (_info.IsExternalError) { listing.Label(_info.PossibleMod == null ? "The error appears to be from outside RimHUD." : $"The error appears to be have been caused by the mod '{_info.PossibleMod.Bold()}'.", color: Color.yellow); } listing.Gap(); listing.Label("Stacktrace:".Bold(), font: GameFont.Tiny); listing.End(); var grid = inRect.GetVGrid(0f, listing.CurHeight, -1f, GUIPlus.SmallButtonHeight + GUIPlus.MediumPadding); Widgets.DrawMenuSection(grid[2]); var stacktraceRect = grid[2].ContractedBy(GUIPlus.SmallPadding); var stacktraceList = new ListingPlus(); stacktraceList.BeginScrollView(stacktraceRect, ref _scrollPosition, ref _scrollView); stacktraceList.Label(_info.StackTrace, font: GameFont.Tiny); stacktraceList.EndScrollView(ref _scrollView); grid[3].yMin += GUIPlus.MediumPadding; var buttonGrid = grid[3].GetHGrid(GUIPlus.MediumPadding, ButtonWidth, -1f, ButtonWidth, ButtonWidth); if (GUIPlus.DrawButton(buttonGrid[1], "Copy to clipboard", font: GameFont.Tiny)) { GUIUtility.systemCopyBuffer = $"[[RimHUD Auto-deactivation report]]\n{_info.Text}"; Mod.Message("RimHUD Auto-deactivation details copied to clipboard"); } if (GUIPlus.DrawButton(buttonGrid[3], "Reactivate", font: GameFont.Tiny)) { Close(); State.Activated = true; } if (GUIPlus.DrawButton(buttonGrid[4], "Close", font: GameFont.Tiny)) { Close(); } }
public override bool Draw(Rect rect) { if (_value < 0f) { return(false); } var percentage = _value / _max; var showLabel = Label != null; var grid = rect.GetHGrid(GUIPlus.TinyPadding, showLabel ? Theme.LabelWidth.Value : 0f, -1f, _valueStyle == ValueStyle.Hidden ? 0f : Theme.ValueWidth.Value); DrawText(grid[1], Label); GUIPlus.DrawBar(grid[2], percentage, GetBarColor(percentage)); DrawThresholds(grid[2]); DrawValue(grid[3], _value, _max); GUIPlus.DrawTooltip(grid[0], Tooltip, false); return(true); }
protected override void DrawContent(Rect rect) { var grid = rect.GetVGrid(Padding, -1f, ButtonHeight); _tabs.Draw(grid[1]); var button = GUIPlus.DrawButtonRow(grid[2], ButtonWidth, Padding, Lang.Get("Dialog_Config.SetToDefault"), Lang.Get("Dialog_Config.OpenFolder"), Lang.Get("Button.Close")); if (button == 1) { ConfirmSetToDefault(); } else if (button == 2) { Persistent.OpenConfigFolder(); } else if (button == 3) { Close(); } }
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(); }
private Dialog_Alert(string message, Buttons buttons = Buttons.Ok, Action onAccept = null, Action onCancel = null) { doCloseButton = false; closeOnAccept = true; closeOnClickedOutside = false; absorbInputAroundWindow = true; draggable = true; _message = message; _buttons = buttons; _onAccept = onAccept; _onCancel = onCancel; var wrap = Text.WordWrap; Text.WordWrap = true; GUIPlus.SetFont(GameFont.Small); InitialSize = new Vector2(400f, 80f + Text.CalcHeight(_message, 364f)); GUIPlus.ResetFont(); Text.WordWrap = wrap; }
public override bool Draw(Rect rect) { if (_value.NullOrEmpty() && (_fallbackValue == null)) { return(false); } var showLabel = Label != null; var grid = rect.GetHGrid(GUIPlus.TinyPadding, showLabel ? Theme.LabelWidth.Value : 0f, -1f); GUIPlus.SetColor(_color); if (showLabel) { DrawText(grid[1], Label); } DrawText(grid[2], _value, alignment: showLabel?TextAnchor.MiddleRight: (TextAnchor?)null); GUIPlus.ResetColor(); GUIPlus.DrawTooltip(grid[0], Tooltip, false); return(true); }
public void Draw(Rect rect) { if (_tabs.Length == 0) { return; } var vGrid = rect.GetVGrid(TabPadding, _tabHeight, -1f); var hGrid = vGrid[1].GetHGrid(TabPadding, Enumerable.Repeat(_tabWidth, _tabs.Length).ToArray()); for (var index = 0; index < _tabs.Length; index++) { var tab = _tabs[index]; GUIPlus.SetColor(tab == _selected ? GUIPlus.ButtonSelectedColor : (Color?)null); if (GUIPlus.DrawButton(hGrid[index + 1], tab.Label, tab.Tooltip, enabled: tab.Enabled)) { _selected = tab; } GUIPlus.ResetColor(); } _selected.Draw(vGrid[2]); }
protected override void DrawContent(Rect rect) { try { var grid = rect.GetVGrid(Padding, -1f, ButtonHeight); _tabs.Draw(grid[1]); var button = GUIPlus.DrawButtonRow(grid[2], ButtonWidth, Padding, Lang.Get("Dialog_Config.SetToDefault"), Lang.Get("Dialog_Config.OpenFolder"), Lang.Get("Button.Close")); GUIPlus.DrawText(grid[2], "Version " + Mod.Version + (Prefs.DevMode && Mod.DevMode ? "[DEV MODE - Click to disable]" : null), style: Theme.SmallTextStyle, alignment: TextAnchor.LowerRight); if (Widgets.ButtonInvisible(grid[2]) && Prefs.DevMode) { Mod.DevMode = !Mod.DevMode; HudTimings.Restart(); } if (button == 1) { ConfirmSetToDefault(); } else if (button == 2) { Persistent.OpenConfigFolder(); } else if (button == 3) { Close(); } } catch (Exception exception) { Mod.HandleError(exception); Close(); } }
protected override void DrawContent(Rect rect) { var vGrid = rect.GetVGrid(GUIPlus.LargePadding, -1f, 70f); var l = new ListingPlus(); l.BeginScrollView(vGrid[1], ref _scrollPosition, ref _scrollView); foreach (var preset in LayoutPreset.UserList) { if (_selected == null) { _selected = preset; } if (l.RadioButton_NewTemp(preset.Label, _selected == preset)) { _selected = preset; } } l.EndScrollView(ref _scrollView); l.Begin(vGrid[2]); var buttonGrid = l.GetButtonGrid(-1f, -1f); if (GUIPlus.DrawButton(buttonGrid[1], Lang.Get("Dialog_Presets.Delete"), enabled: _selected?.IsUserMade ?? false)) { ConfirmDelete(); } if (GUIPlus.DrawButton(buttonGrid[2], Lang.Get("Button.Close"))) { Close(); } l.End(); }
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(); }
public override void Draw(Rect rect) { var l = new ListingPlus(); var hGrid = rect.GetHGrid(GUIPlus.LargePadding, -1f, EditorWidth); l.Begin(hGrid[1]); l.Label(Lang.Get("Dialog_Config.Tab.Content.Editor", GetMode()).Bold()); var editorRect = l.GetRemaining(); _editor.Draw(editorRect); l.End(); l.Begin(hGrid[2]); l.Label(Lang.Get("Dialog_Config.Tab.Content.Layout").Bold()); DrawModeSelector(l); l.Gap(); DrawPresetSelector(l); var importExportGrid = l.GetButtonGrid(-1f, -1f); if (GUIPlus.DrawButton(importExportGrid[1], Lang.Get("Dialog_Config.Tab.Content.Layout.SavePreset"))) { Dialog_SavePreset.Open(); } if (GUIPlus.DrawButton(importExportGrid[2], Lang.Get("Dialog_Config.Tab.Content.Layout.ManagePresets"))) { Dialog_Presets.Open(); } l.Gap(); var canAddContainer = _editor.CanAddContainer; var canAddRow = _editor.CanAddRow; var canAddElement = _editor.CanAddElement; var hasSelected = _editor.HasSelected; l.Label(Lang.Get("Dialog_Config.Tab.Content.Component").Bold()); var moveButtonsGrid = l.GetButtonGrid(-1f, -1f); if (GUIPlus.DrawButton(moveButtonsGrid[1], Lang.Get("Dialog_Config.Tab.Content.Component.MoveUp"), enabled: hasSelected && _editor.Selected.CanMoveUp)) { _editor.Selected.MoveUp(); } if (GUIPlus.DrawButton(moveButtonsGrid[2], Lang.Get("Dialog_Config.Tab.Content.Component.MoveDown"), enabled: hasSelected && _editor.Selected.CanMoveDown)) { _editor.Selected.MoveDown(); } if (l.ButtonText(Lang.Get("Dialog_Config.Tab.Content.Component.Remove"), enabled: hasSelected && _editor.Selected.CanRemove)) { _editor.Selected.Remove(); return; } if (canAddContainer && l.ButtonText(Lang.Get("Dialog_Config.Tab.Content.Component.Stack"), Lang.Get("Dialog_Config.Tab.Content.Component.StackDesc"))) { HudModel.StackComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu(); } if (canAddContainer && l.ButtonText(Lang.Get("Dialog_Config.Tab.Content.Component.Panel"), Lang.Get("Dialog_Config.Tab.Content.Component.PanelDesc"))) { _editor.Add(HudModel.PanelComponent); } if (canAddRow && l.ButtonText(Lang.Get("Dialog_Config.Tab.Content.Component.Row"), Lang.Get("Dialog_Config.Tab.Content.Component.RowDesc"))) { _editor.Add(HudModel.RowComponent); } if (canAddElement && l.ButtonText(Lang.Get("Dialog_Config.Tab.Content.Component.Element"), Lang.Get("Dialog_Config.Tab.Content.Component.ElementDesc"))) { HudModel.ElementComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu(); } var statRecordGrid = l.GetButtonGrid(-1f, -1f); if (canAddElement && GUIPlus.DrawButton(statRecordGrid[1], Lang.Get("Dialog_Config.Tab.Content.Component.Stat"), enabled: HudModel.StatComponents.Length > 0)) { HudModel.StatComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu(); } if (canAddElement && GUIPlus.DrawButton(statRecordGrid[2], Lang.Get("Dialog_Config.Tab.Content.Component.Record"), enabled: HudModel.RecordComponents.Length > 0)) { HudModel.RecordComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu(); } var customButtonsGrid = l.GetButtonGrid(-1f, -1f); if (canAddElement && GUIPlus.DrawButton(customButtonsGrid[1], Lang.Get("Dialog_Config.Tab.Content.Component.Need"), enabled: HudModel.NeedComponents.Length > 0)) { HudModel.NeedComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu(); } if (canAddElement && GUIPlus.DrawButton(customButtonsGrid[2], Lang.Get("Dialog_Config.Tab.Content.Component.SkillOrTraining"), enabled: HudModel.SkillAndTrainingComponents.Length > 0)) { HudModel.SkillAndTrainingComponents.Select(item => new FloatMenuOption(item.Label, () => _editor.Add(item))).ShowMenu(); } l.End(); if (!hasSelected || _editor.Selected.IsRoot) { return; } var selectedRect = hGrid[2].GetVGrid(GUIPlus.MediumPadding, -1f, SelectedHeight)[2]; l.Begin(selectedRect); l.Label(Lang.Get("Dialog_Config.Tab.Content.Selected").Bold() + _editor.Selected.Label.Bold().Italic()); var targets = HudTarget.None; if (l.CheckboxLabeled(Lang.Get("Model.Target.PlayerHumanlike"), _editor.Selected.Targets.HasTarget(HudTarget.PlayerHumanlike), enabled: _editor.Selected.Targets != HudTarget.PlayerHumanlike)) { targets |= HudTarget.PlayerHumanlike; } if (l.CheckboxLabeled(Lang.Get("Model.Target.PlayerCreature"), _editor.Selected.Targets.HasTarget(HudTarget.PlayerCreature), enabled: _editor.Selected.Targets != HudTarget.PlayerCreature)) { targets |= HudTarget.PlayerCreature; } if (l.CheckboxLabeled(Lang.Get("Model.Target.OtherHumanlike"), _editor.Selected.Targets.HasTarget(HudTarget.OtherHumanlike), enabled: _editor.Selected.Targets != HudTarget.OtherHumanlike)) { targets |= HudTarget.OtherHumanlike; } if (l.CheckboxLabeled(Lang.Get("Model.Target.OtherCreature"), _editor.Selected.Targets.HasTarget(HudTarget.OtherCreature), enabled: _editor.Selected.Targets != HudTarget.OtherCreature)) { targets |= HudTarget.OtherCreature; } _editor.Selected.Targets = targets; if (_editor.Selected.Type == LayoutItemType.Stack || _editor.Selected.Type == LayoutItemType.Panel) { _editor.Selected.FillHeight = l.CheckboxLabeled(Lang.Get("Dialog_Config.Tab.Content.Selected.Filled"), _editor.Selected.FillHeight, Lang.Get("Dialog_Config.Tab.Content.Selected.FilledDesc")); } l.End(); }
protected void DrawText(Rect rect, string text, Color?color = null, TextAnchor?alignment = null) => GUIPlus.DrawText(rect, text, color, _textStyle, alignment);