Exemple #1
0
        private void _showForgetAllMessage(Action forgetAllAction)
        {
            List <string> drawStrings = new List <string>();

            string[] messages =
            {
                OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL),
                OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_1),
                OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_2),
                OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_3),
                OldWorld.GetString(EOResourceID.SKILLMASTER_CLICK_HERE_TO_FORGET_ALL)
            };

            TextSplitter ts = new TextSplitter("", Game.Content.Load <SpriteFont>(Constants.FontSize08pt5))
            {
                LineLength = 200
            };

            foreach (string s in messages)
            {
                ts.Text = s;
                if (!ts.NeedsProcessing)
                {
                    //no text clipping needed
                    drawStrings.Add(s);
                    drawStrings.Add(" ");
                    continue;
                }

                drawStrings.AddRange(ts.SplitIntoLines());
                drawStrings.Add(" ");
            }

            //now need to take the processed draw strings and make an ListDialogItem for each one
            foreach (string s in drawStrings)
            {
                string next = s;
                bool   link = false;
                if (next.Length > 0 && next[0] == '*')
                {
                    next = next.Remove(0, 1);
                    link = true;
                }
                ListDialogItem nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small)
                {
                    Text = next
                };
                if (link)
                {
                    nextItem.SetPrimaryTextLink(forgetAllAction);
                }
                AddItemToList(nextItem, false);
            }
        }
        private void _setDialogText()
        {
            ClearItemList();

            List <string> rows = new List <string>();

            TextSplitter ts = new TextSplitter(_pages[_pageIndex], Game.Content.Load <SpriteFont>(Constants.FontSize08pt5));

            if (!ts.NeedsProcessing)
            {
                rows.Add(_pages[_pageIndex]);
            }
            else
            {
                rows.AddRange(ts.SplitIntoLines());
            }

            int index = 0;

            foreach (var row in rows)
            {
                ListDialogItem rowItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++)
                {
                    Text = row
                };
                AddItemToList(rowItem, false);
            }

            if (_pageIndex < _pages.Count - 1)
            {
                return;
            }

            ListDialogItem item = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++)
            {
                Text = " "
            };

            AddItemToList(item, false);

            foreach (var link in _links)
            {
                ListDialogItem linkItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++)
                {
                    Text = link.Value
                };

                var linkIndex = (byte)link.Key;
                linkItem.SetPrimaryTextLink(() => _clickLink(linkIndex));
                AddItemToList(linkItem, false);
            }
        }
Exemple #3
0
        private IReadOnlyList <ChatPair> SplitTextIntoLines(string who, IReadOnlyList <string> input)
        {
            var retStrings = new List <ChatPair>();

            who = who ?? "";

            string indentForUserName = "******"; //padding string for additional lines if it is a multi-line message

            if (!string.IsNullOrEmpty(who))
            {
                while (_chatFont.MeasureString(indentForUserName).X < _chatFont.MeasureString(who).X)
                {
                    indentForUserName += " ";
                }
            }

            var splitter = new TextSplitter("", _chatFont)
            {
                LineLength = LINE_LEN,
                LineIndent = indentForUserName
            };

            foreach (var text in input)
            {
                if (string.IsNullOrWhiteSpace(who) && string.IsNullOrWhiteSpace(text))
                {
                    retStrings.Add(new ChatPair {
                        Text = " ", IsFirstLineOfMultilineMessage = true
                    });
                    continue;
                }

                splitter.Text = text;
                if (!splitter.NeedsProcessing)
                {
                    retStrings.Add(new ChatPair {
                        Text = text, IsFirstLineOfMultilineMessage = true
                    });
                    continue;
                }

                var stringsToAdd = splitter.SplitIntoLines()
                                   .Select((str, i) => new ChatPair {
                    Text = str, IsFirstLineOfMultilineMessage = i == 0
                })
                                   .ToList();
                retStrings.AddRange(stringsToAdd);
            }

            return(retStrings);
        }
		private void _setDialogText()
		{
			ClearItemList();

			List<string> rows = new List<string>();

			TextSplitter ts = new TextSplitter(_pages[_pageIndex], Game.Content.Load<SpriteFont>(Constants.FontSize08pt5));
			if (!ts.NeedsProcessing)
				rows.Add(_pages[_pageIndex]);
			else
				rows.AddRange(ts.SplitIntoLines());

			int index = 0;
			foreach (var row in rows)
			{
				ListDialogItem rowItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++)
				{
					Text = row
				};
				AddItemToList(rowItem, false);
			}

			if (_pageIndex < _pages.Count - 1)
				return;

			ListDialogItem item = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++) { Text = " " };
			AddItemToList(item, false);

			foreach (var link in _links)
			{
				ListDialogItem linkItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++)
				{
					Text = link.Value
				};

				var linkIndex = (byte)link.Key;
				linkItem.SetPrimaryTextLink(() => _clickLink(linkIndex));
				AddItemToList(linkItem, false);
			}
		}
		private void _showForgetAllMessage(Action forgetAllAction)
		{
			List<string> drawStrings = new List<string>();

			string[] messages =
			{
				World.GetString(DATCONST2.SKILLMASTER_FORGET_ALL),
				World.GetString(DATCONST2.SKILLMASTER_FORGET_ALL_MSG_1),
				World.GetString(DATCONST2.SKILLMASTER_FORGET_ALL_MSG_2),
				World.GetString(DATCONST2.SKILLMASTER_FORGET_ALL_MSG_3),
				World.GetString(DATCONST2.SKILLMASTER_CLICK_HERE_TO_FORGET_ALL)
			};

			TextSplitter ts = new TextSplitter("", Game.Content.Load<SpriteFont>(Constants.FontSize08pt5)) { LineLength = 200 };
			foreach (string s in messages)
			{
				ts.Text = s;
				if (!ts.NeedsProcessing)
				{
					//no text clipping needed
					drawStrings.Add(s);
					drawStrings.Add(" ");
					continue;
				}

				drawStrings.AddRange(ts.SplitIntoLines());
				drawStrings.Add(" ");
			}

			//now need to take the processed draw strings and make an ListDialogItem for each one
			foreach (string s in drawStrings)
			{
				string next = s;
				bool link = false;
				if (next.Length > 0 && next[0] == '*')
				{
					next = next.Remove(0, 1);
					link = true;
				}
				ListDialogItem nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small) { Text = next };
				if (link) nextItem.SetPrimaryTextLink(forgetAllAction);
				AddItemToList(nextItem, false);
			}
		}
        /// <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, ChatIcon icon = ChatIcon.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)
                {
                    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, ChatIcon.None, "", col), chatStringsToAdd[i]);
                        }
                    }
                }
            }

            scrollBar.UpdateDimensions(chatStrings.Count);
            if (chatStrings.Count > 7)
            {
                scrollBar.ScrollToEnd();
            }
            if (!Selected)
            {
                tabLabel.ForeColor = Color.White;
            }
            if (!Visible)
            {
                Visible = true;
            }
        }
		/// <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;
		}