Client LuaCsForBarotrauma
SlideshowPrefab.cs
1 using System.Collections.Generic;
2 using System.Collections.Immutable;
3 
4 namespace Barotrauma
5 {
7  {
9 
10  public class Slide
11  {
12  public readonly LocalizedString Text;
13  public readonly Sprite Portrait;
14 
15  public readonly float FadeInDelay, FadeInDuration, FadeOutDuration;
16  public readonly float TextFadeInDelay, TextFadeInDuration;
17 
18  public Slide(ContentXElement element)
19  {
20  string text = element.GetAttributeString(nameof(Text), string.Empty);
21  Text = TextManager.Get(text).Fallback(text);
22 
23  FadeInDelay = element.GetAttributeFloat(nameof(FadeInDelay), 0.0f);
24  FadeInDuration = element.GetAttributeFloat(nameof(FadeInDuration), 2.0f);
25  FadeOutDuration = element.GetAttributeFloat(nameof(FadeOutDuration), 2.0f);
26  TextFadeInDelay = element.GetAttributeFloat(nameof(TextFadeInDelay), 2.0f);
27  TextFadeInDuration = element.GetAttributeFloat(nameof(TextFadeInDuration), 3.0f);
28 
29  foreach (var subElement in element.Elements())
30  {
31  switch (subElement.Name.ToString().ToLowerInvariant())
32  {
33  case "portrait":
34  Portrait = new Sprite(subElement, lazyLoad: true);
35  break;
36  }
37  }
38  }
39  }
40 
41  public readonly ImmutableArray<Slide> Slides;
42 
43  public SlideshowPrefab(ContentFile file, ContentXElement element) : base(file, element.GetAttributeIdentifier("identifier", ""))
44  {
45  List<Slide> slides = new List<Slide>();
46  foreach (var subElement in element.Elements())
47  {
48  switch (subElement.Name.ToString().ToLowerInvariant())
49  {
50  case "slide":
51  slides.Add(new Slide(subElement));
52  break;
53  }
54  }
55  Slides = slides.ToImmutableArray();
56  }
57 
58  public override void Dispose() { }
59  }
60 }
Base class for content file types, which are loaded from filelist.xml via reflection....
Definition: ContentFile.cs:23
string? GetAttributeString(string key, string? def)
float GetAttributeFloat(string key, float def)
LocalizedString Fallback(LocalizedString fallback, bool useDefaultLanguageIfFound=true)
Use this text instead if the original text cannot be found.
Slide(ContentXElement element)
readonly LocalizedString Text
SlideshowPrefab(ContentFile file, ContentXElement element)
static readonly PrefabCollection< SlideshowPrefab > Prefabs
readonly ImmutableArray< Slide > Slides