public TileElement(HudParentBase parent = null) : base(parent)
                {
                    background = new TexturedBox(this)
                    {
                        DimAlignment = DimAlignments.Both,
                        Color        = TerminalFormatting.Gunmetal,
                    };

                    var border = new BorderBox(this)
                    {
                        DimAlignment = DimAlignments.Both,
                        Color        = new Color(58, 68, 77),
                        Thickness    = 1f,
                    };

                    controls = new HudChain <TerminalControlBase>(true, this)
                    {
                        DimAlignment = DimAlignments.Width | DimAlignments.IgnorePadding,
                        SizingMode   = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                        Spacing      = 12f,
                    };

                    Padding = new Vector2(16f);
                    Size    = new Vector2(300f, 250f);
                }
Exemplo n.º 2
0
            public NamedDropdown(HudParentBase parent = null) : base(parent)
            {
                name = new Label()
                {
                    Format     = TerminalFormatting.ControlFormat,
                    Text       = "NewDropdown",
                    AutoResize = false,
                    Height     = 24f,
                };

                dropdown = new Dropdown <T>()
                {
                    Format          = TerminalFormatting.ControlFormat,
                    DropdownHeight  = 172f,
                    MinVisibleCount = 6
                };

                hudChain = new HudChain(true, this)
                {
                    SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                    CollectionContainer = { name, dropdown },
                };

                Padding = new Vector2(20f, 0f);
                Size    = new Vector2(250f, 66f);
            }
            public PropertyWheelWidgetBase(HudParentBase parent = null) : base(parent)
            {
                confirmButton = new BorderedButton()
                {
                    Text        = "Confirm",
                    Height      = 40f,
                    Width       = 150f,
                    Padding     = Vector2.Zero,
                    TextPadding = Vector2.Zero,
                };
                cancelButton = new BorderedButton()
                {
                    Text        = "Cancel",
                    Height      = 40f,
                    Width       = 150f,
                    Padding     = Vector2.Zero,
                    TextPadding = Vector2.Zero,
                };

                buttonChain = new HudChain(false)
                {
                    ParentAlignment     = ParentAlignments.Left | ParentAlignments.Inner,
                    Spacing             = 8f,
                    CollectionContainer = { confirmButton, cancelButton }
                };

                DimAlignment = DimAlignments.Width | DimAlignments.IgnorePadding;

                MouseInput = new MouseInputElement(this)
                {
                    ZOffset      = 10,
                    DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding,
                    ShareCursor  = true,
                };
            }
Exemplo n.º 4
0
            public NamedListBox(HudParentBase parent = null) : base(parent)
            {
                name = new Label()
                {
                    Format     = TerminalFormatting.ControlFormat,
                    Text       = "NewListBox",
                    AutoResize = false,
                    Height     = 24f,
                };

                listBox = new ListBox <T>()
                {
                    Format          = TerminalFormatting.ControlFormat,
                    Height          = 172f,
                    MinVisibleCount = 6
                };

                hudChain = new HudChain(true, this)
                {
                    SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                    CollectionContainer = { name, listBox },
                    Spacing             = 2f
                };

                Padding = new Vector2(10f, 0f);
                Size    = new Vector2(250f, 200f);
            }
Exemplo n.º 5
0
        public NamedOnOffButton(HudParentBase parent) : base(parent)
        {
            name = new Label()
            {
                Format     = TerminalFormatting.ControlFormat.WithAlignment(TextAlignment.Center),
                Text       = "NewOnOffButton",
                AutoResize = false,
                Height     = 22f,
            };

            onOffButton = new OnOffButton()
            {
                Padding = new Vector2(78f, 0f),
            };

            layout = new HudChain(true, this)
            {
                SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                DimAlignment        = DimAlignments.Width | DimAlignments.IgnorePadding,
                Spacing             = 2f,
                CollectionContainer = { name, onOffButton }
            };

            Padding = new Vector2(20f, 0f);
            Size    = new Vector2(300f, 84f);
        }
