Client LuaCsForBarotrauma
LimitLString.cs
1 #nullable enable
2 namespace Barotrauma
3 {
5  {
6  private readonly LocalizedString nestedStr;
7  private readonly GUIFont font;
8  private readonly int maxWidth;
9 
10  private ScalableFont? cachedFont = null;
11 
12  public LimitLString(LocalizedString text, GUIFont font, int maxWidth)
13  {
14  this.nestedStr = text;
15  this.font = font;
16  this.maxWidth = maxWidth;
17  }
18 
19  public override bool Loaded => nestedStr.Loaded;
20  protected override bool MustRetrieveValue()
21  {
22  return base.MustRetrieveValue() || cachedFont != font.Value || cachedFont?.Size != font.Size;
23  }
24 
25  public override void RetrieveValue()
26  {
27  cachedValue = font.Value != null
28  ? ToolBox.LimitString(nestedStr.Value, font.Value, maxWidth)
29  : nestedStr.Value;
30  cachedFont = font.Value;
32  }
33  }
34 }
override bool MustRetrieveValue()
Definition: LimitLString.cs:20
override void RetrieveValue()
Definition: LimitLString.cs:25
override bool Loaded
Definition: LimitLString.cs:19
LimitLString(LocalizedString text, GUIFont font, int maxWidth)
Definition: LimitLString.cs:12