}   // end of HandleTouchInput()

        public override void Render(Camera camera)
        {
            CameraSpaceQuad quad = CameraSpaceQuad.GetInstance();

            Vector2 pos = new Vector2(worldMatrix.Translation.X, worldMatrix.Translation.Y);

            pos.X -= 3.4f;
            quad.Render(camera, tile, alpha, pos, new Vector2(1.2f, 1.2f), "TexturedRegularAlpha");

            pos.X += 0.8f;
            pos.Y += 0.7f;
            Point loc = camera.WorldToScreenCoords(new Vector3(pos.X, pos.Y, 0.0f));

            pos = new Vector2(loc.X, loc.Y);

            if (textBlob.NumLines == 1)
            {
                pos.Y += textBlob.Font().LineSpacing;
            }
            if (textBlob.NumLines == 2)
            {
                pos.Y += 0.5f * textBlob.Font().LineSpacing;
            }

            textBlob.RenderWithButtons(pos, textColor, maxLines: 3);
        }   // end of UIGrid2DProgrammedBotElement Render()
        }   // end of UIGridWaterElement UnloadContent()

        #region Internal
        /// <summary>
        /// Fake the explicit bloom some water materials have, since the real bloom effect doesn't
        /// work in the UI (it's postprocess).
        /// </summary>
        /// <param name="camera"></param>
        /// <param name="worldToCamera"></param>
        /// <param name="materialIndex"></param>
        private void RenderGlow(Camera camera, Matrix worldToCamera, int materialIndex)
        {
            if (Water.Types[materialIndex].ExplicitBloom > 0.0f)
            {
                /// Figure out how tall the water cube is.
                Vector3 normal = Vector3.Zero;
                float   offset = Terrain.GetCycleOffset(Vector2.Zero, ref normal);
                offset -= (float)Time.GameTimeTotalSeconds;
                float waveHeight = Terrain.WaveHeight * (float)(Math.Sin(offset) - 1.0);

                /// Lots of hacky constants here, just trying to get the quad
                /// to match in size with this undulating blobby squishy cube.
                /// Sorry, but not really.
                CameraSpaceQuad quad     = CameraSpaceQuad.GetInstance();
                Vector2         position = new Vector2(Position.X, Position.Y);
                position.X = worldToCamera.Translation.X;
                position.Y = worldToCamera.Translation.Y + (waveHeight + 0.4f) * 0.5f * worldToCamera.Up.Length();
                Vector2 size = new Vector2(
                    Size.X * worldToCamera.Right.Length() * 0.8f,
                    Size.Y * worldToCamera.Up.Length() * (1.0f + waveHeight));
                quad.Render(camera,
                            glowTexture,
                            2.0f * Water.Types[materialIndex].ExplicitBloom,
                            position,
                            size,
                            @"AdditiveBlend");
            }
        }
        }   // end of GetElementInfo()

        public override void Render(Camera camera)
        {
            if (active && alpha > 0.0f)
            {
                // Render reticule around selected brush.
                CameraSpaceQuad        quad = CameraSpaceQuad.GetInstance();
                UIGrid2DTextureElement e    = (UIGrid2DTextureElement)grid.SelectionElement;
                Vector2 position            = new Vector2(e.Position.X, e.Position.Y);
                position.X += grid.WorldMatrix.Translation.X;
                position.Y += grid.WorldMatrix.Translation.Y;
                position.Y -= 0.14f;    // No clue.  Nedd to figure this out.
                Vector2 size = 2.0f * new Vector2(e.Size.X, e.Size.Y);
                quad.Render(camera, reticuleTexture, alpha, position, size, @"AdditiveBlend");

                // Trigger icons?
                double curTime = Time.WallClockTotalSeconds;
                double dTime   = curTime - lastChangedTime;
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad && dTime > kPreFadeTime)
                {
                    dTime -= kPreFadeTime;

                    float   triggerAlpha = Math.Min((float)(dTime / kFadeTime), 1.0f);
                    Vector2 offset       = size * 0.4f;
                    size *= 0.4f;
                    // Note the 12/64 in the positioning accounts for the fact that the
                    // button textures only use the upper 40x40 out of the 64x64 space they allocate.
                    // The 12 is actually (64-40)/2.
                    quad.Render(camera, ButtonTextures.RightTrigger, triggerAlpha, position + offset + size * 12.0f / 64.0f, size, @"TexturedRegularAlpha");
                    offset.X = -offset.X;
                    quad.Render(camera, ButtonTextures.LeftTrigger, triggerAlpha, position + offset + size * 12.0f / 64.0f, size, @"TexturedRegularAlpha");
                }
            }

            base.Render(camera);
        } // end of BrushPicker Render()
            public override void Render(Camera camera)
            {
                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

                CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance();
                ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

                Color darkTextColor = new Color(20, 20, 20);

                var size = shared.location.Size;
                // Render background.
                var pos = shared.location.Min;

                if (shared.parent.Active)
                {
                    var highliteSize = new Vector2(1, 1);
                    ssquad.Render(new Vector4(0, 0, 0, 255), pos - highliteSize, size + (highliteSize * 2));
                }
                ssquad.Render(backgroundTexture, pos, size, @"TexturedRegularAlpha");

                var iconOffset = new Vector2();

                if (iconTexture != null)
                {
                    ssquad.Render(iconTexture, pos, new Vector2(iconTexture.Width, iconTexture.Height),
                                  @"TexturedRegularAlpha");
                    iconOffset = new Vector2(iconTexture.Width, iconTexture.Height);
                }
                //Setup text clipping
                var oldViewport = device.Viewport;
                var newViewport = device.Viewport;

                newViewport.X      = (int)shared.location.Min.X + (int)iconOffset.X;
                newViewport.Y      = (int)shared.location.Min.Y;
                newViewport.Width  = (int)shared.location.Size.X - (int)iconOffset.X;
                newViewport.Height = (int)shared.location.Size.Y;
                device.Viewport    = newViewport;

                //handle horizontal scrolling
                var offset = 0;
                int curLine, curPos;

                shared.blob.FindCursorLineAndPosition(out curLine, out curPos);
                if (curPos > newViewport.Width - 30)
                {
                    offset = -curPos + ((int)newViewport.Width - 30);
                }
                pos = new Vector2(shared.textMargin + offset, shared.textTop + shared.textOffset);

                //Flash cursor every half second
                var cursorOn = DateTime.Now.Millisecond > 500 & shared.parent.Active;

                //Render text
                shared.blob.RenderWithButtons(pos, darkTextColor, renderCursor: cursorOn);

                //Restore viewport
                device.Viewport = oldViewport;
            }   // end of TextInput RenderObj Render()
