}   // 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()
Exemplo n.º 2
0
        }   // end of ThoughtBalloon Activate()

        public void RefreshTexture()
        {
            RenderTarget2D rt = UI2D.Shared.RenderTarget256_256;

            //
            // Render the frame and text to the rendertarget.
            //
            InGame.SetRenderTarget(rt);

            ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

            InGame.Clear(Color.Transparent);

            // Frame
            ssquad.Render(ThoughtBalloonManager.FrameTexture, Vector2.Zero, new Vector2(rt.Width, rt.Height), "TexturedRegularAlpha");

            int      width = 238;
            TextBlob blob  = new TextBlob(UI2D.Shared.GetGameFont30Bold, text, width);

            blob.Justification = Boku.UI2D.UIGridElement.Justification.Center;

            if (blob.NumLines > 3)
            {
                blob.Font = UI2D.Shared.GetGameFont24Bold;
                if (blob.NumLines > 3)
                {
                    blob.Font = UI2D.Shared.GetGameFont24Bold;
                }
            }

            duration = defaultDuration * blob.NumLines;

            int     margin      = 8;
            int     middle      = 76; // Vertical midpoint of space for text.
            int     lineSpacing = blob.Font().LineSpacing;
            int     numLines    = Math.Min(4, blob.NumLines);
            Vector2 pos         = new Vector2(margin, middle - (numLines * 0.5f) * lineSpacing);

            blob.RenderWithButtons(pos, Color.Black, maxLines: numLines);

            InGame.RestoreRenderTarget();

            //
            // Copy result to local texture.
            //
            rt.GetData <int>(_scratchData);
            contentTexture.SetData <int>(_scratchData);
        }   // end of ThoughtBalloon RefreshTexture()
Exemplo n.º 3
0
        public void Draw(Vector2 position)
        {
            blob.RenderWithButtons(position, TextColor);

            // Set hitbox.  Note that the coordinates for the hitbox are relative
            // to the upper left hand corner of the rendertarget we're currently
            // drawing to, not the screen.  Need to adjust when hit testing.
            Vector2 size = new Vector2(blob.Font().MeasureString(blob.ScrubbedText).X, blob.TotalSpacing);

            hitBox.Set(position, position + size);

            /*
             * // Debug highlight of hyperlink hitbox.
             * ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();
             * ssquad.Render(new Vector4(1, 0, 0, 0.5f), position, size);
             */
        }
