コード例 #1
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;
            }
        }