Beispiel #5
0
        }   // end of Update()

        public void Render(Camera camera)
        {
            if (alpha > 0.0f)
            {
                CameraSpaceQuad quad = CameraSpaceQuad.GetInstance();
                Vector2         s    = new Vector2(size);
                quad.Render(camera, texture, alpha, position, s, "TexturedRegularAlpha");
            }
        }   // end of Render()
        }   // end of HandleMouseInput();

        public override void Render(Camera camera)
        {
            if (active && !hidden)
            {
                // Render reticule around selected material.
                CameraSpaceQuad    quad     = CameraSpaceQuad.GetInstance();
                UIGridWaterElement e        = (UIGridWaterElement)grid.SelectionElement;
                Vector2            position = new Vector2(e.Position.X, e.Position.Y);
                position.X += grid.WorldMatrix.Translation.X;
                position.Y += grid.WorldMatrix.Translation.Y;
                Vector2 size = 2.0f * new Vector2(e.Size.X, e.Size.Y);
                quad.Render(camera, reticuleTexture, position, size, @"AdditiveBlend");

                // Trigger icons?
                double curTime = Time.WallClockTotalSeconds;
                double dTime   = curTime - lastChangedTime;
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad && dTime > kPreFadeTime)
                {
                    dTime -= kPreFadeTime;

                    float   alpha  = Math.Min((float)(dTime / kFadeTime), 1.0f);
                    Vector2 offset = size * 0.4f;
                    size *= 0.4f;
                    // Note the 12/64 in the positioning accounts for the fact that the
                    // button textures only use the upper 40x40 out of the 64x64 space they allocate.
                    // The 12 is actually (64-40)/2.
                    quad.Render(camera, ButtonTextures.RightTrigger, alpha, position + offset + size * 12.0f / 64.0f, size, @"TexturedRegularAlpha");
                    offset.X = -offset.X;
                    quad.Render(camera, ButtonTextures.LeftTrigger, alpha, position + offset + size * 12.0f / 64.0f, size, @"TexturedRegularAlpha");
                }
            }

            BokuGame.bokuGame.GraphicsDevice.DepthStencilState = DepthStencilState.None;
            base.Render(camera);

            /*
             * // Debug code to show spherical bounding hits.
             * Vector4 red = new Vector4(1, 0, 0, 0.5f);
             * if (active && !hidden)
             * {
             *  for (int i = 0; i < grid.ActualDimensions.X; i++)
             *  {
             *      UIGridWaterElement e = grid.Get(i, 0) as UIGridWaterElement;
             *
             *      // Don't bother if offscreen.
             *      Vector3 position = e.WorldMatrix.Translation;
             *      float radius = 2.0f;
             *      Frustum.CullResult cullResult = camera.Frustum.CullTest(position, radius);
             *      if (cullResult == Frustum.CullResult.TotallyOutside)
             *          continue;
             *
             *      Utils.DrawSolidSphere(camera, e.HitWorldMatrix.Translation, 1.25f * e.HitWorldMatrix.M33, red);
             *  }
             * }
             */
        } // end of WaterPicker Render()
