Exemple #1
0
                public HudCursor(HudParentBase parent = null) : base(parent)
                {
                    GetHudSpaceFunc        = () => new HudSpaceData(DrawCursorInHudSpace, 1f, PlaneToWorldRef[0]);
                    ZOffset                = sbyte.MaxValue;
                    layerData.zOffsetInner = byte.MaxValue;

                    cursorBox = new TexturedBox(this)
                    {
                        Material = new Material(MyStringId.GetOrCompute("MouseCursor"), new Vector2(64f)),
                        Size     = new Vector2(64f),
                    };

                    var shadow = new TexturedBox(cursorBox)
                    {
                        Material = new Material(MyStringId.GetOrCompute("RadialShadow"), new Vector2(32f, 32f)),
                        Color    = new Color(0, 0, 0, 96),
                        Size     = new Vector2(64f),
                        Offset   = new Vector2(12f, -12f),
                        ZOffset  = -1
                    };

                    toolTip = new LabelBox(cursorBox)
                    {
                        Visible     = false,
                        ZOffset     = -2,
                        TextPadding = new Vector2(10f, 6f),
                        BuilderMode = TextBuilderModes.Lined,
                        AutoResize  = true
                    };
                }
                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);
                }
        public BorderedCheckBox(HudParentBase parent) : base(parent)
        {
            border = new BorderBox(this)
            {
                Thickness    = 1f,
                DimAlignment = DimAlignments.Both,
            };

            tickBox = new TexturedBox()
            {
                DimAlignment = DimAlignments.Both,
                Padding      = new Vector2(17f),
            };
            tickBox.Register(this, true);

            Size = new Vector2(37f);

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

            TickBoxColor          = TerminalFormatting.StormGrey;
            TickBoxHighlightColor = Color.White;
            TickBoxFocusColor     = TerminalFormatting.Cinder;

            BorderColor        = TerminalFormatting.LimedSpruce;
            UseFocusFormatting = true;

            MouseInput.LeftClicked      += ToggleValue;
            MouseInput.GainedInputFocus += GainFocus;
            MouseInput.LostInputFocus   += LoseFocus;
        }
            public PropertyWheelMenuBody(PropertyWheelMenu parent) : base(parent)
            {
                this.propertyWheelMenu = parent;
                background             = new TexturedBox(this)
                {
                    Material = Material.CircleMat,
                    Color    = headerColor,
                    Size     = Vector2.Zero,
                };

                summaryLabel = new Label(this)
                {
                    AutoResize  = false,
                    BuilderMode = TextBuilderModes.Wrapped,
                    Width       = 200f,
                };

                notificationText = new Label(this)
                {
                    AutoResize      = true,
                    ParentAlignment = ParentAlignments.Bottom | ParentAlignments.Inner,
                    BuilderMode     = TextBuilderModes.Wrapped,
                    Width           = 150f,
                    Offset          = new Vector2(0f, 30f),
                };

                colorWidget = new ColorWidget(this)
                {
                    Visible = false
                };
                colorWidgetHSV = new ColorWidgetHSV(this)
                {
                    Visible = false
                };
                comboWidget = new ComboWidget(this)
                {
                    Visible = false
                };
                floatWidget = new FloatWidget(this)
                {
                    Visible = false
                };
                textWidget = new TextWidget(this)
                {
                    Visible = false
                };

                summaryBuilder      = new RichText();
                CloseWidgetCallback = CloseWidget;

                textBuf           = new StringBuilder();
                notificationTimer = new Stopwatch();

                Padding = new Vector2(wheelBodyPeekPadding);
                Size    = new Vector2(maxPeekWrapWidth);
            }
Exemple #5
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 RebindHud(HudParentBase parent) : base(parent)
            {
                background = new TexturedBox(this)
                {
                    Color        = new Color(37, 46, 53),
                    DimAlignment = DimAlignments.Both,
                };

                border = new BorderBox(this)
                {
                    Thickness    = 1f,
                    Color        = new Color(53, 66, 75),
                    DimAlignment = DimAlignments.Both,
                };

                header = new Label(this)
                {
                    AutoResize      = false,
                    DimAlignment    = DimAlignments.Width | DimAlignments.IgnorePadding,
                    Height          = 24f,
                    ParentAlignment = ParentAlignments.Top | ParentAlignments.InnerV | ParentAlignments.UsePadding,
                    Offset          = new Vector2(0f, -42f),
                    Format          = new GlyphFormat(Color.White, TextAlignment.Center, 1.25f),
                    Text            = "SELECT CONTROL",
                };

                var divider = new TexturedBox(header)
                {
                    DimAlignment    = DimAlignments.Width,
                    Height          = 1f,
                    ParentAlignment = ParentAlignments.Bottom,
                    Offset          = new Vector2(0f, -10f),
                    Color           = new Color(84, 98, 111),
                };

                subheader = new Label(divider)
                {
                    AutoResize      = false,
                    DimAlignment    = DimAlignments.Width,
                    Height          = 24f,
                    ParentAlignment = ParentAlignments.Bottom,
                    Offset          = new Vector2(0f, -41f),
                    Format          = new GlyphFormat(GlyphFormat.Blueish.Color, TextAlignment.Center, 1.25f),
                    Text            = "Please press a key",
                };

                Padding = new Vector2(372f, 0f);
                Size    = new Vector2(1210f, 288f);

                ZOffset = sbyte.MaxValue - 1;
                layerData.zOffsetInner = byte.MaxValue - 1;
            }
            public ScrollMenu(int maxListLength)
            {
                background = new TexturedBox(this);

                headerBg = new TexturedBox(background);
                header   = new TextHudMessage(headerBg);

                footerBg    = new TexturedBox(background);
                footerLeft  = new TextHudMessage(footerBg, TextAlignment.Left);
                footerRight = new TextHudMessage(footerBg, TextAlignment.Right);

                highlightBox = new TexturedBox(background);
                tab          = new TexturedBox(highlightBox, new Color(225, 225, 240, 255));

                list = new List <TextHudMessage>(maxListLength);

                for (int n = 0; n < maxListLength; n++)
                {
                    list.Add(new TextHudMessage(background, TextAlignment.Left));
                }
            }