Exemplo n.º 4
0
        override public void Render(Vector2 pos)
        {
            base.Render(pos);
            drawPos = pos;

            tweetBlob.RenderWithButtons(
                drawPos,
                Color.White,
                false,
                UIGridElement.Justification.Left);

            SpriteBatch batch = UI2D.Shared.SpriteBatch;

            batch.Begin();

            foreach (Hyperlink link in hyperlinkList)
            {
                if (useFocus)
                {
                    if (link == hyperlinkList[focusIndex])
                    {
                        link.drawColor = hoverColor;
                    }
                }
                foreach (TextSegment segment in link.segmentList)
                {
                    batch.DrawString(
                        tweetBlob.Font(),
                        segment.Text,
                        drawPos + segment.HitBox.Min,
                        link.drawColor);
                }
                // Always reset the draw color after rendering. This ensures that
                // only items which were changed this frame have a different color.
                link.drawColor = defaultColor;
            }

            batch.End();
        }
        }   // end of OnHelp()

        public void Render()
        {
            if (active)
            {
                titleRect      = new Rectangle(0, 0, dialogWidth, 72);
                dialogBodyRect = new Rectangle(0, 64, dialogWidth, 320);

                // Now that we have the final dialog size, center it on the screen.
                Vector2 pos = BokuGame.ScreenSize / 2.0f;
                pos.X           -= titleRect.Width / 2;
                pos.Y           -= (titleRect.Height + dialogBodyRect.Height) / 2;
                titleRect.X      = (int)pos.X;
                titleRect.Y      = (int)pos.Y;
                dialogBodyRect.X = titleRect.X;
                dialogBodyRect.Y = titleRect.Y + titleRect.Height;

                int padding = 4;
                helpRect = new Rectangle(titleRect.X + titleRect.Width - titleRect.Height - margin, titleRect.Y + padding, titleRect.Height - 2 * padding, titleRect.Height - 2 * padding);

                AuthUI.RenderTile(titleBarTexture, titleRect);
                AuthUI.RenderTile(dialogBodyTexture, dialogBodyRect);

                // Title bar help icon.
                AuthUI.RenderTile(helpIcon, helpRect);
                helpBox.Set(helpRect);

                // Title bar text.
                string str = newUserMode ? Strings.Localize("auth.newUserTitle") : Strings.Localize("auth.signInTitle");
                blob.RawText       = str;
                blob.Font          = UI2D.Shared.GetGameFont30Bold;
                blob.Justification = UIGridElement.Justification.Left;
                blob.RenderWithButtons(new Vector2(titleRect.X + margin, titleRect.Y + 6), Color.White, Color.Black, new Vector2(0, 2), maxLines: 1);

                // Text box labels.
                int verticalBoxSpacing = blob.TotalSpacing + 4;
                blob.Font          = UI2D.Shared.GetGameFont24;
                blob.Justification = UIGridElement.Justification.Right;
                string creatorString = Strings.Localize("auth.creator");
                string pinString     = Strings.Localize("auth.pin");

                int posX = (int)Math.Max(blob.Font().MeasureString(creatorString).X, blob.Font().MeasureString(pinString).X);
                posX        += margin;
                blob.Width   = dialogBodyRect.Width - posX - 2 * margin;
                pos          = new Vector2(dialogBodyRect.X + posX - blob.Width, dialogBodyRect.Y + margin);
                blob.RawText = creatorString;
                blob.RenderWithButtons(pos, Color.White);
                pos.Y       += verticalBoxSpacing;
                blob.RawText = pinString;
                blob.RenderWithButtons(pos, Color.White);

                // Text boxes.
                // Creator.
                creatorBlob.Justification = UIGridElement.Justification.Left;
                pos.Y -= verticalBoxSpacing;
                pos.X  = dialogBodyRect.X + posX + margin;
                int       creatorBoxWidth    = dialogBodyRect.Width - posX - 2 * margin;
                Rectangle creatorTextBoxRect = new Rectangle((int)pos.X, (int)pos.Y, creatorBoxWidth, 40);
                creatorBox.Set(creatorTextBoxRect);
                // If editing, put a focus highlight around it.
                if (EditingCreator)
                {
                    AuthUI.RenderTile(textBoxTexture, creatorTextBoxRect, AuthUI.FocusColor);
                    creatorTextBoxRect = creatorTextBoxRect.Shrink(2);

                    // Also display warning about picking a good creator name.
                    Vector2 warningPos = new Vector2(dialogBodyRect.Left + 8, pinBox.Rectangle.Bottom);
                    int     prevWidth  = blob.Width;
                    blob.Width         = dialogBodyRect.Width - 16;
                    blob.Justification = UIGridElement.Justification.Left;
                    str          = Strings.Localize("auth.helpTextShort");
                    blob.RawText = str;
                    blob.Font    = UI2D.Shared.GetGameFont15_75;
                    blob.RenderWithButtons(warningPos, AuthUI.ErrorColor);
                    blob.Font          = UI2D.Shared.GetGameFont24;
                    blob.Width         = prevWidth;
                    blob.Justification = UIGridElement.Justification.Right;
                }
                AuthUI.RenderTile(textBoxTexture, creatorTextBoxRect);
                creatorBlob.RenderWithButtons(pos, creatorBlob.ScrubbedText == "Guest" ? Color.Gray : Color.Black, renderCursor: EditingCreator);

                // Pin
                pos.Y += verticalBoxSpacing;
                // Use regular blob for measurement.
                blob.Justification = UIGridElement.Justification.Left;
                int       pinBoxWidth    = (int)pinBlob.Font().MeasureString("0000").X; // Assumes 0s are max width characters.
                Rectangle pinTextBoxRect = new Rectangle((int)pos.X, (int)pos.Y, pinBoxWidth, 40);
                pinBox.Set(pinTextBoxRect);
                if (EditingPin)
                {
                    AuthUI.RenderTile(textBoxTexture, pinTextBoxRect, AuthUI.FocusColor);
                    pinTextBoxRect = pinTextBoxRect.Shrink(2);
                }
                AuthUI.RenderTile(textBoxTexture, pinTextBoxRect);

                // Hack to hide pin numbers.  Only show last number unless Guest pin.
                string rawText = pinBlob.ScrubbedText;  // Save existing string.
                if (pinBlob.ScrubbedText != Auth.DefaultCreatorPin)
                {
                    str = "";
                    if (pinBlob.ScrubbedText.Length > 0)
                    {
                        for (int i = 0; i < pinBlob.ScrubbedText.Length - 1; i++)
                        {
                            str += '•';
                        }
                        str            += pinBlob.ScrubbedText[pinBlob.ScrubbedText.Length - 1];
                        pinBlob.RawText = str;
                    }
                }
                pinBlob.RenderWithButtons(pos, pinBlob.ScrubbedText == Auth.DefaultCreatorPin ? Color.Gray : Color.Black, renderCursor: EditingPin);
                // Restore
                pinBlob.RawText = rawText;

                // Pin warnings.
                if (pinBlob.ScrubbedText != Auth.DefaultCreatorPin && !Auth.IsPinValid(pinBlob.ScrubbedText))
                {
                    pos.X += pinTextBoxRect.Width + 8;
                    str    = Strings.Localize("auth.pinError");
                    if (pinBlob.ScrubbedText.Length != 4)
                    {
                        str += "\n" + Strings.Localize("auth.pinTooShort");
                    }
                    else
                    {
                        str += "\n" + Strings.Localize("auth.pinTooSimple");
                    }
                    blob.RawText = str;
                    blob.RenderWithButtons(pos, AuthUI.ErrorColor);
                }

                // Buttons.  Fit at bottom of dialog.
                pos    = new Vector2(dialogBodyRect.Right, dialogBodyRect.Bottom);
                pos.X -= margin;
                pos.Y -= margin;
                pos   -= cancelButton.GetSize();
                cancelButton.Render(pos, useBatch: false);
                pos.X -= margin;
                pos.X -= okButton.GetSize().X;
                okButton.Render(pos, useBatch: false);

                // Keep signed in checkbox.
                // Position vertically just above buttons.
                pos.X        = dialogBodyRect.X + margin;
                pos.Y        = okButton.Box.Min.Y + 32;
                pos.X       += 32; // Adjust for checkbox.
                blob.RawText = Strings.Localize("auth.keepSignedIn");
                blob.Width   = dialogBodyRect.Width - 2 * margin - 32;
                pos.Y       -= blob.NumLines * blob.TotalSpacing;
                Rectangle checkboxRect = new Rectangle((int)pos.X - 32, (int)pos.Y + 4, 32, 32);
                checkBoxBox.Set(checkboxRect);
                AuthUI.RenderTile(keepSignedInChecked ? checkboxLit : checkboxUnlit, checkboxRect);
                blob.RenderWithButtons(pos, Color.White);

                // Adjust dialog size to CreatorName box is the desired size.
                // This keeps the entry box the same size regardless of the length
                // of "Creator" in whatever language is being used.
                dialogWidth += desiredCreatorNameSpace - (int)creatorBox.Width;

                scrollableTextDisplay.Render();
            }

            VirtualKeyboard.Render();
        }   // end of Render()
            }   // end of PreGameRacingWithDesc Update()

            public override void Render(Camera camera)
            {
                if (showingDescription)
                {
                    Vector2 pos = Vector2.Zero;
                    pos.X = BokuGame.bokuGame.GraphicsDevice.Viewport.Width / 4.0f;
                    pos.Y = BokuGame.bokuGame.GraphicsDevice.Viewport.Height / 2.0f - blob.NumLines / 2.0f * blob.Font().LineSpacing;
                    blob.RenderWithButtons(pos, Color.White, outlineColor: Color.Black, outlineWidth: 1.5f, maxLines: 20);
                }
                else
                {
                    ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();

                    Vector2 center = 0.5f * new Vector2(BokuGame.bokuGame.GraphicsDevice.Viewport.Width, BokuGame.bokuGame.GraphicsDevice.Viewport.Height);
                    Vector2 size   = new Vector2(256.0f);

                    // Pick the right number texture to show.
                    double    dt      = Time.WallClockTotalSeconds - startTime;
                    Texture2D texture = texture3;
                    if (dt > 2.0)
                    {
                        texture = texture1;
                        dt     -= 2.0f;
                    }
                    else if (dt > 1.0)
                    {
                        texture = texture2;
                        dt     -= 1.0f;
                    }

                    size   *= 1.0f + 2.0f * (float)dt;
                    center -= 0.5f * size;

                    Vector4 color = new Vector4(1.0f, 1.0f, 1.0f, 1.0f - (float)dt);

                    quad.Render(texture, color, center, size, "TexturedRegularAlpha");
                }
            }   // end of PreGameRacingWithDesc Render()
