Esempio n. 1
0
        }   // end of PreRender()

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

                RenderTarget2D rtFull = UI2D.Shared.RenderTargetDepthStencil1024_768;   // Rendertarget we render whole display into.
                RenderTarget2D rt1k   = UI2D.Shared.RenderTarget1024_768;

                Vector2 rtSize = new Vector2(rtFull.Width, rtFull.Height);

                CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance();
                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);

                // Render the scene to our rendertarget.
                InGame.SetRenderTarget(rtFull);

                // Clear to transparent.
                InGame.Clear(Color.Transparent);

                // Set up params for rendering UI with this camera.
                Fx.ShaderGlobals.SetCamera(camera);

                Vector2 pos;

                // Now render the background tiles.
                Vector2 backgroundSize = new Vector2(backgroundTexture.Width, backgroundTexture.Height);
                pos = (rtSize - backgroundSize) / 2.0f;
                ssquad.Render(backgroundTexture, pos, backgroundSize, @"TexturedRegularAlpha");

                displayPosition = pos;

                // Now render the contents of the rt1k texture but with the edges blended using the mask.
                Vector2 rt1kSize = new Vector2(rt1k.Width, rt1k.Height);
                pos -= new Vector2(40, 70);
                try//minimize bug fix.
                {
                    Vector4 limits = new Vector4(0.095f, 0.112f, 0.57f, 0.64f);
                    ssquad.RenderWithYLimits(rt1k, limits, pos, rt1kSize, @"TexturedPreMultAlpha");
                }
                catch
                {
                    return;
                }

                //
                // Render buttons.
                //

                float margin     = 64.0f;
                float totalWidth = continueButton.GetSize().X + /* margin + backButton.GetSize().X + */ margin + exitTutorialButton.GetSize().X;
                pos    = new Vector2(rtSize.X / 2.0f, rtSize.Y / 2.0f + backgroundSize.Y * 0.28f);
                pos.X -= totalWidth / 2.0f;

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

                continueButton.Render(pos);
                pos.X += continueButton.GetSize().X + margin;

                /*
                 * backButton.Render(pos);
                 * pos.X += backButton.GetSize().X + margin;
                 */

                exitTutorialButton.Render(pos);

                batch.End();

                // Add left stick if needed.
                Vector2 min;
                Vector2 max;
                if (blob.NumLines >= textVisibleLines)
                {
                    pos = displayPosition + new Vector2(-31, 300);
                    ssquad.Render(leftStick, pos, new Vector2(leftStick.Width, leftStick.Height), "TexturedRegularAlpha");
                    min = pos;
                    max = min + new Vector2(leftStick.Width, leftStick.Height / 2.0f);
                    upBox.Set(min, max);
                    min.Y  = max.Y;
                    max.Y += leftStick.Height / 2.0f;
                    downBox.Set(min, max);
                }

                InGame.RestoreRenderTarget();
                InGame.SetViewportToScreen();

                // No put it all together.
                // 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);
                    }
                }

                // Calc scaling and position for rt.
                renderPosition = Vector2.Zero;
                renderScale    = 1.0f;

                // The part of the dialog we care about is 1024x600 so we want to use
                // that as the size to fit to the screen.
                Vector2 dialogSize = new Vector2(1024, 600);
                Vector2 scale      = BokuGame.ScreenSize / dialogSize;
                renderScale = Math.Min(Math.Min(scale.X, scale.Y), 1.0f);
                Vector2 renderSize = rt1kSize * renderScale;

                // Center on screen.
                renderPosition = (BokuGame.ScreenSize - renderSize) / 2.0f;

                ssquad.Render(rtFull, renderPosition, renderSize, @"TexturedRegularAlpha");
            }
        }   // end of ScrollableTextDisplay Render()