Exemplo n.º 6
0
                public BindBox(HudParentBase parent = null) : base(parent)
                {
                    bindName = new Label(this)
                    {
                        Text            = "NewBindBox",
                        Format          = GlyphFormat.Blueish,
                        AutoResize      = false,
                        Size            = new Vector2(150f, 44f),
                        ParentAlignment = ParentAlignments.Left | ParentAlignments.InnerH,
                        DimAlignment    = DimAlignments.Height | DimAlignments.IgnorePadding,
                    };

                    con1 = new BorderedButton()
                    {
                        Text            = "none",
                        Padding         = new Vector2(),
                        Size            = new Vector2(126f, 44f),
                        BorderThickness = 1f,
                    };

                    con1.MouseInput.LeftClicked  += (sender, args) => GetNewControl(0);
                    con1.MouseInput.RightClicked += (sender, args) => RemoveControl(0);

                    con2 = new BorderedButton()
                    {
                        Text            = "none",
                        Padding         = new Vector2(),
                        Size            = new Vector2(126f, 44f),
                        BorderThickness = 1f,
                    };

                    con2.MouseInput.LeftClicked  += (sender, args) => GetNewControl(1);
                    con2.MouseInput.RightClicked += (sender, args) => RemoveControl(1);

                    con3 = new BorderedButton()
                    {
                        Text            = "none",
                        Padding         = new Vector2(),
                        Size            = new Vector2(126f, 44f),
                        BorderThickness = 1f,
                    };

                    con3.MouseInput.LeftClicked  += (sender, args) => GetNewControl(2);
                    con3.MouseInput.RightClicked += (sender, args) => RemoveControl(2);

                    layout = new HudChain(false, this)
                    {
                        SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                        Spacing             = 13f,
                        Padding             = new Vector2(32f, 0f),
                        ParentAlignment     = ParentAlignments.Right | ParentAlignments.InnerH,
                        DimAlignment        = DimAlignments.Height | DimAlignments.IgnorePadding,
                        CollectionContainer = { con1, con2, con3 }
                    };

                    Size = new Vector2(400f, 44f);
                }
Exemplo n.º 7
0
                public BindGroupBox(HudParentBase parent = null) : base(parent)
                {
                    name = new Label()
                    {
                        Format     = GlyphFormat.White,
                        AutoResize = false,
                        Height     = 24f,
                        Padding    = new Vector2(0f, 24f),
                    };

                    resetButton = new BorderedButton(this)
                    {
                        Text            = "Defaults",
                        Size            = new Vector2(234f, 44f),
                        ParentAlignment = ParentAlignments.Top | ParentAlignments.Right | ParentAlignments.Inner,
                        Visible         = false,
                        BorderThickness = 1f,
                    };

                    resetButton.MouseInput.LeftClicked += ResetBinds;

                    scrollBox = new ScrollBox <ScrollBoxEntry <BindBox>, BindBox>(true)
                    {
                        SizingMode = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainOffAxis | HudChainSizingModes.ClampChainAlignAxis,
                        Spacing    = 8f,
                    };

                    scrollBox.Background.Visible = false;

                    var divider1 = new TexturedBox()
                    {
                        Color   = new Color(53, 66, 75),
                        Padding = new Vector2(0f, 16f),
                        Height  = 2f,
                    };

                    var divider2 = new TexturedBox()
                    {
                        Color   = new Color(53, 66, 75),
                        Padding = new Vector2(0f, 16f),
                        Height  = 2f,
                    };

                    layout = new HudChain(true, this)
                    {
                        SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                        DimAlignment        = DimAlignments.Width | DimAlignments.IgnorePadding,
                        Padding             = new Vector2(20f, 0f),
                        Offset              = new Vector2(-10f, 0f),
                        CollectionContainer = { name, divider1, scrollBox, divider2 },
                    };

                    Height = 338f;
                }
                public CategoryElement(bool alignVertical, HudParentBase parent = null) : base(parent)
                {
                    header = new Label()
                    {
                        AutoResize = false,
                        Height     = 24f,
                        Format     = GlyphFormat.White,
                    };

                    subheader = new Label()
                    {
                        AutoResize     = false,
                        VertCenterText = false,
                        Height         = 20f,
                        Padding        = new Vector2(0f, 10f),
                        Format         = GlyphFormat.White.WithSize(.8f),
                        BuilderMode    = TextBuilderModes.Wrapped,
                    };

                    scrollBox = new ScrollBox <TMember>(alignVertical)
                    {
                        SizingMode      = HudChainSizingModes.FitChainOffAxis | HudChainSizingModes.ClampChainAlignAxis,
                        MinVisibleCount = 1,
                        Spacing         = 12f,
                        Height          = 280f,
                        Color           = Color.Red,
                    };

                    scrollBox.Background.Visible = false;

                    layout = new HudChain(true, this)
                    {
                        DimAlignment        = DimAlignments.Width | DimAlignments.IgnorePadding,
                        SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                        CollectionContainer = { header, subheader, scrollBox }
                    };

                    HeaderText    = "NewSettingsCategory";
                    SubheaderText = "Subheading\nLine 1\nLine 2\nLine 3\nLine 4";

                    if (alignVertical)
                    {
                        Width = 334f;
                    }
                    else
                    {
                        Height = 334f;
                    }
                }
