public BindGroupList(HudParentBase parent = null) : base(true, parent) { Spacing = 30f; SizingMode = HudChainSizingModes.ClampChainBoth | HudChainSizingModes.FitMembersOffAxis; Background.Visible = false; }
public SliderBar(HudParentBase parent) : base(parent) { bar = new TexturedBox(this); slider = new TexturedBox(bar) { UseCursor = true, ShareCursor = true }; mouseInput = new MouseInputElement(this) { DimAlignment = DimAlignments.Both }; _barSize = new Vector2(100f, 12f); _sliderSize = new Vector2(6f, 12f); SliderVisible = true; bar.Size = _barSize; slider.Size = _sliderSize; SliderColor = new Color(180, 180, 180, 255); BarColor = new Color(140, 140, 140, 255); SliderHighlight = new Color(200, 200, 200, 255); EnableHighlight = true; _min = 0f; _max = 1f; Current = 0f; Percent = 0f; }
/// <summary> /// Initializes a new Text Editor window and registers it to the specified parent element. /// You can leave the parent null and use the parent element's register method if you prefer. /// </summary> public TextEditor(HudParentBase parent = null) : base(parent) { textBox = new EditorTextBox(body) { ParentAlignment = ParentAlignments.Bottom | ParentAlignments.InnerV, DimAlignment = DimAlignments.Width }; toolBar = new EditorToolBar(header) { DimAlignment = DimAlignments.Width, ParentAlignment = ParentAlignments.Bottom, Format = textBox.text.Format, BulderMode = textBox.text.BuilderMode, }; toolBar.FormatChanged += ChangeFormat; toolBar.BuildModeChanged += ChangeBuilderMode; // Window styling: BodyColor = new Color(41, 54, 62, 150); BorderColor = new Color(58, 68, 77); header.Format = new GlyphFormat(GlyphFormat.Blueish.Color, TextAlignment.Center, 1.08f); header.Height = 30f; HeaderText = "Example Text Editor"; Size = new Vector2(500f, 300f); }
public EditorTextBox(HudParentBase parent = null) : base(parent) { text = new TextBox(this) { // Align the text box to the top left corner of the parent element and place it on the interior ParentAlignment = ParentAlignments.Top | ParentAlignments.Left | ParentAlignments.Inner | ParentAlignments.UsePadding, Padding = new Vector2(8f, 8f), Format = GlyphFormat.White, VertCenterText = false, // This is a text editor; I don't want the text centered. AutoResize = false, // Allows the text box size to be set manually (or via DimAlignment) ClearSelectionOnLoseFocus = false // Leaving this enabled creates problems when trying to reformat text }; // These scroll bars will be used to control text scrolling via textboard text offset verticalScroll = new ScrollBar(this) { // Align this element s.t. it will be to the right of the text box ParentAlignment = ParentAlignments.Top | ParentAlignments.Right | ParentAlignments.Inner | ParentAlignments.UsePadding, Padding = new Vector2(8f), Width = 18f, Vertical = true, }; horizontalScroll = new ScrollBar(this) { // Align this s.t. it will be below both the text box and the right scroll bar ParentAlignment = ParentAlignments.Bottom | ParentAlignments.Inner | ParentAlignments.UsePadding, Padding = new Vector2(8f), Height = 18f, Vertical = false, }; }
public HudSpaceNodeBase(HudParentBase parent = null) : base(parent) { GetHudSpaceFunc = () => new MyTuple <bool, float, MatrixD>(DrawCursorInHudSpace, 1f, PlaneToWorldRef[0]); DrawCursorInHudSpace = true; GetNodeOriginFunc = () => PlaneToWorldRef[0].Translation; PlaneToWorldRef = new MatrixD[1]; }
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 BorderedButton(HudParentBase parent) : base(parent) { border = new BorderBox(this) { Thickness = 1f, DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding, }; AutoResize = false; Format = TerminalFormatting.ControlFormat.WithAlignment(TextAlignment.Center); FocusTextColor = TerminalFormatting.Charcoal; Text = "NewBorderedButton"; TextPadding = new Vector2(32f, 0f); Padding = new Vector2(37f, 0f); Size = new Vector2(253f, 50f); HighlightEnabled = true; Color = TerminalFormatting.OuterSpace; HighlightColor = TerminalFormatting.Atomic; BorderColor = TerminalFormatting.LimedSpruce; FocusColor = TerminalFormatting.Mint; UseFocusFormatting = true; _mouseInput.GainedInputFocus += GainFocus; _mouseInput.LostInputFocus += LoseFocus; }
/// <summary> /// Used internally quickly register a list of child nodes to a parent. /// </summary> public static void RegisterNodes <TCon, TNode>(HudParentBase newParent, List <HudNodeBase> children, IReadOnlyList <TCon> nodes, bool canPreload) where TCon : IHudElementContainer <TNode>, new() where TNode : HudNodeBase { children.EnsureCapacity(children.Count + nodes.Count); for (int n = 0; n < nodes.Count; n++) { HudNodeBase node = nodes[n].Element; node.Parent = newParent; node.State |= HudElementStates.IsRegistered; node.ParentVisible = newParent.Visible; children.Add(node); if (canPreload) { node.State |= HudElementStates.CanPreload; } else { node.State &= ~HudElementStates.CanPreload; } } }
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); }
public NamedSliderBox(HudParentBase parent) : base(parent) { sliderBox = new SliderBox(this) { DimAlignment = DimAlignments.Width | DimAlignments.IgnorePadding, ParentAlignment = ParentAlignments.Bottom | ParentAlignments.InnerV, UseCursor = true, }; name = new Label(this) { AutoResize = false, Format = TerminalFormatting.ControlFormat, Text = "NewSlideBox", Offset = new Vector2(0f, -18f), ParentAlignment = ParentAlignments.InnerH | ParentAlignments.Top | ParentAlignments.Left | ParentAlignments.UsePadding }; current = new Label(this) { AutoResize = false, Format = TerminalFormatting.ControlFormat, Text = "Value", Offset = new Vector2(0f, -18f), ParentAlignment = ParentAlignments.InnerH | ParentAlignments.Top | ParentAlignments.Right | ParentAlignments.UsePadding }; Padding = new Vector2(40f, 0f); Size = new Vector2(317f, 70f); }
public QuickActionMenu(HudParentBase parent = null) : base(parent) { propertyList = new PropertyListMenu(this) { Visible = false }; propertyWheel = new PropertyWheelMenu(this) { Visible = false }; propertyWheel.RegisterShortcut(new PropertyWheelShortcutEntry() { Text = "Open List Menu", ShortcutAction = () => OpenPropertyList(true) }); debugText = new Label(this) { Visible = false, AutoResize = true, BuilderMode = TextBuilderModes.Lined, ParentAlignment = ParentAlignments.Left }; notifText = new StringBuilder(); }
public TestWindow(HudParentBase parent = null) : base(parent) { Size = new Vector2(400f); BodyColor = new Color(41, 54, 62, 150); BorderColor = new Color(58, 68, 77); AllowResizing = false; }
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 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 HudNodeBase(HudParentBase parent) { State &= ~HudElementStates.IsRegistered; ParentVisible = true; Register(parent); }
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 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); }
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, }; }
public TestWindowNode(DemoElements elementEnum, HudParentBase parent = null) : base(parent) { this.elementEnum = elementEnum; cameraNode = new CamSpaceNode(this); window = GetTestWindow(elementEnum); window.Register(cameraNode); }
public HudChain(bool alignVertical, HudParentBase parent = null) : base(parent) { Init(); Spacing = 0f; SizingMode = HudChainSizingModes.FitChainBoth; AlignVertical = alignVertical; }
public CamSpaceNode(HudParentBase parent = null) : base(parent) { PlaneScale = 1f; TransformOffset = new Vector3D(0d, 0d, -MyAPIGateway.Session.Camera.NearPlaneDistance); IsScreenSpace = true; UseResScaling = true; }
public Button(HudParentBase parent) : base(parent) { _mouseInput = new MouseInputElement(this); HighlightColor = new Color(125, 125, 125, 255); HighlightEnabled = true; _mouseInput.CursorEntered += CursorEnter; _mouseInput.CursorExited += CursorExit; }
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); }
public MouseInputElement(HudParentBase parent) : base(parent) { UseCursor = true; ShareCursor = true; HasFocus = false; DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding; LoseFocusCallback = LoseFocus; }
/// <summary> /// Used internally to quickly unregister child nodes from their parent. Removes the range of nodes /// specified in the node list from the child list. /// </summary> public static void UnregisterNodes <TCon, TNode>(HudParentBase parent, List <HudNodeBase> children, IReadOnlyList <TCon> nodes, int index, int count) where TCon : IHudElementContainer <TNode>, new() where TNode : HudNodeBase { if (count > 0) { int conEnd = index + count - 1; if (!(index >= 0 && index < nodes.Count && conEnd <= nodes.Count)) { throw new Exception("Specified indices are out of range."); } if (parent == null) { throw new Exception("Parent cannot be null"); } for (int i = index; i <= conEnd; i++) { int start = 0; while (start < children.Count && children[start] != nodes[i].Element) { start++; } if (children[start] == nodes[i].Element) { int j = start, end = start; while (j < children.Count && i <= conEnd && children[j] == nodes[i].Element) { end = j; i++; j++; } children.RemoveRange(start, end - start + 1); } } for (int n = index; n < count; n++) { HudNodeBase node = nodes[n].Element; HudParentBase nodeParent = node._parent; if (nodeParent != parent) { throw new Exception("The child node specified is not registered to the parent given."); } node.Parent = null; node.State &= ~(HudElementStates.IsRegistered | HudElementStates.WasParentVisible); } } }
public LabelBoxBase(HudParentBase parent) : base(parent) { background = new TexturedBox(this) { DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding, }; FitToTextElement = true; Color = Color.Gray; }
public LabelBoxButton(HudParentBase parent) : base(parent) { _mouseInput = new MouseInputElement(this); Color = Color.DarkGray; HighlightColor = Color.Gray; HighlightEnabled = true; _mouseInput.CursorEntered += CursorEnter; _mouseInput.CursorExited += CursorExit; }
public HighlightBox(HudParentBase parent = null) : base(parent) { tabBoard = new MatBoard() { Color = TerminalFormatting.Mercury }; Color = TerminalFormatting.Atomic; CanDrawTab = true; IsSelectivelyMasked = true; }
public WindowBase(HudParentBase parent) : base(parent) { header = new LabelBoxButton(this) { DimAlignment = DimAlignments.Width, Height = 32f, ParentAlignment = ParentAlignments.Top | ParentAlignments.Inner, ZOffset = 1, Format = GlyphFormat.White.WithAlignment(TextAlignment.Center), HighlightEnabled = false, AutoResize = false, }; body = new EmptyHudElement(header) { DimAlignment = DimAlignments.Width, ParentAlignment = ParentAlignments.Bottom, }; bodyBg = new TexturedBox(body) { DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding, ZOffset = -2, }; border = new BorderBox(this) { ZOffset = 1, Thickness = 1f, DimAlignment = DimAlignments.Both, }; resizeInput = new MouseInputElement(this) { ZOffset = sbyte.MaxValue, Padding = new Vector2(16f), DimAlignment = DimAlignments.Both, CanIgnoreMasking = true }; inputInner = new MouseInputElement(resizeInput) { DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding, }; AllowResizing = true; CanDrag = true; UseCursor = true; ShareCursor = false; IsMasking = true; MinimumSize = new Vector2(200f, 200f); LoseFocusCallback = LoseFocus; GetFocus(); }
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; }