Exemplo n.º 1
0
        public static void SendToAll(string message, ChatColor color = ChatColor.white,
                                     ChatStyle style = ChatStyle.normal, ChatSenderType sender = ChatSenderType.Server)
        {
            var messageBuilt = BuildMessage(message, color, style);

            Chat.SendToAll(messageBuilt, sender);
        }
Exemplo n.º 2
0
        public static string BuildMessageNoLocal(string message,
                                                 ChatColor color = ChatColor.white,
                                                 ChatStyle style = ChatStyle.normal)
        {
            var    colorPrefix = "<color=" + color + ">";
            var    colorSuffix = "</color>";
            string stylePrefix, styleSuffix;

            switch (style)
            {
            case ChatStyle.bold:
                stylePrefix = "<b>";
                styleSuffix = "</b>";
                break;

            case ChatStyle.bolditalic:
                stylePrefix = "<b><i>";
                styleSuffix = "</i></b>";
                break;

            case ChatStyle.italic:
                stylePrefix = "<i>";
                styleSuffix = "</i>";
                break;

            default:
                stylePrefix = "";
                styleSuffix = "";
                break;
            }

            return(stylePrefix + colorPrefix + message + colorSuffix + styleSuffix);
        }
Exemplo n.º 3
0
        public static string BuildMessage(string message,
                                          Players.Player p,
                                          localization.LocalizationHelper localization,
                                          ChatColor color = ChatColor.white,
                                          ChatStyle style = ChatStyle.normal)
        {
            var    colorPrefix = "<color=" + color + ">";
            var    colorSuffix = "</color>";
            string stylePrefix, styleSuffix;

            switch (style)
            {
            case ChatStyle.bold:
                stylePrefix = "<b>";
                styleSuffix = "</b>";
                break;

            case ChatStyle.bolditalic:
                stylePrefix = "<b><i>";
                styleSuffix = "</i></b>";
                break;

            case ChatStyle.italic:
                stylePrefix = "<i>";
                styleSuffix = "</i>";
                break;

            default:
                stylePrefix = "";
                styleSuffix = "";
                break;
            }

            return(stylePrefix + colorPrefix + localization.LocalizeOrDefault(message, p) + colorSuffix + styleSuffix);
        }
Exemplo n.º 4
0
    public static bool TryParse(char code, out ChatColor color)
    {
        color = code switch
        {
            '0' => Black,
            '1' => DarkBlue,
            '2' => DarkGreen,
            '3' => DarkCyan,
            '4' => DarkRed,
            '5' => Purple,
            '6' => Gold,
            '7' => Gray,
            '8' => DarkGray,
            '9' => Blue,
            'a' => BrightGreen,
            'b' => Cyan,
            'c' => Red,
            'd' => Pink,
            'e' => Yellow,
            'f' => White,
            'k' => Obfuscated,
            'l' => Bold,
            'm' => Strikethrough,
            'n' => Underline,
            'o' => Italic,
            'r' => Reset,
            _ => default
        };

        return(color.Code != default);
    }
Exemplo n.º 5
0
        public static void Send(Players.Player ply, string message, ChatColor color = ChatColor.white,
                                params string[] args)
        {
            var messageBuilt = BuildMessage(string.Format(message, args), color);

            Chat.Send(ply, messageBuilt);
        }
