/// <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); }
/// <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); }
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); }