Beispiel #7
0
        public void Render(Camera camera)
        {
            if (Active)
            {
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    touchOver.Render(Boku.InGame.inGame.shared.camera);
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    mouseOver.Render(Boku.InGame.inGame.shared.camera);
                }

                Boku.InGame.RenderColorMenu(focusColorIndex);

                if (sliderActive)
                {
                    // Render menu using local camera.
                    Fx.ShaderGlobals.SetCamera(camera);



                    float tutScale = 1.0f;
                    if (BokuGame.ScreenSize.X > BokuGame.ScreenSize.Y)
                    {
                        float smallestRes = Math.Min(camera.Resolution.X, camera.Resolution.Y);
                        tutScale = (smallestRes > 0) ? BokuGame.ScreenSize.Y / smallestRes : 1.0f;
                    }
                    else
                    {
                        float biggestRes = Math.Max(camera.Resolution.X, camera.Resolution.Y);
                        tutScale = (biggestRes > 0) ? BokuGame.ScreenSize.X / biggestRes : 1.0f;
                    }

                    // Note 7.5 is the default vertical height for the UI camera.
                    float y = -7.5f / 2.0f + tutScale * slider.Size.Y;
                    slider.WorldMatrix = Matrix.CreateScale(tutScale) * Matrix.CreateTranslation(new Vector3(0.0f, y, 0.0f));
                    slider.position    = slider.WorldMatrix.Translation;
                    slider.Render(camera);

                    // Render the CloseBox.
                    CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance();
                    float           scale  = 0.33f;
                    closeSize = tutScale * scale * new Vector2(slider.Height, slider.Height);
                    // Calc position to have top even with top of slider.
                    closePosition    = tutScale * new Vector2(slider.WorldMatrix.Translation.X + slider.Width / 2.0f + closeSize.X / 2.0f, slider.WorldMatrix.Translation.Y + (1.0f - scale) * slider.Height / 2.0f);
                    closePosition    = new Vector2(slider.WorldMatrix.Translation.X, slider.WorldMatrix.Translation.Y);
                    closePosition.X += tutScale * slider.Size.X / 2.0f + closeSize.X / 2.0f;
                    closePosition.Y += tutScale * slider.Size.Y / 2.0f - closeSize.Y / 2.0f;
                    // Hack adjust for issues with art.
                    closePosition += tutScale * new Vector2(-0.04f, -0.03f);
                    csquad.Render(camera, closeSquareTexture, closePosition, closeSize, "TexturedRegularAlpha");
                }
            }
        }   // end of Render()
Beispiel #8
0
        }   // end of HandleTouchInput()

        public override void Render(Camera camera)
        {
            CameraSpaceQuad quad = CameraSpaceQuad.GetInstance();

            Vector2 size = new Vector2(1.0f, 1.0f);
            Vector2 pos  = new Vector2(worldMatrix.Translation.X, worldMatrix.Translation.Y);
            //pos.Y += height / 2.0f;
            float gap = 0.1f;

            if (camera.Frustum.CullTest(worldMatrix.Translation, 1.2f) == Frustum.CullResult.TotallyOutside)
            {
                return;
            }

            // Render the reflex.

            if (tiles != null)
            {
                for (int i = 0; i < tiles.Count; i++)
                {
                    // Not fully selected?
                    if (alpha < 1.0f)
                    {
                        quad.Render(camera, unselectedBackground, pos + new Vector2(i * (size.X + gap), 0), size, @"TexturedRegularAlpha");
                    }

                    // Not fully unselected?
                    if (alpha > 0.0f)
                    {
                        quad.Render(camera, selectedBackground, alpha, pos + new Vector2(i * (size.X + gap), 0), size, @"TexturedRegularAlpha");
                    }

                    quad.Render(camera, tiles[i], pos + new Vector2(i * (size.X + gap), 0), size, @"TexturedRegularAlpha");
                }
            }

            // And the description.
            GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

            //device.BlendState = UI2D.Shared.BlendStateColorWriteRGB;

            pos.Y -= size.Y / 2.0f;
            Point pixelCoord = camera.WorldToScreenCoords(new Vector3(pos.X, pos.Y, 0.0f));

            pos = new Vector2(pixelCoord.X, pixelCoord.Y);
            descBlob.RenderWithButtons(pos, textColor);

            //device.BlendState = BlendState.AlphaBlend;
        }   // end of UIGrid2DExampleElement Render()
Beispiel #9
0
        }   // end of HandleTouchInput()

        public override void Render(Camera camera)
        {
            effect.CurrentTechnique = effect.Techniques["NormalMappedWithEnv"];
            effect.Parameters["DiffuseTexture"].SetValue(diffuse);

            effect.Parameters["WorldMatrix"].SetValue(worldMatrix);
            effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix);

            effect.Parameters["Alpha"].SetValue(Alpha);
            effect.Parameters["DiffuseColor"].SetValue(new Vector4(1.0f, 1.0f, 1.0f, 1.0f));
            effect.Parameters["SpecularColor"].SetValue(specularColor);
            effect.Parameters["SpecularPower"].SetValue(specularPower);

            effect.Parameters["NormalMap"].SetValue(normalMap);

            // Render the base tile.
            geometry.Render(effect);

            // Add the LEDs.
            CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance();

            Vector2 size           = new Vector2(0.2f, 0.2f);
            Vector2 innerFocusSize = new Vector2(0.24f, 0.24f);
            Vector2 outerFocusSize = new Vector2(0.28f, 0.28f);
            Vector2 margin         = new Vector2(0.125f, 0.125f);
            // Postion of first LED.
            Vector2 basePosition = new Vector2(Position.X, Position.Y);

            basePosition.X = basePosition.X - 2.0f * size.X - 2.0f * margin.X;
            basePosition.Y = basePosition.Y + 2.0f * size.Y + 2.0f * margin.Y;
            for (int i = 0; i < 25; i++)
            {
                Vector2 pos = basePosition;
                pos.X += (i % 5) * (size.X + margin.X);
                pos.Y -= (int)(i / 5) * (size.Y + margin.Y);
                Vector4 color = leds[i] ? new Vector4(1, 0, 0, 1) : new Vector4(0, 0, 0, 1);
                if (i == focusIndex)
                {
                    // Highlight around in-focus LED.
                    csquad.Render(camera, white, new Vector4(1, 0, 0, 1), 1.0f, pos, outerFocusSize, "TexturedRegularAlpha");
                    csquad.Render(camera, white, new Vector4(1, 1, 1, 1), 1.0f, pos, innerFocusSize, "TexturedRegularAlpha");
                }
                csquad.Render(camera, white, color, 1.0f, pos, size, "TexturedRegularAlpha");

                // Also set hit box in camera space.
                ledHitBoxes[i].Set(pos - size, pos + size);
            }
        }   // end of UIGrid2DLEDArray Render()
