コード例 #1
0
        /// <summary>
        /// @Author Troy, Edited by Steven
        /// </summary>
        /// <param name="mainScreen"></param>
        private void CreateMenuControls(Screen mainScreen)
        {
            //Logout Button.
            ButtonControl logoutButton = GuiHelper.CreateButton("Back",
                                                                UIConstants.MULTI_LOGOUT_BTN.X, UIConstants.MULTI_LOGOUT_BTN.Y,
                                                                UIConstants.MULTI_LOGOUT_BTN.Width, UIConstants.MULTI_LOGOUT_BTN.Height);

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

            //Multiplayer Button.
            ButtonControl lobbyBrowserButton = GuiHelper.CreateButton("Lobby Browser",
                                                                      UIConstants.MULTI_BROWSER_BTN.X, UIConstants.MULTI_BROWSER_BTN.Y,
                                                                      UIConstants.MULTI_BROWSER_BTN.Width, UIConstants.MULTI_BROWSER_BTN.Height);

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

            //Create Lobby Button.
            ButtonControl createLobbyButton = GuiHelper.CreateButton("Create Lobby",
                                                                     UIConstants.MULTI_CREATE_BTN.X, UIConstants.MULTI_CREATE_BTN.Y,
                                                                     UIConstants.MULTI_CREATE_BTN.Width, UIConstants.MULTI_CREATE_BTN.Height);

            createLobbyButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                game.EnterCreateLobbyMenu();
            };
            mainScreen.Desktop.Children.Add(createLobbyButton);
        }
コード例 #2
0
 public void CreateNewRow(string[] rowArray)
 {
     if (rows == ((currentPage) * (RowsPerPage)) && rows != 0)
     {
         pageFull[currentPage] = 1;
         currentPage++;
         maxPage++;
         for (int i = 0; i < rows; i++)
         {
             screen.Desktop.Children.Remove(joinButton[i]);
         }
         buttonsPerPage = 0;
     }
     for (int j = 0; j < NumberOfColumns; j++)
     {
         RowArray[rows, j] = rowArray[j];
     }
     joinButton[rows]          = GuiHelper.CreateButton("Join", 275, buttonsPerPage * RowRectSizeY - 127, 30, 15);
     joinButton[rows].Pressed += delegate(object sender, EventArgs arguments)
     {
         //insert lobby joining code here
     };
     screen.Desktop.Children.Add(joinButton[rows]);
     buttonsPerPage++;
     rows++;
 }
コード例 #3
0
        /// <summary>
        /// Constructs the interface of resolution selection
        /// @Author Steven
        /// </summary>
        /// <param name="mainScreen"></param>
        private void createWindowState(Screen mainScreen)
        {
            LabelControl winTitleLabel = GuiHelper.CreateLabel("Display Mode",
                                                               UIConstants.OPTION_WINDOW_LABEL.X, UIConstants.OPTION_WINDOW_LABEL.Y,
                                                               UIConstants.OPTION_WINDOW_LABEL.Width, UIConstants.OPTION_WINDOW_LABEL.Height);

            mainScreen.Desktop.Children.Add(winTitleLabel);

            ButtonControl leftWinToggle = GuiHelper.CreateButton("<",
                                                                 UIConstants.OPTION_LEFT_BTN.X, UIConstants.OPTION_LEFT_BTN.Y,
                                                                 UIConstants.OPTION_LEFT_BTN.Width, UIConstants.OPTION_LEFT_BTN.Height);

            leftWinToggle.Pressed += delegate(object sender, EventArgs arugments)
            {
                toggleWindowState(-1);
            };
            mainScreen.Desktop.Children.Add(leftWinToggle);

            currentWinLabel = GuiHelper.CreateLabel(game.windowState,
                                                    UIConstants.OPTION_CURWIN_LABEL.X, UIConstants.OPTION_CURWIN_LABEL.Y,
                                                    UIConstants.OPTION_CURWIN_LABEL.Width, UIConstants.OPTION_CURWIN_LABEL.Height);
            mainScreen.Desktop.Children.Add(currentWinLabel);

            ButtonControl rightWinToggle = GuiHelper.CreateButton(">",
                                                                  UIConstants.OPTION_RIGHT_BTN.X, UIConstants.OPTION_RIGHT_BTN.Y,
                                                                  UIConstants.OPTION_RIGHT_BTN.Width, UIConstants.OPTION_RIGHT_BTN.Height);

            rightWinToggle.Pressed += delegate(object sender, EventArgs arugments)
            {
                toggleWindowState(1);
            };
            mainScreen.Desktop.Children.Add(rightWinToggle);
        }
