From: brady Date: Sat, 20 Mar 2010 09:06:06 +0000 (+0000) Subject: updated search for games screen, loading on second comp to test search X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=7050e6960cdccc7560ea5a7efb8b04e02629f28a;p=chaz%2Fcarfire updated search for games screen, loading on second comp to test search git-svn-id: https://bd85.net/svn/cs3505_group@16 92bb83a3-7c8f-8a45-bc97-515c4e399668 --- diff --git a/Project06/CS 3505 Project 06/CS 3505 Project 06/LobbyGUI.cs b/Project06/CS 3505 Project 06/CS 3505 Project 06/LobbyGUI.cs index 0fe4ad1..516a85a 100644 --- a/Project06/CS 3505 Project 06/CS 3505 Project 06/LobbyGUI.cs +++ b/Project06/CS 3505 Project 06/CS 3505 Project 06/LobbyGUI.cs @@ -55,7 +55,9 @@ namespace CS_3505_Project_06 KeyboardState currentKeyboardState; GamerCollection players; - + AvailableNetworkSessionCollection availableSessions; + + int selectedSessionIndex; private enum lobbyState { @@ -69,7 +71,9 @@ namespace CS_3505_Project_06 public lobbyGUI() { - currentState = lobbyState.Welcome; + currentState = lobbyState.Welcome; + selectedSessionIndex = 0; + ready = false; } public void LoadContent(ContentManager contentManager, GraphicsDeviceManager graphics) @@ -92,13 +96,14 @@ namespace CS_3505_Project_06 MinY = 100; scale = MaxX / 1600f; + //playerlist stuff checkedBox = contentManager.Load("checkedBox"); deselectBox = contentManager.Load("deselectBox"); emptySelectBox = contentManager.Load("emptySelectBox"); menuItem = contentManager.Load("menuItem"); - ready = false; + //menu fonts menuFont = contentManager.Load("menuFont"); @@ -112,7 +117,7 @@ namespace CS_3505_Project_06 returnToMainPos = new Vector2(MaxX / 2, MaxY - 120); returnToMainText = "press [ X ] to return to main menu"; - + } public void UnloadContent() @@ -126,6 +131,11 @@ namespace CS_3505_Project_06 UpdateSpotLight(gameTime); currentKeyboardState = Keyboard.GetState(); + if (networkGame.sessionExists()) + { + players = networkGame.LocalGamers; + } + //check inputs switch (currentState) { @@ -145,12 +155,17 @@ namespace CS_3505_Project_06 selected = createGameText; } break; + case lobbyState.CreateGame: if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X)) { currentState = lobbyState.Welcome; ready = false; - networkGame.LeaveSession(); + if (networkGame.sessionExists()) + { + players = null; + networkGame.LeaveSession(); + } } if (currentKeyboardState.IsKeyDown(Keys.Y) && previousKeyboardState.IsKeyUp(Keys.Y)) { @@ -159,17 +174,28 @@ namespace CS_3505_Project_06 players = networkGame.LocalGamers; } break; + case lobbyState.FindGame: if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X)) { currentState = lobbyState.Welcome; ready = false; } + availableSessions = networkGame.FindSessions(); break; + case lobbyState.Connected: if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X)) + { + ready = false; + if (networkGame.sessionExists()) + { + players = null; + networkGame.LeaveSession(); + } currentState = lobbyState.Welcome; + } if (currentKeyboardState.IsKeyDown(Keys.R) && previousKeyboardState.IsKeyUp(Keys.R)) ready = true; break; @@ -210,14 +236,32 @@ namespace CS_3505_Project_06 spriteBatch.DrawString(menuFont, "X to return to main menu", new Vector2(MaxX /2 + 40, (MaxY / 3) + 2 * menuFont.LineSpacing), Color.White, 0f, zero, .6f, SpriteEffects.None, 0.5f); break; + case lobbyState.FindGame: spriteBatch.Draw(selectGameScreen, backgroundPos, null, Color.White, 0, zero, scale, SpriteEffects.None, 0); - //spriteBatch.DrawString(menuFont, "Select Game", new Vector2(100, 100), Color.Gray, 0, zero, 1f, SpriteEffects.None, 0.5f); + if(availableSessions == null) + spriteBatch.DrawString(menuFont, "searching for available games ....", new Vector2(150, 100), Color.Gray, 0f, zero, .7f, SpriteEffects.None, 0.5f); + else if (availableSessions.Count == 0) + spriteBatch.DrawString(menuFont, "no games currently available, searching ....", new Vector2(150, 100), Color.Gray, 0f, zero, .7f, SpriteEffects.None, 0.5f); + else + { + for (int sessionIndex = 0; sessionIndex < availableSessions.Count; sessionIndex++) + { + Color color = Color.Gray; + + if (sessionIndex == selectedSessionIndex) + color = Color.Red; - //spriteBatch.DrawString(menuFont, returnToMainText, returnToMainPos, Color.Gray, 0, new Vector2(180 , 0), .6f, SpriteEffects.None, 0.5f); + spriteBatch.DrawString(menuFont, availableSessions[sessionIndex].HostGamertag, new Vector2(150, 100 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f); + spriteBatch.DrawString(menuFont, availableSessions[sessionIndex].CurrentGamerCount + " / " + availableSessions[sessionIndex].OpenPublicGamerSlots, new Vector2(400, 300 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f); + spriteBatch.DrawString(menuFont, availableSessions[sessionIndex].QualityOfService + "", new Vector2(350, 100 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f); + } + } break; + case lobbyState.Connected: DrawPlayerList(spriteBatch); + spriteBatch.DrawString(menuFont, "Waiting for ready players...", new Vector2(MaxX / 2, MaxY / 2), Color.White, 0f, zero, .7f, SpriteEffects.None, 0.5f); break; } @@ -325,8 +369,6 @@ namespace CS_3505_Project_06 spriteBatch.DrawString(menuFont, players[g].Gamertag, new Vector2(topOfList.X + 10, topOfList.Y + 10 + 65*g), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f); } } - - //top player } } } diff --git a/Project06/CS 3505 Project 06/CS 3505 Project 06/NetworkGame.cs b/Project06/CS 3505 Project 06/CS 3505 Project 06/NetworkGame.cs index c8cc60c..b273932 100644 --- a/Project06/CS 3505 Project 06/CS 3505 Project 06/NetworkGame.cs +++ b/Project06/CS 3505 Project 06/CS 3505 Project 06/NetworkGame.cs @@ -98,7 +98,7 @@ namespace CS_3505_Project_06 // -Brady public bool sessionExists() { - return mNetworkSession == null; + return mNetworkSession != null; } public AvailableNetworkSessionCollection FindSessions()