private void HandleMouseInput(Vector2 hit)
 {
     if (hitBox.LeftPressed(hit))
     {
         AuthUI.ShowSignOutDialog();
     }
 }
        }   // end of OnCancel()

        /// <summary>
        ///
        /// </summary>
        /// <param name="screenSize">If rendering to an RT allows us to know how to center.</param>
        public void Render(Vector2 screenSize)
        {
            if (active)
            {
                titleRect      = new Rectangle(0, 0, 512, 72);
                dialogBodyRect = new Rectangle(0, 64, 512, 268);

                // Now that we have the final dialog size, center it on the screen.
                Vector2 pos = 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;

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

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

                // World tiles.
                // Update rects.
                Rectangle rect = new Rectangle(dialogBodyRect.X + margin, dialogBodyRect.Y + margin, 128, 128);
                foreach (NewWorldLevel level in levels)
                {
                    level.Box.Set(rect);
                    rect.X += 128 + margin;
                }

                foreach (NewWorldLevel level in levels)
                {
                    SpriteBatch batch = UI2D.Shared.SpriteBatch;
                    batch.Begin();
                    {
                        if (level.FrameColor != Color.Transparent)
                        {
                            int       frameWidth = 4;
                            Rectangle frameRect  = new Rectangle((int)level.Box.Min.X - frameWidth, (int)level.Box.Min.Y - frameWidth, (int)(level.Box.Width + 2 * frameWidth), (int)(level.Box.Height + 2 * frameWidth));
                            batch.Draw(Utils.white, frameRect, level.FrameColor);
                        }

                        batch.Draw(level.ThumbnailTexture, level.Box.Rectangle, Color.White);
                    }
                    batch.End();
                }

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

        private void HandleTouchInput(TouchContact touch, Vector2 hit)
        {
            if (hitBox.Touched(touch, hit))
            {
                Boku.Common.Gesture.TouchGestureManager.Get().TapGesture.ClearWasTapped();
                AuthUI.ShowSignOutDialog();
            }
        }
        }   // end of OnAccept()

        private void OnCancel()
        {
            // Even if we cancel we may have changed this so save the state.
            XmlOptionsData.KeepSignedInOnExit = keepSignedInChecked;

            // Just go away!
            Active = false;

            // Restart status dialog.
            AuthUI.ShowStatusDialog();
        }   // end of OnCancel()
示例#5
0
        }   // end of HandleMouseInput()

        private void OnAccept()
        {
            // Note that setting this also forces the creator name and idHash
            // to be saved from Auth.
            XmlOptionsData.KeepSignedInOnExit = keepSignedInChecked;

            Active = false;

            // Activate the sign-in dialog.
            AuthUI.ShowSignInDialog();
        }   // end of OnAccept()
        }   // end of HandleMouseInput()

        private void OnAccept()
        {
            // If the current creator name or pin isn't valid, don't allow the user to click OK.
            // Skip this check if we have Guest signed in.
            if (creatorBlob.ScrubbedText != Auth.DefaultCreatorName && pinBlob.ScrubbedText != Auth.DefaultCreatorPin)
            {
                if (!Auth.IsPinValid(pinBlob.ScrubbedText) || string.IsNullOrWhiteSpace(creatorBlob.ScrubbedText))
                {
                    Foley.PlayNoBudget();
                    return;
                }
            }

            string newCreatorName = creatorBlob.ScrubbedText;
            string newPin         = pinBlob.ScrubbedText;
            string newIdHash      = Auth.CreateIdHash(newCreatorName, newPin);

            if (!newUserMode)
            {
                bool previouslySeenHash = true;     // TODO (v-chph) Put test here.  Note we should always return true for guest ( Auth.DefaultCreatorHash ) without having to ping the server.

                if (previouslySeenHash)
                {
                    // We've seen this name before.
                    // Update Auth with the new values.
                    Auth.SetCreator(newCreatorName, newIdHash);
                }
                else
                {
                    // We haven't seen this name before so change dialog to New User.
                    newUserMode = true;
                    return; // Don't deactivate.
                }
            }

            // We've seen this name before.
            // Update Auth with the new values.
            Auth.SetCreator(newCreatorName, newIdHash);

            // Note that setting this also forces the creator name and idHash
            // to be saved from Auth.
            XmlOptionsData.KeepSignedInOnExit = keepSignedInChecked;

            // Done, we can exit now.
            Active = false;

            newUserMode = false;

            // Restart status dialog.
            AuthUI.ShowStatusDialog();
        }   // end of OnAccept()
        public void Render()
        {
            if (active)
            {
                // Render the underlying button texture.
                AuthUI.RenderTile(tileTexture, tileRect);

                Vector2 offset = new Vector2(16, 6);
                if (pressed)
                {
                    offset.Y += 1;
                }
                blob.RenderWithButtons(hitBox.Min + offset, Color.White);
            } // end of active
        }     // end of Render()
        }   // 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()
示例#9
0
        }   // end of OnCancel()

        public void Render()
        {
            if (active)
            {
                titleRect      = new Rectangle(0, 0, 512, 72);
                dialogBodyRect = new Rectangle(0, 64, 512, 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;

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

                // Title bar text.
                string str = Strings.Localize("auth.signOutTitle");
                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.Left;
                str = Strings.Localize("auth.currentlySignedInAs") + Auth.CreatorName;

                blob.Width   = dialogBodyRect.Width - 2 * margin;
                pos          = new Vector2(dialogBodyRect.X + margin, dialogBodyRect.Y + margin);
                blob.RawText = str;
                blob.RenderWithButtons(pos, Color.White);

                // 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 -= signOutButton.GetSize().X;
                signOutButton.Render(pos, useBatch: false);

                // Keep signed in checkbox.
                // Position vertically just above buttons.
                pos.X        = dialogBodyRect.X + margin;
                pos.Y        = signOutButton.Box.Min.Y;
                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);
            }
        }   // end of Render()