コード例 #4
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);
        }
コード例 #5
0
ファイル: CreditsMenu.cs プロジェクト: TheDizzler/space-union
        private void CreateMenuControls(Screen mainScreen)
        {
            //Menu Title Label
            //LabelControl menuTitleLabel = GuiHelper.CreateLabel("Credits", -325, -325, 30, 30);
            //mainScreen.Desktop.Children.Add(menuTitleLabel);

            //Logout Button.
            ButtonControl logoutButton = GuiHelper.CreateButton("Back",
                                                                UIConstants.CREDIT_BACK_BTN.X, UIConstants.CREDIT_BACK_BTN.Y,
                                                                UIConstants.CREDIT_BACK_BTN.Width, UIConstants.CREDIT_BACK_BTN.Height);

            logoutButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                game.EnterMainMenu();
            };
            mainScreen.Desktop.Children.Add(logoutButton);
        }
コード例 #6
0
        /// <summary>
        /// @Author Troy, Edited by Steven
        /// </summary>
        /// <param name="mainScreen"></param>
        private void CreateMenuControls(Screen mainScreen)
        {
            //Logout Button.
            ButtonControl backButton = GuiHelper.CreateButton("Back",
                                                              UIConstants.CREATE_BACK_BTN.X, UIConstants.CREATE_BACK_BTN.Y,
                                                              UIConstants.CREATE_BACK_BTN.Width, UIConstants.CREATE_BACK_BTN.Height);

            backButton.Pressed += delegate(object sender, EventArgs arguments) {
                game.EnterMultiplayerMenu();
            };
            mainScreen.Desktop.Children.Add(backButton);
            //Lobby Title Text Entry.
            lobbyTitleInput = GuiHelper.CreateInput("",
                                                    UIConstants.CREATE_LOBBY_INPUT.X, UIConstants.CREATE_LOBBY_INPUT.Y,
                                                    UIConstants.CREATE_LOBBY_INPUT.Width, UIConstants.CREATE_LOBBY_INPUT.Height);
            mainScreen.Desktop.Children.Add(lobbyTitleInput);
            //Create Lobby Button.
            ButtonControl createLobbyButton = GuiHelper.CreateButton("Create Lobby",
                                                                     UIConstants.CREATE_LOBBY_BTN.X, UIConstants.CREATE_LOBBY_BTN.Y,
                                                                     UIConstants.CREATE_LOBBY_BTN.Width, UIConstants.CREATE_LOBBY_BTN.Height);

            createLobbyButton.Pressed += delegate(object sender, EventArgs arguments) {
                game.EnterLobbyMenu();
                //NETWORKING

                /*
                 * if(lobbyTitleInput.Text != null){
                 * Data lobbyData = game.Communication.sendRoomCreationRequest(game.Player, lobbyTitleInput.Text);
                 * if (lobbyData.Type == 10)
                 * {
                 * game.roomInfo = (RoomInfo)lobbyData;
                 * game.EnterLobbyMenu();
                 * }
                 * else if (lobbyData.Type == 7)
                 * {
                 * Console.WriteLine("cannot create lobby");
                 * }
                 * }
                 */
                game.EnterLobbyMenu();
            };
            mainScreen.Desktop.Children.Add(createLobbyButton);
        }
コード例 #7
0
        /// <summary>
        /// Creates the user interface
        /// @Written by Steven
        /// </summary>
        /// <param name="mainScreen"></param>
        private void CreateMenuControls(Screen mainScreen)
        {
            //Logout Button.
            ButtonControl logoutButton = GuiHelper.CreateButton("Back",
                                                                UIConstants.OPTION_LOGOUT_BTN.X, UIConstants.OPTION_LOGOUT_BTN.Y,
                                                                UIConstants.OPTION_LOGOUT_BTN.Width, UIConstants.OPTION_LOGOUT_BTN.Height);

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

            //Apply Changes button.
            applyButton = GuiHelper.CreateButton("Apply",
                                                 UIConstants.OPTION_APPLY_BTN.X, UIConstants.OPTION_APPLY_BTN.Y,
                                                 UIConstants.OPTION_APPLY_BTN.Width, UIConstants.OPTION_APPLY_BTN.Height);
            applyButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                applyChanges();
            };
            mainScreen.Desktop.Children.Add(applyButton);

            createResolutionDropDown(mainScreen);
            createWindowState(mainScreen);
            createSoundVolume(mainScreen);

            //Controls
            ButtonControl keyBindings = GuiHelper.CreateButton("Key Bindings",
                                                               UIConstants.OPTION_KEYS_BTN.X, UIConstants.OPTION_KEYS_BTN.Y,
                                                               UIConstants.OPTION_KEYS_BTN.Width, UIConstants.OPTION_KEYS_BTN.Height);

            keyBindings.Pressed += delegate(object sender, EventArgs arugments)
            {
                game.EnterControlMenu();
            };
            mainScreen.Desktop.Children.Add(keyBindings);
        }