Beispiel #10
0
            public override void Render(Camera camera)
            {
                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

                // Clear the screen & z-buffer.
                InGame.Clear(backgroundColor);

                // Set up params for rendering UI with this camera.
                BokuGame.bokuGame.shaderGlobals.Effect.Parameters["EyeLocation"].SetValue(new Vector4(shared.camera.From, 1.0f));
                BokuGame.bokuGame.shaderGlobals.Effect.Parameters["CameraUp"].SetValue(new Vector4(shared.camera.Up, 1.0f));

                // Render the active grid using the local camera.
                UIGrid curGrid = shared.GetGridFromCurTab();

                if (curGrid != null)
                {
                    curGrid.Render(shared.camera);
                }

                // Render the backdrop/frame on top of the grid.
                ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

                ssquad.Render(shared.backgroundTexture, new Vector2(0.0f), new Vector2(BokuGame.bokuGame.GraphicsDevice.Viewport.Width - 1.0f, BokuGame.bokuGame.GraphicsDevice.Viewport.Height - 1.0f), @"TexturedRegularAlpha");

                // Render the tabs.
#if !HIDE_MISSIONS
                shared.missionsTab.Render(shared.camera);
#endif
                shared.myWorldsTab.Render(shared.camera);
                shared.starterWorldsTab.Render(shared.camera);
                shared.downloadsTab.Render(shared.camera);


                // Render the bottom bar.  Well, actually, instead of rendering the bar
                // we'll just steal the texture from it and render than.
                shared.bottomBar.Render(shared.camera);
                CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance();

                //csquad.Render(shared.camera, shared.bottomBar.Diffuse.GetTexture(), new Vector2(0.0f, -3.35f), new Vector2(9.5f, 0.5f), @"TexturedRegularAlpha");

                // Render the buttons for the bottom bar.
                if (shared.parent.curTab == Tab.MyWorlds || shared.parent.curTab == Tab.Downloads)
                {
                    csquad.Render(shared.camera, ButtonTextures.XButton, shared.xButtonPosition, shared.buttonSize, @"TexturedRegularAlpha");
                }
                csquad.Render(shared.camera, ButtonTextures.YButton, shared.yButtonPosition, shared.buttonSize, @"TexturedRegularAlpha");
            }   // end of LoadLevelMenu RenderObj Render()
Beispiel #11
0
        public void Render()
        {
            if (active)
            {
                // Render menu using local camera.
                Fx.ShaderGlobals.SetCamera(camera);

                // Darken the background to emphasize to the user that they need to pick a tool.
                ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();
                ssquad.Render(dropShadowTexture, new Vector4(0, 0, 0, 0.9f), new Vector2(0, 0.6f * BokuGame.ScreenSize.Y), new Vector2(BokuGame.ScreenSize.X, 0.4f * BokuGame.ScreenSize.Y), "TexturedRegularAlpha");

                grid.Render(camera);

                // Render reticule around selected tools tile.
                CameraSpaceQuad        csquad = CameraSpaceQuad.GetInstance();
                UIGrid2DTextureElement e      = (UIGrid2DTextureElement)grid.SelectionElement;
                Vector2 position = new Vector2(e.Position.X, e.Position.Y);
                position.X += grid.WorldMatrix.Translation.X;
                position.Y += grid.WorldMatrix.Translation.Y;
                position.Y -= 0.14f;    // No clue.  Nedd to figure this out.
                Vector2 size  = 2.0f * new Vector2(e.Size.X, e.Size.Y);
                float   alpha = 1.0f;
                csquad.Render(camera, BasePicker.reticuleTexture, alpha, position, size, @"AdditiveBlend");

                // Don't bother with trigger icons if we're modal.
                if (!XmlOptionsData.ModalToolMenu)
                {
                    // Trigger icons?
                    double curTime = Time.WallClockTotalSeconds;
                    double dTime   = curTime - lastChangedTime;
                    if (dTime > kPreFadeTime)
                    {
                        dTime -= kPreFadeTime;

                        float   triggerAlpha = Math.Min((float)(dTime / kFadeTime), 1.0f);
                        Vector2 offset       = size * 0.4f;
                        size *= 0.4f;
                        // Note the 12/64 in the positioning accounts for the fact that the
                        // button textures only use the upper 40x40 out of the 64x64 space they allocate.
                        // The 12 is actually (64-40)/2.
                        csquad.Render(camera, ButtonTextures.RightTrigger, triggerAlpha, position + offset + size * 12.0f / 64.0f, size, @"TexturedRegularAlpha");
                        offset.X = -offset.X;
                        csquad.Render(camera, ButtonTextures.LeftTrigger, triggerAlpha, position + offset + size * 12.0f / 64.0f, size, @"TexturedRegularAlpha");
                    }
                }
            }
        }   // end of ToolMenu Render()
