Ejemplo n.º 1
0
        public static void DrawInputBoxInContainer(MonoInputBox textbox, ref SpriteBatch spBatch, GUIContainer container)
        {
            Rectangle location;
            int       x = textbox.DrawingBounds.X + container.DrawingBounds.X;
            int       y = textbox.DrawingBounds.Y + container.DrawingBounds.Y;

            location = new Rectangle(x, y, textbox.DrawingBounds.Width, textbox.DrawingBounds.Height);
            spBatch.Draw(textbox.Image, location, RenderingPipe.colorMask);
            DrawString(textbox.Font, textbox.Text, location, Alignment.Left, RenderingPipe.colorMask, ref spBatch);

            Rectangle carrotLocation = CalculateCarrotBounds(textbox, container);

            spBatch.Draw(textbox.CarrotTexture, carrotLocation, RenderingPipe.colorMask);
        }
Ejemplo n.º 2
0
        public NewWorldMenuContainer(bool visible) : base(TextureLoader.GUIMenuBackground, RenderInfo.FullScreenWindow, false)
        {
            this.Visible = visible;

            this.GameName = new MonoInputBox(TextureLoader.GUIInputBox100x50, TextureLoader.GUICursorCarrot, NewWorldMenuLayout.GameNameInputBox,
                                             int.MaxValue, TextureLoader.FontMainMenuFont12x, false,
                                             Rendering.Text.SimpleTextRenderer.Alignment.Left, true);

            this.Controls.Add(this.WorldWidth);
            this.Controls.Add(this.WorldLength);
            this.Controls.Add(this.NextButton);
            this.Controls.Add(this.LengthLabel);
            this.Controls.Add(this.WidthLabel);
            this.Controls.Add(this.GameName);
        }
Ejemplo n.º 3
0
        private static Rectangle CalculateCarrotBounds(MonoInputBox textbox, GUIContainer container)
        {
            Vector2 size   = textbox.Font.MeasureString(textbox.Text);
            Vector2 pos    = new Vector2(textbox.DrawingBounds.Center.X, textbox.DrawingBounds.Center.Y);
            Vector2 origin = size * 0.5f;

#pragma warning disable RCS1096 // Use bitwise operation instead of calling 'HasFlag'.
            if (textbox.TextAlignment.HasFlag(Alignment.Left))
            {
                origin.X += (textbox.DrawingBounds.Width / 2) - (size.X / 2);
            }

            if (textbox.TextAlignment.HasFlag(Alignment.Right))
            {
                origin.X -= (textbox.DrawingBounds.Width / 2) - (size.X / 2);
            }

            if (textbox.TextAlignment.HasFlag(Alignment.Top))
            {
                origin.Y += (textbox.DrawingBounds.Height / 2) - (size.Y / 2);
            }

            if (textbox.TextAlignment.HasFlag(Alignment.Bottom))
            {
                origin.Y -= (textbox.DrawingBounds.Height / 2) - (size.Y / 2);
            }

            string TextBeforeCarrot = textbox.Text.Substring(0, textbox.CarrotPosition);
            int    XPos             = (int)Math.Round(origin.X + textbox.DrawingBounds.X + textbox.Font.MeasureString(TextBeforeCarrot).X) + container.DrawingBounds.X;
            int    YPos             = (int)Math.Round(origin.Y + textbox.DrawingBounds.Y) + container.DrawingBounds.Y;

            switch (textbox.TextAlignment)
            {
            case Alignment.Left:
                XPos -= (int)Math.Round(origin.X);
                YPos += (int)Math.Round(origin.Y);
                break;

            default:
                break;
            }

            return(new Rectangle(XPos, YPos, textbox.CarrotWidth, textbox.CarrotHeight));
        }