Exemplo n.º 9
0
            public DropdownDisplay(HudParentBase parent = null) : base(parent)
            {
                border = new BorderBox(this)
                {
                    Thickness    = 1f,
                    DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding,
                };

                name = new Label()
                {
                    AutoResize = false,
                    Padding    = new Vector2(10f, 0f)
                };

                divider = new TexturedBox()
                {
                    Padding = new Vector2(4f, 17f),
                    Width   = 2f,
                    Color   = new Color(104, 113, 120),
                };

                arrow = new TexturedBox()
                {
                    Width        = 38f,
                    MatAlignment = MaterialAlignment.FitVertical,
                    Material     = arrowMat,
                };

                layout = new HudChain(false, this)
                {
                    SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                    DimAlignment        = DimAlignments.Height | DimAlignments.IgnorePadding,
                    CollectionContainer = { name, divider, arrow }
                };

                Format         = TerminalFormatting.ControlFormat;
                FocusTextColor = TerminalFormatting.Charcoal;

                Color          = TerminalFormatting.OuterSpace;
                HighlightColor = TerminalFormatting.Atomic;
                FocusColor     = TerminalFormatting.Mint;
                BorderColor    = TerminalFormatting.LimedSpruce;

                HighlightEnabled   = true;
                UseFocusFormatting = true;

                _mouseInput.GainedInputFocus += GainFocus;
                _mouseInput.LostInputFocus   += LoseFocus;
            }
Exemplo n.º 10
0
            public ColorWidget(HudParentBase parent = null) : base(parent)
            {
                colorPicker = new ColorPickerRGB();

                layout = new HudChain(true, this)
                {
                    Padding             = new Vector2(20f),
                    DimAlignment        = DimAlignments.Width,
                    SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                    Spacing             = 8f,
                    CollectionContainer =
                    {
                        colorPicker,
                        buttonChain
                    }
                };
            }
Exemplo n.º 11
0
            public TreeBoxDisplay(HudParentBase parent = null) : base(parent)
            {
                background = new TexturedBox(this)
                {
                    Color        = TerminalFormatting.EbonyClay,
                    DimAlignment = DimAlignments.Both,
                };

                name = new Label()
                {
                    AutoResize = false,
                    Padding    = new Vector2(10f, 0f),
                    Format     = GlyphFormat.Blueish.WithSize(1.1f),
                };

                divider = new TexturedBox()
                {
                    Padding = new Vector2(2f, 6f),
                    Size    = new Vector2(2f, 39f),
                    Color   = new Color(104, 113, 120),
                };

                arrow = new TexturedBox()
                {
                    Width        = 20f,
                    Padding      = new Vector2(8f, 0f),
                    MatAlignment = MaterialAlignment.FitHorizontal,
                    Color        = new Color(227, 230, 233),
                    Material     = rightArrow,
                };

                layout = new HudChain(false, this)
                {
                    SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                    DimAlignment        = DimAlignments.Height | DimAlignments.IgnorePadding,
                    CollectionContainer = { arrow, divider, name }
                };

                mouseInput = new MouseInputElement(this)
                {
                    DimAlignment = DimAlignments.Both
                };
            }
