예제 #1
0
 public void Draw(IGraphicsBatch graphics)
 {
     for (int i = 0; i < this.stars.Length; i++)
         graphics.DrawFilledRectangle(new Rectangle((int)this.stars[i].X, (int)this.stars[i].Y, this.stars[i].Size, this.stars[i].Size), Color.White);
 }
예제 #2
0
        public void Draw(IGraphicsBatch graphics)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            this.EnsureFont();

            if (this.IsVisible)
            {
                float top = 0.0f;

                if (this.State == GameConsoleState.SlideDown || this.State == GameConsoleState.SlideUp)
                    top = this.Height - (this.Height * (float)(this.AnimationTime.TotalSeconds / this.animationElapsedTime.TotalSeconds));

                Rectangle rectangle = new Rectangle(0, (int)top, this.Window.DisplayWidth, this.Height);

                if (this.BackgroundTexture != null)
                    graphics.DrawTexture(this.BackgroundTexture, rectangle, this.BackgroundColor);
                else
                    graphics.DrawFilledRectangle(rectangle, this.BackgroundColor);

                float y = top + this.Height - this.Padding;

                if (this.InputEnabled)
                {
                    y -= this.Font.LineHeight + this.Font.LineSpacing;

                    graphics.DrawString(this.Font, this.InputPrompt, new Vector2(this.Padding, y), this.InputColor);

                    Size promptSize = this.Font.MeasureString(this.InputPrompt);
                    graphics.DrawString(this.Font, this.input.ToString(), new Vector2(this.Padding + promptSize.Width, y), this.InputColor);

                    Size cursorLocation = Size.Zero;
                    if (this.cursorPosition > 0 && this.input.Length > 0)
                        cursorLocation = this.Font.MeasureString(this.input.ToString(), 0, this.cursorPosition);

                    graphics.DrawString(this.Font, "_", new Vector2(this.Padding + promptSize.Width + cursorLocation.Width, y), this.InputColor);
                }

                for (int i = 0; i < this.lineCount; i++)
                {
                    int index = this.firstLine - i;

                    if (index < 0)
                        index += this.lines.Length;

                    y -= this.Font.LineHeight + this.Font.LineSpacing;
                    graphics.DrawString(this.Font, this.lines[index].Text, new Vector2(this.Padding, y), this.lines[index].Color);
                }
            }
        }