Example #1
0
        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);
        }
Example #2
0
        public ButtonPanel(GameScene game, Rectangle rect)
            : base(game)
        {
            m_Rect = rect;

            int mid = m_Rect.Left + (m_Rect.Width >> 1);
            int buttonSize = (int)(Constants.ButtonPanel_ButtonSize * Scene.Game.ScreenHeight);
            int buttonSpace = (int)(Constants.ButtonPanel_ButtonSpace * Scene.Game.ScreenHeight);
            int buttonsLeft = mid - (buttonSize >> 1);

            int startY = (int)(Constants.HelpPanel_Height * Scene.Game.ScreenHeight);

            m_Buttons = new UIButton[5];
            m_Buttons[0] = new UIButton(0, "P", Assets.DialogFont, new Rectangle(buttonsLeft, startY, buttonSize, buttonSize), Assets.ScrollBar);
            m_Buttons[1] = new UIButton(1, "H", Assets.DialogFont, new Rectangle(buttonsLeft, startY + buttonSize + buttonSpace, buttonSize, buttonSize), Assets.ScrollBar);
            m_Buttons[2] = new UIButton(2, "MH", Assets.DialogFont, new Rectangle(buttonsLeft, startY + ((buttonSize + buttonSpace) * 2), buttonSize, buttonSize), Assets.ScrollBar);
            m_Buttons[3] = new UIButton(3, "U", Assets.DialogFont, new Rectangle(buttonsLeft, startY + ((buttonSize + buttonSpace) * 3), buttonSize, buttonSize), Assets.ScrollBar);
            m_Buttons[4] = new UIButton(4, "HC", Assets.DialogFont, new Rectangle(buttonsLeft, startY + ((buttonSize + buttonSpace) * 4), buttonSize, buttonSize), Assets.ScrollBar);

            int coinMargin = (int)(Constants.ButtonPanel_CoinMargin * Scene.Game.ScreenHeight);
            int coinSize = (int)(Constants.ButtonPanel_CoinSize * Scene.Game.ScreenHeight);
            m_GoldCoinRect = new Rectangle(coinMargin, startY - (coinSize + coinMargin), coinSize, coinSize);
            m_vCoinsPosition.X = m_GoldCoinRect.Right + coinMargin;
            m_vCoinsPosition.Y = m_GoldCoinRect.Bottom - coinSize;
            m_CoinClickRect = new Rectangle(m_Rect.Left, m_Rect.Top, m_Rect.Width, startY - coinMargin);

            HideClueEnabled = false;
        }
Example #3
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);
        }