Exemplo n.º 12
0
            public PropertyListEntryElement() : base(null)
            {
                name    = new Label();
                postfix = new Label();
                value   = new TextBox()
                {
                    UseCursor = false,
                };

                layout = new HudChain(false, this)
                {
                    Padding             = new Vector2(18f, 0f),
                    ParentAlignment     = ParentAlignments.Left | ParentAlignments.Inner,
                    CollectionContainer = { name, value, postfix }
                };

                Height          = 19f;
                ParentAlignment = ParentAlignments.Left;
            }
Exemplo n.º 13
0
            public ComboWidget(HudParentBase parent = null) : base(parent)
            {
                comboBox = new Dropdown <KeyValuePair <long, StringBuilder> >()
                {
                    DropdownHeight  = 0f,
                    MinVisibleCount = 4,
                };

                layout = new HudChain(true, this)
                {
                    DimAlignment        = DimAlignments.Width,
                    SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                    Spacing             = 8f,
                    CollectionContainer =
                    {
                        comboBox,
                        buttonChain
                    }
                };
            }
Exemplo n.º 14
0
        public NamedCheckBox(HudParentBase parent) : base(parent)
        {
            name = new Label()
            {
                Format     = TerminalFormatting.ControlFormat.WithAlignment(TextAlignment.Right),
                Text       = "NewCheckbox",
                AutoResize = false
            };

            checkbox = new BorderedCheckBox();

            layout = new HudChain(false, this)
            {
                Spacing             = 17f,
                CollectionContainer = { name, checkbox }
            };

            AutoResize = true;
            Size       = new Vector2(250f, 37f);
        }
Exemplo n.º 15
0
            public FloatWidget(HudParentBase parent = null) : base(parent)
            {
                sliderBox = new CustomSliderBox()
                {
                    Min     = 0f,
                    Max     = 1f,
                    Padding = Vector2.Zero,
                };

                layout = new HudChain(true, this)
                {
                    DimAlignment        = DimAlignments.Width,
                    SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                    Spacing             = 8f,
                    CollectionContainer =
                    {
                        sliderBox,
                        buttonChain
                    }
                };
            }
Exemplo n.º 16
0
            public TextWidget(HudParentBase parent = null) : base(parent)
            {
                label = new Label()
                {
                    Format          = GlyphFormat.Blueish.WithSize(1.08f),
                    ParentAlignment = ParentAlignments.Left | ParentAlignments.Inner
                };
                textField = new TextField();

                layout = new HudChain(true, this)
                {
                    DimAlignment        = DimAlignments.Width,
                    SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                    Spacing             = 8f,
                    CollectionContainer =
                    {
                        label,
                        textField,
                        buttonChain
                    }
                };
            }
Exemplo n.º 17
0
        public ColorPickerRGB(HudParentBase parent) : base(parent)
        {
            // Header
            name = new Label()
            {
                Format     = GlyphFormat.Blueish.WithSize(1.08f),
                Text       = "NewColorPicker",
                AutoResize = false,
                Size       = new Vector2(88f, 22f)
            };

            display = new TexturedBox()
            {
                Width = 231f,
                Color = Color.Black
            };

            var dispBorder = new BorderBox(display)
            {
                Color        = Color.White,
                Thickness    = 1f,
                DimAlignment = DimAlignments.Both,
            };

            headerChain = new HudChain(false)
            {
                SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                Height              = 22f,
                Spacing             = 0f,
                CollectionContainer = { name, display }
            };

            // Color picker
            sliderText = new Label[]
            {
                new Label()
                {
                    AutoResize = false, Format = TerminalFormatting.ControlFormat, Height = 47f
                },
                new Label()
                {
                    AutoResize = false, Format = TerminalFormatting.ControlFormat, Height = 47f
                },
                new Label()
                {
                    AutoResize = false, Format = TerminalFormatting.ControlFormat, Height = 47f
                }
            };

            colorNameColumn = new HudChain <HudElementContainer <Label>, Label>(true)
            {
                SizingMode          = HudChainSizingModes.FitMembersBoth | HudChainSizingModes.FitChainBoth,
                Width               = 87f,
                Spacing             = 5f,
                CollectionContainer = { sliderText[0], sliderText[1], sliderText[2] }
            };

            sliders = new SliderBox[]
            {
                new SliderBox()
                {
                    Min = 0f, Max = 255f, Height = 47f
                },
                new SliderBox()
                {
                    Min = 0f, Max = 255f, Height = 47f
                },
                new SliderBox()
                {
                    Min = 0f, Max = 255f, Height = 47f
                }
            };

            colorSliderColumn = new HudChain <HudElementContainer <SliderBox>, SliderBox>(true)
            {
                SizingMode          = HudChainSizingModes.FitMembersBoth | HudChainSizingModes.FitChainBoth,
                Width               = 231f,
                Spacing             = 5f,
                CollectionContainer = { sliders[0], sliders[1], sliders[2] }
            };

            colorChain = new HudChain(false)
            {
                SizingMode          = HudChainSizingModes.FitChainBoth,
                CollectionContainer =
                {
                    colorNameColumn,
                    colorSliderColumn,
                }
            };

            mainChain = new HudChain(true, this)
            {
                SizingMode          = HudChainSizingModes.FitChainBoth,
                Spacing             = 5f,
                CollectionContainer =
                {
                    headerChain,
                    colorChain,
                }
            };

            Size         = new Vector2(318f, 163f);
            valueBuilder = new StringBuilder();

            UseCursor   = true;
            ShareCursor = true;
        }
