Beispiel #1
0
        public void HandleKeyUp(KeyArgs key)
        {
            UIInputField focused = null;

            if (m_Email.Focused)
            {
                focused = m_Email;
            }
            else if (m_Password.Focused)
            {
                focused = m_Password;
            }
            else if (m_Password2.Focused)
            {
                focused = m_Password2;
            }
            if (focused != null)
            {
                if (key.Key == Keys.Enter)
                {
                    if (focused != m_Password2)
                    {
                        NextFocus();
                    }
                    else
                    {
                        VirtualKeyboard.Hide();
                        if (OnSignIn != null)
                        {
                            OnSignIn(this, null);
                        }
                    }
                }
                else if (key.Key == Keys.Tab)
                {
                    NextFocus();
                    Happiness.Game.SoundManager.PlaySound(SoundManager.SEInst.MenuNavigate);
                }
                else
                {
                    focused.HandleKey(key);
                }
            }
        }
        public DisplayNameDialog(int screenWidth, int screenHeight)
        {
            int centerScreenX = screenWidth >> 1;
            int centerScreenY = screenHeight >> 1;

            int width        = (int)(Constants.DisplayNameDialog_Width * screenWidth);
            int height       = (int)(Constants.DisplayNameDialog_Height * screenHeight);
            int topMargin    = (int)(Constants.DisplayNameDialog_MarginTopBottom * screenHeight);
            int lineSpace    = (int)(Constants.DisplayNameDialog_LineSpace * screenHeight);
            int inputWidth   = (int)(Constants.DisplayNameDialog_InputWidth * screenWidth);
            int inputHeight  = (int)(Constants.DisplayNameDialog_InputHeight * screenHeight);
            int buttonWidth  = (int)(Constants.DisplayNameDialog_ButtonWidth * screenWidth);
            int buttonHeight = (int)(Constants.DisplayNameDialog_ButtonHeight * screenHeight);

            m_Rect = new Rectangle(centerScreenX - (width >> 1), centerScreenY - (height >> 1), width, height);

            m_szTitle = "Choose a display name";
            Vector2 size = Assets.DialogFont.MeasureString(m_szTitle);

            m_vTitlePosition = new Vector2(centerScreenX - (size.X * 0.5f), m_Rect.Top + topMargin);

            m_szSecondaryText      = "Pick a name for other players to see you as";
            m_vSecondaryPosition.Y = m_vTitlePosition.Y + size.Y + lineSpace;
            size = Assets.HelpFont.MeasureString(m_szSecondaryText);
            m_vSecondaryPosition.X = centerScreenX - (size.X * 0.5f);

            m_Input         = new UIInputField(new Rectangle(centerScreenX - (inputWidth >> 1), (int)(m_vSecondaryPosition.Y + size.Y + lineSpace + lineSpace), inputWidth, inputHeight));
            m_Input.Focused = true;

            int buttonY = m_Input.Rect.Bottom + lineSpace;

            height       = (buttonY + buttonHeight + topMargin) - m_Rect.Top;
            m_Buttons    = new UIButton[2];
            m_Buttons[0] = new UIButton(0, "Done", Assets.HelpFont, new Rectangle(centerScreenX + (buttonWidth >> 1), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
            m_Buttons[1] = new UIButton(1, "Cancel", Assets.HelpFont, new Rectangle(centerScreenX - ((buttonWidth >> 1) + buttonWidth), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
        }
Beispiel #3
0
        public SignInDialog(int screenWidth, int screenHeight)
        {
            m_Mode = Mode.SignInButtons;

            m_iCenterDialogX = (screenWidth >> 1);
            int centerY = (screenHeight >> 1);

            int width  = (int)(Constants.SignInDialog_Width * screenWidth);
            int height = (int)(Constants.SignInDialog_Height * screenHeight);
            int left   = m_iCenterDialogX - (width >> 1);
            int top    = centerY - (height >> 1);

            m_Rect = new Rectangle(left, top, width, height);

            m_iMargin        = (int)(Constants.SignInDialog_Margin * screenHeight);
            m_iStatusOffsetY = (int)(Constants.SignInDialog_StatusOffsetY * screenHeight);

            SetTitle("Sign In");

            int iconSize     = (int)(Constants.SignInDialog_AuthSize * screenHeight);
            int buttonWidth  = (int)(Constants.SignInDialog_IconButtonWidth * screenWidth);
            int iconX        = (int)(Constants.SignInDialog_IconMarginLeftRight * screenWidth);
            int iconY        = (int)(Constants.SignInDialog_IconMarginTopBottom * screenHeight);
            int buttonMargin = (int)(Constants.SignInDialog_IconButtonGap * screenHeight);
            int buttonHeight = iconSize + (iconY * 2);
            int buttonLeft   = m_iCenterDialogX - (buttonWidth / 2);

            int buttonsHeight = (buttonHeight * 4) + (buttonMargin * 3);
            int buttonsTop    = (centerY - (buttonsHeight / 2)) + 30;


            m_SignInButtons = new UIButton[4];
            int buttonTop = buttonsTop;

            m_SignInButtons[0] = new IconButton(0, new Rectangle(buttonLeft, buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar,
                                                new Rectangle(buttonLeft + iconX, buttonTop + iconY, iconSize, iconSize), Assets.Facebook,
                                                "Facebook\nSign In", Assets.DialogFont);
            buttonTop         += buttonHeight + buttonMargin;
            m_SignInButtons[1] = new IconButton(1, new Rectangle(buttonLeft, buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar,
                                                new Rectangle(buttonLeft + iconX, buttonTop + iconY, iconSize, iconSize), Assets.Google,
                                                "Google\nSign In", Assets.DialogFont);
            buttonTop         += buttonHeight + buttonMargin;
            m_SignInButtons[2] = new IconButton(2, new Rectangle(buttonLeft, buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar,
                                                new Rectangle(buttonLeft + iconX, buttonTop + iconY, iconSize, iconSize), Assets.Email,
                                                "Email\nSign In", Assets.DialogFont);
            buttonTop         += buttonHeight + buttonMargin;
            m_SignInButtons[3] = new UIButton(3, "Exit", Assets.DialogFont, new Rectangle(buttonLeft, buttonTop, buttonWidth, buttonHeight), Assets.ScrollBar);


            int inputFieldWidth = (int)(Constants.SignInDialog_InputWidth * screenWidth);
            int inputFieldLeft  = m_Rect.Left + (int)(Constants.SignInDialog_InputLeft * screenWidth);
            int inputFieldTop   = m_Rect.Top + (int)(Constants.SignInDialog_InputTop * screenHeight);

            m_szEmailText = "Email:";
            Vector2 emailSize = Assets.HelpFont.MeasureString(m_szEmailText);

            m_vEmailLabelPosition = new Vector2(inputFieldLeft - (emailSize.X + 2), inputFieldTop);
            m_Email = new UIInputField(new Rectangle(inputFieldLeft, inputFieldTop, inputFieldWidth, (int)emailSize.Y));

            int passwordY = m_Email.Rect.Bottom + m_iMargin;

            m_szPasswordText = "Password:"******"Confirm Password:"******"Sign In", Assets.DialogFont, new Rectangle(m_iCenterDialogX + 20, btnY, btnLargeW, btnH), Assets.ScrollBar);
            m_DialogButtons[1] = new UIButton(1, "Cancel", Assets.DialogFont, new Rectangle(m_iCenterDialogX - 20 - btnLargeW, btnY, btnLargeW, btnH), Assets.ScrollBar);

            SetupAccountStatusMode(true);

            m_Email.Focused = true;

            m_bInputEnabled = true;
            int waitSize  = (int)(Constants.SignInDialog_WaitIconSize * screenHeight);
            int waitSpace = (int)(Constants.SignInDialog_WaitIconSpace * screenHeight);
            //m_WaitRect = new Rectangle(m_DialogButtons[2].Rect.Right - waitSize, m_DialogButtons[2].Rect.Top - (waitSpace + waitSize), waitSize, waitSize);
        }
Beispiel #4
0
        public void HandleKeyUp(KeyArgs key)
        {
            UIInputField focused = null;

            if (m_Email.Focused)
            {
                focused = m_Email;
            }
            else if (m_Password.Focused)
            {
                focused = m_Password;
            }
            else if (m_Password2.Focused)
            {
                focused = m_Password2;
            }
            if (focused != null)
            {
                if (key.Key == Keys.Enter)
                {
                    if (OnSignIn != null)
                    {
                        OnSignIn(this, null);
                    }
                }
                else if (key.Key == Keys.Tab)
                {
                    if (m_Email.Focused)
                    {
                        m_Email.Focused     = false;
                        m_Password.Focused  = true;
                        m_Password2.Focused = false;
                    }
                    else if (m_Password.Focused)
                    {
                        if (m_bEmailCreate)
                        {
                            m_Email.Focused     = false;
                            m_Password.Focused  = false;
                            m_Password2.Focused = true;
                        }
                        else
                        {
                            m_Email.Focused     = true;
                            m_Password.Focused  = false;
                            m_Password2.Focused = false;
                        }
                    }
                    else if (m_Password2.Focused)
                    {
                        m_Email.Focused     = true;
                        m_Password.Focused  = false;
                        m_Password2.Focused = false;
                    }
                    Happiness.Game.SoundManager.PlaySound(SoundManager.SEInst.MenuNavigate);
                }
                else
                {
                    focused.HandleKey(key);
                }
            }
        }
Beispiel #5
0
 public static void ShowKeyboard(UIInputField inputField)
 {
     s_Instance.InternalShowKeyboard(inputField);
 }
Beispiel #6
0
 protected abstract void InternalShowKeyboard(UIInputField inputField);