Exemplo n.º 6
0
        public JsonObject Serialize()
        {
            JsonObject obj = new JsonObject {
                { NameTag, Name }, { IDTag, ID }
            };

            string colorName = ChatColor.GetName(Color);

            if (colorName != null)
            {
                obj.Add(ColorTag, colorName);
            }

            if (Prefix.Length > 0)
            {
                obj.Add(PrefixTag, Prefix);
            }
            obj.Add(AgBlocksTag, AntiGriefBlocks);
            obj.Add(AgSecondsTag, AntiGriefSeconds);

            if (DrawLimit > 0)
            {
                obj.Add(DrawLimitTag, DrawLimit);
            }
            if (IdleKickTimer > 0)
            {
                obj.Add(IdleKickTag, IdleKickTimer);
            }
            if (ReservedSlot)
            {
                obj.Add(ReserveTag, ReservedSlot);
            }
            if (AllowSecurityCircumvention)
            {
                obj.Add(SecurityCircTag, AllowSecurityCircumvention);
            }

            obj.Add(CopyTag, CopySlots);
            obj.Add(FillTag, FillLimit);
            List <PermissionJsonObject> perms = new List <PermissionJsonObject>();

            for (int i = 0; i < Enum.GetValues(typeof(Permission)).Length; i++)
            {
                PermissionJsonObject pt = new PermissionJsonObject();
                if (Permissions[i])
                {
                    pt.PermissionValue = i;

                    if (PermissionLimits[i] != null)
                    {
                        pt.PerissionLimitString = "max: " + GetLimit((Permission)i).FullName;
                    }
                }

                perms.Add(pt);
            }

            return(obj);
        }
Exemplo n.º 7
0
        protected PluginNameConversationPrefix(IPlugin plugin, string separator, ChatColor prefixColor)
        {
            this.separator   = separator;
            this.prefixColor = prefixColor;
            this.plugin      = plugin;

            cachedPrefix = prefixColor + plugin.GetPluginInfo().Name + separator + ChatColor.White;
        }
Exemplo n.º 8
0
 /// <summary>
 ///     Broadcasts the specified message to online members.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="ignoreIndexes">
 ///     A collection of player indices that specifies which players should not receive the message.
 /// </param>
 public void SendMessage(string message, params int[] ignoreIndexes)
 {
     foreach (var player in TShock.Players.Where(p =>
                                                 Members.Any(m => m.Equals(p?.User?.Name)) && !ignoreIndexes.Contains(p.Index)))
     {
         player.SendMessage(message, ChatColor.GetColor());
     }
 }
Exemplo n.º 9
0
 private void SetConnectionResultMessage(ChatColor color, string format, params object[] args)
 {
     ExecuteOnUIThread.Invoke(() =>
     {
         ConnectionResult      = String.Format(format, args);
         ConnectionResultColor = color;
     });
 }
Exemplo n.º 10
0
 protected void AddServerMessage(ChatColor color, string format, params object[] args)
 {
     AddEntry(new ServerMessageEntry
     {
         Message = String.Format(format, args),
         Color   = color,
     });
 }
Exemplo n.º 11
0
 public ChatStyle(int StartIndex, int Length, bool IsBold, bool IsCursive, bool IsUnderline, ChatColor Color)
 {
     this.StartIndex = StartIndex;
     this.Length = Length;
     this.IsBold = IsBold;
     this.IsCursive = IsCursive;
     this.IsUnderline = IsUnderline;
     this.Color = Color;
 }
Exemplo n.º 12
0
 public static void SendThrottle(Players.Player ply, string message, ChatColor color = ChatColor.white, ChatStyle style = ChatStyle.normal, Pipliz.Chatting.ChatSenderType sender = Pipliz.Chatting.ChatSenderType.Server)
 {
     if (CanSendMesssage(ply))
     {
         string messageBuilt = BuildMessage(message, color, style);
         Pipliz.Chatting.Chat.Send(ply, messageBuilt, sender);
         _nextSendTime[ply] = Time.SecondsSinceStartDouble + 10;
     }
 }
Exemplo n.º 13
0
 public ChatStyle()
 {
     StartIndex = 0;
     Length = 0;
     IsBold = false;
     IsCursive = false;
     IsUnderline = false;
     Color = ChatColor.Black;
 }
Exemplo n.º 14
0
 public static void SendThrottle(Players.Player ply, string message, ChatColor color = ChatColor.white, params string[] args)
 {
     if (CanSendMesssage(ply))
     {
         string messageBuilt = BuildMessage(string.Format(message, args), color);
         Pipliz.Chatting.Chat.Send(ply, messageBuilt);
         _nextSendTime[ply] = Time.SecondsSinceStartDouble + 10;
     }
 }
Exemplo n.º 15
0
 public ChatStyle()
 {
     StartIndex  = 0;
     Length      = 0;
     IsBold      = false;
     IsCursive   = false;
     IsUnderline = false;
     Color       = ChatColor.Black;
 }