Exemplo n.º 18
0
            public PropertyListMenu(QuickActionMenu parent) : base(parent)
            {
                quickActionMenu = parent;

                header = new LabelBox()
                {
                    Format     = listHeaderFormat,
                    Text       = "Build Vision",
                    AutoResize = false,
                    Size       = new Vector2(300f, 34f),
                    Color      = headerColor,
                };

                listBody = new ScrollBox <PropertyListEntry, PropertyListEntryElement>(true)
                {
                    MemberMinSize      = new Vector2(300f, 0f),
                    SizingMode         = HudChainSizingModes.ClampChainOffAxis | HudChainSizingModes.FitChainAlignAxis,
                    Padding            = new Vector2(30f, 16f),
                    Color              = bodyColor,
                    EnableScrolling    = false,
                    UseSmoothScrolling = false,
                    MinVisibleCount    = 10,
                    Visible            = false,
                };

                listBody.ScrollBar.Padding = new Vector2(12f, 16f);
                listBody.ScrollBar.Width   = 4f;

                peekBody = new LabelBox()
                {
                    AutoResize     = false,
                    VertCenterText = false,
                    Color          = bodyColor,
                    TextPadding    = new Vector2(48f, 16f),
                    BuilderMode    = TextBuilderModes.Lined,
                };

                var border = new BorderBox(listBody)
                {
                    DimAlignment = DimAlignments.Both,
                    Color        = new Color(58, 68, 77),
                    Thickness    = 1f,
                };

                highlightBox = new HighlightBox(listBody.Background)
                {
                    Padding = new Vector2(16f, 0f)
                };

                footer = new DoubleLabelBox()
                {
                    AutoResize  = false,
                    TextPadding = new Vector2(48f, 0f),
                    Size        = new Vector2(300f, 24f),
                    Color       = headerColor,
                };

                layout = new HudChain(true, this)
                {
                    MemberMinSize       = new Vector2(300f, 0f),
                    SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                    CollectionContainer =
                    {
                        header,
                        { listBody,true      },
                        { peekBody,true      },
                        footer
                    }
                };

                debugText = new Label(layout)
                {
                    ParentAlignment = ParentAlignments.Right,
                    BuilderMode     = TextBuilderModes.Lined
                };

                peekBuilder       = new RichText();
                entryPool         = new ObjectPool <PropertyListEntry>(() => new PropertyListEntry(), x => x.Reset());
                notificationTimer = new Stopwatch();
                listWrapTimer     = new Stopwatch();
            }
Exemplo n.º 19
0
 public ListInputElement(HudChain <TElementContainer, TElement> parent = null) : this(parent, parent)
 {
 }
