Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LegacyChatMonitor.cs
Go to the documentation of this file.
5
7
9{
10 private int numChatLines;
11
12 private ChatLine[] chatLine;
13
14 private int chatLength;
15
16 private int showCount;
17
18 private int startChatLine;
19
20 public int TextMaxLengthForScreen => Main.screenWidth - 320;
21
22 public void OnResolutionChange()
23 {
24 }
25
27 {
28 showCount = 10;
29 numChatLines = 500;
30 chatLength = 600;
32 for (int i = 0; i < numChatLines; i++)
33 {
34 chatLine[i] = new ChatLine();
35 }
36 }
37
38 public void Clear()
39 {
40 for (int i = 0; i < numChatLines; i++)
41 {
42 chatLine[i] = new ChatLine();
43 }
44 }
45
46 public void ResetOffset()
47 {
48 startChatLine = 0;
49 }
50
51 public void Update()
52 {
53 for (int i = 0; i < numChatLines; i++)
54 {
56 }
57 }
58
59 public void Offset(int linesOffset)
60 {
61 showCount = (int)((float)(Main.screenHeight / 3) / FontAssets.MouseText.Value.MeasureString("1").Y) - 1;
62 switch (linesOffset)
63 {
64 case 1:
67 {
69 }
70 if (chatLine[startChatLine + showCount].originalText == "")
71 {
73 }
74 break;
75 case -1:
77 if (startChatLine < 0)
78 {
79 startChatLine = 0;
80 }
81 break;
82 }
83 }
84
85 public void NewText(string newText, byte R = byte.MaxValue, byte G = byte.MaxValue, byte B = byte.MaxValue)
86 {
87 NewTextMultiline(newText, force: false, new Color(R, G, B));
88 }
89
90 public void NewTextInternal(string newText, byte R = byte.MaxValue, byte G = byte.MaxValue, byte B = byte.MaxValue, bool force = false)
91 {
92 int num = 80;
93 if (!force && newText.Length > num)
94 {
95 string oldText = newText;
96 oldText = TrimIntoMultipleLines(R, G, B, num, oldText);
97 if (oldText.Length > 0)
98 {
99 NewTextInternal(oldText, R, G, B, force: true);
100 }
101 return;
102 }
103 for (int num2 = numChatLines - 1; num2 > 0; num2--)
104 {
106 }
107 chatLine[0].color = new Color(R, G, B);
109 chatLine[0].parsedText = ChatManager.ParseMessage(chatLine[0].originalText, chatLine[0].color).ToArray();
112 }
113
114 private string TrimIntoMultipleLines(byte R, byte G, byte B, int maxTextSize, string oldText)
115 {
116 while (oldText.Length > maxTextSize)
117 {
118 int num = maxTextSize;
119 int num2 = num;
120 while (oldText.Substring(num2, 1) != " ")
121 {
122 num2--;
123 if (num2 < 1)
124 {
125 break;
126 }
127 }
128 if (num2 == 0)
129 {
130 while (oldText.Substring(num, 1) != " ")
131 {
132 num++;
133 if (num >= oldText.Length - 1)
134 {
135 break;
136 }
137 }
138 }
139 else
140 {
141 num = num2;
142 }
143 if (num >= oldText.Length - 1)
144 {
145 num = oldText.Length;
146 }
147 string newText = oldText.Substring(0, num);
148 NewTextInternal(newText, R, G, B, force: true);
149 oldText = oldText.Substring(num);
150 if (oldText.Length > 0)
151 {
152 while (oldText.Substring(0, 1) == " ")
153 {
154 oldText = oldText.Substring(1);
155 }
156 }
157 }
158 return oldText;
159 }
160
161 public void NewTextMultiline(string text, bool force = false, Color c = default(Color), int WidthLimit = -1)
162 {
163 if (c == default(Color))
164 {
165 c = Color.White;
166 }
168 for (int i = 0; i < list.Count; i++)
169 {
170 NewText(list[i]);
171 }
172 }
173
174 public void NewText(List<TextSnippet> snippets)
175 {
176 for (int num = numChatLines - 1; num > 0; num--)
177 {
178 chatLine[num].Copy(chatLine[num - 1]);
179 }
180 chatLine[0].originalText = "this is a hack because draw checks length is higher than 0";
181 chatLine[0].parsedText = snippets.ToArray();
184 }
185
186 public void DrawChat(bool drawingPlayerChat)
187 {
188 int num = startChatLine;
190 if (num2 >= numChatLines)
191 {
192 num2 = --numChatLines;
193 num = num2 - showCount;
194 }
195 int num3 = 0;
196 int num4 = -1;
197 int num5 = -1;
198 for (int i = num; i < num2; i++)
199 {
200 if (drawingPlayerChat || (chatLine[i].showTime > 0 && chatLine[i].parsedText.Length != 0))
201 {
202 int hoveredSnippet = -1;
204 if (hoveredSnippet >= 0 && chatLine[i].parsedText[hoveredSnippet].CheckForHover)
205 {
206 num4 = i;
208 }
209 }
210 num3++;
211 }
212 if (num4 > -1)
213 {
216 {
218 }
219 }
220 }
221}
static void PlaySound(int type, Vector2 position, int style=1)
static Asset< DynamicSpriteFont > MouseText
Definition FontAssets.cs:10
string TrimIntoMultipleLines(byte R, byte G, byte B, int maxTextSize, string oldText)
void NewTextInternal(string newText, byte R=byte.MaxValue, byte G=byte.MaxValue, byte B=byte.MaxValue, bool force=false)
void NewText(string newText, byte R=byte.MaxValue, byte G=byte.MaxValue, byte B=byte.MaxValue)
void NewText(List< TextSnippet > snippets)
void NewTextMultiline(string text, bool force=false, Color c=default(Color), int WidthLimit=-1)
static SpriteBatch spriteBatch
Definition Main.cs:974
static bool mouseLeftRelease
Definition Main.cs:1755
static int screenHeight
Definition Main.cs:1721
static bool mouseLeft
Definition Main.cs:614
void Copy(ChatLine other)
Definition ChatLine.cs:31
TextSnippet[] parsedText
Definition ChatLine.cs:13
static Vector2 DrawColorCodedStringWithShadow(SpriteBatch spriteBatch, DynamicSpriteFont font, TextSnippet[] snippets, Vector2 position, float rotation, Vector2 origin, Vector2 baseScale, out int hoveredSnippet, float maxWidth=-1f, float spread=2f)
static List< TextSnippet > ParseMessage(string text, Color baseColor)
static List< List< TextSnippet > > WordwrapStringSmart(string text, Color c, DynamicSpriteFont font, int maxWidth, int maxLines)
Definition Utils.cs:438