Example #4
0
        public FloorSelectDialog(int tower, int screenWidth, int screenHeight, Happiness game)
        {
            m_Game = game;
            m_iTower = tower;

            int iCenterX = screenWidth >> 1;
            int iCenterY = screenHeight >> 1;
            m_FloorScrollPosition = 0;
            m_iSelectedFloor = -1;

            // Frame rect
            int width = (int)(Constants.FloorSelectDialog_Width * screenWidth);
            int height = (int)(Constants.FloorSelectDialog_Height * screenHeight);
            m_Rect = new Rectangle(iCenterX - (width >> 1), iCenterY - (height >> 1), width, height);

            // Title
            int iTopMargin = (int)(Constants.FloorSelectDialog_MarginTopBottom * screenHeight);
            string title = string.Format("{0} x {0}", tower + 3);
            m_Title = new UILabel(title, iCenterX, m_Rect.Top + iTopMargin, Color.Goldenrod, Assets.MenuFont, UILabel.XMode.Center);

            // Buttons
            m_iLeftRightMargin = (int)(Constants.FloorSelectDialog_MarginLeftRight * screenWidth);
            int navButtonTop = m_Rect.Top + iTopMargin;
            int navButtonWidth = (int)(Constants.FloorSelectDialog_NavButtonWidth * screenWidth);
            int navButtonHeight = (int)(Constants.FloorSelectDialog_NavButtonHeight * screenHeight);
            int lbButtonWidth = (int)(Constants.FloorSelectDialog_LBButtonWidth * screenWidth);
            int lbButtonHeight = (int)(Constants.FloorSelectDialog_LBButtonHeight * screenHeight);
            m_Buttons = new UIButton[3];
            m_Buttons[0] = new UIButton(0, "<", Assets.MenuFont, new Rectangle(m_Rect.Left + m_iLeftRightMargin, navButtonTop, navButtonWidth, navButtonHeight), Assets.ScrollBar);
            m_Buttons[1] = new UIButton(1, ">", Assets.MenuFont, new Rectangle(m_Rect.Right - (m_iLeftRightMargin + navButtonWidth), navButtonTop, navButtonWidth, navButtonHeight), Assets.ScrollBar);
            m_Buttons[2] = new UIButton(2, "Leaderboard", Assets.DialogFont, new Rectangle(m_Rect.Right - (m_iLeftRightMargin + lbButtonWidth), m_Rect.Bottom - (iTopMargin + lbButtonHeight), lbButtonWidth, lbButtonHeight), Assets.ScrollBar);
            m_Buttons[1].Enabled = false;
            m_Buttons[2].Enabled = false;

            // Floors
            int floorScrollWidth = (int)(Constants.FloorSelectDialog_FloorScrollWidth * screenWidth);
            int floorScrollTop = m_Title.PositionY + m_Title.Height + (iTopMargin >> 1);
            int floorScrollBottom = m_Rect.Bottom - iTopMargin;
            int floorScrollHeight = floorScrollBottom - floorScrollTop;
            int waitIconSize = (int)(Constants.FloorSelectDialog_WaitIconSize * screenHeight);
            int halfWaitIconSize = waitIconSize >> 1;
            m_FloorScrollRect = new Rectangle(iCenterX - (floorScrollWidth >> 1), floorScrollTop, floorScrollWidth, floorScrollHeight);
            m_FloorWaitRectangle = new Rectangle(iCenterX - halfWaitIconSize, iCenterY - halfWaitIconSize, waitIconSize, waitIconSize);

            m_FloorDataFetchText = new UILabel("Fetching Data...", iCenterX, m_FloorWaitRectangle.Bottom, Color.White, Assets.DialogFont, UILabel.XMode.Center);

            m_ScrollFrame = new UIFrame(5, m_FloorScrollRect);

            // Request the data from the server
            NetworkManager.Net.RequestTowerData(tower, true);

            m_iFloorSelectTutorialWidth = (int)(Constants.FloorSelectDialog_FloorSelectTutorialWidth * screenWidth);
            int floorPlayTutorialWidth = (int)(Constants.FloorSelectDialog_PlayTutorialWidth * screenWidth);
            m_Game.Tutorial.SetPieceData(TutorialSystem.TutorialPiece.FloorPlay, new Vector2(m_Buttons[1].Rect.Left, m_Buttons[1].Rect.Bottom), (float)-Math.PI / 4,
                                                                                 new Rectangle(m_FloorScrollRect.Right + m_iLeftRightMargin, m_Buttons[1].Rect.Bottom + m_Game.Tutorial.ArrowWidth, floorPlayTutorialWidth, 0), "Press this button to play the selected floor.", TutorialSystem.TutorialPiece.None, m_Buttons[1].Rect);
        }