Exemplo n.º 20
0
                public TerminalWindow(HudParentBase parent = null) : base(parent)
                {
                    HeaderBuilder.Format = TerminalFormatting.HeaderFormat;
                    HeaderBuilder.SetText("Rich HUD Terminal");

                    header.Height = 60f;

                    topDivider = new TexturedBox(header)
                    {
                        ParentAlignment = ParentAlignments.Bottom,
                        DimAlignment    = DimAlignments.Width,
                        Padding         = new Vector2(80f, 0f),
                        Height          = 1f,
                    };

                    modList = new ModList()
                    {
                        Width = 270f
                    };

                    middleDivider = new TexturedBox()
                    {
                        Padding = new Vector2(24f, 0f),
                        Width   = 26f,
                    };

                    bodyChain = new HudChain(false, topDivider)
                    {
                        SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.ClampChainBoth,
                        ParentAlignment     = ParentAlignments.Bottom | ParentAlignments.Left | ParentAlignments.InnerH,
                        Padding             = new Vector2(80f, 40f),
                        Spacing             = 12f,
                        CollectionContainer = { modList, middleDivider },
                    };

                    bottomDivider = new TexturedBox(this)
                    {
                        ParentAlignment = ParentAlignments.Bottom | ParentAlignments.InnerV,
                        DimAlignment    = DimAlignments.Width,
                        Offset          = new Vector2(0f, 40f),
                        Padding         = new Vector2(80f, 0f),
                        Height          = 1f,
                    };

                    closeButton = new Button(header)
                    {
                        Material        = closeButtonMat,
                        HighlightColor  = Color.White,
                        ParentAlignment = ParentAlignments.Top | ParentAlignments.Right | ParentAlignments.Inner,
                        Size            = new Vector2(30f),
                        Offset          = new Vector2(-18f, -14f),
                        Color           = new Color(173, 182, 189),
                    };

                    modList.SelectionChanged                 += HandleSelectionChange;
                    closeButton.MouseInput.LeftClicked       += (sender, args) => CloseMenu();
                    SharedBinds.Escape.NewPressed            += CloseMenu;
                    MasterBinds.ToggleTerminalOld.NewPressed += () => { if (MyAPIGateway.Gui.ChatEntryVisible)
                                                                        {
                                                                            ToggleMenu();
                                                                        }
                    };
                    MasterBinds.ToggleTerminal.NewPressed += ToggleMenu;

                    BodyColor   = new Color(37, 46, 53);
                    BorderColor = new Color(84, 98, 107);

                    Padding     = new Vector2(80f, 40f);
                    MinimumSize = new Vector2(1044f, 500f);

                    Size = new Vector2(1044f, 850f);
                    Vector2 normScreenSize = new Vector2(HudMain.ScreenWidth, HudMain.ScreenHeight) / HudMain.ResScale;

                    if (normScreenSize.Y < 1080 || HudMain.AspectRatio < (16f / 9f))
                    {
                        Height = MinimumSize.Y;
                    }

                    Offset = (normScreenSize - Size) * .5f - new Vector2(40f);
                }
