示例#1
0
        /// <summary>
        /// Constructs the drop down menu for available resolutions
        /// @Author Steven
        /// </summary>
        /// <param name="mainScreen"></param>
        private void createResolutionDropDown(Screen mainScreen)
        {
            resoTitleLabel = GuiHelper.CreateLabel("Resolution",
                                                   UIConstants.OPTION_RESO_LABEL.X, UIConstants.OPTION_RESO_LABEL.Y,
                                                   UIConstants.OPTION_RESO_LABEL.Width, UIConstants.OPTION_RESO_LABEL.Height);
            mainScreen.Desktop.Children.Add(resoTitleLabel);

            currentResoLabel = GuiHelper.CreateLabel(game.width + "x" + game.height,
                                                     UIConstants.OPTION_RESO_CUR_LABEL.X, UIConstants.OPTION_RESO_CUR_LABEL.Y,
                                                     UIConstants.OPTION_RESO_CUR_LABEL.Width, UIConstants.OPTION_RESO_CUR_LABEL.Height);
            mainScreen.Desktop.Children.Add(currentResoLabel);

            //Toggle resolution list button.
            ButtonControl toggleResoButton = GuiHelper.CreateButton("V",
                                                                    UIConstants.OPTION_RESO_BTN.X, UIConstants.OPTION_RESO_BTN.Y,
                                                                    UIConstants.OPTION_RESO_BTN.Width, UIConstants.OPTION_RESO_BTN.Height);

            toggleResoButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                if (toggleReso)
                {
                    resoList.Bounds = GuiHelper.CenterBound(UIConstants.OPTION_RESO_HIDE_LIST.X, UIConstants.OPTION_RESO_HIDE_LIST.Y,
                                                            UIConstants.OPTION_RESO_HIDE_LIST.Width, UIConstants.OPTION_RESO_HIDE_LIST.Height);
                }
                else
                {
                    resoList.Bounds = GuiHelper.CenterBound(UIConstants.OPTION_RESO_SHOW_LIST.X, UIConstants.OPTION_RESO_SHOW_LIST.Y,
                                                            UIConstants.OPTION_RESO_SHOW_LIST.Width, UIConstants.OPTION_RESO_SHOW_LIST.Height);
                }
                toggleReso = !toggleReso;
            };
            mainScreen.Desktop.Children.Add(toggleResoButton);

            //Resolution list
            resoList = new ListControl();
            resoList.SelectionMode = ListSelectionMode.Single;

            foreach (String reso in Resolution.GetScreenResolutions())
            {
                resoList.Items.Add(reso);
            }
            resoList.Bounds = GuiHelper.CenterBound(UIConstants.OPTION_RESO_HIDE_LIST.X, UIConstants.OPTION_RESO_HIDE_LIST.Y,
                                                    UIConstants.OPTION_RESO_HIDE_LIST.Width, UIConstants.OPTION_RESO_HIDE_LIST.Height);

            resoList.SelectionChanged += delegate(object sender, EventArgs arguments)
            {
                if (resoList.SelectedItems.Count != 0)
                {
                    currentResoLabel.Text = resoList.Items[resoList.SelectedItems[0]].ToString();
                    currentWinLabel.Text  = "Windowed";
                    winState   = 0;
                    toggleReso = false;
                }
                resoList.Bounds = GuiHelper.CenterBound(UIConstants.OPTION_RESO_HIDE_LIST.X, UIConstants.OPTION_RESO_HIDE_LIST.Y,
                                                        UIConstants.OPTION_RESO_HIDE_LIST.Width, UIConstants.OPTION_RESO_HIDE_LIST.Height);
            };
            mainScreen.Desktop.Children.Add(resoList);
        }
