Пример #1
0
        // actually create GO elements, etc
        public void Create()
        {
            entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDPopupMessage"));

            bgMesh = AppendMeshGO("background", make_background_mesh(),
                                  MaterialUtil.CreateFlatMaterialF(BackgroundColor),
                                  entry);
            bgMesh.RotateD(Vector3f.AxisX, -90.0f);


            IBoxModelElement contentArea = BoxModel.PaddedBounds(this, Padding);

            BoxPosition titleBoxPos = BoxModel.ToPosition(TitleAlignment, VerticalAlignment.Top);

            titleTextMesh = (titleText == "") ? null : GameObjectFactory.CreateTextMeshGO(
                "title", TitleText, TextColor, TitleTextHeight, titleBoxPos, SceneGraphConfig.TextLabelZOffset);
            float fTitleHeight = 0;

            if (titleTextMesh != null)
            {
                Vector2f titleToPos = BoxModel.GetBoxPosition(contentArea, titleBoxPos);
                BoxModel.Translate(titleTextMesh, Vector2f.Zero, titleToPos);
                AppendNewGO(titleTextMesh, entry, false);
                fTitleHeight = TitleTextHeight;
            }

            IBoxModelElement messageArea = BoxModel.PaddedBounds(contentArea, 0, 0, 0, Padding + fTitleHeight);
            Vector2f         textDims    = messageArea.Size2D;

            BoxPosition textBoxPos = BoxModel.ToPosition(Alignment, VerticalAlignment.Top);

            textMesh = GameObjectFactory.CreateTextAreaGO(
                "message", Text, TextColor, TextHeight, textDims, Alignment, textBoxPos, SceneGraphConfig.TextLabelZOffset);
            Vector2f textToPos = BoxModel.GetBoxPosition(messageArea, textBoxPos);

            BoxModel.Translate(textMesh, Vector2f.Zero, textToPos);
            AppendNewGO(textMesh, entry, false);



            if (EnableClickToDismiss)
            {
                footerTextMesh = GameObjectFactory.CreateTextMeshGO(
                    "footer", DismissText, DismissTextColor, TextHeight * 0.5f,
                    BoxPosition.CenterBottom, SceneGraphConfig.TextLabelZOffset);
                BoxModel.Translate(footerTextMesh, Vector2f.Zero, BoxModel.GetBoxPosition(contentArea, BoxPosition.CenterBottom));
                AppendNewGO(footerTextMesh, entry, false);
            }
        }
Пример #2
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;
            }
        }