コード例 #1
0
        }   // end of HandleMouseInput()

        public void Render()
        {
            if (Active)
            {
                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;
                InGame.SetViewportToScreen();

                ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

                Color darkTextColor  = new Color(20, 20, 20);
                Color greyTextColor  = new Color(127, 127, 127);
                Color greenTextColor = new Color(8, 123, 110);
                Color whiteTextColor = new Color(255, 255, 255);

                // Get display size, may be a rt.
                Vector2 displaySize = BokuGame.ScreenSize;
                if (useRtCoords)
                {
                    // Need rt size.
                    displaySize = InGame.GetCurrentRenderTargetSize();
                    InGame.SetViewportToRendertarget();
                }

                // Start with the background.
                if (useBackgroundThumbnail)
                {
                    if (!thumbnail.GraphicsDevice.IsDisposed && !thumbnail.IsDisposed)
                    {
                        // Render the blurred thumbnail (if valid) full screen.
                        if (!thumbnail.GraphicsDevice.IsDisposed)
                        {
                            InGame.RestoreViewportToFull();
                            Vector2 screenSize = new Vector2(device.Viewport.Width, device.Viewport.Height);
                            ssquad.Render(thumbnail, Vector2.Zero, screenSize, @"TexturedNoAlpha");
                            InGame.SetViewportToScreen();
                        }
                    }
                    else
                    {
                        // No valid thumbnail, clear to dark.
                        device.Clear(darkTextColor);
                    }
                }

                //
                // Background frame.
                //
                Vector2 size = new Vector2(backgroundTexture.Width, backgroundTexture.Height);
                renderPosition = (displaySize - size) / 2.0f;

                ssquad.Render(backgroundTexture, renderPosition, size, "TexturedRegularAlpha");

                //
                // Text.
                //

                // Disable write to alpha.
                device.BlendState = UI2D.Shared.BlendStateColorWriteRGB;

                Vector2 pos        = renderPosition;
                int     blankLines = maxLines - blob.NumLines;
                pos.Y += blankLines / 2.0f * Font().LineSpacing;

                // Clamp position to integer coords.
                pos.X = (int)pos.X;
                pos.Y = (int)pos.Y;
                ssquad.Render(UI2D.Shared.RenderTarget512_512, pos, new Vector2(512, 512), "TexturedRegularAlpha");

                //
                // Add button icons with labels.
                //

                SpriteBatch batch = UI2D.Shared.SpriteBatch;
                batch.Begin();

                Vector2 min;    // Used to capture info for mouse hit boxes.
                Vector2 max;

                // Calc center position.
                pos = new Vector2(displaySize.X / 2.0f, displaySize.Y / 2.0f + size.Y / 2.0f - 1.8f * Font().LineSpacing);

                // Calc overall width buttons and text.  Leave a button width's space between each section.
                float aWidth      = Font().MeasureString(Strings.Localize("toast.continue")).X;
                int   buttonWidth = 48;
                float totalWidth  = aWidth + 1.0f * buttonWidth;

                pos.X -= totalWidth / 2.0f;

                // A button
                min = pos;
                ssquad.Render(ButtonTextures.AButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha");
                pos.X += buttonWidth;
                TextHelper.DrawString(Font, Strings.Localize("toast.continue"), pos, labelAColor);
                max = new Vector2(pos.X + aWidth, min.Y + buttonWidth);
                hitBoxA.Set(min, max);

                batch.End();

                // Restore write to alpha.
                device.BlendState = BlendState.NonPremultiplied;
            }
        }   // end of TextDisplay Render()