Example #5
0
        public PauseMenu(int screenWidth, int screenHeight)
        {
            m_iSelection = 0;
            m_iScreenWidth = screenWidth;
            m_iScreenHeight = screenHeight;

            m_iSelection = 0;
            m_iScrollOffset = 0;

            int buttonX = (int)(Constants.PauseMenu_ButtonX * screenWidth);
            int buttonY = (int)(Constants.PauseMenu_ButtonY * screenHeight);
            int buttonWidth = (int)(Constants.PauseMenu_ButtonWidth * screenWidth);
            int buttonHeight = (int)(Constants.PauseMenu_ButtonHeight * screenWidth);
            int buttonSpace = (int)(Constants.PauseMenu_ButtonSpace * screenHeight);

            m_Buttons = new UIButton[5];
            Rectangle brect = new Rectangle(buttonX, buttonY, buttonWidth, buttonHeight);
            m_Buttons[0] = new UIButton(0, "Resume Game", Assets.DialogFont, brect, Assets.ScrollBar);
            brect.Y += buttonHeight + buttonSpace;
            m_Buttons[1] = new UIButton(1, "Reset Puzzle", Assets.DialogFont, brect, Assets.ScrollBar);
            brect.Y += buttonHeight + buttonSpace;
            m_Buttons[2] = new UIButton(2, "Unhide Clues", Assets.DialogFont, brect, Assets.ScrollBar);
            brect.Y += buttonHeight + buttonSpace;
            m_Buttons[3] = new UIButton(3, "Buy Coins", Assets.DialogFont, brect, Assets.ScrollBar);
            brect.Y += buttonHeight + buttonSpace;
            m_Buttons[4] = new UIButton(4, "Save & Exit", Assets.DialogFont, brect, Assets.ScrollBar);

            m_ButtonBackground = new Rectangle((int)(Constants.PauseMenu_ButtonAreaBGX * screenWidth), (int)(Constants.PauseMenu_ButtonAreaBGY * screenHeight), (int)(Constants.PauseMenu_ButtonAreaBGW * screenWidth), (int)(Constants.PauseMenu_ButtonAreaBGH * screenHeight));

            int helpLeft = (int)(Constants.PauseMenu_HelpLeft * screenWidth);
            m_HelpRectangle = new Rectangle(helpLeft, 0, screenWidth - helpLeft, screenHeight);
            m_HelpTextLeft = (int)(Constants.PauseMenu_HelpTextLeft * screenWidth);
            m_HelpTextTop = (int)(Constants.PauseMenu_HelpTextTop * screenHeight);
            m_iIconSize = (int)(Constants.PauseMenu_IconSize * screenHeight);
            m_iIconSizeSmall = (int)(Constants.PauseMenu_IconSizeSmall * screenHeight);

            m_PauseStart = DateTime.Now;
        }
Example #6
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);
            }
        }
Example #7
0
        public void SetInstructions(Rectangle rect, string text, bool okButton)
        {
            m_Lines = Happiness.FormatLines(rect.Width - (m_iTextMarginLeftRight * 2), text, Assets.HelpFont);

            int buttonHeight = okButton ? m_iButtonHeight + m_iTextMarginTopBottom : 0;
            int autoHeight = ((m_Lines.Length + 1) * m_iTextLineHeight) + buttonHeight;
            m_InstructionRect = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height == 0 ? autoHeight : rect.Height);
            m_InstructionFrame = new UIFrame(1, m_InstructionRect);

            if( okButton )
                m_OKButton = new UIButton(0, "OK", Assets.HelpFont, new Rectangle(m_InstructionRect.Left + (m_InstructionRect.Width >> 1) - (m_iButtonWidth >> 1), m_InstructionRect.Bottom - (m_iButtonHeight + m_iTextMarginTopBottom), m_iButtonWidth, m_iButtonHeight), Assets.ScrollBar);
            else
                m_OKButton = null;
        }
Example #8
0
        public void FinishPiece(TutorialPiece piece)
        {
            if (m_Pieces[piece].Triggered)
            {
                m_Pieces[piece].Finished = true;
                Save();
            }

            if (m_CurrentPiece == piece)
            {
                if (m_Pieces[piece].NextPiece != TutorialPiece.None)
                    TriggerPiece(m_Pieces[piece].NextPiece);
                else
                {
                    m_CurrentPiece = TutorialPiece.None;
                    m_OKButton = null;
                }
            }
        }