Ejemplo n.º 1
0
        public SignInDialog(int screenWidth, int screenHeight)
        {
            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);

            int margin = (int)(Constants.SignInDialog_Margin * screenHeight);

            m_szTitleText = "Sign In";
            Vector2 titleSize = Assets.MenuFont.MeasureString(m_szTitleText);
            m_vTitlePosition = new Vector2(m_iCenterDialogX - (titleSize.X * 0.5f), m_Rect.Top + margin);

            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 + margin;
            m_szPasswordText = "Password:"******"Remember Me", inputFieldLeft, m_Password.Rect.Bottom + margin, screenHeight);

            int authY = m_RememberMe.Rect.Bottom + (int)(Constants.SignInDialog_AuthGap * screenHeight);
            int authSize = (int)(Constants.SignInDialog_AuthSize * screenHeight);
            m_AuthButtons = new UIButton[2];
            m_AuthButtons[0] = new UIButton(0, null, null, new Rectangle(m_iCenterDialogX - ((authSize >> 1) + authSize), authY, authSize, authSize), Assets.Facebook);
            m_AuthButtons[1] = new UIButton(1, null, null, new Rectangle(m_iCenterDialogX + (authSize >> 1), authY, authSize, authSize), Assets.Google);

            m_StatusColor = Color.White;
            m_fStatusTextY = m_AuthButtons[0].Rect.Bottom + (int)(Constants.SignInDialog_StatusGap * screenHeight);

            int btnY = m_Rect.Bottom - (int)(Constants.SignInDialog_ButtonGap * screenHeight);
            int btnX = (int)(Constants.SignInDialog_ButtonGapLeft * screenWidth);
            int btnLargeW = (int)(Constants.SignInDialog_ButtonWidthLarge * screenWidth);
            int btnSmallW = (int)(Constants.SignInDialog_ButtonWidthSmall * screenWidth);
            int btnH = (int)(Constants.SignInDialog_ButtonHeight * screenHeight);
            m_DialogButtons = new UIButton[3];
            m_DialogButtons[0] = new UIButton(0, "Sign In", Assets.DialogFont, new Rectangle(m_iCenterDialogX - (btnLargeW >> 1), btnY, btnLargeW, btnH), Assets.ScrollBar);
            m_DialogButtons[1] = new UIButton(1, "Exit", Assets.DialogFont, new Rectangle(m_Rect.Left + btnX, btnY, btnSmallW, btnH), Assets.ScrollBar);
            m_DialogButtons[2] = new UIButton(2, "Skip", Assets.DialogFont, new Rectangle(m_Rect.Right - (btnSmallW + btnX), btnY, btnSmallW, btnH), Assets.ScrollBar);

            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);
        }