Exemplo n.º 16
0
 public ChatStyle(int StartIndex, int Length, bool IsBold, bool IsCursive, bool IsUnderline, ChatColor Color)
 {
     this.StartIndex  = StartIndex;
     this.Length      = Length;
     this.IsBold      = IsBold;
     this.IsCursive   = IsCursive;
     this.IsUnderline = IsUnderline;
     this.Color       = Color;
 }
Exemplo n.º 17
0
        private static string getColorName(ChatColor Color)
        {
            switch (Color)
            {
            case ChatColor.Black:
                return("black");

            case ChatColor.DarkBlue:
                return("dark_blue");

            case ChatColor.DarkGreen:
                return("dark_green");

            case ChatColor.Aqua:
                return("dark_aqua");

            case ChatColor.DarkRed:
                return("dark_red");

            case ChatColor.Purple:
                return("dark_purple");

            case ChatColor.Gold:
                return("gold");

            case ChatColor.Gray:
                return("gray");

            case ChatColor.DarkGray:
                return("dark_gray");

            case ChatColor.Blue:
                return("blue");

            case ChatColor.Green:
                return("green");

            case ChatColor.Cyan:
                return("aqua");

            case ChatColor.Red:
                return("red");

            case ChatColor.Pink:
                return("light_purple");

            case ChatColor.Yellow:
                return("yellow");

            case ChatColor.White:
                return("white");
            }
            return("reset");
        }
Exemplo n.º 18
0
 public void Log(ChatColor color, string message, params object[] args)
 {
     if (args != null && args.Length != 0)
     {
         ServerLog.LogAsyncMessage(new LogMessage(PandaChat.BuildMessageNoLocal(GetFormattedMessage(string.Format(message, args)), color), LogType.Log));
     }
     else
     {
         ServerLog.LogAsyncMessage(new LogMessage(PandaChat.BuildMessageNoLocal(GetFormattedMessage(message), color), LogType.Log));
     }
 }
Exemplo n.º 19
0
 public void WriteLine(string text, ChatColor color = ChatColor.Gold)
 {
     if (_pointer != IntPtr.Zero)
     {
         ChatWindowNode_t.AppendText(_pointer, StdString.Create(text).Pointer, color);
     }
     else
     {
         Chat.WriteLine(text, color);
     }
 }
Exemplo n.º 20
0
 public static void Send(Players.Player player, localization.LocalizationHelper localizationHelper,
                         string message,
                         ChatColor color         = ChatColor.white,
                         ChatStyle style         = ChatStyle.normal,
                         EChatSendOptions sender = EChatSendOptions.Default)
 {
     if (player.IsConnected())
     {
         var messageBuilt = BuildMessage(message, player, localizationHelper, color, style);
         Chat.Send(player, messageBuilt, sender);
     }
 }
Exemplo n.º 21
0
 public ChatIndex(int index = 0, ChatType type = ChatType.None, string who = "", ChatColor color = ChatColor.Default)
 {
     _index = index;
     Type   = type;
     if (who != null && who.Length >= 1)
     {
         //first character of the who string is capitalized: always!
         who = who.Substring(0, 1).ToUpper() + who.Substring(1).ToLower();
     }
     Who = who;
     col = color;
 }
