Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ NewText() [3/3]

static int Terraria.PopupText.NewText ( PopupTextContext context,
Item newItem,
int stack,
bool noStack = false,
bool longText = false )
inlinestatic

Definition at line 169 of file PopupText.cs.

170 {
171 if (!Main.showItemText)
172 {
173 return -1;
174 }
175 if (newItem.Name == null || !newItem.active)
176 {
177 return -1;
178 }
179 if (Main.netMode == 2)
180 {
181 return -1;
182 }
183 bool flag = newItem.type >= 71 && newItem.type <= 74;
184 for (int i = 0; i < 20; i++)
185 {
186 PopupText popupText = Main.popupText[i];
187 if (!popupText.active || popupText.notActuallyAnItem || (!(popupText.name == newItem.AffixName()) && (!flag || !popupText.coinText)) || popupText.NoStack || noStack)
188 {
189 continue;
190 }
191 string text = newItem.Name + " (" + (popupText.stack + stack) + ")";
192 string text2 = newItem.Name;
193 if (popupText.stack > 1)
194 {
195 text2 = text2 + " (" + popupText.stack + ")";
196 }
197 Vector2 vector = FontAssets.MouseText.Value.MeasureString(text2);
198 vector = FontAssets.MouseText.Value.MeasureString(text);
199 if (popupText.lifeTime < 0)
200 {
201 popupText.scale = 1f;
202 }
203 if (popupText.lifeTime < 60)
204 {
205 popupText.lifeTime = 60;
206 }
207 if (flag && popupText.coinText)
208 {
209 long num = 0L;
210 if (newItem.type == 71)
211 {
212 num += stack;
213 }
214 else if (newItem.type == 72)
215 {
216 num += 100 * stack;
217 }
218 else if (newItem.type == 73)
219 {
220 num += 10000 * stack;
221 }
222 else if (newItem.type == 74)
223 {
224 num += 1000000 * stack;
225 }
226 popupText.AddToCoinValue(num);
227 text = ValueToName(popupText.coinValue);
228 vector = FontAssets.MouseText.Value.MeasureString(text);
229 popupText.name = text;
230 if (popupText.coinValue >= 1000000)
231 {
232 if (popupText.lifeTime < 300)
233 {
234 popupText.lifeTime = 300;
235 }
236 popupText.color = new Color(220, 220, 198);
237 }
238 else if (popupText.coinValue >= 10000)
239 {
240 if (popupText.lifeTime < 240)
241 {
242 popupText.lifeTime = 240;
243 }
244 popupText.color = new Color(224, 201, 92);
245 }
246 else if (popupText.coinValue >= 100)
247 {
248 if (popupText.lifeTime < 180)
249 {
250 popupText.lifeTime = 180;
251 }
252 popupText.color = new Color(181, 192, 193);
253 }
254 else if (popupText.coinValue >= 1)
255 {
256 if (popupText.lifeTime < 120)
257 {
258 popupText.lifeTime = 120;
259 }
260 popupText.color = new Color(246, 138, 96);
261 }
262 }
263 popupText.stack += stack;
264 popupText.scale = 0f;
265 popupText.rotation = 0f;
266 popupText.position.X = newItem.position.X + (float)newItem.width * 0.5f - vector.X * 0.5f;
267 popupText.position.Y = newItem.position.Y + (float)newItem.height * 0.25f - vector.Y * 0.5f;
268 popupText.velocity.Y = -7f;
269 popupText.context = context;
270 popupText.npcNetID = 0;
271 if (popupText.coinText)
272 {
273 popupText.stack = 1L;
274 }
275 return i;
276 }
277 int num2 = FindNextItemTextSlot();
278 if (num2 >= 0)
279 {
280 string text3 = newItem.AffixName();
281 if (stack > 1)
282 {
283 text3 = text3 + " (" + stack + ")";
284 }
285 Vector2 vector2 = FontAssets.MouseText.Value.MeasureString(text3);
286 PopupText popupText2 = Main.popupText[num2];
287 ResetText(popupText2);
288 popupText2.active = true;
289 popupText2.position.X = newItem.position.X + (float)newItem.width * 0.5f - vector2.X * 0.5f;
290 popupText2.position.Y = newItem.position.Y + (float)newItem.height * 0.25f - vector2.Y * 0.5f;
291 popupText2.color = Color.White;
292 if (newItem.rare == 1)
293 {
294 popupText2.color = new Color(150, 150, 255);
295 }
296 else if (newItem.rare == 2)
297 {
298 popupText2.color = new Color(150, 255, 150);
299 }
300 else if (newItem.rare == 3)
301 {
302 popupText2.color = new Color(255, 200, 150);
303 }
304 else if (newItem.rare == 4)
305 {
306 popupText2.color = new Color(255, 150, 150);
307 }
308 else if (newItem.rare == 5)
309 {
310 popupText2.color = new Color(255, 150, 255);
311 }
312 else if (newItem.rare == -13)
313 {
314 popupText2.master = true;
315 }
316 else if (newItem.rare == -11)
317 {
318 popupText2.color = new Color(255, 175, 0);
319 }
320 else if (newItem.rare == -1)
321 {
322 popupText2.color = new Color(130, 130, 130);
323 }
324 else if (newItem.rare == 6)
325 {
326 popupText2.color = new Color(210, 160, 255);
327 }
328 else if (newItem.rare == 7)
329 {
330 popupText2.color = new Color(150, 255, 10);
331 }
332 else if (newItem.rare == 8)
333 {
334 popupText2.color = new Color(255, 255, 10);
335 }
336 else if (newItem.rare == 9)
337 {
338 popupText2.color = new Color(5, 200, 255);
339 }
340 else if (newItem.rare == 10)
341 {
342 popupText2.color = new Color(255, 40, 100);
343 }
344 else if (newItem.rare >= 11)
345 {
346 popupText2.color = new Color(180, 40, 255);
347 }
348 popupText2.expert = newItem.expert;
349 popupText2.name = newItem.AffixName();
350 popupText2.stack = stack;
351 popupText2.velocity.Y = -7f;
352 popupText2.lifeTime = 60;
353 popupText2.context = context;
354 if (longText)
355 {
356 popupText2.lifeTime *= 5;
357 }
358 popupText2.coinValue = 0L;
359 popupText2.coinText = newItem.type >= 71 && newItem.type <= 74;
360 if (popupText2.coinText)
361 {
362 long num3 = 0L;
363 if (newItem.type == 71)
364 {
365 num3 += popupText2.stack;
366 }
367 else if (newItem.type == 72)
368 {
369 num3 += 100 * popupText2.stack;
370 }
371 else if (newItem.type == 73)
372 {
373 num3 += 10000 * popupText2.stack;
374 }
375 else if (newItem.type == 74)
376 {
377 num3 += 1000000 * popupText2.stack;
378 }
379 popupText2.AddToCoinValue(num3);
380 popupText2.ValueToName();
381 popupText2.stack = 1L;
382 if (popupText2.coinValue >= 1000000)
383 {
384 if (popupText2.lifeTime < 300)
385 {
386 popupText2.lifeTime = 300;
387 }
388 popupText2.color = new Color(220, 220, 198);
389 }
390 else if (popupText2.coinValue >= 10000)
391 {
392 if (popupText2.lifeTime < 240)
393 {
394 popupText2.lifeTime = 240;
395 }
396 popupText2.color = new Color(224, 201, 92);
397 }
398 else if (popupText2.coinValue >= 100)
399 {
400 if (popupText2.lifeTime < 180)
401 {
402 popupText2.lifeTime = 180;
403 }
404 popupText2.color = new Color(181, 192, 193);
405 }
406 else if (popupText2.coinValue >= 1)
407 {
408 if (popupText2.lifeTime < 120)
409 {
410 popupText2.lifeTime = 120;
411 }
412 popupText2.color = new Color(246, 138, 96);
413 }
414 }
415 }
416 return num2;
417 }
static Asset< DynamicSpriteFont > MouseText
Definition FontAssets.cs:10
static void ResetText(PopupText text)
Definition PopupText.cs:79
static int FindNextItemTextSlot()
Definition PopupText.cs:425
PopupTextContext context
Definition PopupText.cs:50

References Terraria.Entity.active, Terraria.PopupText.active, Terraria.PopupText.AddToCoinValue(), Terraria.Item.AffixName(), Terraria.PopupText.coinText, Terraria.PopupText.coinValue, Terraria.PopupText.context, Terraria.Item.expert, Terraria.PopupText.FindNextItemTextSlot(), Terraria.Entity.height, System.L, Terraria.PopupText.lifeTime, Terraria.GameContent.FontAssets.MouseText, Terraria.Item.Name, Terraria.PopupText.name, Terraria.Main.netMode, Terraria.PopupText.NoStack, Terraria.PopupText.notActuallyAnItem, Terraria.Main.popupText, Terraria.Item.rare, Terraria.PopupText.ResetText(), Terraria.Main.showItemText, Terraria.PopupText.stack, System.text, Terraria.Item.type, Terraria.PopupText.ValueToName(), Terraria.PopupText.ValueToName(), Microsoft.Xna.Framework.Color.White, Terraria.Entity.width, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.