Ejemplo n.º 2
0
        public MessageBox(string message, MessageBoxButtons buttons, int context, int screenWidth, int screenHeight, string checkboxText = null)
        {
            m_iContext  = context;
            m_TextColor = Color.White;

            int iCheckboxSize = (int)(Constants.MessageBox_CheckboxSize * screenHeight);

            m_iMarginLeftRight = (int)(Constants.MessageBox_LeftRightMargin * screenWidth);
            m_iMarginTopBottom = (int)(Constants.MessageBox_TopBottomMargin * screenHeight);

            int checkboxHeight = checkboxText == null ? 0 : m_iMarginTopBottom + iCheckboxSize;

            int width = (int)(Constants.MessageBox_Width * screenWidth);

            m_Lines = Happiness.FormatLines(width - (m_iMarginLeftRight * 2), message, Assets.DialogFont);

            int buttonWidth  = (int)(Constants.MessageBox_ButtonWidth * screenWidth);
            int buttonHeight = (int)(Constants.MessageBox_ButtonHeight * screenHeight);

            int     lineSpace    = (int)(Constants.MessageBox_LineSpace * screenHeight);
            Vector2 testTextSize = Assets.DialogFont.MeasureString("TEST");

            m_iTextLineHeight = (int)testTextSize.Y + lineSpace;

            int buttonAreaHeight = buttons == MessageBoxButtons.None ? 0 : m_iMarginTopBottom + buttonHeight;
            int dialogHeight     = (m_iMarginTopBottom + m_iMarginTopBottom) + (m_iTextLineHeight * m_Lines.Length) + buttonAreaHeight + checkboxHeight;

            int halfScreenW = screenWidth >> 1;
            int halfScreenH = screenHeight >> 1;
            int halfDialogW = width >> 1;
            int halfDialogH = dialogHeight >> 1;

            m_iCenterDialogX = halfScreenW;

            m_Rect = new Rectangle(halfScreenW - halfDialogW, halfScreenH - halfDialogH, width, dialogHeight);

            int buttonY         = (m_Rect.Bottom - m_iMarginTopBottom) - buttonHeight;
            int halfButtonWidth = buttonWidth >> 1;

            switch (buttons)
            {
            case MessageBoxButtons.OK:
                m_Buttons    = new UIButton[1];
                m_Buttons[0] = new UIButton((int)MessageBoxResult.OK, "OK", Assets.HelpFont, new Rectangle(halfScreenW - halfButtonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
                break;

            case MessageBoxButtons.YesNo:
                m_Buttons    = new UIButton[2];
                m_Buttons[0] = new UIButton((int)MessageBoxResult.Yes, "Yes", Assets.HelpFont, new Rectangle(halfScreenW - (halfButtonWidth + buttonWidth), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
                m_Buttons[1] = new UIButton((int)MessageBoxResult.No, "No", Assets.HelpFont, new Rectangle(halfScreenW + halfButtonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
                break;

            case MessageBoxButtons.BuyCoinsCancel:
                m_Buttons    = new UIButton[2];
                m_Buttons[0] = new UIButton((int)MessageBoxResult.BuyCoins, "Buy Coins", Assets.HelpFont, new Rectangle(halfScreenW - (halfButtonWidth + buttonWidth), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
                m_Buttons[1] = new UIButton((int)MessageBoxResult.Cancel, "Cancel", Assets.HelpFont, new Rectangle(halfScreenW + halfButtonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
                break;

            case MessageBoxButtons.None:
                break;
            }

            if (checkboxText != null)
            {
                m_CheckBox      = new UICheckbox(checkboxText, 0, buttonY - (m_iMarginTopBottom + iCheckboxSize), screenHeight);
                m_CheckBox.Left = m_iCenterDialogX - (m_CheckBox.Rect.Width >> 1);
            }
        }
Ejemplo n.º 3
0
        public MessageBox(string message, MessageBoxButtons buttons, int context, int screenWidth, int screenHeight, string checkboxText = null)
        {
            m_iContext = context;
            m_TextColor = Color.White;

            int iCheckboxSize = (int)(Constants.MessageBox_CheckboxSize * screenHeight);

            m_iMarginLeftRight = (int)(Constants.MessageBox_LeftRightMargin * screenWidth);
            m_iMarginTopBottom = (int)(Constants.MessageBox_TopBottomMargin * screenHeight);

            int checkboxHeight = checkboxText == null ? 0 : m_iMarginTopBottom + iCheckboxSize;

            int width = (int)(Constants.MessageBox_Width * screenWidth);
            m_Lines = Happiness.FormatLines(width - (m_iMarginLeftRight * 2), message, Assets.DialogFont);

            int buttonWidth = (int)(Constants.MessageBox_ButtonWidth * screenWidth);
            int buttonHeight = (int)(Constants.MessageBox_ButtonHeight * screenHeight);

            int lineSpace = (int)(Constants.MessageBox_LineSpace * screenHeight);
            Vector2 testTextSize = Assets.DialogFont.MeasureString("TEST");
            m_iTextLineHeight = (int)testTextSize.Y + lineSpace;

            int buttonAreaHeight = buttons == MessageBoxButtons.None ? 0 : m_iMarginTopBottom + buttonHeight;
            int dialogHeight = (m_iMarginTopBottom + m_iMarginTopBottom) + (m_iTextLineHeight * m_Lines.Length) + buttonAreaHeight + checkboxHeight;

            int halfScreenW = screenWidth >> 1;
            int halfScreenH = screenHeight >> 1;
            int halfDialogW = width >> 1;
            int halfDialogH = dialogHeight >> 1;

            m_iCenterDialogX = halfScreenW;

            m_Rect = new Rectangle(halfScreenW - halfDialogW, halfScreenH - halfDialogH, width, dialogHeight);

            int buttonY = (m_Rect.Bottom - m_iMarginTopBottom) - buttonHeight;
            int halfButtonWidth = buttonWidth >> 1;
            switch (buttons)
            {
                case MessageBoxButtons.OK:
                    m_Buttons = new UIButton[1];
                    m_Buttons[0] = new UIButton((int)MessageBoxResult.OK, "OK", Assets.HelpFont, new Rectangle(halfScreenW - halfButtonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
                    break;
                case MessageBoxButtons.YesNo:
                    m_Buttons = new UIButton[2];
                    m_Buttons[0] = new UIButton((int)MessageBoxResult.Yes, "Yes", Assets.HelpFont, new Rectangle(halfScreenW - (halfButtonWidth + buttonWidth), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
                    m_Buttons[1] = new UIButton((int)MessageBoxResult.No, "No", Assets.HelpFont, new Rectangle(halfScreenW + halfButtonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
                    break;
                case MessageBoxButtons.BuyCoinsCancel:
                    m_Buttons = new UIButton[2];
                    m_Buttons[0] = new UIButton((int)MessageBoxResult.BuyCoins, "Buy Coins", Assets.HelpFont, new Rectangle(halfScreenW - (halfButtonWidth + buttonWidth), buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
                    m_Buttons[1] = new UIButton((int)MessageBoxResult.Cancel, "Cancel", Assets.HelpFont, new Rectangle(halfScreenW + halfButtonWidth, buttonY, buttonWidth, buttonHeight), Assets.ScrollBar);
                    break;
                case MessageBoxButtons.None:
                    break;
            }

            if (checkboxText != null)
            {
                m_CheckBox = new UICheckbox(checkboxText, 0, buttonY - (m_iMarginTopBottom + iCheckboxSize), screenHeight);
                m_CheckBox.Left = m_iCenterDialogX - (m_CheckBox.Rect.Width >> 1);
            }
        }
Ejemplo n.º 4
0
        public Options(Happiness game)
        {
            m_Game = game;

            int screenWidth  = game.ScreenWidth;
            int screenHeight = game.ScreenHeight;

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

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

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

            int bottom           = top + height;
            int marginTopBottom  = (int)(Constants.OptionsDialog_TopBottomMargin * screenHeight);
            int buttonWidth      = (int)(Constants.OptionsDialog_ButtonWidth * screenWidth);
            int buttonHeight     = (int)(Constants.OptionsDialog_ButtonHeight * screenHeight);
            int centerButtonLeft = m_iCenterDialogX - (buttonWidth >> 1);

            m_DoneButton = new UIButton(0, "Done", Assets.HelpFont, new Rectangle(centerButtonLeft, ((bottom - marginTopBottom) - buttonHeight), buttonWidth, buttonHeight), Assets.ScrollBar);

            int sliderWidth  = (int)(Constants.OptionsDialog_SliderWidth * screenWidth);
            int sliderHeight = (int)(Constants.OptionsDialog_SliderHeight * screenHeight);
            int cursorWidth  = (int)(Constants.OptionsDialog_SliderCursorWidth * screenWidth);
            int cursorHeight = (int)(Constants.OptionsDialog_SliderCursorHeight * screenHeight);
            int sliderLeft   = m_iCenterDialogX - (sliderWidth >> 1);

            m_AudioSlider            = new UISlider(SoundManager.Inst.SoundVolume, 0.0f, 0.3f, new Rectangle(sliderLeft, top + marginTopBottom, sliderWidth, sliderHeight), Assets.SliderBar, Assets.SliderCursor, new Rectangle(0, 0, cursorWidth, cursorHeight), "Sound Volume", Assets.HelpFont);
            m_AudioSlider.OnChanged += OnSoundChanged;
            m_MusicSlider            = new UISlider(SoundManager.Inst.MusicVolume, 0.0f, 0.5f, new Rectangle(sliderLeft, top + marginTopBottom + (sliderHeight * 3), sliderWidth, sliderHeight), Assets.SliderBar, Assets.SliderCursor, new Rectangle(0, 0, cursorWidth, cursorHeight), "Music Volume", Assets.HelpFont);
            m_MusicSlider.OnChanged += OnMusicChanged;

            int cbY = top + (marginTopBottom * 2) + (sliderHeight * 5);

            m_ExpSlowdown         = new UICheckbox("Disable Exp Bonus (VIP 2)", m_iCenterDialogX, cbY, screenHeight, UICheckbox.XMode.Center);
            m_ExpSlowdown.Checked = m_Game.ExpSlowdown;

            cbY                    += m_ExpSlowdown.Rect.Height + marginTopBottom;
            m_ErrorDetector         = new UICheckbox("Error Detector (VIP 4)", m_iCenterDialogX, cbY, screenHeight, UICheckbox.XMode.Center);
            m_ErrorDetector.Checked = m_Game.ErrorDetector;

            cbY += m_ExpSlowdown.Rect.Height + marginTopBottom;
            m_ErrorDetector2         = new UICheckbox("Super Error Detector (VIP 8)", m_iCenterDialogX, cbY, screenHeight, UICheckbox.XMode.Center);
            m_ErrorDetector2.Checked = m_Game.ErrorDetector2;

            cbY                   += m_ExpSlowdown.Rect.Height + marginTopBottom;
            m_DisableTimer         = new UICheckbox("Disable Timer (VIP 1)", m_iCenterDialogX, cbY, screenHeight, UICheckbox.XMode.Center);
            m_DisableTimer.Checked = m_Game.DisableTimer;


            m_ExpSlowdown.Enabled    = m_Game.TheGameInfo.VipData.Level >= 2;
            m_ErrorDetector.Enabled  = m_Game.TheGameInfo.VipData.Level >= 4;
            m_ErrorDetector2.Enabled = m_Game.TheGameInfo.VipData.Level >= 8;
            m_DisableTimer.Enabled   = m_Game.TheGameInfo.VipData.Level >= 1;

            if (m_Game.CurrentScene is GameScene)
            {
                m_DisableTimer.Enabled = false;
            }
        }