コード例 #8
0
        private void CreateMenuControls(Screen mainScreen)
        {
            //Logout Button.
            ButtonControl backButton = GuiHelper.CreateButton("Back",
                                                              UIConstants.BROWSE_BACK_BTN.X, UIConstants.BROWSE_BACK_BTN.Y,
                                                              UIConstants.BROWSE_BACK_BTN.Width, UIConstants.BROWSE_BACK_BTN.Height);

            backButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                game.EnterMultiplayerMenu();
            };
            mainScreen.Desktop.Children.Add(backButton);
            prevPageButton = GuiHelper.CreateButton("Prev",
                                                    UIConstants.BROWSE_PREV_BTN.X, UIConstants.BROWSE_PREV_BTN.Y,
                                                    UIConstants.BROWSE_PREV_BTN.Width, UIConstants.BROWSE_PREV_BTN.Height);
            prevPageButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                LobbyBrowserTable.PrevPage();
            };

            nextPageButton = GuiHelper.CreateButton("Next",
                                                    UIConstants.BROWSE_NEXT_BTN.X, UIConstants.BROWSE_NEXT_BTN.Y,
                                                    UIConstants.BROWSE_NEXT_BTN.Width, UIConstants.BROWSE_NEXT_BTN.Height);
            nextPageButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                LobbyBrowserTable.NextPage();
            };

            mainScreen.Desktop.Children.Add(nextPageButton);
            mainScreen.Desktop.Children.Add(prevPageButton);

            pagesLabel = GuiHelper.CreateLabel(LobbyBrowserTable.currentPage + "/" + LobbyBrowserTable.maxPage,
                                               UIConstants.BROWSE_PAGE_LABEL.X, UIConstants.BROWSE_PAGE_LABEL.Y,
                                               UIConstants.BROWSE_PAGE_LABEL.Width, UIConstants.BROWSE_PAGE_LABEL.Height);

            mainScreen.Desktop.Children.Add(pagesLabel);
        }
