private Rect DrawTitle(Rect rect) { if (Title.NullOrEmpty()) { return(rect); } var header = new ListingPlus(); header.Begin(rect); header.Label(Title, font: GameFont.Medium); if (!string.IsNullOrEmpty(Subtitle)) { var titleSize = GUIPlus.GetTextSize(Title, GUIPlus.GetGameFontStyle(GameFont.Medium)); var titleOffset = titleSize.x + GUIPlus.MediumPadding; var subtitleRect = new Rect(rect.x + titleOffset, rect.y, rect.width - titleOffset, titleSize.y); GUIPlus.DrawText(subtitleRect, Subtitle, style: Theme.SmallTextStyle); } header.GapLine(); header.End(); var contentRect = new Rect(rect.x, rect.y + header.CurHeight, rect.width, rect.height - header.CurHeight); if (doCloseButton) { contentRect.height -= CloseButtonOffset; } return(contentRect); }
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, style: Theme.SmallTextStyle, alignment: TextAnchor.LowerRight); if (button == 1) { ConfirmSetToDefault(); } else if (button == 2) { Persistent.OpenConfigFolder(); } else if (button == 3) { Close(); } } catch (Exception exception) { Mod.HandleError(exception); Close(); } }
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 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(); }
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(); } }
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(); }
protected void DrawText(Rect rect, string text, Color?color = null, TextAnchor?alignment = null) => GUIPlus.DrawText(rect, text, color, _textStyle, alignment);