internal static Chatline Create(string text_, int timeMilliseconds_) { Chatline c = new Chatline(); c.text = text_; c.timeMilliseconds = timeMilliseconds_; c.clickable = false; return c; }
internal static Chatline Create(string text_, int timeMilliseconds_) { Chatline c = new Chatline(); c.text = text_; c.timeMilliseconds = timeMilliseconds_; c.clickable = false; return(c); }
internal static Chatline CreateClickable(string text_, int timeMilliseconds_, string linkTarget_) { Chatline c = new Chatline(); c.text = text_; c.timeMilliseconds = timeMilliseconds_; c.clickable = true; c.linkTarget = linkTarget_; return c; }
internal static Chatline CreateClickable(string text_, int timeMilliseconds_, string linkTarget_) { Chatline c = new Chatline(); c.text = text_; c.timeMilliseconds = timeMilliseconds_; c.clickable = true; c.linkTarget = linkTarget_; return(c); }
public ModGuiChat() { one = 1; ChatFontSize = 11; ChatScreenExpireTimeSeconds = 20; ChatLinesMaxToDraw = 10; font = new FontCi(); font.family = "Arial"; font.size = ChatFontSize; chatlines2 = new Chatline[1024]; }
public ModGuiChat() { one = 1; ChatFontSize = 11; ChatScreenExpireTimeSeconds = 20; ChatLinesMaxToDraw = 10; font = new FontCi(); font.family = "Arial"; font.size = ChatFontSize; chatlines2 = new Chatline[1024]; color_background = Game.ColorFromArgb(80, 0, 0, 0); }
/// <summary> /// Draws Radar and Chat GUI elements /// </summary> /// <param name="spriteBatch"></param> /// <param name="planetList"></param> /// <param name="shipPos"></param> public virtual void Draw(SpriteBatch spriteBatch, List <Planet> planetList, Vector2 shipPos) { pos_Console.Y = spriteBatch.GraphicsDevice.Viewport.Height - tex_Console.Height; spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); spriteBatch.Draw(tex_Console, pos_Console, null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 1f); for (int i = 0; i < chatList.Count(); i++) { Chatline c = chatList[i]; spriteBatch.DrawString(textFont, c.text, new Vector2(pos_Console.X + 10, pos_Console.Y + (textFont.LineSpacing * c.row)), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, .9f); chatList[i] = c; } spriteBatch.DrawString(textFont, currentString, new Vector2(pos_Console.X + 10, pos_Console.Y + tex_Console.Height - textFont.LineSpacing - 5), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, .9f); DebugTextManager.DrawTextToScreenLeft(spriteBatch, 12, "" + KeyboardManager.IsTyping); spriteBatch.End(); }
/// <summary> /// Runs any admin commands specified /// </summary> /// <param name="c">Chatline read</param> /// <returns>Chatline returned, set to not display</returns> public Chatline CheckAdminCommands(Chatline c) { c.text = c.text.Remove(0, 1);//Remove slash if (c.text.Length <= 0) { return(c); } string[] parsed = c.text.Split(' '); switch (parsed[0].ToLower()) { case "system": //case "systemstats": // _messageManager.sendAdminTextInput("", _clientManager.Client, (byte) AdminCommands.systemStatistics); break; //case "setship": // _messageManager.sendAdminTextInput(parsed[1], _clientManager.Client, (byte)AdminCommands.setShip); // break; case "who": case "whoplayer": break; case "killplayer": case "kill": break; //case "ally": // _messageManager.sendAdminTextInput(_clientShipManager.PlayerShip.Teams.ElementAt(0).ToString(), _clientManager.Client, (byte)AdminCommands.allyNPCs); //break; //case "makenpc": // _messageManager.sendAdminTextInput(parsed[1], _clientManager.Client, (byte)AdminCommands.makeNPCs); // break; //case "stop": //_clientShipManager.PlayerShip._body.LinearVelocity = Vector2.Zero; //break; } c.chatType = ChatTypes.nodisplay; return(c); }
public void DrawChatLines(bool all) { chatlines2Count = 0; int timeNow = game.platform.TimeMillisecondsFromStart(); int scroll; if (!all) { scroll = 0; } else { scroll = ChatPageScroll; } int first = game.ChatLinesCount - ChatLinesMaxToDraw * (scroll + 1); if (first < 0) { first = 0; } int count = game.ChatLinesCount; if (count > ChatLinesMaxToDraw) { count = ChatLinesMaxToDraw; } for (int i = first; i < first + count; i++) { Chatline c = game.ChatLines[i]; if (all || ((one * (timeNow - c.timeMilliseconds) / 1000) < ChatScreenExpireTimeSeconds)) { chatlines2[chatlines2Count++] = c; } } font.size = ChatFontSize * game.Scale(); float posX = 20; float posY = 90; float lineSpacing = font.size * 1.75f; if (chatlines2Count > 0) { // draw chatbox background game.Draw2dTexture(game.WhiteTexture(), (posX - chatboxMargin) * game.Scale(), (posY - chatboxMargin) * game.Scale(), (750 + 2 * chatboxMargin) * game.Scale(), (chatlines2Count * lineSpacing + chatboxMargin) * game.Scale(), null, 0, color_background, false); } for (int i = 0; i < chatlines2Count; i++) { if (chatlines2[i].clickable) { //Different display of links in chat //2 = italic //3 = bold italic font.style = 3; } else { //0 = normal //1 = bold font.style = 1; } game.Draw2dText(chatlines2[i].text, font, posX * game.Scale(), (posY + i * lineSpacing) * game.Scale(), null, false); } if (ChatPageScroll != 0) { game.Draw2dText(game.platform.StringFormat("&7Page: {0}", game.platform.IntToString(ChatPageScroll)), font, posX * game.Scale(), (posY + (-1) * lineSpacing) * game.Scale(), null, false); } }
public virtual void Update(GameTime gameTime) { if (KeyboardManager.IsTyping) { if (KeyboardManager.currentState.IsKeyDown(Keys.LeftShift) || (KeyboardManager.currentState.IsKeyDown(Keys.RightShift))) { #region Capitals if (KeyboardManager.currentState.IsKeyDown(Keys.A) && KeyboardManager.oldState.IsKeyUp(Keys.A)) { currentString += "A"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.B) && KeyboardManager.oldState.IsKeyUp(Keys.B)) { currentString += "B"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.C) && KeyboardManager.oldState.IsKeyUp(Keys.C)) { currentString += "C"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.D) && KeyboardManager.oldState.IsKeyUp(Keys.D)) { currentString += "D"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.E) && KeyboardManager.oldState.IsKeyUp(Keys.E)) { currentString += "E"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.F) && KeyboardManager.oldState.IsKeyUp(Keys.F)) { currentString += "F"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.G) && KeyboardManager.oldState.IsKeyUp(Keys.G)) { currentString += "G"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.H) && KeyboardManager.oldState.IsKeyUp(Keys.H)) { currentString += "H"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.I) && KeyboardManager.oldState.IsKeyUp(Keys.I)) { currentString += "I"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.J) && KeyboardManager.oldState.IsKeyUp(Keys.J)) { currentString += "J"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.K) && KeyboardManager.oldState.IsKeyUp(Keys.K)) { currentString += "K"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.L) && KeyboardManager.oldState.IsKeyUp(Keys.L)) { currentString += "L"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.M) && KeyboardManager.oldState.IsKeyUp(Keys.M)) { currentString += "M"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.N) && KeyboardManager.oldState.IsKeyUp(Keys.N)) { currentString += "N"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.O) && KeyboardManager.oldState.IsKeyUp(Keys.O)) { currentString += "O"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.P) && KeyboardManager.oldState.IsKeyUp(Keys.P)) { currentString += "P"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.Q) && KeyboardManager.oldState.IsKeyUp(Keys.Q)) { currentString += "Q"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.R) && KeyboardManager.oldState.IsKeyUp(Keys.R)) { currentString += "R"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.S) && KeyboardManager.oldState.IsKeyUp(Keys.S)) { currentString += "S"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.T) && KeyboardManager.oldState.IsKeyUp(Keys.T)) { currentString += "T"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.U) && KeyboardManager.oldState.IsKeyUp(Keys.U)) { currentString += "U"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.V) && KeyboardManager.oldState.IsKeyUp(Keys.V)) { currentString += "V"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.W) && KeyboardManager.oldState.IsKeyUp(Keys.W)) { currentString += "W"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.X) && KeyboardManager.oldState.IsKeyUp(Keys.X)) { currentString += "X"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.Y) && KeyboardManager.oldState.IsKeyUp(Keys.Y)) { currentString += "Y"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.Z) && KeyboardManager.oldState.IsKeyUp(Keys.Z)) { currentString += "Z"; hasText = true; } #endregion } else { #region Lower Case if (KeyboardManager.currentState.IsKeyDown(Keys.A) && KeyboardManager.oldState.IsKeyUp(Keys.A)) { currentString += "a"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.B) && KeyboardManager.oldState.IsKeyUp(Keys.B)) { currentString += "b"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.C) && KeyboardManager.oldState.IsKeyUp(Keys.C)) { currentString += "c"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.D) && KeyboardManager.oldState.IsKeyUp(Keys.D)) { currentString += "d"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.E) && KeyboardManager.oldState.IsKeyUp(Keys.E)) { currentString += "e"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.F) && KeyboardManager.oldState.IsKeyUp(Keys.F)) { currentString += "f"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.G) && KeyboardManager.oldState.IsKeyUp(Keys.G)) { currentString += "g"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.H) && KeyboardManager.oldState.IsKeyUp(Keys.H)) { currentString += "h"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.I) && KeyboardManager.oldState.IsKeyUp(Keys.I)) { currentString += "i"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.J) && KeyboardManager.oldState.IsKeyUp(Keys.J)) { currentString += "j"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.K) && KeyboardManager.oldState.IsKeyUp(Keys.K)) { currentString += "k"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.L) && KeyboardManager.oldState.IsKeyUp(Keys.L)) { currentString += "l"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.M) && KeyboardManager.oldState.IsKeyUp(Keys.M)) { currentString += "m"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.N) && KeyboardManager.oldState.IsKeyUp(Keys.N)) { currentString += "n"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.O) && KeyboardManager.oldState.IsKeyUp(Keys.O)) { currentString += "o"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.P) && KeyboardManager.oldState.IsKeyUp(Keys.P)) { currentString += "p"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.Q) && KeyboardManager.oldState.IsKeyUp(Keys.Q)) { currentString += "q"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.R) && KeyboardManager.oldState.IsKeyUp(Keys.R)) { currentString += "r"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.S) && KeyboardManager.oldState.IsKeyUp(Keys.S)) { currentString += "s"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.T) && KeyboardManager.oldState.IsKeyUp(Keys.T)) { currentString += "t"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.U) && KeyboardManager.oldState.IsKeyUp(Keys.U)) { currentString += "u"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.V) && KeyboardManager.oldState.IsKeyUp(Keys.V)) { currentString += "v"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.W) && KeyboardManager.oldState.IsKeyUp(Keys.W)) { currentString += "w"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.X) && KeyboardManager.oldState.IsKeyUp(Keys.X)) { currentString += "x"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.Y) && KeyboardManager.oldState.IsKeyUp(Keys.Y)) { currentString += "y"; hasText = true; } if (KeyboardManager.currentState.IsKeyDown(Keys.Z) && KeyboardManager.oldState.IsKeyUp(Keys.Z)) { currentString += "z"; hasText = true; } #endregion } #region Other if (KeyboardManager.currentState.IsKeyDown(Keys.Space) && KeyboardManager.oldState.IsKeyUp(Keys.Space)) { currentString += " "; } if (KeyboardManager.currentState.IsKeyDown(Keys.OemPeriod) && KeyboardManager.oldState.IsKeyUp(Keys.OemPeriod)) { currentString += "."; hasText = true; } #endregion } if (KeyboardManager.currentState.IsKeyDown(Keys.Enter) && KeyboardManager.oldState.IsKeyUp(Keys.Enter) && !KeyboardManager.IsTyping) { KeyboardManager.IsTyping = true; } else if (KeyboardManager.currentState.IsKeyUp(Keys.Enter) && KeyboardManager.oldState.IsKeyDown(Keys.Enter) && KeyboardManager.IsTyping) { KeyboardManager.IsTyping = false; } else if (KeyboardManager.currentState.IsKeyDown(Keys.Enter) && KeyboardManager.IsTyping) { if (currentString != null) { oldString = currentString; currentString = ""; if (hasText) { Chatline c = new Chatline(); c.row = increment; oldString = WrapText(textFont, oldString, (tex_Console.Width - 40)); c.text = oldString; chatList.Add(c); increment++; hasText = false; } } KeyboardManager.IsTyping = false; } //Console.WriteLine(chatList.Count()); }
/// <summary> /// Commands in the console are parsed here. /// </summary> /// <param name="c">Chatline to read.</param> /// <returns>Returns parsed line, this is set to chat or sent to server after.</returns> public Chatline CheckCommands(Chatline c) { if (!c.text.StartsWith(@"/")) // Return if we're just radio-ing #if ADMIN { if (!c.text.StartsWith(@".")) // Check for an admin command or not { return(c); } else { c = CheckAdminCommands(c); return(c); } } #else { return(c); } #endif c.text = c.text.Remove(0, 1); // Removes '/' if (c.text.Length == 0) { return(c); } if (c.text.Length <= 2)//Prevents client crashes from trying to remove from "/s " { c.chatType = ChatTypes.Error; c.text = "Invalid command or not enough arguments passed"; c.prefix = "Error: "; return(c); } string[] parsed = c.text.Split(' '); // Grab before the space switch (parsed[0].ToLower()) // Non-case sensitive commands { case "hug": if (c.text.StartsWith("hug ")) { c.text = c.text.Remove(0, 4); } else { c.text = c.text.Remove(0, 2); } c.chatType = ChatTypes.hug; c.prefix = ""; break; case "online": c.chatType = ChatTypes.whosonline; c.prefix = ""; // Ask for players online break; case "bloom": c.chatType = ChatTypes.nodisplay; var b = new Chatline(); b.prefixColor = Color.DarkCyan; b.text = " "; c.text = null; if (SettingsManager.isBloom) { SettingsManager.isBloom = false; b.prefix = "Bloom disabled."; } else { SettingsManager.isBloom = true; b.prefix = "Bloom enabled."; } // DisplayToChatbox(b); break; default: c.chatType = ChatTypes.Error; c.text = "Invalid command."; c.prefix = "Error: "; break; } return(c); }
public void DrawChatLines(bool all) { chatlines2Count = 0; int timeNow = game.platform.TimeMillisecondsFromStart(); int scroll; if (!all) { scroll = 0; } else { scroll = ChatPageScroll; } int first = game.ChatLinesCount - ChatLinesMaxToDraw * (scroll + 1); if (first < 0) { first = 0; } int count = game.ChatLinesCount; if (count > ChatLinesMaxToDraw) { count = ChatLinesMaxToDraw; } for (int i = first; i < first + count; i++) { Chatline c = game.ChatLines[i]; if (all || ((one * (timeNow - c.timeMilliseconds) / 1000) < ChatScreenExpireTimeSeconds)) { chatlines2[chatlines2Count++] = c; } } font.size = ChatFontSize * game.Scale(); float dx = 20; //if (!game.platform.IsMousePointerLocked()) //{ // dx += 100; //} for (int i = 0; i < chatlines2Count; i++) { if (chatlines2[i].clickable) { //Different display of links in chat //2 = italic //3 = bold italic font.style = 3; } else { //0 = normal //1 = bold font.style = 1; } game.Draw2dText(chatlines2[i].text, font, dx * game.Scale(), (90 + i * 25) * game.Scale(), null, false); } if (ChatPageScroll != 0) { game.Draw2dText(game.platform.StringFormat("&7Page: {0}", game.platform.IntToString(ChatPageScroll)), font, dx * game.Scale(), (90 + (-1) * 25) * game.Scale(), null, false); } }
void ChatLinesAdd(Chatline chatline) { if (ChatLinesCount >= ChatLinesMax) { Chatline[] lines2 = new Chatline[ChatLinesMax * 2]; for (int i = 0; i < ChatLinesMax; i++) { lines2[i] = ChatLines[i]; } ChatLines = lines2; ChatLinesMax *= 2; } ChatLines[ChatLinesCount++] = chatline; }