Client LuaCsForBarotrauma
BarotraumaClient/ClientSource/Events/EventLog.cs
1 #nullable enable
2 
3 using Microsoft.Xna.Framework;
4 using System;
5 using System.Collections.Generic;
6 using System.Linq;
7 
8 namespace Barotrauma;
9 
10 partial class EventLog
11 {
12  public bool UnreadEntries { get; private set; }
13 
14  public void AddEntry(Identifier eventPrefabId, Identifier entryId, string text)
15  {
16  TryAddEntryInternal(eventPrefabId, entryId, text);
17  GameMain.GameSession?.EnableEventLogNotificationIcon(enabled: true);
18  UnreadEntries = true;
19  }
20 
21  public void CreateEventLogUI(GUIComponent parent, TraitorManager.TraitorResults? traitorResults = null)
22  {
23  UnreadEntries = false;
24 
25  int spacing = GUI.IntScale(5);
26  foreach (var ev in events.Values)
27  {
28  LocalizedString nameString = string.Empty;
29  int difficultyIconCount = 0;
30 
31  EventPrefab.Prefabs.TryGet(ev.EventIdentifier, out EventPrefab? eventPrefab);
32  if (eventPrefab is not null)
33  {
34  nameString = RichString.Rich(eventPrefab.Name);
35  if (eventPrefab is TraitorEventPrefab traitorEventPrefab)
36  {
37  difficultyIconCount = traitorEventPrefab.DangerLevel;
38  }
39  }
40  var textContent = new List<LocalizedString>();
41  textContent.AddRange(ev.Entries.Select(e => (LocalizedString)e.Text));
42 
43  var icon = GUIStyle.GetComponentStyle("TraitorMissionIcon")?.GetDefaultSprite();
44 
45  RoundSummary.CreateMissionEntry(
46  parent,
47  nameString,
48  textContent,
49  difficultyIconCount,
50  icon, GUIStyle.Red,
51  out GUIImage missionIcon);
52 
53  if (traitorResults != null &&
54  traitorResults.Value.TraitorEventIdentifier == ev.EventIdentifier)
55  {
56  RoundSummary.UpdateMissionStateIcon(traitorResults.Value.ObjectiveSuccessful, missionIcon);
57  }
58  }
59  }
60 }
61 
void CreateEventLogUI(GUIComponent parent, TraitorManager.TraitorResults? traitorResults=null)
void AddEntry(Identifier eventPrefabId, Identifier entryId, string text)