From: brady Date: Wed, 31 Mar 2010 07:02:34 +0000 (+0000) Subject: Chat working, testing X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=5fe6f523ee35dd412ef0dd9102839b666733ed4b;p=chaz%2Fcarfire Chat working, testing git-svn-id: https://bd85.net/svn/cs3505_group@46 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 17275a9..bc73eef 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 @@ -166,7 +166,17 @@ namespace CS_3505_Project_06 private void UpdateChat(GameTime gameTime, NetworkGame networkGame) { - currentChat.Concat(networkGame.ReceiveChats()); + List chts = networkGame.ReceiveChats(); + for (int x = 0; x < chts.Count(); x++) + currentChat.Enqueue(chts[x]); + //if number of chat messages has reached max remove older messages as new ones are added + if (currentChat.Count() > 8) + { + for (int x = 0; x < chts.Count(); x++) + { + currentChat.Dequeue(); + } + } } @@ -260,12 +270,16 @@ namespace CS_3505_Project_06 } } - - Console.WriteLine("Finding"); break; + case lobbyState.Connected: - if (chatActive) + if (chatActive) //If chat is activated by pressing T all inputs go to chat. Enter finishes chat esc returns { + if (currentKeyboardState.IsKeyDown(Keys.Escape) && previousKeyboardState.IsKeyUp(Keys.Escape)) + { + chatActive = false; + break; + } if (currentKeyboardState.IsKeyDown(Keys.Enter) && previousKeyboardState.IsKeyUp(Keys.Enter)) { networkGame.SendChat(chatMessage); @@ -440,12 +454,12 @@ namespace CS_3505_Project_06 for (int y = 0; y < currentChat.Count; y++) { spriteBatch.DrawString(menuFont, currentChat.ElementAt(y).Sender + ": " + currentChat.ElementAt(y).Message - , new Vector2(400, 100 - y*10), Color.Blue, 0f, zero, .6f, SpriteEffects.None, 1f); + , new Vector2(400, 10 + y*15), Color.Blue, 0f, zero, .6f, SpriteEffects.None, 1f); } } if(chatActive) - spriteBatch.DrawString(menuFont, chatMessage, new Vector2(400, 100), Color.Green, 0f, zero, .6f, SpriteEffects.None, 1f); + spriteBatch.DrawString(menuFont, chatMessage, new Vector2(400, 10 + 15*(currentChat.Count + 1)), Color.Green, 0f, zero, .6f, SpriteEffects.None, 1f); } private void DrawPlayerList(SpriteBatch spriteBatch) @@ -459,10 +473,12 @@ namespace CS_3505_Project_06 spriteBatch.DrawString(menuFont, "Command Options: to mark your self as ready", new Vector2(20, 20), Color.Gray, 0f, zero, .6f, SpriteEffects.None, 1f); spriteBatch.DrawString(menuFont, "type players # to toggle chat", new Vector2(175, 40), Color.Gray, 0f, zero, .6f, SpriteEffects.None, 1f); spriteBatch.DrawString(menuFont, "return to main menu", new Vector2(175, 60), Color.Gray, 0f, zero, .6f, SpriteEffects.None, 1f); + spriteBatch.DrawString(menuFont, "enter chat mode", new Vector2(175, 80), Color.Gray, 0f, zero, .6f, SpriteEffects.None, 1f); spriteBatch.DrawString(menuFont, "R", new Vector2(145, 20), Color.DarkGreen, 0f, zero, .6f, SpriteEffects.None, 1f); spriteBatch.DrawString(menuFont, "#", new Vector2(145, 40), Color.DarkGreen, 0f, zero, .6f, SpriteEffects.None, 1f); spriteBatch.DrawString(menuFont, "X", new Vector2(145, 60), Color.DarkGreen, 0f, zero, .6f, SpriteEffects.None, 1f); - + spriteBatch.DrawString(menuFont, "T", new Vector2(145, 80), Color.DarkGreen, 0f, zero, .6f, SpriteEffects.None, 1f); + //Background squares spriteBatch.Draw(menuItem, topOfList, null, Color.White, 0, zero, scale, SpriteEffects.None, 1f); spriteBatch.Draw(menuItem, new Vector2(topOfList.X, topOfList.Y + 65), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);