public UserDisplayPanel(ParentComponent parent, User user, int index) : base(parent, new Rectangle()) { this.user = user; this.UpdateBounds(index); Boolean enabled = false; if (user.id == ChatServerConnectionManager.GetInstance().user.id) enabled = true; readyCheckBox = new XNACheckBox(this, new Rectangle(10, 10, 20, 20), ""); readyCheckBox.onClickListeners += this.OnReadyChanged; readyCheckBox.enabled = enabled; // readyCheckBox usernameLbl = new XNALabel(this, new Rectangle(40, 5, 230, 30), user.username); usernameLbl.font = MenuManager.BIG_TEXTFIELD_FONT; teamDropdown = new XNADropdown(this, new Rectangle(280, 5, 50, 30)); teamDropdown.dropdownLineSpace = 15; teamDropdown.arrowSize = 8; teamDropdown.onOptionSelectedChangedListeners += this.OnTeamChanged; for (int i = 0; i < 8; i++) teamDropdown.AddOption((i + 1) + ""); teamDropdown.enabled = enabled; colorDropdown = new XNADropdown(this, new Rectangle(340, 5, 50, 30)); colorDropdown.dropdownLineSpace = 15; colorDropdown.arrowSize = 8; for (int i = 0; i < colors.Length; i++) { colorDropdown.AddOption(""); colorDropdown.SetBackgroundColor(i + 1, colors[i]); } colorDropdown.onOptionSelectedChangedListeners += this.OnColorChanged; colorDropdown.enabled = enabled; kickBtn = new XNAButton(this, new Rectangle(400, 5, 75, 30), "Kick"); kickBtn.visible = false; if (((GameLobby)MenuManager.GetInstance().GetCurrentlyDisplayedMenu()).IsCurrentUserHost() && this.user.id != ChatServerConnectionManager.GetInstance().user.id) { kickBtn.visible = true; kickBtn.onClickListeners += this.OnKickButtonPressed; } if (this.user.id == 1) { // Wotuu this.SelectColor(1); this.readyCheckBox.selected = true; this.teamDropdown.SelectItem(0); } else if (this.user.id == 2) { this.SelectColor(3); this.readyCheckBox.selected = true; this.teamDropdown.SelectItem(1); } }
public override void OnOKClick(XNAButton source) { if (this.GetSelectedMap() != null) { StateManager.GetInstance().gameState = StateManager.State.GameInit; MenuManager.GetInstance().ShowMenu(MenuManager.Menu.SinglePlayerLoadMenu); StateManager.GetInstance().gameState = StateManager.State.GameLoading; this.Dispose(); } else XNAMessageDialog.CreateDialog("Please select a map first.", XNAMessageDialog.DialogType.OK); }
public XNADropdown(ParentComponent parent, Rectangle bounds) : base(parent, bounds) { this.enabled = true; optionHeight = this.bounds.Height; shownButton = new XNAButton(this, new Rectangle( 0, 0, this.bounds.Width, optionHeight), ""); shownButton.onClickListeners += ShownButtonClicked; dropdownLineSpace = 30; arrowSize = 10; }
public GameDisplayPanel(ParentComponent parent, int index, MultiplayerGame multiplayerGame) : base(parent, new Rectangle()) { this.index = index; this.bounds = new Rectangle(5, 5 + (componentHeight + componentSpacing) * this.index, 580, componentHeight); this.border = new Border(this, 2, Color.Pink); this.multiplayerGame = multiplayerGame; XNALabel gameNameLbl = new XNALabel(this, new Rectangle(5, 5, 180, 30), this.multiplayerGame.gamename); mapNameLbl = new XNALabel(this, new Rectangle(195, 5, 180, 30), this.multiplayerGame.mapname); joinGameBtn = new XNAButton(this, new Rectangle(475, 5, 100, 30), "Join game"); joinGameBtn.onClickListeners += this.JoinGame; }
public MainMenu() : base(null, new Rectangle( Game1.GetInstance().graphics.PreferredBackBufferWidth / 2 - 200, Game1.GetInstance().graphics.PreferredBackBufferHeight / 2 - 200, 400, 400)) { XNAButton startGameButton = new XNAButton(this, new Rectangle((this.bounds.Width / 2) - (buttonWidth / 2), buttonSpacing, buttonWidth, buttonHeight), "Start Test Game"); startGameButton.font = MenuManager.BUTTON_FONT; startGameButton.onClickListeners += this.StartGameClicked; XNAButton multiplayerButton = new XNAButton(this, new Rectangle((this.bounds.Width / 2) - (buttonWidth / 2), buttonSpacing * 2 + buttonHeight, buttonWidth, buttonHeight), "Multiplayer"); multiplayerButton.font = MenuManager.BUTTON_FONT; multiplayerButton.onClickListeners += this.MultiplayerClicked; XNAButton optionsButton = new XNAButton(this, new Rectangle((this.bounds.Width / 2) - (buttonWidth / 2), buttonSpacing * 3 + buttonHeight * 2, buttonWidth, buttonHeight), "Options"); optionsButton.font = MenuManager.BUTTON_FONT; optionsButton.onClickListeners += this.OptionsClicked; XNAButton creditsButton = new XNAButton(this, new Rectangle((this.bounds.Width / 2) - (buttonWidth / 2), buttonSpacing * 4 + buttonHeight * 3, buttonWidth, buttonHeight), "Credits"); creditsButton.font = MenuManager.BUTTON_FONT; creditsButton.onClickListeners += this.CreditsClicked; XNAButton exitButton = new XNAButton(this, new Rectangle((this.bounds.Width / 2) - (buttonWidth / 2), buttonSpacing * 5 + buttonHeight * 4, buttonWidth, buttonHeight), "Exit Game"); exitButton.font = MenuManager.BUTTON_FONT; exitButton.onClickListeners += this.ExitClicked; /*XNALabel label = new XNALabel(this, new Rectangle(10, 10, 100, 30), "Label test!"); label.border = new Border(label, 1, Color.Red); label.textAlign = XNALabel.TextAlign.LEFT; XNAButton button = new XNAButton(this, new Rectangle(10, 50, 100, 40), "Click me"); XNACheckBox checkBox = new XNACheckBox(this, new Rectangle(10, 110, 100, 20), "Checkbox test!"); XNATextField textField = new XNATextField(this, new Rectangle(10, 140, 300, 60), 2);*/ }
public LoginScreen() : base(null, new Rectangle( Game1.GetInstance().graphics.PreferredBackBufferWidth / 2 - 200, Game1.GetInstance().graphics.PreferredBackBufferHeight / 2 - 200, 400, 400)) { XNALabel ipLbl = new XNALabel(this, new Rectangle(70, 70, 100, 30), "IP"); ipLbl.border = null; ipLbl.textAlign = XNALabel.TextAlign.RIGHT; ipLbl.font = MenuManager.BIG_TEXTFIELD_FONT; ipTF = new XNATextField(this, new Rectangle(190, 70, 100, 35), 1); ipTF.border = new Border(ipTF, 1, Color.Blue); ipTF.font = MenuManager.BIG_TEXTFIELD_FONT; ipTF.text = "localhost"; XNALabel usernameLbl = new XNALabel(this, new Rectangle(70, 110, 100, 30), "Username"); usernameLbl.border = null; usernameLbl.textAlign = XNALabel.TextAlign.RIGHT; usernameLbl.font = MenuManager.BIG_TEXTFIELD_FONT; usernameTF = new XNATextField(this, new Rectangle(190, 110, 100, 35), 1); usernameTF.border = new Border(usernameTF, 1, Color.Blue); usernameTF.font = MenuManager.BIG_TEXTFIELD_FONT; connectingLbl = new XNALabel(this, new Rectangle(0, 160, 400, 30), ""); connectingLbl.border = null; connectingLbl.textAlign = XNALabel.TextAlign.CENTER; connectingLbl.font = MenuManager.BUTTON_FONT; XNAButton loginButton = new XNAButton(this, new Rectangle(150, 210, 100, 40), "Log in"); loginButton.font = MenuManager.BUTTON_FONT; loginButton.onClickListeners += this.LoginClicked; XNAButton backButton = new XNAButton(this, new Rectangle(150, 300, 100, 40), "Back"); backButton.font = MenuManager.BUTTON_FONT; backButton.onClickListeners += this.BackClicked; }
public GameLobby() : base(null, new Rectangle( Game1.GetInstance().graphics.PreferredBackBufferWidth / 2 - 400, Game1.GetInstance().graphics.PreferredBackBufferHeight / 2 - 300, 800, 600)) { gameOptionsPanel = new XNAPanel(this, new Rectangle(5, 5, 500, 330)); gameOptionsPanel.border = new Border(gameOptionsPanel, 1, Color.Blue); XNAPanel mapPreviewPanel = new XNAPanel(this, new Rectangle(510, 5, 200, 200)); mapPreviewPanel.border = new Border(gameOptionsPanel, 1, Color.Blue); this.creationTime = new TimeSpan(DateTime.UtcNow.Ticks).TotalMilliseconds; XNAPanel messagesPanel = new XNAPanel(this, new Rectangle(5, 340, 790, 210)); messagesPanel.border = new Border(messagesPanel, 1, Color.Blue); messagesTextField = new XNATextField(messagesPanel, new Rectangle(5, 5, 780, 170), Int32.MaxValue); messagesTextField.border = new Border(messagesTextField, 1, Color.Black); messagesTextField.font = MenuManager.SMALL_TEXTFIELD_FONT; messagesTextField.isEditable = false; messageTextField = new XNATextField(messagesPanel, new Rectangle(5, 180, 780, 25), 1); messageTextField.border = new Border(messageTextField, 1, Color.Black); messageTextField.font = MenuManager.SMALL_TEXTFIELD_FONT; messageTextField.onTextFieldKeyPressedListeners += this.OnKeyPressed; startGameButton = new XNAButton(this, new Rectangle(this.bounds.Width - 105, this.bounds.Height - 45, 100, 40), "Start Game"); startGameButton.onClickListeners += StartGame; startGameButton.visible = false; leaveGameButton = new XNAButton(this, new Rectangle(5, this.bounds.Height - 45, 100, 40), "Leave Game"); leaveGameButton.onClickListeners += LeaveGame; }
public MultiplayerLobby() : base(null, new Rectangle( Game1.GetInstance().graphics.PreferredBackBufferWidth / 2 - 400, Game1.GetInstance().graphics.PreferredBackBufferHeight / 2 - 300, 800, 600)) { gamesPanel = new XNAPanel(this, new Rectangle(5, 5, 590, 330)); gamesPanel.border = new Border(gamesPanel, 1, Color.Blue); XNAPanel usersPanel = new XNAPanel(this, new Rectangle(600, 5, 195, 330)); usersPanel.border = new Border(usersPanel, 1, Color.Blue); usersField = new XNATextField(usersPanel, new Rectangle(5, 5, 185, 320), Int32.MaxValue); usersField.font = MenuManager.SMALL_TEXTFIELD_FONT; usersField.isEditable = false; XNAPanel messagesPanel = new XNAPanel(this, new Rectangle(5, 340, 790, 210)); messagesPanel.border = new Border(messagesPanel, 1, Color.Blue); messagesTextField = new XNATextField(messagesPanel, new Rectangle(5, 5, 780, 170), 12); messagesTextField.border = new Border(messagesTextField, 1, Color.Black); messagesTextField.font = MenuManager.SMALL_TEXTFIELD_FONT; messagesTextField.isEditable = false; messageTextField = new XNATextField(messagesPanel, new Rectangle(5, 180, 780, 25), 1); messageTextField.border = new Border(messageTextField, 1, Color.Black); messageTextField.font = MenuManager.SMALL_TEXTFIELD_FONT; messageTextField.onTextFieldKeyPressedListeners += this.OnKeyPressed; disconnectButton = new XNAButton(this, new Rectangle(this.bounds.Width - 105, this.bounds.Height - 45, 100, 40), "Disconnect"); disconnectButton.onClickListeners += DisconnectBtnClicked; createGameButton = new XNAButton(this, new Rectangle(5, this.bounds.Height - 45, 100, 40), "Create Game"); createGameButton.onClickListeners += CreateGameBtnClicked; }
public void OptionsClicked(XNAButton source) { }
public void ExitClicked(XNAButton source) { Game1.GetInstance().Exit(); }
public void OnExitToWindows(XNAButton source) { Game1.GetInstance().Exit(); }
public void OnResumeGame(XNAButton source) { MenuManager.GetInstance().ShowMenu(MenuManager.Menu.NoMenu); if (!Game1.GetInstance().IsMultiplayerGame()) StateManager.GetInstance().gameState = StateManager.State.GameRunning; }
/// <summary> /// User wants to join this game. /// </summary> /// <param name="button">The button that was pressed.</param> public void JoinGame(XNAButton button) { Packet joinPacket = new Packet(Headers.CLIENT_REQUEST_JOIN); joinPacket.AddInt(this.multiplayerGame.id); joinPacket.AddInt(ChatServerConnectionManager.GetInstance().user.id); ChatServerConnectionManager.GetInstance().SendPacket(joinPacket); }
/// <summary> /// Re-does the layout for this Message Dialog. Should be called when the user specifies a custom font /// rather than the the default font, or when the client window size changes. /// </summary> public override void DoLayout() { Vector2 messageDimensions = this.font.MeasureString(message); int windowHeight = (int)messageDimensions.Y + this.padding.top + this.padding.bottom + 50; this.bounds = new Rectangle((CLIENT_WINDOW_WIDTH / 2) - 200, (CLIENT_WINDOW_HEIGHT / 2) - (windowHeight / 2), 400, windowHeight); this.label = new XNALabel(this, new Rectangle( 0, this.padding.top, this.bounds.Width, (int)messageDimensions.Y), message); this.label.textAlign = XNALabel.TextAlign.CENTER; this.label.border = null; if (type == DialogType.OK) { this.button1 = new XNAButton(this, new Rectangle( (this.bounds.Width / 2) - (this.buttonWidth / 2), this.label.bounds.Bottom + 10, this.buttonWidth, 40), "OK"); this.button1.onClickListeners += this.Dispose; } else if (type == DialogType.YES_CANCEL || type == DialogType.YES_NO || type == DialogType.OK_CANCEL) { String[] buttonText = new String[2]; if (type == DialogType.YES_CANCEL) { buttonText[0] = "Yes"; buttonText[1] = "Cancel"; } else if (type == DialogType.OK_CANCEL) { buttonText[0] = "OK"; buttonText[1] = "Cancel"; } else if (type == DialogType.YES_NO) { buttonText[0] = "Yes"; buttonText[1] = "No"; } button1 = new XNAButton(this, new Rectangle( (this.bounds.Width / 2) - (this.buttonWidth) - (this.buttonSpacing / 2), this.label.bounds.Bottom + 10, this.buttonWidth, 40), buttonText[0]); this.button1.onClickListeners += this.Dispose; this.button2 = new XNAButton(this, new Rectangle( (this.bounds.Width / 2) + (this.buttonSpacing / 2), this.label.bounds.Bottom + 10, this.buttonWidth, 40), buttonText[1]); this.button2.onClickListeners += this.Dispose; } else if (type == DialogType.YES_NO_CANCEL) { this.button1 = new XNAButton(this, new Rectangle( (this.bounds.Width / 2) - (this.buttonWidth / 2) - this.buttonWidth - this.buttonSpacing, this.label.bounds.Bottom + 10, this.buttonWidth, 40), "Yes"); this.button1.onClickListeners += this.Dispose; this.button2 = new XNAButton(this, new Rectangle( (this.bounds.Width / 2) - (this.buttonWidth / 2), this.label.bounds.Bottom + 10, this.buttonWidth, 40), "No"); this.button2.onClickListeners += this.Dispose; this.button3 = new XNAButton(this, new Rectangle( (this.bounds.Width / 2) + (this.buttonWidth / 2) + this.buttonSpacing, this.label.bounds.Bottom + 10, this.buttonWidth, 40), "Cancel"); this.button3.onClickListeners += this.Dispose; } }
/// <summary> /// The user wants to disconnect. /// </summary> /// <param name="source"></param> public void DisconnectBtnClicked(XNAButton source) { ChatServerConnectionManager.GetInstance().DisconnectFromServer(); }
/// <summary> /// User wants to create a game. /// </summary> /// <param name="source">Bla</param> public void CreateGameBtnClicked(XNAButton source) { gameNameInput = XNAInputDialog.CreateDialog("Please enter the game name: ", XNAInputDialog.DialogType.OK_CANCEL); gameNameInput.button1.onClickListeners += CreateGame; }
/// <summary> /// When the back button was clicked. /// </summary> /// <param name="source">XNAButton that was clicked</param> public void OnBackBtnClicked(XNAButton source) { MenuManager.GetInstance().ShowMenu(MenuManager.Menu.MainMenu); }
public void OnCreditsPressed(XNAButton source) { this.creditsPresentation = new CreditsPresentation(); this.visible = false; /* StateManager.GetInstance().SetRunningGame(StateManager.RunningGame.MiniGameOverview); StateManager.GetInstance().SetState(StateManager.State.Running);*/ }
public void OnExitGame(XNAButton source) { Game1.GetInstance().map.Dispose(); MenuManager.GetInstance().ShowMenu(MenuManager.Menu.NoMenu); if (!Game1.GetInstance().IsMultiplayerGame()) StateManager.GetInstance().gameState = StateManager.State.MainMenu; }
public void OnExitGameBtnPressed(XNAButton source) { Game1.GetInstance().Exit(); }
/// <summary> /// When the kick button has been pressed. /// </summary> public void OnKickButtonPressed(XNAButton source) { Packet p = new Packet(Headers.GAME_KICK_CLIENT); p.AddInt(user.channelID); p.AddInt(user.id); ChatServerConnectionManager.GetInstance().SendPacket(p); }
public void OnGameStartPressed(XNAButton source) { MenuManager.GetInstance().ShowMenu(MenuManager.Menu.NoMenu); StateManager.GetInstance().SetRunningGame(StateManager.RunningGame.MiniGameOverview); StateManager.GetInstance().SetState(StateManager.State.Running); Game1.GetInstance().gameStartMoviePlayer = new SimpleMoviePlayer( Game1.GetInstance().Content.Load<Video>("Media/Video/gamestart")); Game1.GetInstance().gameStartMoviePlayer.videoPlayer.fadeOutAfterMS = 29000; Game1.GetInstance().gameStartMoviePlayer.videoPlayer.fadeOutDurationMS = 2000; /* if (Game1.GetInstance().gameStartMoviePanel == null) { Game1.GetInstance().gameStartMoviePanel = new GameStartMoviePanel(); }*/ }
public void StartGameClicked(XNAButton source) { MenuManager.GetInstance().ShowMenu(MenuManager.Menu.SinglePlayerMapSelectionMenu); }
/* public void OnBallonGameBtnPressed(XNAButton source) { MenuManager.GetInstance().ShowMenu(MenuManager.Menu.NoMenu); StateManager.GetInstance().SetRunningGame(StateManager.RunningGame.BalloonPaintBucketGame); StateManager.GetInstance().SetState(StateManager.State.Running); } public void OnBugsGameBtnPressed(XNAButton source) { MenuManager.GetInstance().ShowMenu(MenuManager.Menu.NoMenu); StateManager.GetInstance().SetRunningGame(StateManager.RunningGame.SquatBugsGame); StateManager.GetInstance().SetState(StateManager.State.Running); }*/ public void OnKinectGameBtnPressed(XNAButton source) { MenuManager.GetInstance().ShowMenu(MenuManager.Menu.NoMenu); StateManager.GetInstance().SetRunningGame(StateManager.RunningGame.DigGame); //StateManager.GetInstance().SetRunningGame(StateManager.RunningGame.KinectGame); StateManager.GetInstance().SetState(StateManager.State.Running); }
public void CreditsClicked(XNAButton source) { MenuManager.GetInstance().ShowMenu(MenuManager.Menu.CreditsMenu); }
/// <summary> /// User accepted disconnect by the server. /// </summary> /// <param name="source"></param> public void ServerDisconnectOKButtonPressed(XNAButton source) { MenuManager.GetInstance().ShowMenu(MenuManager.Menu.MultiplayerLogin); }
public void MultiplayerClicked(XNAButton source) { MenuManager.GetInstance().ShowMenu(MenuManager.Menu.MultiplayerLogin); }
/// <summary> /// When the game should be started. /// </summary> /// <param name="source">Source button</param> public void OnStartGamePressed(XNAButton source) { if (onGameStartListeners != null) onGameStartListeners(this.selectedGame); MiniGameOverviewMainGame.GetInstance().OnHide(); this.Unload(); }
/// <summary> /// Every button calls this, as in .. on click, remove! /// </summary> /// <param name="source">The button that clicked it (irrelevant schmuck)</param> public void Dispose(XNAButton source) { this.Dispose(); }
/// <summary> /// User wants to log in! /// </summary> /// <param name="source"></param> public void LoginClicked(XNAButton source) { if (this.usernameTF.text.Length < 2) { XNAMessageDialog.CreateDialog( "Please enter a nickname of 3 characters or longer.", XNAMessageDialog.DialogType.OK); } else { GameServerConnectionManager.GetInstance().serverLocation = ipTF.text; ChatServerConnectionManager.GetInstance().serverLocation = ipTF.text; ChatServerConnectionManager.GetInstance().user = new User(usernameTF.text); ChatServerConnectionManager.GetInstance().ConnectToServer(); } }