Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ItemTooltip.cs
Go to the documentation of this file.
3
4namespace Terraria.UI;
5
6public class ItemTooltip
7{
8 public static readonly ItemTooltip None = new ItemTooltip();
9
11
12 private static ulong _globalValidatorKey = 1uL;
13
14 private string[] _tooltipLines;
15
16 private ulong _validatorKey;
17
18 private readonly LocalizedText _text;
19
20 private string _processedText;
21
22 public int Lines
23 {
24 get
25 {
27 if (_tooltipLines == null)
28 {
29 return 0;
30 }
31 return _tooltipLines.Length;
32 }
33 }
34
35 private ItemTooltip()
36 {
37 }
38
39 private ItemTooltip(string key)
40 {
41 _text = Language.GetText(key);
42 }
43
44 public static ItemTooltip FromLanguageKey(string key)
45 {
46 if (!Language.Exists(key))
47 {
48 return None;
49 }
50 return new ItemTooltip(key);
51 }
52
53 public string GetLine(int line)
54 {
56 return _tooltipLines[line];
57 }
58
59 private void ValidateTooltip()
60 {
62 {
63 return;
64 }
66 if (_text == null)
67 {
68 _tooltipLines = null;
69 _processedText = string.Empty;
70 return;
71 }
72 string text = _text.Value;
74 {
75 text = globalProcessor(text);
76 }
77 _tooltipLines = text.Split('\n');
78 _processedText = text;
79 }
80
85
90
91 public static void ClearGlobalProcessors()
92 {
93 _globalProcessors.Clear();
94 }
95
96 public static void InvalidateTooltips()
97 {
99 if (_globalValidatorKey == ulong.MaxValue)
100 {
102 }
103 }
104}
static LocalizedText GetText(string key)
Definition Language.cs:10
static bool Exists(string key)
Definition Language.cs:45
static readonly List< TooltipProcessor > _globalProcessors
static ulong _globalValidatorKey
static void AddGlobalProcessor(TooltipProcessor processor)
string GetLine(int line)
readonly LocalizedText _text
static void InvalidateTooltips()
static readonly ItemTooltip None
Definition ItemTooltip.cs:8
static void ClearGlobalProcessors()
static void RemoveGlobalProcessor(TooltipProcessor processor)
static ItemTooltip FromLanguageKey(string key)
delegate string TooltipProcessor(string tooltip)