コード例 #9
0
ファイル: ControlMenu.cs プロジェクト: TheDizzler/space-union
        public ControlMenu(Game1 game)
        {
            this.game = game;
            game.mainScreen.Desktop.Children.Clear();             //Clear the gui
            screen = game.mainScreen;

            TexBanner = Game1.Assets.suOptionKeys;
            Banner    = new Rectangle((int)game.mainScreen.Width / 2 - UIConstants.SU_BANNER.X, (int)game.mainScreen.Height / 2 - UIConstants.SU_BANNER.Y,
                                      UIConstants.SU_BANNER.Width, UIConstants.SU_BANNER.Height);

            Background = Game1.Assets.guiRectangle;

            nonInputKeys = new List <Keys>();
            nonInputKeys.Add(Keys.LeftControl);
            nonInputKeys.Add(Keys.LeftAlt);
            nonInputKeys.Add(Keys.LeftShift);
            nonInputKeys.Add(Keys.RightAlt);
            nonInputKeys.Add(Keys.RightControl);
            nonInputKeys.Add(Keys.RightShift);

            keyLabelList = new List <LabelControl>();
            keyLabelList.Add(forwardLabel = GuiHelper.CreateLabel("Forward Thrust", 0, 0, UIConstants.CONTROL_KEY_LABEL.Width, UIConstants.CONTROL_KEY_LABEL.Height));
            keyLabelList.Add(leftLabel    = GuiHelper.CreateLabel("Turn Left", 0, 0, UIConstants.CONTROL_KEY_LABEL.Width, UIConstants.CONTROL_KEY_LABEL.Height));
            keyLabelList.Add(rightLabel   = GuiHelper.CreateLabel("Turn Right", 0, 0, UIConstants.CONTROL_KEY_LABEL.Width, UIConstants.CONTROL_KEY_LABEL.Height));
            keyLabelList.Add(fireLabel    = GuiHelper.CreateLabel("Primary Fire", 0, 0, UIConstants.CONTROL_KEY_LABEL.Width, UIConstants.CONTROL_KEY_LABEL.Height));
            keyLabelList.Add(altFireLabel = GuiHelper.CreateLabel("Secondary Fire", 0, 0, UIConstants.CONTROL_KEY_LABEL.Width, UIConstants.CONTROL_KEY_LABEL.Height));

            keyButtonList = new List <ButtonControl>();
            keyButtonList.Add(keyButton0 = GuiHelper.CreateButton(game.keylist[0].ToString(), 0, 0, UIConstants.CONTROL_KEY_BTN.Width, UIConstants.CONTROL_KEY_BTN.Height));
            keyButtonList.Add(keyButton1 = GuiHelper.CreateButton(game.keylist[1].ToString(), 0, 0, UIConstants.CONTROL_KEY_BTN.Width, UIConstants.CONTROL_KEY_BTN.Height));
            keyButtonList.Add(keyButton2 = GuiHelper.CreateButton(game.keylist[2].ToString(), 0, 0, UIConstants.CONTROL_KEY_BTN.Width, UIConstants.CONTROL_KEY_BTN.Height));
            keyButtonList.Add(keyButton3 = GuiHelper.CreateButton(game.keylist[3].ToString(), 0, 0, UIConstants.CONTROL_KEY_BTN.Width, UIConstants.CONTROL_KEY_BTN.Height));
            keyButtonList.Add(keyButton4 = GuiHelper.CreateButton(game.keylist[4].ToString(), 0, 0, UIConstants.CONTROL_KEY_BTN.Width, UIConstants.CONTROL_KEY_BTN.Height));

            CreateMenuControls(game.mainScreen);
        }
コード例 #10
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);
        }
コード例 #11
0
ファイル: LobbyMenu.cs プロジェクト: TheDizzler/space-union
        /// <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);
        }
