Client LuaCsForBarotrauma
InputTypeLString.cs
1 #nullable enable
2 using System;
3 
4 namespace Barotrauma
5 {
7  {
8  private readonly LocalizedString nestedStr;
9  private bool useColorHighlight;
10 
11  public InputTypeLString(LocalizedString nStr, bool useColorHighlight = false)
12  {
13  nestedStr = nStr;
14  this.useColorHighlight = useColorHighlight;
15  }
16 
17  protected override bool MustRetrieveValue()
18  {
19  //TODO: check for config changes!
20  return base.MustRetrieveValue();
21  }
22 
23  public override bool Loaded => nestedStr.Loaded;
24  public override void RetrieveValue()
25  {
26  cachedValue = nestedStr.Value;
27 #if CLIENT
28  //TODO: server shouldn't have this type at all
29  foreach (InputType? inputType in Enum.GetValues(typeof(InputType)))
30  {
31  if (!inputType.HasValue) { continue; }
32 
33  string keyBindText = GameSettings.CurrentConfig.KeyMap.KeyBindText(inputType.Value).Value;
34  if (useColorHighlight)
35  {
36  keyBindText = $"‖color:gui.orange‖{keyBindText}‖end‖";
37  }
38  cachedValue = cachedValue.Replace($"[{inputType}]", keyBindText, StringComparison.OrdinalIgnoreCase);
39  cachedValue = cachedValue.Replace($"[InputType.{inputType}]", keyBindText, StringComparison.OrdinalIgnoreCase);
40  }
41 #endif
43  }
44  }
45 }
InputTypeLString(LocalizedString nStr, bool useColorHighlight=false)
override bool MustRetrieveValue()