}   // end of Update()

            public void Render()
            {
                if (blob == null)
                {
                    blob = new TextBlob(UI2D.Shared.GetGameFont30Bold, "foo", 1000);
                }

                // NOTE: Assumes Begin has already been called on batch
                // and End will be called elsewhere.
                SpriteBatch batch = UI2D.Shared.SpriteBatch;

                bool invertColors = false;

                if (pressed && OnKey == null)
                {
                    invertColors = true;
                }

                // KeyCap
                batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
                Rectangle rect = new Rectangle((int)hitBox.Min.X, (int)hitBox.Min.Y, (int)hitBox.Size.X, (int)hitBox.Size.Y);

                batch.Draw(VirtualKeyboard.whiteTexture, rect, invertColors ? labelColor : keyCapColor);
                batch.End();

                // Texture
                // Note we render textures before labels just in case key has both.
                if (texture != null)
                {
                    // Center texture on keycap.
                    Vector2 size = new Vector2(texture.Width, texture.Height);
                    Vector2 pos  = this.position;
                    pos += (hitBox.Size - size) / 2.0f;
                    batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
                    batch.Draw(texture, pos, labelColor);
                    batch.End();
                }

                // Label
                if (!string.IsNullOrEmpty(label))
                {
                    blob.Font    = Font;
                    blob.RawText = label;

                    float width = blob.GetLineWidth(0);

                    // Center side to side based on actual width but top to bottom based on line spacing.
                    Vector2 pos = this.position;
                    pos.X += (hitBox.Size.X - width) / 2.0f;
                    pos.Y += (hitBox.Size.Y - Font().LineSpacing) / 2.0f;
                    // Clamp to int to get better looking glyphs.
                    pos.X = (int)pos.X;
                    pos.Y = (int)pos.Y;
                    blob.RenderWithButtons(pos, invertColors ? keyCapColor : labelColor);
                }
            }   // end of Render()
        public void Update()
        {
            if (active)
            {
                string s = "";
                s           += Strings.Localize("auth.creator") + " : " + Auth.CreatorName;
                blob.RawText = s;

                float   scale = 0.75f;
                Vector2 size  = new Vector2(blob.GetLineWidth(0), tileTexture.Height * scale);
                // Add some extra width to allow the text to be centered horizontally.
                size.X += 32;
                Vector2 upperRightCorner = new Vector2((int)BokuGame.ScreenPosition.X + (int)BokuGame.ScreenSize.X, 0);
                Vector2 pos = upperRightCorner - new Vector2(size.X, 0);
                // Add a bit of a margin from the top of the screen.
                pos += new Vector2(-8, 8);
                pos  = pos.Truncate();

                hitBox.Set(pos, pos + size);
                tileRect = new Rectangle((int)pos.X, (int)pos.Y, (int)size.X, (int)size.Y);

                //
                // Input?
                //
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    for (int i = 0; i < TouchInput.TouchCount; i++)
                    {
                        TouchContact touch = TouchInput.GetTouchContactByIndex(i);

                        Vector2 touchHit = touch.position;
                        HandleTouchInput(touch, touchHit);
                    }
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    Vector2 hit = MouseInput.PositionVec;
                    HandleMouseInput(hit);
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad)
                {
                    // Do nothing.  Since signing in requires keyboard/mouse it
                    // really doesn't make sense to partially support gamepad.
                }
            }
        }   // end of Update()
        public void TextInput(char c)
        {
            // Handle special character input.
            if (KeyboardInput.AltWasPressed)
            {
                specialChar = null;
            }
            if (KeyboardInput.AltIsPressed)
            {
                // accumulate keystrokes
                specialChar += c;
                return;
            }

            // Grab the tab and use it for cycling through the focus options.
            if (c == '\t')
            {
                ToggleEditTarget();
                KeyboardInput.ClearAllWasPressedState(Keys.Tab);

                return;
            }

            if (EditingCreator || EditingPin)
            {
                // Ignore enter.
                if (c == 13)
                {
                    return;
                }

                string str = new string(c, 1);
                str = TextHelper.FilterInvalidCharacters(str);

                if (!string.IsNullOrEmpty(str))
                {
                    // Check if we've gotten too long.
                    if (EditingCreator)
                    {
                        creatorBlob.InsertString(str);

                        int width = creatorBlob.GetLineWidth(0);
                        if (width >= creatorBox.Width)
                        {
                            // Bzzzt!
                            Foley.PlayNoBudget();
                            for (int i = 0; i < str.Length; i++)
                            {
                                creatorBlob.Backspace();
                            }
                        }
                        else
                        {
                            Foley.PlayClickDown();
                        }
                    }
                    else if (EditingPin)
                    {
                        // With the pin, max out at 4 digits and only allow digits.
                        if (pinBlob.ScrubbedText.Length > 3 || !char.IsDigit(str[0]))
                        {
                            Foley.PlayNoBudget();
                        }
                        else
                        {
                            pinBlob.InsertString(str);
                        }
                    }
                }
            }
        }   // end of TextInput()