コード例 #12
0
        /// <summary>
        /// Constructs the volume interface for both Music and Sound
        /// @Author Konstantin and Edited by Steven
        /// </summary>
        /// <param name="mainScreen"></param>
        private void createSoundVolume(Screen mainScreen)
        {
            /* Sound volume control */
            LabelControl soundControlLabel = GuiHelper.CreateLabel("Sound",
                                                                   UIConstants.OPTION_SOUND_LABEL.X, UIConstants.OPTION_SOUND_LABEL.Y,
                                                                   UIConstants.OPTION_SOUND_LABEL.Width, UIConstants.OPTION_SOUND_LABEL.Height);

            mainScreen.Desktop.Children.Add(soundControlLabel);

            ButtonControl soundOffButton = GuiHelper.CreateButton("OFF",
                                                                  UIConstants.OPTION_SOUND_OFF_BTN.X, UIConstants.OPTION_SOUND_OFF_BTN.Y,
                                                                  UIConstants.OPTION_SOUND_OFF_BTN.Width, UIConstants.OPTION_SOUND_OFF_BTN.Height);

            soundOffButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                currentSoundLabel.Text   = "Off";
                game.currentSound        = "Off";
                SoundEffect.MasterVolume = 0f;
            };
            mainScreen.Desktop.Children.Add(soundOffButton);

            ButtonControl soundLowButton = GuiHelper.CreateButton("LOW",
                                                                  UIConstants.OPTION_SOUND_LOW_BTN.X, UIConstants.OPTION_SOUND_LOW_BTN.Y,
                                                                  UIConstants.OPTION_SOUND_LOW_BTN.Width, UIConstants.OPTION_SOUND_LOW_BTN.Height);

            soundLowButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                currentSoundLabel.Text   = "Low";
                game.currentSound        = "Low";
                SoundEffect.MasterVolume = .10f;
            };
            mainScreen.Desktop.Children.Add(soundLowButton);

            ButtonControl soundMediumButton = GuiHelper.CreateButton("MED",
                                                                     UIConstants.OPTION_SOUND_MED_BTN.X, UIConstants.OPTION_SOUND_MED_BTN.Y,
                                                                     UIConstants.OPTION_SOUND_MED_BTN.Width, UIConstants.OPTION_SOUND_MED_BTN.Height);

            soundMediumButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                currentSoundLabel.Text   = "Medium";
                game.currentSound        = "Medium";
                SoundEffect.MasterVolume = .50f;
            };
            mainScreen.Desktop.Children.Add(soundMediumButton);

            ButtonControl soundHighButton = GuiHelper.CreateButton("HIGH",
                                                                   UIConstants.OPTION_SOUND_HIGH_BTN.X, UIConstants.OPTION_SOUND_HIGH_BTN.Y,
                                                                   UIConstants.OPTION_SOUND_HIGH_BTN.Width, UIConstants.OPTION_SOUND_HIGH_BTN.Height);

            soundHighButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                currentSoundLabel.Text   = "High";
                game.currentSound        = "High";
                SoundEffect.MasterVolume = 1f;
            };
            mainScreen.Desktop.Children.Add(soundHighButton);

            currentSoundLabel = GuiHelper.CreateLabel(game.currentSound,
                                                      UIConstants.OPTION_SOUND_CUR_LABEL.X, UIConstants.OPTION_SOUND_CUR_LABEL.Y,
                                                      UIConstants.OPTION_SOUND_CUR_LABEL.Width, UIConstants.OPTION_SOUND_CUR_LABEL.Height);
            mainScreen.Desktop.Children.Add(currentSoundLabel);

            /* Music volume control */
            LabelControl musicControlLabel = GuiHelper.CreateLabel("Music",
                                                                   UIConstants.OPTION_MUSIC_LABEL.X, UIConstants.OPTION_MUSIC_LABEL.Y,
                                                                   UIConstants.OPTION_MUSIC_LABEL.Width, UIConstants.OPTION_MUSIC_LABEL.Height);

            mainScreen.Desktop.Children.Add(musicControlLabel);

            ButtonControl musicOffButton = GuiHelper.CreateButton("OFF",
                                                                  UIConstants.OPTION_MUSIC_OFF_BTN.X, UIConstants.OPTION_MUSIC_OFF_BTN.Y,
                                                                  UIConstants.OPTION_MUSIC_OFF_BTN.Width, UIConstants.OPTION_MUSIC_OFF_BTN.Height);

            musicOffButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                currentMusicLabel.Text = "Off";
                game.currentMusic      = "Off";
                MediaPlayer.Volume     = 0;
            };
            mainScreen.Desktop.Children.Add(musicOffButton);

            ButtonControl musicLowButton = GuiHelper.CreateButton("LOW",
                                                                  UIConstants.OPTION_MUSIC_LOW_BTN.X, UIConstants.OPTION_MUSIC_LOW_BTN.Y,
                                                                  UIConstants.OPTION_MUSIC_LOW_BTN.Width, UIConstants.OPTION_MUSIC_LOW_BTN.Height);

            musicLowButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                currentMusicLabel.Text = "Low";
                game.currentMusic      = "Low";
                MediaPlayer.Volume     = .33f;
            };
            mainScreen.Desktop.Children.Add(musicLowButton);

            ButtonControl musicMediumButton = GuiHelper.CreateButton("MED",
                                                                     UIConstants.OPTION_MUSIC_MED_BTN.X, UIConstants.OPTION_MUSIC_MED_BTN.Y,
                                                                     UIConstants.OPTION_MUSIC_MED_BTN.Width, UIConstants.OPTION_MUSIC_MED_BTN.Height);

            musicMediumButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                currentMusicLabel.Text = "Medium";
                game.currentMusic      = "Medium";
                MediaPlayer.Volume     = .66f;
            };
            mainScreen.Desktop.Children.Add(musicMediumButton);

            ButtonControl musicHighButton = GuiHelper.CreateButton("HIGH",
                                                                   UIConstants.OPTION_MUSIC_HIGH_BTN.X, UIConstants.OPTION_MUSIC_HIGH_BTN.Y,
                                                                   UIConstants.OPTION_MUSIC_HIGH_BTN.Width, UIConstants.OPTION_MUSIC_HIGH_BTN.Height);

            musicHighButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                currentMusicLabel.Text = "High";
                game.currentMusic      = "High";
                MediaPlayer.Volume     = 1f;
            };
            mainScreen.Desktop.Children.Add(musicHighButton);

            currentMusicLabel = GuiHelper.CreateLabel(game.currentMusic,
                                                      UIConstants.OPTION_MUSIC_CUR_LABEL.X, UIConstants.OPTION_MUSIC_CUR_LABEL.Y,
                                                      UIConstants.OPTION_MUSIC_CUR_LABEL.Width, UIConstants.OPTION_MUSIC_CUR_LABEL.Height);
            mainScreen.Desktop.Children.Add(currentMusicLabel);
        }
