예제 #1
0
        void BuildParameterPanel(Cockpit cockpit)
        {
            float panel_width             = 500 * cockpit.GetPixelScale();
            HUDParametersPanel paramPanel = new HUDParametersPanel(cockpit)
            {
                Width              = panel_width,
                Height             = panel_width,
                ParameterRowHeight = panel_width / 10.0f,
                ParametersPadding  = panel_width * 0.025f,
            };

            paramPanel.Create();
            paramPanel.Name = "ParametersPanel";
            cockpit.AddUIElement(paramPanel, true);
            paramPanel.IsVisible = true;

            cockpit.DefaultLayout.Add(paramPanel, new LayoutOptions()
            {
                Flags            = LayoutFlags.None,
                PinSourcePoint2D = LayoutUtil.BoxPointF(paramPanel, BoxPosition.TopLeft),
                PinTargetPoint2D = LayoutUtil.BoxPointF(cockpit.DefaultLayout.BoxElement, BoxPosition.TopRight)
                                   //PinTargetPoint2D = LayoutUtil.BoxPointInterpF(cockpit.DefaultLayout.BoxElement, BoxPosition.TopRight, BoxPosition.BottomRight, 0.5f)
            });

            //UnityUtil.TranslateInFrame(shapesButton.RootGameObject, fButtonW * 0.5f, 0, 0, CoordSpace.WorldCoords);
        }
예제 #2
0
        void add(HUDStandardItem element, LayoutOptions options)
        {
            if (element.IsVisible == false)
            {
                element.IsVisible = true;
            }

            IBoxModelElement elemBoxModel = element as IBoxModelElement;

            childSet.Add(element);

            Func <Vector2f> pinSourceF = options.PinSourcePoint2D;

            if (pinSourceF == null)
            {
                pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center);
            }

            Func <Vector2f> pinTargetF = options.PinTargetPoint2D;

            if (pinTargetF == null)
            {
                pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center);
            }

            Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift);
        }
예제 #3
0
        void add(HUDStandardItem element, LayoutOptions options)
        {
            if (element.IsVisible == false)
            {
                element.IsVisible = true;
            }

            IBoxModelElement elemBoxModel = element as IBoxModelElement;

            // for 2D view (but doesn't matter if we are doing a layout anyway!)
            Frame3f viewFrame = Cockpit.GetViewFrame2D();

            // with 3D view we should use this...
            //Frame3f viewFrame = Frame3f.Identity;

            element.SetObjectFrame(Frame3f.Identity);
            HUDUtil.PlaceInViewPlane(element, viewFrame);
            Cockpit.AddUIElement(element);

            Func <Vector2f> pinSourceF = options.PinSourcePoint2D;

            if (pinSourceF == null)
            {
                pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center);
            }

            Func <Vector2f> pinTargetF = options.PinTargetPoint2D;

            if (pinTargetF == null)
            {
                pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center);
            }

            Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift);

            // if we want to shift result in its layout frame, do that via a post-transform
            if (options.FrameAxesShift != Vector3f.Zero)
            {
                Solver.AddPostTransform(element, (e) => {
                    Frame3f f = (e as IElementFrame).GetObjectFrame();
                    f.Translate(options.FrameAxesShift.x * f.X + options.FrameAxesShift.y * f.Y + options.FrameAxesShift.z * f.Z);
                    (e as IElementFrame).SetObjectFrame(f);
                });
            }


            // auto-show
            if ((options.Flags & LayoutFlags.AnimatedShow) != 0)
            {
                HUDUtil.AnimatedShow(element);
            }
        }
예제 #4
0
        void add(HUDStandardItem element, LayoutOptions options)
        {
            if (element.IsVisible == false)
            {
                element.IsVisible = true;
            }

            IBoxModelElement elemBoxModel = element as IBoxModelElement;

            // for 2D view (but doesn't matter if we are doing a layout anyway!)
            Frame3f viewFrame = Cockpit.GetViewFrame2D();

            // with 3D view we should use this...
            //Frame3f viewFrame = Frame3f.Identity;

            element.SetObjectFrame(Frame3f.Identity);
            HUDUtil.PlaceInViewPlane(element, viewFrame);
            Cockpit.AddUIElement(element);

            Func <Vector2f> pinSourceF = options.PinSourcePoint2D;

            if (pinSourceF == null)
            {
                pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center);
            }

            Func <Vector2f> pinTargetF = options.PinTargetPoint2D;

            if (pinTargetF == null)
            {
                pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center);
            }

            Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift);

            // auto-show
            if ((options.Flags & LayoutFlags.AnimatedShow) != 0)
            {
                HUDUtil.AnimatedShow(element);
            }
        }
예제 #5
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;
            }
        }