Exemplo n.º 22
0
        public async Task PluginsAsync(CommandContext Context)
        {
            var srv         = (Server)Context.Server;
            var sender      = Context.Sender;
            var pluginCount = srv.PluginManager.Plugins.Count;
            var message     = new ChatMessage
            {
                Text = $"{ChatColor.Reset}List of plugins ({ChatColor.Gold}{pluginCount}{ChatColor.Reset}): ",
            };

            var messages = new List <ChatMessage>();

            for (int i = 0; i < pluginCount; i++)
            {
                var pluginContainer = srv.PluginManager.Plugins[i];
                var info            = pluginContainer.Info;

                var plugin       = new ChatMessage();
                var colorByState = pluginContainer.Loaded || pluginContainer.IsReady ? HexColor.Green : HexColor.Red;

                plugin.Text  = pluginContainer.Info.Name;
                plugin.Color = colorByState;

                plugin.HoverEvent = new HoverComponent {
                    Action = EHoverAction.ShowText, Contents = $"{colorByState}{info.Name}{ChatColor.Reset}\nVersion: {colorByState}{info.Version}{ChatColor.Reset}\nAuthor(s): {colorByState}{info.Authors}{ChatColor.Reset}"
                };
                if (pluginContainer.Info.ProjectUrl != null)
                {
                    plugin.ClickEvent = new ClickComponent {
                        Action = EClickAction.OpenUrl, Value = pluginContainer.Info.ProjectUrl.AbsoluteUri
                    }
                }
                ;

                messages.Add(plugin);

                messages.Add(new ChatMessage
                {
                    Text = $"{ChatColor.Reset}{(i + 1 < srv.PluginManager.Plugins.Count ? ", " : "")}"
                });
            }
            if (messages.Count > 0)
            {
                message.AddExtra(messages);
            }
            else
            {
                message.Text = $"{ChatColor.Gold}There is no plugins installed{ChatColor.Reset}";
            }

            await sender.SendMessageAsync(message);
        }
Exemplo n.º 23
0
 public static void Send(ColonyState colony,
                         localization.LocalizationHelper localizationHelper,
                         string message,
                         ChatColor color = ChatColor.white,
                         ChatStyle style = ChatStyle.normal, EChatSendOptions sender = EChatSendOptions.Default)
 {
     colony.ColonyRef.ForEachOwner(p => {
         if (p.IsConnected())
         {
             var messageBuilt = BuildMessage(colony.ColonyRef.Name + ": " + localizationHelper.LocalizeOrDefault(message, p), p, localizationHelper, color, style);
             Chat.Send(p, messageBuilt, sender);
         }
     });
 }
Exemplo n.º 24
0
        public static void PossibleCommands(Players.Player player, ChatColor color)
        {
            PandaChat.Send(player, "Current Difficulty: " + PlayerState.GetPlayerState(player).Difficulty.Name, color);
            PandaChat.Send(player, "Possible commands:", color);

            var diffs = string.Empty;

            foreach (var diff in GameDifficulty.GameDifficulties)
            {
                diffs += diff.Key + " | ";
            }

            PandaChat.Send(player, "/difficulty " + diffs.Substring(0, diffs.Length - 2), color);
        }
Exemplo n.º 25
0
 public static void Send(Colony colony,
                         localization.LocalizationHelper localizationHelper,
                         string message, ChatColor color = ChatColor.white,
                         params string[] args)
 {
     colony.ForEachOwner(o =>
     {
         if (o.IsConnected())
         {
             var messageBuilt = BuildMessage(colony.Name + ": " + string.Format(localizationHelper.LocalizeOrDefault(message, o), LocalizeArgs(o, localizationHelper, args)), o, localizationHelper, color);
             Chat.Send(o, messageBuilt);
         }
     });
 }
Exemplo n.º 26
0
        public static void RenderColoredConsoleMessage(this string message)
        {
            var output = Console.Out;
            int start  = 0;
            int end    = message.Length - 1;

            for (int i = 0; i < end; i++)
            {
                if (message[i] != '&' && message[i] != '§')
                {
                    continue;
                }

                // Validate color code
                char colorCode = message[i + 1];
                if (!ChatColor.TryParse(colorCode, out var color))
                {
                    continue;
                }

                // Print text with previous color
                if (start != i)
                {
                    output.Write(message.AsSpan(start, i - start));
                }

                // Change color
                if (colorCode == 'r')
                {
                    Console.ResetColor();
                }
                else
                {
                    Console.ForegroundColor = color.ConsoleColor.Value;
                }

                // Skip color code
                i++;
                start = i + 1;
            }

            // Print remaining text if any
            if (start != message.Length)
            {
                output.Write(message.AsSpan(start));
            }

            Console.ResetColor();
        }
