Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RemadeChatMonitor.cs
Go to the documentation of this file.
1using System;
5
7
9{
10 private const int MaxMessages = 500;
11
12 private int _showCount;
13
14 private int _startChatLine;
15
17
19
21 {
22 _showCount = 10;
25 }
26
27 public void NewText(string newText, byte R = byte.MaxValue, byte G = byte.MaxValue, byte B = byte.MaxValue)
28 {
29 AddNewMessage(newText, new Color(R, G, B));
30 }
31
32 public void NewTextMultiline(string text, bool force = false, Color c = default(Color), int WidthLimit = -1)
33 {
35 }
36
47
48 public void DrawChat(bool drawingPlayerChat)
49 {
50 int num = _startChatLine;
51 int num2 = 0;
52 int num3 = 0;
53 while (num > 0 && num2 < _messages.Count)
54 {
55 int num4 = Math.Min(num, _messages[num2].LineCount);
56 num -= num4;
57 num3 += num4;
58 if (num3 == _messages[num2].LineCount)
59 {
60 num3 = 0;
61 num2++;
62 }
63 }
64 int num5 = 0;
65 int? num6 = null;
66 int snippetIndex = -1;
67 int? num7 = null;
68 int hoveredSnippet = -1;
69 while (num5 < _showCount && num2 < _messages.Count)
70 {
72 if (!chatMessageContainer.Prepared || !(drawingPlayerChat | chatMessageContainer.CanBeShownWhenChatIsClosed))
73 {
74 break;
75 }
76 TextSnippet[] snippetWithInversedIndex = chatMessageContainer.GetSnippetWithInversedIndex(num3);
78 if (hoveredSnippet >= 0)
79 {
81 num6 = num2;
83 }
84 num5++;
85 num3++;
86 if (num3 >= chatMessageContainer.LineCount)
87 {
88 num3 = 0;
89 num2++;
90 }
91 }
92 if (num6.HasValue && num7.HasValue)
93 {
94 TextSnippet[] snippetWithInversedIndex2 = _messages[num6.Value].GetSnippetWithInversedIndex(snippetIndex);
95 snippetWithInversedIndex2[num7.Value].OnHover();
97 {
98 snippetWithInversedIndex2[num7.Value].OnClick();
99 }
100 }
101 }
102
103 public void Clear()
104 {
106 }
107
108 public void Update()
109 {
111 {
113 for (int i = 0; i < _messages.Count; i++)
114 {
115 _messages[i].MarkToNeedRefresh();
116 }
117 }
118 for (int j = 0; j < _messages.Count; j++)
119 {
120 _messages[j].Update();
121 }
122 }
123
124 public void Offset(int linesOffset)
125 {
128 }
129
130 private void ClampMessageIndex()
131 {
132 int num = 0;
133 int num2 = 0;
134 int num3 = 0;
136 while (num < num4 && num2 < _messages.Count)
137 {
138 int num5 = Math.Min(num4 - num, _messages[num2].LineCount);
139 num += num5;
140 if (num < num4)
141 {
142 num2++;
143 num3 = 0;
144 }
145 else
146 {
147 num3 = num5;
148 }
149 }
150 int num6 = _showCount;
151 while (num6 > 0 && num > 0)
152 {
153 num3--;
154 num6--;
155 num--;
156 if (num3 < 0)
157 {
158 num2--;
159 if (num2 == -1)
160 {
161 break;
162 }
163 num3 = _messages[num2].LineCount - 1;
164 }
165 }
166 _startChatLine = num;
167 }
168
169 public void ResetOffset()
170 {
171 _startChatLine = 0;
172 }
173
174 public void OnResolutionChange()
175 {
177 }
178}
void Insert(int index, T item)
Definition List.cs:650
void RemoveAt(int index)
Definition List.cs:824
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static Asset< DynamicSpriteFont > MouseText
Definition FontAssets.cs:10
void AddNewMessage(string text, Color color, int widthLimitInPixels=-1)
void NewText(string newText, byte R=byte.MaxValue, byte G=byte.MaxValue, byte B=byte.MaxValue)
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
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)