Exemplo n.º 21
0
            public EditorToolBar(HudParentBase parent = null) : base(parent)
            {
                var background = new TexturedBox(this)
                {
                    DimAlignment = DimAlignments.Both,
                    Color        = new Color(41, 54, 62),
                };

                // Font selection
                fontList = new EditorDropdown <IFontMin>()
                {
                    Height = 24f,
                    Width  = 140f,
                };

                foreach (IFontMin font in FontManager.Fonts)
                {
                    fontList.Add(new RichText(font.Name, GlyphFormat.White.WithFont(font.Regular)), font);
                }

                // Text size
                sizeList = new EditorDropdown <float>()
                {
                    Height = 24f,
                    Width  = 60f,
                };

                for (int n = 0; n < textSizes.Length; n++)
                {
                    sizeList.Add(textSizes[n].ToString(), textSizes[n]);
                }

                // Builder mode
                textBuilderModes = new EditorDropdown <TextBuilderModes>()
                {
                    Height = 24f,
                    Width  = 140f,
                };

                textBuilderModes.Add("Unlined", TextBuilderModes.Unlined);
                textBuilderModes.Add("Lined", TextBuilderModes.Lined);
                textBuilderModes.Add("Wrapped", TextBuilderModes.Wrapped);

                // Font style toggle
                IFontMin    abhaya       = FontManager.GetFont("AbhayaLibreMedium");
                GlyphFormat buttonFormat = new GlyphFormat(Color.White, TextAlignment.Center, 1.0f, abhaya.Regular);

                boldToggle = new EditorToggleButton()
                {
                    Format = buttonFormat,
                    Text   = "B",
                };

                underlineToggle = new EditorToggleButton()
                {
                    Format = buttonFormat.WithStyle(FontStyles.Underline),
                    Text   = "U",
                };

                italicToggle = new EditorToggleButton()
                {
                    Format = buttonFormat.WithStyle(FontStyles.Italic),
                    Text   = "I",
                };

                /* HudChain is useful for organizing collections of elements into straight lines with regular spacing,
                 * either vertically horizontally. In this case, I'm organizing elements horizontally from left to right
                 * in the same order indicated by the collection initializer below.
                 *
                 * HudChain and its related types, like ScrollBox and the SelectionBox types, are powerful tools for
                 * organizing UI elements, especially when used in conjunction with oneanother.
                 */
                layout = new HudChain(false, this) // Set to alignVertical false to align the elements horizontally
                {
                    // Automatically resize the height of the elements to match that of the chain and allow the chain to be
                    // wider than the total size of the members
                    SizingMode = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.ClampChainAlignAxis,
                    // Match the height of the chain and its children to the toolbar
                    DimAlignment = DimAlignments.Height | DimAlignments.IgnorePadding,
                    // The width of the parent could very well be greater than the width of the controls.
                    ParentAlignment = ParentAlignments.Left | ParentAlignments.InnerH | ParentAlignments.UsePadding,
                    // The order the elements will appear on the toolbar from left to right.
                    CollectionContainer = { fontList, sizeList, boldToggle, underlineToggle, italicToggle, textBuilderModes }
                };

                fontList.SelectionChanged              += UpdateFormat;
                sizeList.SelectionChanged              += UpdateFormat;
                boldToggle.MouseInput.LeftClicked      += UpdateFormat;
                underlineToggle.MouseInput.LeftClicked += UpdateFormat;
                italicToggle.MouseInput.LeftClicked    += UpdateFormat;

                Height  = 30f;
                Padding = new Vector2(16f, 0f);
                _format = GlyphFormat.White;
            }
Exemplo n.º 22
0
        public OnOffButton(HudParentBase parent) : base(parent)
        {
            mouseInput = new MouseInputElement(this);

            background = new TexturedBox(this)
            {
                DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding,
            };

            bgBorder = new BorderBox(background)
            {
                DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding,
            };

            on = new LabelBox()
            {
                AutoResize = false,
                Size       = new Vector2(71f, 49f),
                Format     = TerminalFormatting.ControlFormat.WithAlignment(TextAlignment.Center),
                Text       = "On"
            };

            onBorder = new BorderBox(on)
            {
                Thickness    = 2f,
                DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding,
            };

            off = new LabelBox()
            {
                AutoResize = false,
                Size       = new Vector2(71f, 49f),
                Format     = TerminalFormatting.ControlFormat.WithAlignment(TextAlignment.Center),
                Text       = "Off"
            };

            offBorder = new BorderBox(off)
            {
                Thickness    = 2f,
                DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding,
            };

            buttonChain = new HudChain(false, bgBorder)
            {
                SizingMode          = HudChainSizingModes.FitMembersBoth | HudChainSizingModes.FitChainBoth,
                Padding             = new Vector2(12f, 10f),
                Spacing             = 9f,
                CollectionContainer = { on, off }
            };

            Size = new Vector2(166f, 58f);

            BackgroundColor = TerminalFormatting.Cinder.SetAlphaPct(0.8f);
            HighlightColor  = TerminalFormatting.Atomic;
            FocusColor      = TerminalFormatting.Mint;
            BorderColor     = TerminalFormatting.LimedSpruce;

            UnselectedColor = TerminalFormatting.OuterSpace;
            SelectionColor  = TerminalFormatting.DullMint;

            HighlightEnabled   = true;
            UseFocusFormatting = true;

            mouseInput.LeftClicked += LeftClick;
        }