示例#2
0
        public void DrawMenu(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            WhiteBackground = new Rectangle((int)game.mainScreen.Width / 2 - UIConstants.CONTROL_WHITE_BG.X,
                                            (int)game.mainScreen.Height / 2 - UIConstants.CONTROL_WHITE_BG.Y,
                                            UIConstants.CONTROL_WHITE_BG.Width, UIConstants.CONTROL_WHITE_BG.Height);
            game.scroll.draw(spriteBatch);
            spriteBatch.Draw(TexBanner, Banner, Color.White);
            spriteBatch.Draw(Background, WhiteBackground, Color.White * 0.75f);
            spriteBatch.End();

            game.gui_manager.Draw(gameTime);
            keyState = Keyboard.GetState();

            /* Used to allow for modifier keys to be bound */
            if (changingKey)
            {
                foreach (Keys key in nonInputKeys)
                {
                    if (keyState.IsKeyDown(key))
                    {
                        keyToEnter.Text = "hi";                         // Random text
                    }
                }
            }

            /* Occurs after a key has been typed into the field and binds the new key */
            if (changingKey && keyToEnter.Text != "")
            {
                if (validateKey(keyState.GetPressedKeys()))
                {
                    currentKeyChange.Text     = keyState.GetPressedKeys()[0].ToString();
                    game.keylist[keyToChange] = keyState.GetPressedKeys()[0];

                    keyToEnter.Bounds = GuiHelper.CenterBound(
                        UIConstants.CONTROL_KEY_HIDE_LABEL.X, UIConstants.CONTROL_KEY_HIDE_LABEL.Y,
                        UIConstants.CONTROL_KEY_HIDE_LABEL.Width, UIConstants.CONTROL_KEY_HIDE_LABEL.Height);
                    keyToEnterLabel.Text = "";

                    changingKey = false;
                }
                else
                {
                    keyToEnterLabel.Text = keyState.GetPressedKeys()[0].ToString() + " Key already in use, enter a new key";
                    keyToEnter.Text      = "";
                }
            }
        }
示例#3
0
        /// <summary>
        /// Builds the UI for the ships to be selected
        /// @Author Steven
        /// </summary>
        /// <param name="mainScreen"></param>
        private void createShipSelection(Screen mainScreen)
        {
            //Choose Ship Label
            LabelControl chooseShipLabel = GuiHelper.CreateLabel("Choose Your Ship",
                                                                 UIConstants.LOBBY_SHIP_LABEL.X, UIConstants.LOBBY_SHIP_LABEL.Y,
                                                                 UIConstants.LOBBY_SHIP_LABEL.Width, UIConstants.LOBBY_SHIP_LABEL.Height);

            mainScreen.Desktop.Children.Add(chooseShipLabel);

            int i = 0;

            foreach (ChoiceControl choice in shipChoiceList)
            {
                choice.Bounds = GuiHelper.CenterBound(UIConstants.LOBBY_CHOICE_RADIO.X + i * UIConstants.LOBBY_CHOICE_RADIO_SPACE,
                                                      UIConstants.LOBBY_CHOICE_RADIO.Y, UIConstants.LOBBY_CHOICE_RADIO.Width, UIConstants.LOBBY_CHOICE_RADIO.Height);
                mainScreen.Desktop.Children.Add(choice);
                i++;
            }
        }
示例#4
0
        /// <summary>
        /// @Author Troy, Edited by Steven
        /// </summary>
        /// <param name="mainScreen"></param>
        private void CreateMenuControls(Screen mainScreen)
        {
            //Logout Button.
            ButtonControl logoutButton = GuiHelper.CreateButton("Logout",
                                                                UIConstants.MAIN_LOGOUT_BTN.X, UIConstants.MAIN_LOGOUT_BTN.Y,
                                                                UIConstants.MAIN_LOGOUT_BTN.Width, UIConstants.MAIN_LOGOUT_BTN.Height);

            logoutButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                game.EnterLoginMenu();
            };
            mainScreen.Desktop.Children.Add(logoutButton);

            //Multiplayer Button.
            ButtonControl multiplayerButton = GuiHelper.CreateButton("MULTIPLAYER",
                                                                     UIConstants.MAIN_MULTI_BTN.X, UIConstants.MAIN_MULTI_BTN.Y,
                                                                     UIConstants.MAIN_MULTI_BTN.Width, UIConstants.MAIN_MULTI_BTN.Height);

            multiplayerButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                game.EnterMultiplayerMenu();
            };
            mainScreen.Desktop.Children.Add(multiplayerButton);

            //Options Button.
            ButtonControl optionsButton = GuiHelper.CreateButton("Options",
                                                                 UIConstants.MAIN_OPTION_BTN.X, UIConstants.MAIN_OPTION_BTN.Y,
                                                                 UIConstants.MAIN_OPTION_BTN.Width, UIConstants.MAIN_OPTION_BTN.Height);

            optionsButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                game.EnterOptionsMenu();
            };
            mainScreen.Desktop.Children.Add(optionsButton);

            //Credits Button.
            ButtonControl creditsButton = GuiHelper.CreateButton("Credits",
                                                                 UIConstants.MAIN_CREDIT_BTN.X, UIConstants.MAIN_CREDIT_BTN.Y,
                                                                 UIConstants.MAIN_CREDIT_BTN.Width, UIConstants.MAIN_CREDIT_BTN.Height);

            creditsButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                game.EnterCreditsMenu();
            };
            mainScreen.Desktop.Children.Add(creditsButton);

            //Button to close game.
            ButtonControl quitButton = GuiHelper.CreateButton("Quit",
                                                              UIConstants.MAIN_QUIT_BTN.X, UIConstants.MAIN_QUIT_BTN.Y,
                                                              UIConstants.MAIN_QUIT_BTN.Width, UIConstants.MAIN_QUIT_BTN.Height);

            quitButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                game.Exit();
            };
            mainScreen.Desktop.Children.Add(quitButton);

            //Player Username Label
            LabelControl playerUsernameLabel = new LabelControl();

            //NETWORKING
            //playerUsernameLabel.Text = game.Player.Username.ToString();
            playerUsernameLabel.Text = "DEVELOPER";

            playerUsernameLabel.Bounds = GuiHelper.CenterBound(UIConstants.MAIN_PLAYER_LABEL.X, UIConstants.MAIN_PLAYER_LABEL.Y,
                                                               UIConstants.MAIN_PLAYER_LABEL.Width, UIConstants.MAIN_PLAYER_LABEL.Height);
            mainScreen.Desktop.Children.Add(playerUsernameLabel);
        }
