public void add_text_entry_field(Cockpit cockpit)
        {
            float fUseRadius = HUDRadius * 0.85f;
            float fAngle     = -35.0f;

            entryField            = new HUDTextEntry();
            entryField.Text       = GetDefaultFileName();
            entryField.Width      = 1.0f;
            entryField.Height     = 0.08f;
            entryField.TextHeight = 0.06f;
            entryField.Create();
            entryField.Name = "selectFileName";
            HUDUtil.PlaceInSphere(entryField, fUseRadius, 0.0f, fAngle);
            cockpit.AddUIElement(entryField, true);

            tooltipText                 = new HUDLabel();
            tooltipText.Shape           = new HUDShape(HUDShapeType.Rectangle, 1.0f, 0.04f);
            tooltipText.Text            = Tooltip;
            tooltipText.TextHeight      = 0.03f;
            tooltipText.BackgroundColor = Colorf.TransparentBlack;
            tooltipText.TextColor       = Colorf.Silver;
            tooltipText.Create();
            tooltipText.Name = "tooltip";
            HUDUtil.PlaceInSphere(tooltipText, fUseRadius, 0.0f, fAngle);
            UnityUtil.TranslateInFrame(tooltipText.RootGameObject, 0.0f, -entryField.Height, 0, CoordSpace.WorldCoords);
            cockpit.AddUIElement(tooltipText, true);


            HUDButton saveButton = HUDBuilder.CreateRectIconClickButton(
                0.2f, 0.1f, fUseRadius, 0.0f, fAngle,
                "icons/save_v1");

            UnityUtil.TranslateInFrame(saveButton.RootGameObject, 0.2f, -0.1f, 0, CoordSpace.WorldCoords);
            saveButton.Name = "save";
            cockpit.AddUIElement(saveButton, true);
            saveButton.OnClicked += (s, e) => { SaveFromEntryText(); };

            HUDButton cancelButton = HUDBuilder.CreateRectIconClickButton(
                0.2f, 0.1f, fUseRadius, 0.0f, fAngle,
                "icons/cancel_v1");

            UnityUtil.TranslateInFrame(cancelButton.RootGameObject, 0.4f, -0.1f, 0, CoordSpace.WorldCoords);
            cancelButton.Name = "cancel";
            cockpit.AddUIElement(cancelButton, true);
            cancelButton.OnClicked += (s, e) => {
                cockpit.Context.PopCockpit(true);
            };
        }
        HUDElementList make_horz_labeled_param(string textLabel, HUDStandardItem item)
        {
            HUDElementList container = new HUDElementList()
            {
                Direction = ListDirection.Horizontal,
                Width     = this.Width,
                Height    = this.RowHeight,
                Spacing   = this.Padding
            };
            HUDLabel label = new HUDLabel()
            {
                Shape      = new HUDShape(HUDShapeType.Rectangle, HorzParamLabelWidth, LabelTextHeight),
                TextHeight = LabelTextHeight,
                Text       = textLabel
            };

            label.Create();
            container.AddListItem(label);
            container.AddListItem(item);
            container.Create();
            return(container);
        }
Example #3
0
        public override void Create()
        {
            base.Create();

            HUDElementLayout layout          = new HUDElementLayout(this, new HUDPanelContentBox(this), this.Children);
            float            fZ              = -0.01f;
            Vector2f         vertFieldOffset = -this.Padding * Vector2f.AxisY;

            background = new HUDShapeElement()
            {
                Shape = BackgroundShapeF(this.Width, this.Height),
                Color = this.BackgroundColor, IsInteractive = false
            };
            background.Create();
            background.Name = "background";
            layout.Add(background, new LayoutOptions()
            {
                Flags            = LayoutFlags.None,
                PinSourcePoint2D = LayoutUtil.BoxPointF(background, BoxPosition.Center),
                PinTargetPoint2D = LayoutUtil.BoxPointF(layout.BoxElement, BoxPosition.Center)
            });


            header_label = new HUDLabel(this.PaddedWidth, HeaderStyle.TextHeight, HeaderStyle)
            {
                Text = TitleText, IsInteractive = false
            };
            header_label.Create();
            header_label.Name = "header_label";
            BoxPosition headerBoxPos = BoxModel.ToPosition(HeaderStyle.AlignmentHorz, VerticalAlignment.Top);

            layout.Add(header_label,
                       LayoutUtil.PointToPoint(header_label, headerBoxPos, layout.BoxElement, headerBoxPos, fZ));


            float message_height = this.PaddedHeight - HeaderStyle.TextHeight - ButtonStyle.Height;

            message_area = new HUDMultiLineLabel(this.PaddedWidth, message_height, MessageStyle)
            {
                Text = MessageText, IsInteractive = false
            };
            message_area.Create();
            message_area.Name = "message_area";
            BoxPosition messageAreaBoxPos = BoxModel.ToPosition(MessageStyle.AlignmentHorz, VerticalAlignment.Top);

            layout.Add(message_area,
                       LayoutUtil.PointToPoint(message_area, messageAreaBoxPos, header_label, BoxModel.ToBottom(headerBoxPos), vertFieldOffset, fZ));


            IBoxModelElement prev      = layout.BoxElement;
            BoxPosition      prevPos   = BoxPosition.BottomRight;
            Vector2f         prevShift = Vector2f.Zero;

            for (int i = buttons.Count - 1; i >= 0; --i)
            {
                buttons[i].Create();
                buttons[i].Name = buttons[i].Text;
                layout.Add(buttons[i],
                           LayoutUtil.PointToPoint(buttons[i], BoxPosition.BottomRight, prev, prevPos, prevShift, fZ));
                prev      = buttons[i];
                prevPos   = BoxPosition.BottomLeft;
                prevShift = -Padding * Vector2f.AxisX;
            }
        }