KeyboardState currentKeyboardState;\r
\r
GamerCollection<LocalNetworkGamer> players;\r
- \r
+ AvailableNetworkSessionCollection availableSessions;\r
+\r
+ int selectedSessionIndex;\r
\r
private enum lobbyState\r
{\r
\r
public lobbyGUI()\r
{\r
- currentState = lobbyState.Welcome; \r
+ currentState = lobbyState.Welcome;\r
+ selectedSessionIndex = 0;\r
+ ready = false;\r
}\r
\r
public void LoadContent(ContentManager contentManager, GraphicsDeviceManager graphics)\r
MinY = 100;\r
\r
scale = MaxX / 1600f;\r
+\r
//playerlist stuff\r
checkedBox = contentManager.Load<Texture2D>("checkedBox");\r
deselectBox = contentManager.Load<Texture2D>("deselectBox");\r
emptySelectBox = contentManager.Load<Texture2D>("emptySelectBox");\r
menuItem = contentManager.Load<Texture2D>("menuItem");\r
\r
- ready = false;\r
+ \r
\r
//menu fonts\r
menuFont = contentManager.Load<SpriteFont>("menuFont");\r
returnToMainPos = new Vector2(MaxX / 2, MaxY - 120);\r
returnToMainText = "press [ X ] to return to main menu";\r
\r
-\r
+ \r
}\r
\r
public void UnloadContent()\r
UpdateSpotLight(gameTime);\r
currentKeyboardState = Keyboard.GetState();\r
\r
+ if (networkGame.sessionExists())\r
+ {\r
+ players = networkGame.LocalGamers;\r
+ }\r
+\r
//check inputs\r
switch (currentState)\r
{\r
selected = createGameText;\r
}\r
break;\r
+\r
case lobbyState.CreateGame:\r
if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))\r
{\r
currentState = lobbyState.Welcome;\r
ready = false;\r
- networkGame.LeaveSession();\r
+ if (networkGame.sessionExists())\r
+ {\r
+ players = null;\r
+ networkGame.LeaveSession();\r
+ }\r
}\r
if (currentKeyboardState.IsKeyDown(Keys.Y) && previousKeyboardState.IsKeyUp(Keys.Y))\r
{\r
players = networkGame.LocalGamers;\r
} \r
break;\r
+\r
case lobbyState.FindGame:\r
if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))\r
{\r
currentState = lobbyState.Welcome;\r
ready = false;\r
}\r
+ availableSessions = networkGame.FindSessions();\r
\r
break;\r
+\r
case lobbyState.Connected:\r
if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))\r
+ {\r
+ ready = false;\r
+ if (networkGame.sessionExists())\r
+ {\r
+ players = null;\r
+ networkGame.LeaveSession();\r
+ }\r
currentState = lobbyState.Welcome;\r
+ }\r
if (currentKeyboardState.IsKeyDown(Keys.R) && previousKeyboardState.IsKeyUp(Keys.R))\r
ready = true;\r
break;\r
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);\r
\r
break;\r
+\r
case lobbyState.FindGame:\r
spriteBatch.Draw(selectGameScreen, backgroundPos, null, Color.White, 0, zero, scale, SpriteEffects.None, 0);\r
- //spriteBatch.DrawString(menuFont, "Select Game", new Vector2(100, 100), Color.Gray, 0, zero, 1f, SpriteEffects.None, 0.5f);\r
+ if(availableSessions == null)\r
+ spriteBatch.DrawString(menuFont, "searching for available games ....", new Vector2(150, 100), Color.Gray, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+ else if (availableSessions.Count == 0)\r
+ spriteBatch.DrawString(menuFont, "no games currently available, searching ....", new Vector2(150, 100), Color.Gray, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+ else\r
+ {\r
+ for (int sessionIndex = 0; sessionIndex < availableSessions.Count; sessionIndex++)\r
+ {\r
+ Color color = Color.Gray;\r
+\r
+ if (sessionIndex == selectedSessionIndex)\r
+ color = Color.Red;\r
\r
- //spriteBatch.DrawString(menuFont, returnToMainText, returnToMainPos, Color.Gray, 0, new Vector2(180 , 0), .6f, SpriteEffects.None, 0.5f);\r
+ spriteBatch.DrawString(menuFont, availableSessions[sessionIndex].HostGamertag, new Vector2(150, 100 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+ spriteBatch.DrawString(menuFont, availableSessions[sessionIndex].CurrentGamerCount + " / " + availableSessions[sessionIndex].OpenPublicGamerSlots, new Vector2(400, 300 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+ spriteBatch.DrawString(menuFont, availableSessions[sessionIndex].QualityOfService + "", new Vector2(350, 100 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+ }\r
+ }\r
break;\r
+\r
case lobbyState.Connected:\r
DrawPlayerList(spriteBatch);\r
+ spriteBatch.DrawString(menuFont, "Waiting for ready players...", new Vector2(MaxX / 2, MaxY / 2), Color.White, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
break;\r
}\r
\r
spriteBatch.DrawString(menuFont, players[g].Gamertag, new Vector2(topOfList.X + 10, topOfList.Y + 10 + 65*g), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f);\r
}\r
}\r
-\r
- //top player\r
}\r
}\r
}\r