Client LuaCsForBarotrauma
FormattedLString.cs
1 #nullable enable
2 using System;
3 using System.Collections.Immutable;
4 using System.Linq;
5 
6 namespace Barotrauma
7 {
9  {
10  private readonly LocalizedString str;
11  private readonly ImmutableArray<LocalizedString> subStrs;
12  public FormattedLString(LocalizedString str, params LocalizedString[] subStrs)
13  {
14  this.str = str;
15  this.subStrs = subStrs.ToImmutableArray();
16  }
17 
18  public override bool Loaded => str.Loaded && subStrs.All(s => s.Loaded);
19  public override void RetrieveValue()
20  {
21  //TODO: possibly broken!
22  try
23  {
24  cachedValue = string.Format(str.Value, subStrs.Select(s => s.Value as object).ToArray());
25  }
26  catch (FormatException)
27  {
28  cachedValue = str.Value;
29  }
31  }
32  }
33 }
FormattedLString(LocalizedString str, params LocalizedString[] subStrs)