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