Beispiel #4
0
        }   // end of LiveFeedDisplay Render()

        #endregion

        #region Internal

        private void RenderFeedBasePlate()
        {
            GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;
            // default width = 300 px
            // default height = 190 px
            // Adjustment Scale X
            // Adjustment Scale Y
            Vector2 defaultScreenSize = new Vector2(1280, 1024);
            Vector2 extraSize         = Vector2.Zero;
            Vector2 cOffset           = Vector2.Zero; //center Offset of cloud background;
            float   xCrushScale       = 1.0f;
            float   xCrushPixel       = 0.0f;

            extraSize.X = 80;//moves over the word "News"

            ScreenSpaceQuad ssquad         = ScreenSpaceQuad.GetInstance();
            Color           darkTextColor  = new Color(20, 20, 20);
            Color           greyTextColor  = new Color(127, 127, 127);
            Color           greenTextColor = new Color(0, 255, 45);
            Vector2         screenSize     = BokuGame.ScreenSize;

            Vector2 scaledBy = new Vector2(screenSize.X / defaultScreenSize.X, screenSize.Y / defaultScreenSize.Y);

            if (expanded)
            {
                extraSize.Y += 600.0f * scaledBy.Y;
            }
            if (scaledBy.X < 0.9f)
            {
                xCrushScale = scaledBy.X;
                xCrushPixel = cloudTL.Width - (cloudTL.Width * scaledBy.X);
            }
            Vector2 pos = new Vector2(2.0f, 80.0f);

            cOffset    = pos;
            cOffset.X += cloudTL.Width;
            cOffset.Y += cloudTL.Height - 25.0f;

            Vector2 baseSize   = FeedSize;
            Vector2 iconSize   = new Vector2(42.0f, 42.0f);
            Vector4 baseColor  = new Vector4(0.0f, 0.0f, 0.0f, 0.7f);
            Vector2 headerSize = baseSize;

            headerSize.X *= 0.8f;
            headerSize.Y *= 0.055f;
            Vector2 headerPos = pos;
            Vector2 baseOffset;

            baseOffset.Y = (float)cloudTL.Height + cloudLC.Height * scaledBy.Y;

            headerPos.Y -= headerSize.Y;

            iconSize = new Vector2(headerSize.Y * 0.95f, headerSize.Y * 0.95f);

            Vector2 cornerSize = new Vector2(headerSize.Y * 0.25f, headerSize.Y * 0.25f);

            Vector2 titlePos = headerPos + textPosition;

            titlePos.X += iconSize.X;

            Vector2 iconPos = iconPosition;

            iconPos.Y += headerPos.Y;
            if (screenSize.X > 1200)
            {
                iconPos.Y += 5.0f;
            }

            //  ssquad.Render(baseColor, headerPos, headerSize);
            //  ssquad.Render(baseColor, pos, baseSize);
            //  ssquad.Render(baseColor, headerPos + new Vector2(headerSize.X, cornerSize.Y), new Vector2(cornerSize.X, headerSize.Y - cornerSize.Y));

            //Top left cloud
            ssquad.Render(
                cloudTL, cOffset - new Vector2(cloudTL.Width, cloudTL.Height / 1.25f),
                new Vector2(cloudTL.Width * xCrushScale, cloudTL.Height / 1.25f), "TexturedRegularAlpha");
            //Bottom left cloud
            ssquad.Render(
                cloudBL, cOffset - new Vector2(cloudBL.Width, -((cloudLC.Height + extraSize.Y) * scaledBy.Y)), //baseOffset.Y + ((cloudLC.Height + extraSize.Y) * scaledBy.Y)),
                new Vector2(cloudBL.Width * xCrushScale, cloudBL.Height), "TexturedRegularAlpha");
            // left center Fill
            ssquad.Render(
                cloudLC, cOffset - new Vector2(cloudLC.Width, 0.0f),
                new Vector2(cloudLC.Width * xCrushScale, (cloudLC.Height + extraSize.Y) * scaledBy.Y), "TexturedRegularAlpha");

            //Top right cloud
            ssquad.Render(
                cloudTR, cOffset + new Vector2(((cloudTC.Width + extraSize.X) * scaledBy.X) - xCrushPixel, -(cloudTR.Height / 1.25f)),
                new Vector2(cloudTR.Width * xCrushScale, cloudTR.Height / 1.25f), "TexturedRegularAlpha");
            //Bottom right cloud
            ssquad.Render(
                cloudBR, cOffset + new Vector2(((cloudTC.Width + extraSize.X) * scaledBy.X) - xCrushPixel, (cloudLC.Height + extraSize.Y) * scaledBy.Y),
                new Vector2(cloudBR.Width * xCrushScale, cloudBR.Height), "TexturedRegularAlpha");
            // right center Fill
            ssquad.Render(
                cloudRC, cOffset + new Vector2(((cloudTC.Width + extraSize.X) * scaledBy.X) - xCrushPixel, 0.0f),
                new Vector2(cloudRC.Width * xCrushScale, (cloudRC.Height + extraSize.Y) * scaledBy.Y), "TexturedRegularAlpha");
            // Top center Fill
            ssquad.Render(
                cloudTC, cOffset - new Vector2(xCrushPixel, cloudTC.Height / 1.25f),
                new Vector2((cloudTC.Width + extraSize.X) * scaledBy.X, cloudTC.Height / 1.25f), "TexturedRegularAlpha");
            // Top bottom Fill
            ssquad.Render(
                cloudBC, cOffset + new Vector2(-xCrushPixel, (cloudLC.Height + extraSize.Y) * scaledBy.Y),
                new Vector2((cloudBC.Width + extraSize.X) * scaledBy.X, cloudBC.Height), "TexturedRegularAlpha");

            // Center Fill
            ssquad.Render(
                cloudCenter, cOffset + new Vector2(-xCrushPixel, 0.0f),
                new Vector2((cloudTC.Width + extraSize.X) * scaledBy.X,
                            (cloudCenter.Height + extraSize.Y) * scaledBy.Y), "TexturedRegularAlpha");

            Vector2 moreLessBoxLT =
                new Vector2(
                    (cOffset.X - ((cloudBL.Width * 0.70f) * xCrushScale) - xCrushPixel),
                    (cOffset.Y + ((cloudLC.Height + extraSize.Y) * scaledBy.Y) + cloudBL.Height * 0.40f));
            Vector2 moreLessBoxBR = moreLessBoxLT;

            float moreLessPos = (cloudBL.Width * xCrushScale * 0.52f);

            if (newsScroller.Count > 1)
            {
                if (!expanded)
                {
                    moreLessPos -= (float)(flagMoreBlob.GetLineWidth(0) / 3);
                    flagMoreBlob.Justification = UIGridElement.Justification.Center;
                    pos = new Vector2(moreLessPos, moreLessBoxLT.Y + 8);
                    // Clamp to pixel coords so text doesn't look like #$%.
                    pos.X = (int)pos.X;
                    pos.Y = (int)pos.Y;
                    flagMoreBlob.RenderWithButtons(pos, flagMoreLessColor, maxLines: 1);
                    moreLessBoxBR.X += flagMoreBlob.Width * 2.5f;         //2.5 makes click area larger.
                    moreLessBoxBR.Y += flagMoreBlob.TotalSpacing * 1.85f; //1.85 makes click area larger.
                }
                else
                {
                    moreLessPos -= (float)(flagLessBlob.GetLineWidth(0) / 3);
                    flagLessBlob.Justification = UIGridElement.Justification.Center;
                    pos = new Vector2(moreLessPos, moreLessBoxLT.Y + 8);
                    // Clamp to pixel coords so text doesn't look like #$%.
                    pos.X = (int)pos.X;
                    pos.Y = (int)pos.Y;
                    flagLessBlob.RenderWithButtons(pos, flagMoreLessColor, maxLines: 1);
                    moreLessBoxBR.X += (int)flagMoreBlob.Width * 2.5f;         //2.5 makes click area larger.
                    moreLessBoxBR.Y += (int)flagMoreBlob.TotalSpacing * 1.85f; //1.85 makes click area larger.
                }

                moreLessHitBox.Set(moreLessBoxLT, moreLessBoxBR);
            }
            else
            {
                moreLessHitBox.Set(new Vector2(0, 0), new Vector2(0, 0));
            }


            pos = new Vector2(cOffset.X - ((cloudTL.Width / 1.8f) * xCrushScale) - xCrushPixel, cOffset.Y - cloudTL.Height * 0.65f);
            // Clamp to pixel coords so text doesn't look like #$%.
            pos.X = (int)pos.X + 3;
            pos.Y = (int)pos.Y;

            smallblob.RenderWithButtons(pos, Active ? greenTextColor : darkTextColor, maxLines: 1);
        }
        }   // end of LoadLevelPopup Update()

        public void Render(Camera camera)
        {
            if (Active)
            {
                ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();

                // Frame.
                quad.Render(frame, position, _size, "TexturedRegularAlpha");

                // Calc alpha value to use for elements based on expanded size of frame.
                float alpha = _size.X / size.X;
                alpha *= alpha;

                // Items.

                float   additionalSpacing = (_size.Y - itemList.Count * ItemFont().LineSpacing) / (itemList.Count + 1);
                Vector2 barSize           = new Vector2(_size.X, ItemFont().LineSpacing);
                float   margin            = 6;
                Vector2 pos = Vector2.Zero;
                pos.X  = position.X + _size.X - margin;
                pos.Y  = position.Y + _size.Y / 2.0f;   // Center.
                pos.Y -= itemList.Count / 2.0f * ItemFont().LineSpacing + (itemList.Count - 1) / 2.0f * additionalSpacing;
                for (int i = 0; i < itemList.Count; i++)
                {
                    // Render bar if needed.
                    if (itemList[i].BarAlpha > 0.0f)
                    {
                        quad.Render(greenBar, new Vector4(1.0f, 1.0f, 1.0f, itemList[i].BarAlpha * alpha), pos - new Vector2(_size.X, -2), barSize, "TexturedRegularAlpha");
                    }

                    // Set up mouse hit box.
                    itemList[i].hitBox.Set(pos - new Vector2(_size.X, -2), pos - new Vector2(_size.X, -2) + barSize);

                    // Render text
                    Color textColor = itemList[i].TextColor;
                    if (alpha < 1.0f)
                    {
                        textColor.A = (byte)(textColor.A * alpha);
                    }
                    blob.RawText = itemList[i].Text;
                    Vector2 textPos   = pos - new Vector2(505, 0);
                    int     lineWidth = blob.GetLineWidth(0);
                    int     spacing   = blob.TotalSpacing;
                    if (lineWidth > 180)
                    {
                        blob.Font = UI2D.Shared.GetGameFont20;
                        lineWidth = blob.GetLineWidth(0);
                        if (lineWidth > 180)
                        {
                            blob.Font = UI2D.Shared.GetGameFont18Bold;
                            lineWidth = blob.GetLineWidth(0);
                            if (lineWidth > 180)
                            {
                                blob.Font = UI2D.Shared.GetGameFont15_75;
                            }
                        }
                    }
                    int down = (int)((spacing - blob.TotalSpacing) / 2.0f);
                    blob.RenderWithButtons(textPos + new Vector2(0, down), textColor);

                    // Restore larger font.
                    blob.Font = UI2D.Shared.GetGameFont24;

                    pos.Y += ItemFont().LineSpacing + additionalSpacing;
                }
            }
        }   // end of LoadLevelPopup Render()
        }   // end of ApplyExclusiveFiltering()

        public void Render(Camera camera)
        {
            if (Active && geometry != null)
            {
                // Black background.
                effect.CurrentTechnique = effect.Techniques["NormalMappedNoTexture"];

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

                effect.Parameters["Alpha"].SetValue(1.0f);
                effect.Parameters["DiffuseColor"].SetValue(new Vector4(0, 0, 0, 1));
                effect.Parameters["SpecularColor"].SetValue(new Vector4(0.2f, 0.2f, 0.2f, 1.0f));
                effect.Parameters["SpecularPower"].SetValue(32.0f);

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

                geometry.Render(effect);


                ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();

                Vector3 upperLeftCorner = worldMatrix.Translation;
                upperLeftCorner.X -= geometry.Width / 2.0f;
                upperLeftCorner.Y += geometry.Height / 2.0f;

                upperLeftCorner.X += tileBorder;
                upperLeftCorner.Y -= tileBorder / 2.0f;

                Point   loc = camera.WorldToScreenCoords(upperLeftCorner);
                Vector2 pos = new Vector2(loc.X, loc.Y);

                loc = camera.WorldToScreenCoords(2.0f * worldMatrix.Translation - upperLeftCorner);
                Vector2 size = new Vector2(loc.X, loc.Y) - pos;

                int lineSpacing = Font().LineSpacing;

                // Render highlight.
                quad.Render(whiteHighlight, new Vector4(1.0f, 1.0f, 1.0f, 0.3f), pos + new Vector2(-4, 0), new Vector2(w + 6, w / 2.0f), "TexturedRegularAlpha");

                // Render the green bar().
                for (int i = 0; i < itemList.Count; i++)
                {
                    if (itemList[i].BarAlpha > 0.0)
                    {
                        quad.Render(greenBar, new Vector4(1.0f, 1.0f, 1.0f, itemList[i].BarAlpha), pos + new Vector2(0, 2 + i * lineSpacing), new Vector2(w, lineSpacing), "TexturedRegularAlpha");
                    }
                }

                // Render the text.
                SpriteBatch batch = UI2D.Shared.SpriteBatch;
                batch.Begin();
                for (int i = 0; i < itemList.Count; i++)
                {
                    Vector2 position = pos + new Vector2(margin + checkboxSize + gap, i * lineSpacing);
                    TextHelper.DrawString(Font, itemList[i].Text, position, itemList[i].TextColor);
                    // Calc bounds in UV space.
                    Vector2 min = new Vector2(0, i * lineSpacing);
                    Vector2 max = min + new Vector2(w, lineSpacing);
                    min /= size;
                    max /= size;
                    itemList[i].UVBoundingBox.Set(min, max);
                }
                batch.End();

                // Render the checkboxes.
                for (int i = 0; i < itemList.Count; i++)
                {
                    float a = itemList[i].LitValue;

                    // If not fully lit.
                    if (a < 1.0f)
                    {
                        quad.Render(AllExclusive ? radioButtonUnlit : checkboxUnlit, pos + new Vector2(margin, 6 + i * lineSpacing), new Vector2(checkboxSize), "TexturedRegularAlpha");
                    }

                    // If lit at all.
                    if (a > 0.0f)
                    {
                        quad.Render(AllExclusive ? radioButtonLit : checkboxLit, new Vector4(1, 1, 1, a), pos + new Vector2(margin, 6 + i * lineSpacing), new Vector2(checkboxSize), "TexturedRegularAlpha");
                    }
                }

                if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad)
                {
                    // Render help.
                    string   str  = "<a> " + Strings.Localize("saveLevelDialog.change") + "\n<b> " + Strings.Localize("saveLevelDialog.back");
                    TextBlob blob = new TextBlob(UI2D.Shared.GetGameFont24, str, 400);
                    pos   += size;
                    pos.X += 16;
                    pos.Y -= 2.0f * blob.TotalSpacing;
                    blob.RenderWithButtons(pos, Color.White);

                    // Mouse hit boxes for help.
                    changeBox.Set(pos, pos + new Vector2(blob.GetLineWidth(0), blob.TotalSpacing));
                    backBox.Set(pos + new Vector2(0, blob.TotalSpacing), pos + new Vector2(0, blob.TotalSpacing) + new Vector2(blob.GetLineWidth(1), blob.TotalSpacing));
                }
            } // end if active
        }     // end of ModularCheckboxList Render()
        }   // end of UIGridModularButtonElement Render()

        /// <summary>
        /// If the state of the element has changed, we may need to re-create the texture.
        /// </summary>
        public void RefreshTexture()
        {
            // dirty = true;  // Debug only.

            if (dirty || diffuse.IsContentLost)
            {
                InGame.SetRenderTarget(diffuse);
                InGame.Clear(Color.White);

                int w = diffuse.Width;
                int h = diffuse.Height;

                ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();


                // Render the white region with highlight.
                Vector2 position = new Vector2(h - 2, 0);
                Vector2 size     = new Vector2(w, h) - position;
                quad.Render(checkboxWhite, position, size, "TexturedNoAlpha");

                // Render the black box.
                position = Vector2.Zero;
                size.X   = size.Y;
                quad.Render(blackSquare, position, size, "TexturedRegularAlpha");

                // Disable writing to alpha channel.
                // This prevents transparent fringing around the text.
                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;
                device.BlendState = UI2D.Shared.BlendStateColorWriteRGB;

                // Render the label text into the texture.
                int margin = 16;
                position.X = (int)size.X + margin;

                string text = label + "\n";
                if (aButtonText != null)
                {
                    text += "    <A> " + aButtonText + "\n";
                }
                if (xButtonText != null)
                {
                    text += "    <X> " + xButtonText;
                }

                TextBlob blob = new TextBlob(Font, text, w - (int)position.X - margin);

                position.Y = (int)((h - blob.TotalSpacing) / 2.0f) - 2;
                if (blob.NumLines == 2)
                {
                    position.Y -= blob.TotalSpacing / 2.0f;
                }
                else if (blob.NumLines == 3)
                {
                    position.Y -= blob.TotalSpacing;
                }

                Color   fontColor    = new Color(127, 127, 127);
                Color   shadowColor  = new Color(0, 0, 0, 20);
                Vector2 shadowOffset = new Vector2(0, 6);

                blob.RenderWithButtons(position, fontColor, shadowColor, shadowOffset, maxLines: 3);

                // Restore default blending.
                device.BlendState = BlendState.AlphaBlend;

                int line = blob.NumLines - 1;   // Which line in the text has the button.

                // Calc bounding boxes in UV space for A and X buttons/labels.
                if (onXButton != null)
                {
                    Vector2 min = new Vector2(position.X / w, (position.Y + line * blob.TotalSpacing) / h);
                    Vector2 max = min + new Vector2((float)blob.GetLineWidth(line) / w, (float)blob.TotalSpacing / h);
                    xButtonBox.Set(min, max);
                    --line;
                }

                if (onAButton != null)
                {
                    Vector2 min = new Vector2(position.X / w, (position.Y + line * blob.TotalSpacing) / h);
                    Vector2 max = min + new Vector2((float)blob.GetLineWidth(line) / w, (float)blob.TotalSpacing / h);
                    aButtonBox.Set(min, max);
                }

                // DEBUG Show hit box for a button as overlay.

                /*
                 * if (onAButton != null)
                 * {
                 *  position = new Vector2(diffuse.Width * aButtonBox.Min.X, diffuse.Height * aButtonBox.Min.Y);
                 *  size = new Vector2(diffuse.Width * (aButtonBox.Size.X), diffuse.Height * aButtonBox.Size.Y);
                 *  quad.Render(new Vector4(1, 0, 0, 0.5f), position, size);
                 * }
                 * if (onXButton != null)
                 * {
                 *  position = new Vector2(diffuse.Width * xButtonBox.Min.X, diffuse.Height * xButtonBox.Min.Y);
                 *  size = new Vector2(diffuse.Width * (xButtonBox.Size.X), diffuse.Height * xButtonBox.Size.Y);
                 *  quad.Render(new Vector4(0, 1, 0, 0.5f), position, size);
                 * }
                 */

                // Restore backbuffer.
                InGame.RestoreRenderTarget();

                dirty = false;
            }
        }   // end of UIGridModularButtonElement Render()