Beispiel #12
0
        }  // end of HandleTouchInput()

        public override void Render(Camera camera)
        {
            CameraSpaceQuad quad = CameraSpaceQuad.GetInstance();

            Vector2 size = new Vector2(width, height);
            Vector2 pos  = new Vector2(worldMatrix.Translation.X, worldMatrix.Translation.Y);

            // Not fully selected?
            if (alpha < 1.0f)
            {
                quad.Render(camera, backUnselectedTexture, 0.5f, pos, size, @"TexturedRegularAlpha");
            }

            // Not fully unselected?
            if (alpha > 0.0f)
            {
                quad.Render(camera, backSelectedTexture, alpha, pos, size, @"TexturedRegularAlpha");
            }

            quad.Render(camera, foreTexture, pos, size, @"TexturedRegularAlpha");
        }   // end of UIGrid2DDualTextureElement Render()
Beispiel #13
0
        }   // end of HandleMouseInput()

        /// <summary>
        /// Renders the text to be displayed into the 1024x768 rendertarget.
        /// </summary>
        private void PreRender()
        {
            GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

            RenderTarget2D rt1k = UI2D.Shared.RenderTarget1024_768;

            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 text into the 1k rendertarget.
            InGame.SetRenderTarget(rt1k);
            InGame.Clear(Color.Transparent);

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

            //
            // Text.
            //

            // If we don't have enough text to go into scrolling, center vertically.
            int centering = 0;

            if (blob.NumLines < textVisibleLines)
            {
                centering += (int)(blob.TotalSpacing * (textVisibleLines - blob.NumLines) / 2.0f);
            }

            Vector2 pos;

            pos = new Vector2(textMargin, textTop + textOffset + centering);
            blob.RenderWithButtons(pos, darkTextColor);

            InGame.RestoreRenderTarget();
        }   // end of PreRender()
Beispiel #14
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()
Beispiel #15
0
        }   // end of HandleMouseInput()

        /// <summary>
        /// Renders the dialog into a rendertarget.  This happens during Update() phase so
        /// that we don't need to swap rendertargets during the Render call.  This allows
        /// the dialog to be safely rendered into the scene when the scene itself is being
        /// rendered into a rendertarget.
        /// </summary>
        private void PreRender()
        {
            GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

            //
            // First, render the text into a rendertarget.
            //

            RenderTarget2D rt1k = UI2D.Shared.RenderTarget1024_768;

            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 text into the 1k rendertarget.
            InGame.SetRenderTarget(rt1k);
            InGame.Clear(Color.Transparent);

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

            //
            // Text.
            //

            // If we don't have enough text to go into scrolling, center vertically.
            int centering = 0;

            if (blob.NumLines < textVisibleLines)
            {
                centering += (int)(blob.TotalSpacing * (textVisibleLines - blob.NumLines) / 2.0f);
            }

            Vector2 pos;

            pos = new Vector2(textMargin, textTop + textOffset + centering);

            int startLine = 0;

            if (textOffset < 0)
            {
                startLine = -(int)(textOffset / blob.TotalSpacing);
                pos.Y    += startLine * blob.TotalSpacing;
            }

            // Clamp to pixel coords.
            pos.X = (int)pos.X;
            pos.Y = (int)pos.Y;
            blob.RenderWithButtons(pos, greyTextColor, startLine: startLine, maxLines: textVisibleLines + 2);

            InGame.RestoreRenderTarget();

            //
            // Second, render all the chrome with the text into the final rendertarget.

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

            // 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 rtSize = new Vector2(rtFull.Width, rtFull.Height);

            // Now render the background tiles.
            Vector2 backgroundSize = new Vector2(backgroundTexture.Width, backgroundTexture.Height);

            pos = (rtSize - backgroundSize) / 2.0f;
            // Clamp to pixel coords.
            pos.X = (int)pos.X;
            pos.Y = (int)pos.Y;
            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);

            // Clamp to nearest pixel;
            pos.X = (int)pos.X;
            pos.Y = (int)pos.Y;

            try//minimize bug fix.
            {
                Vector4 limits = new Vector4(0.095f, 0.112f, 0.57f, 0.64f);
                ssquad.RenderWithYLimits(rt1k, limits, pos, rt1kSize, @"TexturedRegularAlpha");
            }
            catch
            {
                InGame.RestoreRenderTarget();
                return;
            }

            //
            // Add button icon with label.
            //

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

            batch.Begin();
            {
                pos = new Vector2(rtSize.X / 2.0f, rtSize.Y / 2.0f + backgroundSize.Y * 0.28f);
                int buttonWidth = 48;
                pos.X -= (Font().MeasureString(Strings.Localize("textDialog.continue")).X + buttonWidth) / 2.0f;
                // Also account for B button if we have one.
                int margin = 24;
                if (!string.IsNullOrEmpty(textB))
                {
                    pos.X -= (Font().MeasureString(textB).X + buttonWidth + margin) / 2.0f;
                }
                min = pos;

                // Render the A button and it's label.
                ssquad.Render(ButtonTextures.AButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha");
                pos.X += buttonWidth;
                max    = new Vector2(pos.X + Font().MeasureString(Strings.Localize("textDialog.continue")).X, min.Y + buttonWidth);
                hitBoxA.Set(min, max);

                TextHelper.DrawString(Font, Strings.Localize("textDialog.continue"), pos, labelAColor);

                pos.X += Font().MeasureString(Strings.Localize("textDialog.continue")).X + margin;
                min    = pos;

                // Render the B button and it's label.
                if (!string.IsNullOrEmpty(textB))
                {
                    ssquad.Render(ButtonTextures.BButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha");
                    pos.X += buttonWidth;
                    max    = new Vector2(pos.X + Font().MeasureString(textB).X, min.Y + buttonWidth);
                    hitBoxB.Set(min, max);

                    TextHelper.DrawString(Font, textB, pos, labelBColor);
                }
            }
            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();
        }   // end of PreRender()
        }   // end of HandleKeyboardMouse()

        public void Render()
        {
            if (active)
            {
                GraphicsDevice device     = BokuGame.bokuGame.GraphicsDevice;
                SpriteBatch    batch      = UI2D.Shared.SpriteBatch;
                Vector2        screenSize = BokuGame.ScreenSize;

                InGame.SetViewportToScreen();

                // Render dialog using local camera.
                Fx.ShaderGlobals.SetCamera(camera);

                device.Clear(ClearOptions.DepthBuffer | ClearOptions.Target, new Color(20, 20, 20), 1.0f, 0);

                // Start by using the blurred version of the scene as a backdrop.
                // If no thumbnail use the black we just cleared to.
                if (thumbnail != null && !thumbnail.IsDisposed && !thumbnail.GraphicsDevice.IsDisposed)
                {
                    batch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied);
                    {
                        Rectangle rect = new Rectangle(0, 0, (int)screenSize.X, (int)screenSize.Y);
                        batch.Draw(thumbnail, rect, Color.White);
                    }
                    batch.End();
                }

                brightnessSlider.Render(camera);
                durationSlider.Render(camera);
                ledGrid.Render(camera);
                bar.Render(camera);

                // If in GamePad input mode, render left and right stick icons.
                // Actual rendering is done based on alpha.
                if (stickAlpha > 0)
                {
                    CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance();
                    Vector2         size   = new Vector2(0.6f, 1.0f);

                    csquad.Render(camera, leftStickTexture, stickAlpha, leftStickPosition, size, "TexturedRegularAlpha");
                    csquad.Render(camera, rightStickTexture, stickAlpha, rightStickPosition, size, "TexturedRegularAlpha");
                }

                // Buttons
                {
                    float margin = 32;
                    // Start with lower bar.
                    Vector3 screen = new Vector3(bar.Position.X, bar.Position.Y, 0);
                    // Convert to pixels.
                    Vector2 barPos = camera.WorldToScreenCoordsVector2(screen);
                    // Find right edge.
                    Vector2 pos = barPos;
                    pos.X += bar.Width / 2.0f * camera.DPI;
                    float barHeight = bar.Height * camera.DPI;
                    // Center on bar.
                    Vector2 size = cancelButton.GetSize();
                    pos.Y -= size.Y / 2.0f;

                    pos.X -= size.X + 2 * margin;

                    cancelButton.Render(pos, useBatch: false);
                    size   = saveButton.GetSize();
                    pos.X -= size.X + margin;
                    saveButton.Render(pos, useBatch: false);

                    // Find left edge for Toggle button.
                    pos.X = barPos.X - bar.Width / 2.0f * camera.DPI + margin;
                    toggleLEDButton.Render(pos, useBatch: false);
                }
            } // end if active
        }     // end of Render()
