Esempio n. 1
0
        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);
            if (!Hud.IsMouseOverConfigButton && Widgets.ButtonInvisible(rect.ExpandedBy(GUIPlus.TinyPadding)))
            {
                _onClick?.Invoke();
            }
            GUIPlus.ResetColor();

            if (!Hud.IsMouseOverConfigButton)
            {
                GUIPlus.DrawTooltip(grid[0], Tooltip, false);
            }
            return(true);
        }
Esempio n. 2
0
 public override bool Draw(HudComponent component, Rect rect)
 {
     GUIPlus.SetColor(Theme.LineColor.Value);
     Widgets.DrawLineHorizontal(rect.x, rect.y + (rect.height / 2f), rect.width);
     GUIPlus.ResetColor();
     return(true);
 }
Esempio n. 3
0
 public void ColorOptionSelect(ColorOption colorOption, ref ColorOption selected, bool enabled = true)
 {
     GUIPlus.SetColor(colorOption.Value);
     if (RadioButton(colorOption.Label, selected == colorOption, tooltip: colorOption.Tooltip))
     {
         selected = colorOption;
     }
     GUIPlus.ResetColor();
 }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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();
        }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        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();
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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]);
        }
Esempio n. 11
0
 public void BoolToggle(BoolOption option, bool enabled = true)
 {
     GUIPlus.SetEnabledColor(enabled);
     option.Value = CheckboxLabeled(option.Label, option.Value, option.Tooltip, enabled);
     GUIPlus.ResetColor();
 }
Esempio n. 12
0
        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();
        }