コード例 #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.
                Vector2        rtSize = new Vector2(rtFull.Width, rtFull.Height);

                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);

                // No put it all together.
                // Start with the background.
                Vector2 screenSize = BokuGame.ScreenSize;
                if (useRtCoords)
                {
                    // Need the size of the RT instead.
                    screenSize = InGame.GetCurrentRenderTargetSize();
                    Debug.Assert(screenSize != Vector2.Zero);
                }

                if (useBackgroundThumbnail)
                {
                    if (!thumbnail.GraphicsDevice.IsDisposed && !thumbnail.IsDisposed)
                    {
                        // Render the blurred thumbnail (if valid) full screen.
                        if (!thumbnail.GraphicsDevice.IsDisposed)
                        {
                            InGame.RestoreViewportToFull();
                            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      = screenSize / dialogSize;
                renderScale = Math.Min(Math.Min(scale.X, scale.Y), 1.0f);
                Vector2 renderSize = rtSize * renderScale;

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

                // Clamp to pixel coords.
                renderPosition.X = (int)renderPosition.X;
                renderPosition.Y = (int)renderPosition.Y;

                ssquad.Render(rtFull, renderPosition, renderSize, @"TexturedRegularAlpha");
            }
        }   // end of ScrollableTextDisplay Render()
コード例 #2
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;
                }

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

                SpriteBatch batch = UI2D.Shared.SpriteBatch;
                Vector2     min; // Used to capture info for mouse hit boxes.
                Vector2     max;

                batch.Begin();
                {
                    // Calc center position.
                    pos = new Vector2(rtSize.X / 2.0f, rtSize.Y / 2.0f + backgroundSize.Y * 0.28f);

                    // Calc overall width buttons and text.  Leave a button width's space between each section.
                    float aWidth      = Font().MeasureString(Strings.Localize("toast.continue")).X;
                    float xWidth      = Font().MeasureString(Strings.Localize("toast.dismiss")).X;
                    int   buttonWidth = 48;
                    float totalWidth  = aWidth + xWidth + 3.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);

                    pos.X += aWidth;

                    // Space
                    pos.X += buttonWidth;

                    // X button
                    min = pos;
                    ssquad.Render(ButtonTextures.XButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha");
                    pos.X += buttonWidth;
                    TextHelper.DrawString(Font, Strings.Localize("toast.dismiss"), pos, labelBColor);
                    max = new Vector2(pos.X + xWidth, min.Y + buttonWidth);
                    hitBoxB.Set(min, max);
                }
                batch.End();

                // Add left stick if needed.
                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 ScrollableModalHint Render()
コード例 #3
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);

                // 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 = (BokuGame.ScreenSize - 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;
                blob.RenderWithButtons(pos + textPosition, greyTextColor);

                //
                // 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(BokuGame.ScreenSize.X / 2.0f, BokuGame.ScreenSize.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;
                float xWidth      = Font().MeasureString(Strings.Localize("toast.dismiss")).X;
                int   buttonWidth = 48;
                float totalWidth  = aWidth + xWidth + 3.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);

                pos.X += aWidth;

                // Space
                pos.X += buttonWidth;

                // X button
                min = pos;
                ssquad.Render(ButtonTextures.XButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha");
                pos.X += buttonWidth;
                TextHelper.DrawString(Font, Strings.Localize("toast.dismiss"), pos, labelBColor);
                max = new Vector2(pos.X + xWidth, min.Y + buttonWidth);
                hitBoxB.Set(min, max);

                batch.End();

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