コード例 #1
0
ファイル: TimeRuler.cs プロジェクト: willcraftia/Blocks
        protected override void LoadContent()
        {
            var titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea;

            // 表示幅を TitleSafeArea から余白を考慮した値に設定。
            width = titleSafeArea.Width - 16;

            // 表示位置を計算します。
            // 高さは Bar の数で変動するため、Bottom 合わせで固定し、Bottom ラインをベースに描画時に調整します。
            var layout = new DebugLayout()
            {
                ContainerBounds     = titleSafeArea,
                Width               = width,
                Height              = 0,
                HorizontalMargin    = 8,
                VerticalMargin      = 8,
                HorizontalAlignment = DebugHorizontalAlignment.Center,
                VerticalAlignment   = DebugVerticalAlignment.Bottom
            };

            layout.Arrange();

            offsetX = layout.ArrangedBounds.X;
            offsetY = layout.ArrangedBounds.Y;

            spriteBatch = new SpriteBatch(GraphicsDevice);
            fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice);

            base.LoadContent();
        }
コード例 #2
0
        public override void Draw(GameTime gameTime)
        {
            // Draw 呼び出しをサンプリングします。
            sampleFrames++;

            spriteBatch.Begin();

            // 背景領域を計算します。
            var layout = new DebugLayout();

            layout.ContainerBounds     = GraphicsDevice.Viewport.TitleSafeArea;
            layout.Width               = (int)fontSize.X + 4;
            layout.Height              = (int)fontSize.Y + 2;
            layout.HorizontalMargin    = 8;
            layout.VerticalMargin      = 8;
            layout.HorizontalAlignment = HorizontalAlignment;
            layout.VerticalAlignment   = VerticalAlignment;
            layout.Arrange();

            spriteBatch.Draw(fillTexture, layout.ArrangedBounds, BackgroundColor);

            // 文字列表示領域を計算します。
            layout.ContainerBounds     = layout.ArrangedBounds;
            layout.Width               = (int)fontSize.X;
            layout.Height              = (int)fontSize.Y;
            layout.HorizontalMargin    = 2;
            layout.VerticalMargin      = 0;
            layout.HorizontalAlignment = DebugHorizontalAlignment.Center;
            layout.VerticalAlignment   = DebugVerticalAlignment.Center;
            layout.Arrange();

            // 文字色を決定します。
            var color = !gameTime.IsRunningSlowly ? ForegroundColor : RunningSlowlyForegroundColor;

            spriteBatch.DrawString(font, stringBuilder, new Vector2(layout.ArrangedBounds.X, layout.ArrangedBounds.Y), color);

            spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #3
0
        protected override void Draw(GameTime gameTime)
        {
            drawMarker.Begin();

            GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            // ゲームオブジェクトの描画
            DrawGameObjects();

            // ステータス表示
            float margin = font.LineSpacing * 0.2f;
            Vector2 size = font.MeasureString(statusString);
            size.Y += margin * 2.0f;

            var layout = new DebugLayout();
            layout.ContainerBounds = GraphicsDevice.Viewport.Bounds;
            layout.Width = (int) size.X;
            layout.Height = (int) size.Y;
            layout.HorizontalAlignment = DebugHorizontalAlignment.Left;
            layout.VerticalAlignment = DebugVerticalAlignment.Top;
            layout.HorizontalMargin = 8;
            layout.VerticalMargin = 8;
            layout.Arrange();

            spriteBatch.Begin();
            spriteBatch.Draw(fillTexture, layout.ArrangedBounds, new Color(0, 0, 0, 200));
            spriteBatch.DrawString(
                font, statusString, new Vector2(layout.ArrangedBounds.X, layout.ArrangedBounds.Y + margin), Color.White);
            spriteBatch.End();

            drawMarker.End();

            base.Draw(gameTime);
        }
コード例 #4
0
ファイル: TimeRuler.cs プロジェクト: willcraftia/Blocks
        protected override void LoadContent()
        {
            var titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea;

            // 表示幅を TitleSafeArea から余白を考慮した値に設定。
            width = titleSafeArea.Width - 16;

            // 表示位置を計算します。
            // 高さは Bar の数で変動するため、Bottom 合わせで固定し、Bottom ラインをベースに描画時に調整します。
            var layout = new DebugLayout()
            {
                ContainerBounds = titleSafeArea,
                Width = width,
                Height = 0,
                HorizontalMargin = 8,
                VerticalMargin = 8,
                HorizontalAlignment = DebugHorizontalAlignment.Center,
                VerticalAlignment = DebugVerticalAlignment.Bottom
            };
            layout.Arrange();

            offsetX = layout.ArrangedBounds.X;
            offsetY = layout.ArrangedBounds.Y;

            spriteBatch = new SpriteBatch(GraphicsDevice);
            fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice);

            base.LoadContent();
        }
コード例 #5
0
ファイル: FpsCounter.cs プロジェクト: willcraftia/Blocks
        public override void Draw(GameTime gameTime)
        {
            // Draw 呼び出しをサンプリングします。
            sampleFrames++;

            spriteBatch.Begin();

            // 背景領域を計算します。
            var layout = new DebugLayout();
            layout.ContainerBounds = GraphicsDevice.Viewport.TitleSafeArea;
            layout.Width = (int) fontSize.X + 4;
            layout.Height = (int) fontSize.Y + 2;
            layout.HorizontalMargin = 8;
            layout.VerticalMargin = 8;
            layout.HorizontalAlignment = HorizontalAlignment;
            layout.VerticalAlignment = VerticalAlignment;
            layout.Arrange();

            spriteBatch.Draw(fillTexture, layout.ArrangedBounds, BackgroundColor);

            // 文字列表示領域を計算します。
            layout.ContainerBounds = layout.ArrangedBounds;
            layout.Width = (int) fontSize.X;
            layout.Height = (int) fontSize.Y;
            layout.HorizontalMargin = 2;
            layout.VerticalMargin = 0;
            layout.HorizontalAlignment = DebugHorizontalAlignment.Center;
            layout.VerticalAlignment = DebugVerticalAlignment.Center;
            layout.Arrange();

            // 文字色を決定します。
            var color = !gameTime.IsRunningSlowly ? ForegroundColor : RunningSlowlyForegroundColor;

            spriteBatch.DrawString(font, stringBuilder, new Vector2(layout.ArrangedBounds.X, layout.ArrangedBounds.Y), color);

            spriteBatch.End();

            base.Draw(gameTime);
        }