Exemple #8
0
            public EditorToggleButton(HudElementBase parent = null) : base(parent)
            {
                // This overlay will be drawn over the button when it's disabled
                disabledOverlay = new TexturedBox(this)
                {
                    Visible      = false,
                    DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding
                };

                Color          = TerminalFormatting.OuterSpace;
                HighlightColor = TerminalFormatting.Atomic;
                SelectColor    = new Color(58, 68, 77);
                DisabledColor  = new Color(0, 0, 0, 80);

                AutoResize = false;
                Enabled    = true;

                Size = new Vector2(42f, 30f);

                MouseInput.LeftClicked += LeftClick;
            }
Exemple #9
0
                    public ModList(HudParentBase parent = null) : base(parent)
                    {
                        scrollBox = new ScrollBox <ModControlRoot, LabelElementBase>(true, this)
                        {
                            SizingMode      = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.ClampChainBoth,
                            ParentAlignment = ParentAlignments.Bottom | ParentAlignments.InnerV,
                            Color           = TerminalFormatting.DarkSlateGrey,
                            Padding         = new Vector2(6f)
                        };

                        listInput = new ListInputElement <ModControlRoot, LabelElementBase>(scrollBox);

                        header = new LabelBox(scrollBox)
                        {
                            AutoResize      = false,
                            ParentAlignment = ParentAlignments.Top,
                            DimAlignment    = DimAlignments.Width,
                            Size            = new Vector2(200f, 36f),
                            Color           = new Color(32, 39, 45),
                            Format          = TerminalFormatting.ControlFormat,
                            Text            = "Mod List:",
                            TextPadding     = new Vector2(30f, 0f),
                        };

                        var listDivider = new TexturedBox(header)
                        {
                            ParentAlignment = ParentAlignments.Bottom,
                            DimAlignment    = DimAlignments.Width,
                            Height          = 1f,
                            Color           = new Color(53, 66, 75),
                        };

                        var listBorder = new BorderBox(this)
                        {
                            DimAlignment = DimAlignments.Both,
                            Thickness    = 1f,
                            Color        = new Color(53, 66, 75),
                        };
                    }
Exemple #10
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;
        }
            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;
            }
Exemple #12
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;
        }
                public ScrollableTextBox(HudParentBase parent = null) : base(parent)
                {
                    header = new Label(this)
                    {
                        ParentAlignment = ParentAlignments.Top | ParentAlignments.Left | ParentAlignments.Inner,
                        Height          = 24f,
                        AutoResize      = false,
                        Format          = new GlyphFormat(Color.White, TextAlignment.Center)
                    };

                    subheader = new Label(header)
                    {
                        ParentAlignment = ParentAlignments.Bottom,
                        Height          = 20f,
                        Padding         = new Vector2(0f, 10f),
                        BuilderMode     = TextBuilderModes.Wrapped,
                        AutoResize      = false,
                        VertCenterText  = false,
                        Format          = new GlyphFormat(Color.White, TextAlignment.Center, .8f),
                    };

                    textBox = new TextBox(subheader)
                    {
                        ParentAlignment           = ParentAlignments.Bottom | ParentAlignments.Left | ParentAlignments.InnerH,
                        Padding                   = new Vector2(8f, 8f),
                        BuilderMode               = TextBuilderModes.Wrapped,
                        AutoResize                = false,
                        Format                    = GlyphFormat.White,
                        VertCenterText            = false,
                        EnableEditing             = false,
                        EnableHighlighting        = true,
                        ClearSelectionOnLoseFocus = true
                    };

                    headerDivider = new TexturedBox(textBox)
                    {
                        Color           = new Color(53, 66, 75),
                        ParentAlignment = ParentAlignments.Top,
                        DimAlignment    = DimAlignments.Width,
                        Padding         = new Vector2(0f, 2f),
                        Height          = 1f,
                    };

                    verticalScroll = new ScrollBar(textBox)
                    {
                        ParentAlignment = ParentAlignments.Right,
                        DimAlignment    = DimAlignments.Height | DimAlignments.IgnorePadding,
                        Vertical        = true,
                    };

                    scrollDivider = new TexturedBox(verticalScroll)
                    {
                        Color           = new Color(53, 66, 75),
                        ParentAlignment = ParentAlignments.Left | ParentAlignments.InnerH,
                        DimAlignment    = DimAlignments.Height,
                        Padding         = new Vector2(2f, 0f),
                        Width           = 1f,
                    };

                    HeaderText    = "Text Page Header";
                    SubHeaderText = "Subheading\nLine 1\nLine 2\nLine 3\nLine 4";

                    UseCursor   = true;
                    ShareCursor = true;
                }
Exemple #14
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);
                }