示例#5
0
        /// <summary>
        /// @Author Troy, Edited by Steven
        /// </summary>
        /// <param name="mainScreen"></param>
        private void CreateMenuControls(Screen mainScreen)
        {
            //Menu Name Label
            LabelControl menuNameLabel = new LabelControl();

            //NETWORKING
            //menuNameLabel.Text = "Lobby: " + game.roomInfo.RoomName;
            menuNameLabel.Text = "Lobby: ";

            menuNameLabel.Bounds = GuiHelper.MENU_TITLE_LABEL;
            mainScreen.Desktop.Children.Add(menuNameLabel);

            //Players Labels
            playersLabel = GuiHelper.CreateLabel("Players:",
                                                 UIConstants.LOBBY_PLAYER_LABEL.X, UIConstants.LOBBY_PLAYER_LABEL.Y - UIConstants.LOBBY_PLAYER_LABEL_SPACE,
                                                 UIConstants.LOBBY_PLAYER_LABEL.Width, UIConstants.LOBBY_PLAYER_LABEL.Height);
            mainScreen.Desktop.Children.Add(playersLabel);

            int i = 0;

            foreach (LabelControl ctrl in playerLabelList)
            {
                //ctrl.Text = playerNameList[i]; // Use if using the List<string> to store player names
                ctrl.Bounds = GuiHelper.CenterBound(
                    UIConstants.LOBBY_PLAYER_LABEL.X, UIConstants.LOBBY_PLAYER_LABEL.Y + i * UIConstants.LOBBY_PLAYER_LABEL_SPACE,
                    UIConstants.LOBBY_PLAYER_LABEL.Width, UIConstants.LOBBY_PLAYER_LABEL.Height);
                mainScreen.Desktop.Children.Add(ctrl);
                i++;
            }

            shipChoice_1.Changed += delegate(object sender, EventArgs arguments)
            {
                selectShipIcon(0);
            };
            shipChoice_2.Changed += delegate(object sender, EventArgs arguments)
            {
                selectShipIcon(1);
            };
            shipChoice_3.Changed += delegate(object sender, EventArgs arguments)
            {
                selectShipIcon(2);
            };

            createShipSelection(mainScreen);

            //Ready Up Button.
            OptionControl readyUpButton = GuiHelper.CreateOption("I'm Ready!",
                                                                 UIConstants.LOBBY_READY_BTN.X, UIConstants.LOBBY_READY_BTN.Y,
                                                                 UIConstants.LOBBY_READY_BTN.Width, UIConstants.LOBBY_READY_BTN.Height);

            mainScreen.Desktop.Children.Add(readyUpButton);

            //Start Game Button
            ButtonControl startGameButton = GuiHelper.CreateButton("Start Game",
                                                                   UIConstants.LOBBY_START_BTN.X, UIConstants.LOBBY_START_BTN.Y,
                                                                   UIConstants.LOBBY_START_BTN.Width, UIConstants.LOBBY_START_BTN.Height);

            startGameButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                if (readyUpButton.Selected == true &&
                    (shipChoice_1.Selected == true || shipChoice_2.Selected == true || shipChoice_3.Selected == true))
                {
                    menuNameLabel.Text = "You are ready";
                }
                else
                {
                    menuNameLabel.Text = "You are not ready";
                }
            };
            if (!isLeader)
            {
                startGameButton.Enabled = false;
            }

            mainScreen.Desktop.Children.Add(startGameButton);

            //Cancel Button
            ButtonControl cancelGameButton = GuiHelper.CreateButton("Cancel",
                                                                    UIConstants.LOBBY_CANCEL_BTN.X, UIConstants.LOBBY_CANCEL_BTN.Y,
                                                                    UIConstants.LOBBY_CANCEL_BTN.Width, UIConstants.LOBBY_CANCEL_BTN.Height);

            cancelGameButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                //NETWORKING
                //game.Communication.sendRoomExitRequest(game.Player, game.roomInfo.RoomNumber);
                game.EnterLobbyBrowserMenu();
            };
            mainScreen.Desktop.Children.Add(cancelGameButton);
        }