コード例 #13
0
        /// <summary>
        /// @Author Troy, Edited by Steven
        /// </summary>
        /// <param name="mainScreen"></param>
        private void CreateMenuControls(Screen mainScreen)
        {
            //TODO: Change Label Colors to white
            //Account Name Label

            LabelControl accountNameLabel = GuiHelper.CreateLabel("Account Name",
                                                                  UIConstants.LOGIN_ACCOUNT_LABEL.X, UIConstants.LOGIN_ACCOUNT_LABEL.Y,
                                                                  UIConstants.LOGIN_ACCOUNT_LABEL.Width, UIConstants.LOGIN_ACCOUNT_LABEL.Height);

            mainScreen.Desktop.Children.Add(accountNameLabel);

            //Error Text Label
            errorText        = new LabelControl();
            errorText.Bounds = new UniRectangle(275.0f, 300.0f, 110.0f, 25.0f);
            mainScreen.Desktop.Children.Add(errorText);

            //Account Name Input
            accountNameInput = GuiHelper.CreateInput("",
                                                     UIConstants.LOGIN_ACCOUNT_INPUT.X, UIConstants.LOGIN_ACCOUNT_INPUT.Y,
                                                     UIConstants.LOGIN_ACCOUNT_INPUT.Width, UIConstants.LOGIN_ACCOUNT_INPUT.Height);
            mainScreen.Desktop.Children.Add(accountNameInput);

            //Password Label
            passwordLabel = GuiHelper.CreateLabel("Password",
                                                  UIConstants.LOGIN_PASSWORD_LABEL.X, UIConstants.LOGIN_PASSWORD_LABEL.Y,
                                                  UIConstants.LOGIN_ACCOUNT_LABEL.Width, UIConstants.LOGIN_PASSWORD_LABEL.Height);
            mainScreen.Desktop.Children.Add(passwordLabel);

            //TODO: Create Password field where characters show up as black circles
            //Password Input
            passwordInput = GuiHelper.CreatePasswordInput(UIConstants.LOGIN_PASSWORD_INPUT.X, UIConstants.LOGIN_PASSWORD_INPUT.Y,
                                                          UIConstants.LOGIN_PASSWORD_INPUT.Width, UIConstants.LOGIN_PASSWORD_INPUT.Height);
            mainScreen.Desktop.Children.Add(passwordInput);

            //TODO: Change to a contrasting color (Yellow)
            //Login Button.
            ButtonControl loginButton = GuiHelper.CreateButton("Login",
                                                               UIConstants.LOGIN_BUTTON.X, UIConstants.LOGIN_BUTTON.Y,
                                                               UIConstants.LOGIN_BUTTON.Width, UIConstants.LOGIN_BUTTON.Height);

            loginButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                errorText.Text = "";
                errors         = false;
                if (accountNameInput.Text == "")
                {
                    errorText.Text += "Username field cannot be empty!\n";
                    errors          = true;
                }
                if (passwordInput.Text == "")
                {
                    errorText.Text += "Password field cannot be empty!";
                    errors          = true;
                }
                if (errors)
                {
                    return;
                }

                /*
                 * game.Player.Username = accountNameInput.Text;
                 * game.Player.Password = passwordInput.GetText();
                 *
                 * game.Communication.sendLoginRequest(game.Player);
                 * Thread.Sleep(2000);
                 * game.Player = game.Communication.getPlayer();
                 * Console.WriteLine(game.Player.Username);
                 * if (game.Player != null)*/
                game.EnterMainMenu();
            };
            mainScreen.Desktop.Children.Add(loginButton);

            //Debug Button.
            ButtonControl multiplayerButton = GuiHelper.CreateButton("Debug Game", -300, -300, 200, 50);

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

            //Ship Select Button.
            ButtonControl shipSelectButton = GuiHelper.CreateButton("Select Ship", -300, -225, 200, 50);

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

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

            quitButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                game.Exit();
            };
            mainScreen.Desktop.Children.Add(quitButton);
        }
コード例 #14
0
ファイル: ControlMenu.cs プロジェクト: TheDizzler/space-union
        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);
        }