Exemplo n.º 27
0
 public static void SendToAll(string message,
                              localization.LocalizationHelper localizationHelper,
                              ChatColor color         = ChatColor.white,
                              ChatStyle style         = ChatStyle.normal,
                              EChatSendOptions sender = EChatSendOptions.Default)
 {
     foreach (var p in Players.PlayerDatabase.Values)
     {
         if (p.IsConnected())
         {
             var messageBuilt = BuildMessage(message, p, localizationHelper, color, style);
             Chat.Send(p, messageBuilt, sender);
         }
     }
 }
Exemplo n.º 28
0
        public static void PossibleCommands(Players.Player player, ChatColor color)
        {
            if (player.ActiveColony != null)
            {
                PandaChat.Send(player, _localizationHelper, "CurrentDifficulty", color, ColonyState.GetColonyState(player.ActiveColony).Difficulty.Name);
                PandaChat.Send(player, _localizationHelper, "PossibleCommands", color);

                var diffs = string.Empty;

                foreach (var diff in GameDifficulty.GameDifficulties)
                {
                    diffs += diff.Key + " | ";
                }

                PandaChat.Send(player, _localizationHelper, "/difficulty " + diffs.Substring(0, diffs.Length - 2), color);
            }
        }
Exemplo n.º 29
0
        public async Task PluginsAsync(ObsidianContext Context)
        {
            var srv         = (Server)Context.Server;
            var player      = (Player)Context.Player;
            var pluginCount = srv.PluginManager.Plugins.Count;
            var message     = new ChatMessage
            {
                Text = $"{ChatColor.Reset}List of plugins ({ChatColor.Gold}{pluginCount}{ChatColor.Reset}): ",
            };

            var messages = new List <ChatMessage>();

            for (int i = 0; i < pluginCount; i++)
            {
                var pluginContainer = srv.PluginManager.Plugins[i];
                var info            = pluginContainer.Info;

                var plugin       = new ChatMessage();
                var colorByState = pluginContainer.Loaded || pluginContainer.IsReady ? ChatColor.DarkGreen : ChatColor.DarkRed;
                plugin.Text = colorByState + pluginContainer.Info.Name;

                plugin.HoverEvent = new TextComponent {
                    Action = ETextAction.ShowText, Value = $"{colorByState}{info.Name}{ChatColor.Reset}\nVersion: {colorByState}{info.Version}{ChatColor.Reset}\nAuthor(s): {colorByState}{info.Authors}{ChatColor.Reset}"
                };
                if (pluginContainer.Info.ProjectUrl != null)
                {
                    plugin.ClickEvent = new TextComponent {
                        Action = ETextAction.OpenUrl, Value = pluginContainer.Info.ProjectUrl.AbsoluteUri
                    }
                }
                ;

                messages.Add(plugin);

                messages.Add(new ChatMessage
                {
                    Text = $"{ChatColor.Reset}{(i + 1 < srv.PluginManager.Plugins.Count ? ", " : "")}"
                });
            }
            if (messages.Count > 0)
            {
                message.AddExtra(messages);
            }

            await player.SendMessageAsync(message);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Creates a local 'ServerString' instance for given text and
        /// style settings.
        /// </summary>
        /// <param name="Text"></param>
        /// <param name="IsBold"></param>
        /// <param name="IsCursive"></param>
        /// <param name="IsUnderline"></param>
        /// <param name="Color"></param>
        /// <returns></returns>
        public static ServerString GetServerStringForString(
            string Text,
            bool IsBold      = false,
            bool IsCursive   = false,
            bool IsUnderline = false,
            ChatColor Color  = ChatColor.Red)
        {
            ChatStyle style = new ChatStyle(
                0, Text.Length, IsBold, IsCursive, IsUnderline, Color);

            ServerString message = new ServerString();

            message.FullString = Text;
            message.Styles.Add(style);

            return(message);
        }
Exemplo n.º 31
0
        public static Color ToColor(this ChatColor chatColor)
        {
            switch (chatColor)
            {
            case ChatColor.Default: return(Color.Black);

            case ChatColor.Error: return(Color.FromNonPremultiplied(0x7d, 0x0a, 0x0a, 0xff));

            case ChatColor.PM: return(Color.FromNonPremultiplied(0x5a, 0x3c, 0x00, 0xff));

            case ChatColor.Server: return(Color.FromNonPremultiplied(0xe6, 0xd2, 0xc8, 0xff));

            case ChatColor.ServerGlobal: return(ColorConstants.LightYellowText);

            case ChatColor.Admin: return(Color.FromNonPremultiplied(0xc8, 0xaa, 0x96, 0xff));

            default: throw new ArgumentOutOfRangeException(nameof(chatColor), chatColor, "Unrecognized chat color");
            }
        }
Exemplo n.º 32
0
 private void ChangeChatColor()
 {
     if (chatProgramIsStart)
     {
         if (mainController == MainController.ServerController)
         {
             serverController.ChangeChatColor();
             MessageBox.Show("채팅 색상이 변경되었습니다.");
         }
         else
         {
             clientController.ChangeChatColor(ChatColor.ToString());
         }
     }
     else
     {
         MessageBox.Show("먼저 접속하여 주세요.", "오류", MessageBoxButtons.OK);
     }
 }
Exemplo n.º 33
0
        /// <summary>
        /// Changes properties based on a known StyleChar
        /// </summary>
        /// <param name="StyleCharacter"></param>
        /// <param name="MessageType"></param>
        public void ProcessStyleCharacter(char StyleCharacter, ChatMessageType MessageType)
        {
            switch (StyleCharacter)
            {
                // colors
                case STYLEBLACK:
                    Color = ChatColor.Black;
                    break;

                case STYLEWHITE:
                    Color = ChatColor.White;
                    break;

                case STYLERED:
                    Color = ChatColor.Red;
                    break;

                case STYLEGREEN:
                    Color = ChatColor.Green;
                    break;

                case STYLEBLUE:
                    Color = ChatColor.Blue;
                    break;

                case STYLEPURPLE:
                    Color = ChatColor.Purple;
                    break;

#if !VANILLA
                case STYLEBRIGHTRED:
                    Color = ChatColor.BrightRed;
                    break;

                case STYLELIGHTGREEN:
                    Color = ChatColor.LightGreen;
                    break;

                case STYLEYELLOW:
                    Color = ChatColor.Yellow;
                    break;

                case STYLEPINK:
                    Color = ChatColor.Pink;
                    break;

                case STYLEORANGE:
                    Color = ChatColor.Orange;
                    break;

                case STYLEAQUAMARINE:
                    Color = ChatColor.Aquamarine;
                    break;

                case STYLECYAN:
                    Color = ChatColor.Cyan;
                    break;

                case STYLETEAL:
                    Color = ChatColor.Teal;
                    break;

                case STYLEDARKGREY:
                    Color = ChatColor.DarkGrey;
                    break;

                case STYLEVIOLET:
                    Color = ChatColor.Violet;
                    break;

                case STYLEMAGENTA:
                    Color = ChatColor.Magenta;
                    break;
#endif

                // modifiers
                case STYLEBOLD:
                    IsBold = !IsBold;
                    break;

                case STYLECURSIVE:
                    IsCursive = !IsCursive;
                    break;
                
                case STYLEUNDERLINE:
                    IsUnderline = !IsUnderline;
                    break;

                case STYLENORMAL:
                    switch (MessageType)
                    {
                        case ChatMessageType.ObjectChatMessage:
                            Color = ChatColor.White;
                            break;

                        case ChatMessageType.ServerChatMessage:
                            Color = ChatColor.Purple;
                            break;

                        case ChatMessageType.SystemMessage:
                            Color = ChatColor.Blue;
                            break;

                        default:
                            Color = ChatColor.White;
                            break;
                    }
                    
                    IsBold = false;
                    IsCursive = false;
                    IsUnderline = false;
                    break;
            }
        }
Exemplo n.º 34
0
			public ChatIndex(int index = 0, ChatType type = ChatType.None, string who = "", ChatColor color = ChatColor.Default)
			{
				_index = index;
				Type = type;
				if (who != null && who.Length >= 1)
				{
					//first character of the who string is capitalized: always!
					who = who.Substring(0, 1).ToUpper() + who.Substring(1).ToLower();
				}
				Who = who;
				col = color;
			}
Exemplo n.º 35
0
		/// <summary>
		/// Adds text to the tab. For multi-line text strings, does text wrapping. For text length > 415 pixels, does text wrapping
		/// </summary>
		/// <param name="who">Person that spoke</param>
		/// <param name="text">Message that was spoken</param>
		/// <param name="icon">Icon to display next to the chat</param>
		/// <param name="col">Rendering color (enumerated value)</param>
		public void AddText(string who, string text, ChatType icon = ChatType.None, ChatColor col = ChatColor.Default)
		{
			const int LINE_LEN = 380;

			//special case: blank line, like in the news panel between news items
			if (string.IsNullOrWhiteSpace(who) && string.IsNullOrWhiteSpace(text))
			{
				lock(ChatStringsLock)
					chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), " ");
				scrollBar.UpdateDimensions(chatStrings.Count);
				if (chatStrings.Count > 7 && WhichTab != ChatTabs.None)
				{
					scrollBar.ScrollToEnd();
				}
				if (!Selected)
					tabLabel.ForeColor = Color.White;
				if (!Visible)
					Visible = true;
				return;
			}

			string whoPadding = "  "; //padding string for additional lines if it is a multi-line message
			if (!string.IsNullOrEmpty(who))
				while (EOGame.Instance.DBGFont.MeasureString(whoPadding).X < EOGame.Instance.DBGFont.MeasureString(who).X)
					whoPadding += " ";

			TextSplitter ts = new TextSplitter(text, EOGame.Instance.DBGFont)
			{
				LineLength = LINE_LEN,
				LineEnd = "",
				LineIndent = whoPadding
			};
			
			if (!ts.NeedsProcessing)
			{
				lock (ChatStringsLock)
					chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), text);
			}
			else
			{
				List<string> chatStringsToAdd = ts.SplitIntoLines();

				for (int i = 0; i < chatStringsToAdd.Count; ++i)
				{
					lock (ChatStringsLock)
					{
						if (i == 0)
							chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), chatStringsToAdd[0]);
						else
							chatStrings.Add(new ChatIndex(chatStrings.Count, ChatType.None, "", col), chatStringsToAdd[i]);
					}
				}
			}

			scrollBar.UpdateDimensions(chatStrings.Count);
			if (chatStrings.Count > 7 && WhichTab != ChatTabs.None)
			{
				scrollBar.ScrollToEnd();
			}
			if (!Selected)
				tabLabel.ForeColor = Color.White;
			if (!Visible)
				Visible = true;
		}