示例#6
0
        private void CreateMenuControls(Screen mainScreen)
        {
            /* Constructs the labels and key buttons UI */
            int i = 0;

            foreach (LabelControl lbl in keyLabelList)
            {
                lbl.Bounds = GuiHelper.CenterBound(UIConstants.CONTROL_KEY_LABEL.X, UIConstants.CONTROL_KEY_LABEL.Y + i * UIConstants.CONTROL_KEY_SPACE,
                                                   UIConstants.CONTROL_KEY_LABEL.Width, UIConstants.CONTROL_KEY_LABEL.Height);
                mainScreen.Desktop.Children.Add(lbl);
                keyButtonList[i].Bounds = GuiHelper.CenterBound(UIConstants.CONTROL_KEY_BTN.X, UIConstants.CONTROL_KEY_BTN.Y + i * UIConstants.CONTROL_KEY_SPACE,
                                                                UIConstants.CONTROL_KEY_BTN.Width, UIConstants.CONTROL_KEY_BTN.Height);
                i++;
            }
            keyButton0.Pressed += delegate(object sender, EventArgs arguments)
            {
                changeKey(0, keyButton0, forwardLabel);
            };
            mainScreen.Desktop.Children.Add(keyButton0);

            keyButton1.Pressed += delegate(object sender, EventArgs arguments)
            {
                changeKey(1, keyButton1, leftLabel);
            };
            mainScreen.Desktop.Children.Add(keyButton1);

            keyButton2.Pressed += delegate(object sender, EventArgs arguments)
            {
                changeKey(2, keyButton2, rightLabel);
            };
            mainScreen.Desktop.Children.Add(keyButton2);

            keyButton3.Pressed += delegate(object sender, EventArgs arguments)
            {
                changeKey(3, keyButton3, fireLabel);
            };
            mainScreen.Desktop.Children.Add(keyButton3);

            keyButton4.Pressed += delegate(object sender, EventArgs arguments)
            {
                changeKey(4, keyButton4, altFireLabel);
            };
            mainScreen.Desktop.Children.Add(keyButton4);

            keyToEnterLabel = GuiHelper.CreateLabel("",
                                                    UIConstants.CONTROL_KEYTOENTER_BTN.X, UIConstants.CONTROL_KEYTOENTER_BTN.Y,
                                                    UIConstants.CONTROL_KEYTOENTER_BTN.Width, UIConstants.CONTROL_KEYTOENTER_BTN.Height);
            mainScreen.Desktop.Children.Add(keyToEnterLabel);

            // Used to determine if the user pressed a key
            keyToEnter = GuiHelper.CreateInput("", UIConstants.CONTROL_KEY_HIDE_LABEL.X, UIConstants.CONTROL_KEY_HIDE_LABEL.Y,
                                               UIConstants.CONTROL_KEY_HIDE_LABEL.Width, UIConstants.CONTROL_KEY_HIDE_LABEL.Height);
            mainScreen.Desktop.Children.Add(keyToEnter);

            // Back button
            backButton = GuiHelper.CreateButton("Back",
                                                UIConstants.CONTROL_BACK_BTN.X, UIConstants.CONTROL_BACK_BTN.Y,
                                                UIConstants.CONTROL_BACK_BTN.Width, UIConstants.CONTROL_BACK_BTN.Height);
            backButton.Pressed += delegate(object sender, EventArgs arugments)
            {
                game.EnterOptionsMenu();
            };
            mainScreen.Desktop.Children.Add(backButton);

            ButtonControl debug = GuiHelper.CreateButton("Debug", 165, 190, 70, 32);

            debug.Pressed += delegate(object sender, EventArgs arugments)
            {
                game.StartGame();
            };
            mainScreen.Desktop.Children.Add(debug);
        }