Exemplo n.º 23
0
                public DemoBox(HudParentBase parent = null) : base(parent)
                {
                    // Spawn controls
                    //
                    // List of available control types
                    typeList     = new ListBox <DemoElements>();
                    createButton = new BorderedButton()
                    {
                        Text = "Create", Padding = Vector2.Zero
                    };

                    typeColumn = new HudChain(true)
                    {
                        SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                        CollectionContainer = { typeList, createButton },
                        Spacing             = 8f
                    };

                    // Add list of supported test elements to the type list
                    var supportedTypes = Enum.GetValues(typeof(DemoElements)) as DemoElements[];

                    for (int n = 0; n < supportedTypes.Length; n++)
                    {
                        typeList.Add(supportedTypes[n].ToString(), supportedTypes[n]);
                    }

                    createButton.MouseInput.LeftClicked += InstantiateSelectedType;

                    // Instance list
                    instanceList = new ListBox <TestWindowNode>();
                    removeButton = new BorderedButton()
                    {
                        Text = "Remove", Padding = Vector2.Zero
                    };
                    clearAllButton = new BorderedButton()
                    {
                        Text = "Clear All", Padding = Vector2.Zero
                    };

                    instanceButtonRow = new HudChain(false)
                    {
                        SizingMode          = HudChainSizingModes.FitMembersBoth | HudChainSizingModes.FitChainBoth,
                        CollectionContainer = { removeButton, clearAllButton },
                        Spacing             = 8f,
                    };

                    instanceColumn = new HudChain(true)
                    {
                        SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                        CollectionContainer = { instanceList, instanceButtonRow },
                        Spacing             = 8f
                    };

                    removeButton.MouseInput.LeftClicked   += RemoveSelectedInstance;
                    clearAllButton.MouseInput.LeftClicked += ClearInstances;
                    instanceList.SelectionChanged         += UpdateSelection;

                    // Transform controls
                    //
                    // Column 1
                    screenSpaceToggle = new NamedCheckBox()
                    {
                        Name = "Screen Space"
                    };
                    xAxisBar = new NamedSliderBox()
                    {
                        Name = "AxisX", Padding = new Vector2(40f, 0f), Min = -1f, Max = 1f
                    };
                    yAxisBar = new NamedSliderBox()
                    {
                        Name = "AxisY", Padding = new Vector2(40f, 0f), Min = -1f, Max = 1f
                    };
                    zAxisBar = new NamedSliderBox()
                    {
                        Name = "AxisZ", Padding = new Vector2(40f, 0f), Min = -1f, Max = 1f
                    };
                    angleBar = new NamedSliderBox()
                    {
                        Name = "Angle", Padding = new Vector2(40f, 0f), Min = -(float)(Math.PI), Max = (float)(Math.PI)
                    };

                    transformCol1 = new HudChain(true)
                    {
                        Spacing             = 10f,
                        CollectionContainer = { screenSpaceToggle, xAxisBar, yAxisBar, zAxisBar, angleBar }
                    };

                    // Column 2
                    resScaleToggle = new NamedCheckBox()
                    {
                        Name = "Res Scaling"
                    };
                    scaleBar = new NamedSliderBox()
                    {
                        Name = "Scale", Padding = new Vector2(40f, 0f), Min = 0.001f, Max = 1f
                    };
                    xPosBar = new NamedSliderBox()
                    {
                        Name = "PosX", Padding = new Vector2(40f, 0f), Min = -.5f, Max = .5f
                    };
                    yPosBar = new NamedSliderBox()
                    {
                        Name = "PosY", Padding = new Vector2(40f, 0f), Min = -.5f, Max = .5f
                    };
                    zPosBar = new NamedSliderBox()
                    {
                        Name = "PosZ", Padding = new Vector2(40f, 0f), Min = -2f, Max = 0f
                    };

                    transformCol2 = new HudChain(true)
                    {
                        Spacing             = 10f,
                        CollectionContainer = { resScaleToggle, scaleBar, xPosBar, yPosBar, zPosBar }
                    };

                    spawnControls = new HudChain(false)
                    {
                        CollectionContainer = { typeColumn, instanceColumn },
                        Spacing             = 16f,
                    };

                    transformControls = new HudChain(false)
                    {
                        CollectionContainer = { transformCol1, transformCol2 }
                    };

                    var layout = new HudChain(true, this)
                    {
                        ParentAlignment     = ParentAlignments.Left | ParentAlignments.Inner,
                        Spacing             = 10f,
                        CollectionContainer = { spawnControls, transformControls }
                    };

                    Padding  = new Vector2(40f, 8f);
                    demoRoot = new HudCollection(HudMain.HighDpiRoot);
                }