Exemplo n.º 36
0
		public void AddTextToTab(ChatTabs tab, string who, string text, ChatType icon = ChatType.None, ChatColor col = ChatColor.Default)
		{
			tabs[(int)tab].AddText(who, text, icon, col);
		}
Exemplo n.º 37
0
 public void AddChat(ChatTabs whichTab, string who, string message, ChatType chatType = ChatType.None, ChatColor chatColor = ChatColor.Default)
 {
     chatRenderer.AddTextToTab(whichTab, who, message, chatType, chatColor);
 }
Exemplo n.º 38
0
 public ChatMessage(string Message, ChatColor color)
 {
     this.Text = Message;
     this.Color = color;
 }
        /// <summary>
        /// Creates a local ChatMessage instance for given text and
        /// style settings.
        /// </summary>
        /// <param name="Text"></param>
        /// <param name="IsBold"></param>
        /// <param name="IsCursive"></param>
        /// <param name="IsUnderline"></param>
        /// <param name="Color"></param>
        /// <returns></returns>
        public static ChatMessage GetChatMessageForString(
            string Text, 
            bool IsBold = false, 
            bool IsCursive = false, 
            bool IsUnderline = false,
            ChatColor Color = ChatColor.Red)
        {
            ChatStyle style = new ChatStyle(
                0, Text.Length, IsBold, IsCursive, IsUnderline, Color);

            ChatMessage message = new ChatMessage();
            message.FullString = Text;
            message.Styles.Add(style);

            return message;
        }