Exemplo n.º 7
0
            }   // end of PreGameDesc Update()

            public override void Render(Camera camera)
            {
                Texture2D logoTexture = null;

                if (!string.IsNullOrEmpty(logo))
                {
                    switch (logo)
                    {
                    case "n23":
                        logoTexture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\NASA_JPL");
                        break;

                    default:
                        logoTexture = null;
                        break;
                    }
                }

                Vector2 pos = Vector2.Zero;

                pos.X = BokuGame.bokuGame.GraphicsDevice.Viewport.Width / 4.0f;
                pos.Y = BokuGame.bokuGame.GraphicsDevice.Viewport.Height / 2.0f - blob.NumLines / 2.0f * blob.Font().LineSpacing;

                if (logoTexture != null)
                {
                    Vector2 logoSize = new Vector2(logoTexture.Width, logoTexture.Height);

                    ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();
                    // Position logo in upper right corner.
                    Vector2 logoPos = new Vector2(BokuGame.bokuGame.GraphicsDevice.Viewport.Width * 0.98f - logoSize.X, BokuGame.bokuGame.GraphicsDevice.Viewport.Width * 0.02f);
                    // Force to be pixel aligned.
                    logoPos.X = (int)logoPos.X;
                    logoPos.Y = (int)logoPos.Y;
                    ssquad.Render(logoTexture, logoPos, logoSize, "TexturedRegularAlpha");
                }

                blob.RenderWithButtons(pos, Color.White, outlineColor: Color.Black, outlineWidth: 1.5f, maxLines: 20);
            }   // end of PreGameDesc Render()