Beispiel #17
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()
Beispiel #18
0
            public override void Render(Camera camera)
            {
                if (parent.saveLevelDialog.Active)
                {
                    parent.saveLevelDialog.Render(null);
                }
                else
                {
                    ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

                    // This clear is not needed in desktop build but is required to clear z-buffer in WinRT version.
                    // TODO (****) Maybe issue is that z-test should be off for this?
                    InGame.Clear(new Color(20, 20, 20));

                    // Fill the background with the thumbnail if valid.
                    RenderTarget2D smallThumb = InGame.inGame.SmallThumbNail as RenderTarget2D;
                    if (smallThumb != null && !smallThumb.IsDisposed)
                    {
                        SpriteBatch batch = UI2D.Shared.SpriteBatch;
                        batch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
                        {
                            // Stretch thumbnail across whole screen.  Don't worry about distorting it
                            // since it's blurred anyway.
                            Microsoft.Xna.Framework.Rectangle dstRect = new Microsoft.Xna.Framework.Rectangle((int)BokuGame.ScreenPosition.X, (int)BokuGame.ScreenPosition.Y, (int)BokuGame.ScreenSize.X, (int)BokuGame.ScreenSize.Y);

                            Microsoft.Xna.Framework.Rectangle srcRect;
                            if (BokuGame.ScreenPosition.Y > 0)
                            {
                                // Set srcRect to ignore part of image at top of screen.
                                int y = (int)(BokuGame.ScreenPosition.Y * smallThumb.Height / (float)BokuGame.ScreenSize.Y);
                                srcRect = new Microsoft.Xna.Framework.Rectangle(0, y, smallThumb.Width, smallThumb.Height - y);
                            }
                            else
                            {
                                // Set srcRect to cover full thumbnail.
                                srcRect = new Microsoft.Xna.Framework.Rectangle(0, 0, smallThumb.Width, smallThumb.Height);
                            }
                            batch.Draw(smallThumb, dstRect, srcRect, Color.White);
                        }
                        batch.End();
                    }
                    else
                    {
                        // No thumbnail so just clear to black.
                        InGame.Clear(new Color(20, 20, 20));
                    }

                    InGame.SetViewportToScreen();

                    if (parent.newWorldDialog.Active)
                    {
                        // Hide the dialog if auth UI is active.  Just keeps things cleaner.
                        if (!AuthUI.IsModalActive)
                        {
                            // If options menu is active, render instead of main menu.
                            parent.newWorldDialog.Render(BokuGame.ScreenSize);
                        }
                    }
                    else
                    {
                        // Render menu using local camera.
                        shared.camera.Resolution = new Point((int)BokuGame.ScreenSize.X, (int)BokuGame.ScreenSize.Y);
                        shared.camera.Update();
                        Fx.ShaderGlobals.SetCamera(shared.camera);
                        shared.menu.Render(shared.camera);

                        {
                            CameraSpaceQuad quad = CameraSpaceQuad.GetInstance();
                            // Position Home icon on same baseline as menu title text.
                            // Assume uniform scaling.
                            float height = shared.menu.Height * shared.menu.WorldMatrix.M22;
                            float y      = height / 2.0f - 0.18f;
                            quad.Render(shared.camera, parent.homeTexture, new Vector2(-2.4f, y), new Vector2(1.2f, 1.2f), "TexturedRegularAlpha");
                        }

                        // Render sign out button if user is logged in.
                        Vector2 screenSize = BokuGame.ScreenSize;

                        // Messages will only render if active.
                        parent.saveChangesMessage.Render();
                        parent.saveChangesWithDiscardMessage.Render();
                        parent.shareSuccessMessage.Render();
                        parent.noCommunityMessage.Render();

                        shared.communityShareMenu.Render();

                        HelpOverlay.Render();
                    }
                }
            }   // end of Render()
            public override void Render(Camera camera)
            {
                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

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

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

                CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance();
                ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

                Color   greyTextColor   = new Color(127, 127, 127);
                Color   shadowTextColor = new Color(0, 0, 0, 20);
                Color   greenTextColor  = new Color(0, 255, 12);
                Color   whiteTextColor  = new Color(255, 255, 255);
                Vector2 shadowOffset    = new Vector2(0, 6);

                // Render the description text and examples into the 1k rendertarget.
                InGame.SetRenderTarget(rt1k);
                InGame.Clear(Color.Transparent);

                SpriteBatch batch = UI2D.Shared.SpriteBatch;

                UI2D.Shared.GetFont FontHuge = UI2D.Shared.GetGameFont20;

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

                //
                // Render the samples grid.
                //
                bool noExamples = shared.examplesGrid == null || shared.examplesGrid.ActualDimensions == Point.Zero;

                if (!noExamples)
                {
                    // Clear the stencil buffer.
                    device.Clear(ClearOptions.Stencil, Color.Transparent, 1.0f, 0);

                    // Render the new stencil mask.  Magic numbers from Photoshop.
                    ssquad.RenderStencil(Vector4.One, new Vector2(100, 300), new Vector2(820, 400));

                    // Turn off stencil writing while rendering the grid.
                    device.DepthStencilState = depthStencilStateNoWrite;

                    shared.examplesGrid.Render(shared.camera1k);

                    // Restore default.
                    device.DepthStencilState = DepthStencilState.Default;
                }

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

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

                InGame.Clear(Color.Transparent);

                // Set up effect for rendering tiles.
                effect.CurrentTechnique = effect.Techniques["NormalMappedNoTexture"];

                effect.Parameters["Alpha"].SetValue(1.0f);
                effect.Parameters["SpecularColor"].SetValue(Vector4.Zero);
                effect.Parameters["SpecularPower"].SetValue(16.0f);
                effect.Parameters["NormalMap"].SetValue(normalMap);

                // Render tiles.
                Matrix world = Matrix.Identity;

                world.Translation = new Vector3(-3.4f, 2.5f, 0.0f);
                effect.Parameters["WorldMatrix"].SetValue(world);
                effect.Parameters["WorldViewProjMatrix"].SetValue(world * shared.camera.ViewProjectionMatrix);
                effect.Parameters["DiffuseColor"].SetValue(new Vector4(1.0f, 1.0f, 1.0f, 0.2f));
                glassTile.Render(effect);

                world.Translation = new Vector3(1.15f, 2.5f, 0.0f);
                effect.Parameters["WorldMatrix"].SetValue(world);
                effect.Parameters["WorldViewProjMatrix"].SetValue(world * shared.camera.ViewProjectionMatrix);
                effect.Parameters["DiffuseColor"].SetValue(new Vector4(1.0f, 1.0f, 1.0f, 1.0f));
                descTile.Render(effect);

                world.Translation = new Vector3(0.0f, -1.1f, 0.0f);
                effect.Parameters["WorldMatrix"].SetValue(world);
                effect.Parameters["WorldViewProjMatrix"].SetValue(world * shared.camera.ViewProjectionMatrix);
                effect.Parameters["DiffuseColor"].SetValue(new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
                examplesTile.Render(effect);

                // Render highlights on tiles.
                CameraSpaceQuad quad = CameraSpaceQuad.GetInstance();

                device.BlendState = UI2D.Shared.BlendStateColorWriteRGB;

                // Glass tile.
                quad.Render(shared.camera, glassTileHighlight, Vector4.One, 1.0f, new Vector2(-3.4f, 2.9f), new Vector2(2.02f, 1.25f), "TexturedRegularAlpha");

                // Desc tile.
                quad.Render(shared.camera, whiteHighlight, new Vector4(0.6f, 1.0f, 0.8f, 0.2f), 1.0f, new Vector2(1.15f, 1.85f), new Vector2(6.52f, 0.7f), "TexturedRegularAlpha");

                // Examples tile.
                quad.Render(shared.camera, blackHighlight, Vector4.One, 1.0f, new Vector2(0.0f, 0.3f), new Vector2(8.82f, 2.0f), "TexturedRegularAlpha");

                device.BlendState = BlendState.AlphaBlend;

                // Actor Icon.
                if (shared.actorHelp.upid != null)
                {
                    Texture2D actorImage = CardSpace.Cards.CardFaceTexture(shared.actorHelp.upid);
                    if (actorImage != null)
                    {
                        quad.Render(shared.camera, actorImage, new Vector2(-3.4f, 2.5f), new Vector2(1.8f, 1.8f), @"TexturedRegularAlpha");
                    }
                }

                // Stick Icons.
                ssquad.Render(leftStickTexture, new Vector2(181, 560), new Vector2(leftStickTexture.Width, leftStickTexture.Height), @"TexturedRegularAlpha");
                Vector2 min = new Vector2(181, 560);
                Vector2 max = min + new Vector2(leftStickTexture.Width, leftStickTexture.Height);

                shared.leftStickBox.Set(min, max);
                if (shared.descBlob.NumLines > 3)
                {
                    ssquad.Render(rightStickTexture, new Vector2(1036, 70), new Vector2(rightStickTexture.Width, rightStickTexture.Height), @"TexturedRegularAlpha");
                    min = new Vector2(1036, 70);
                    max = min + new Vector2(rightStickTexture.Width, rightStickTexture.Height);
                    shared.rightStickBox.Set(min, max);
                }

                // A button
                ssquad.Render(ButtonTextures.AButton, new Vector2(1000, 245), new Vector2(80, 80), "TexturedRegularAlpha");
                shared.chooseBox.Set(new Vector2(990 - UI2D.Shared.GetGameFont24().MeasureString(Strings.Localize("helpCard.choose")).X, 245), new Vector2(1060, 245 + 55));

                // Text labels.

                // Actor description
                // Render the new stencil mask.  Magic numbers from Photoshop.
                ssquad.RenderStencil(Vector4.One, new Vector2(310, 75), new Vector2(590, 140));

                device.DepthStencilState = depthStencilState;

                // Description.
                if (shared.descBlob != null)
                {
                    Vector2 pos = new Vector2(shared.descMargin, shared.descTop + shared.descOffset);
                    pos.X = 450;
                    shared.descBlob.RenderWithButtons(pos, greyTextColor, maxLines: 3);
                }

                // Restore DepthStencilState to default.
                device.DepthStencilState = DepthStencilState.Default;

                batch.Begin();

                // Actor name
                TextHelper.DrawString(UI2D.Shared.GetGameFont30Bold, shared.curActorName, new Vector2(450, 30) + shadowOffset, shadowTextColor);
                TextHelper.DrawString(UI2D.Shared.GetGameFont30Bold, shared.curActorName, new Vector2(450, 30), greyTextColor);

                // Create
                TextHelper.DrawString(UI2D.Shared.GetGameFont24Bold, Strings.Localize("helpCard.create"), new Vector2(268, 250), whiteTextColor);

                // Choose
                TextHelper.DrawString(UI2D.Shared.GetGameFont24, Strings.Localize("helpCard.choose"), new Vector2(990 - UI2D.Shared.GetGameFont24().MeasureString(Strings.Localize("helpCard.choose")).X, 250), greyTextColor);

                batch.End();


                // Now render the contents of the rt1k texture but with the edges blended using the mask.
                Vector4 limits = new Vector4(0.4f, 0.41f, 0.857f, 0.93f);

                ssquad.RenderWithYLimits(rt1k, limits, new Vector2((rtFull.Width - rt1k.Width) / 2, 0), new Vector2(rt1k.Width, rtFull.Height), @"TexturedPreMultAlpha");

                // Restore rt for final rendering.
                InGame.RestoreRenderTarget();

                device.Clear(ClearOptions.DepthBuffer, Color.Pink, 1.0f, 0);

                // Start by using the blurred version of the scene as a backdrop.
                if (!shared.thumbnail.GraphicsDevice.IsDisposed)
                {
                    //InGame.Clear(Color.Transparent);
                    ssquad.Render(shared.thumbnail, Vector2.Zero, new Vector2(device.Viewport.Width, device.Viewport.Height), @"TexturedNoAlpha");
                }
                else
                {
                    Color backgroundColor = new Color(16, 66, 52);  // 1/4 strength turquoise.
                    InGame.Clear(backgroundColor);
                }

                // Copy the rendered scene to the rendertarget.
                float   rtAspect = rtSize.X / rtSize.Y;
                Vector2 position = Vector2.Zero;
                Vector2 newSize  = screenSize;

                newSize.X  = rtAspect * newSize.Y;
                position.X = (screenSize.X - newSize.X) / 2.0f;

                ssquad.Render(rtFull, position + BokuGame.ScreenPosition, newSize, @"TexturedRegularAlpha");
            }   // end of AddItemHelpCard RenderObj Render()