Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ChatMessageLineComponent.c
Go to the documentation of this file.
1 class SCR_ChatMessageLineComponent : ScriptedWidgetComponent
2 {
3  protected ref SCR_ChatMessageLineWidgets m_Widgets = new SCR_ChatMessageLineWidgets();
4 
5  protected ResourceName CHAT_IMAGESET = "{1872FFA1133724A2}UI/Textures/Chat/chat.imageset";
6 
7  protected Widget m_wRoot;
8 
9  //------------------------------------------------------------------------------------------------
10  override void HandlerAttached(Widget w)
11  {
12  m_wRoot = w;
13  m_Widgets.Init(w);
14  SetEmptyMessage();
15  }
16 
17  //------------------------------------------------------------------------------------------------
20  void SetMessage(notnull SCR_ChatMessage msg, SCR_ChatMessageStyle style)
21  {
22  // Enable elements which can be disabled for empty message lines
23  m_Widgets.m_Badge.SetVisible(true);
24  m_Widgets.m_TypeImage.SetVisible(true);
25 
26  SCR_ChatMessageGeneral messageGeneral = SCR_ChatMessageGeneral.Cast(msg);
27  SCR_ChatMessagePrivate messagePrivate = SCR_ChatMessagePrivate.Cast(msg);
29 
30  Color channelColor = style.m_Color;
31  string chatTypeImageName = style.m_sIconName;
32 
33  //---------------------------------------------------------------------------------
34  // Common properties derived from the resolved style, regardless of message type
35 
36  // Message color
37  m_Widgets.m_MessageText.SetColor(Color.FromInt(Color.WHITE)); // Message is always white now
38 
39  // Badge color
40  Color badgeColor = Color.FromInt(Color.WHITE);
41  if (style.m_bColoredBadge)
42  badgeColor = channelColor;
43 
44  m_Widgets.m_Badge.SetColor(badgeColor);
45 
46  // Image color
47  Color imageColor = Color.FromInt(Color.WHITE);
48  if (style.m_bColoredIcon)
49  imageColor = channelColor;
50 
51  m_Widgets.m_TypeImage.SetColor(imageColor);
52 
53  // Background color
54  float bgAlphaOld = m_Widgets.m_BackgroundImage.GetColor().A();
55  Color bgColorNew = Color.FromInt(Color.BLACK);
56  if (style.m_bColoredBackground)
57  bgColorNew = Color.FromInt(style.m_Color.PackToInt());
58 
59  bgColorNew.SetA(bgAlphaOld); // Keep the old alpha value
60  m_Widgets.m_BackgroundImage.SetColor(bgColorNew);
61  m_Widgets.m_BackgroundImage.SetVisible(true);
62 
63  //---------------------------------------------------------------------------------
64  // Properties specific to message type
65 
66  // Set properties depending on channel class
67  string senderNameText;
68  if (messagePrivate)
69  senderNameText = messagePrivate.m_sSenderName + ": ";
70  else if (messageGeneral)
71  senderNameText = messageGeneral.m_sSenderName + ": ";
72 
73  Color textColor = Color.FromInt(Color.WHITE);
74 
75  // Player name color
76  if (!senderNameText.IsEmpty() && style.m_bColoredPlayerName)
77  textColor = style.m_Color;
78 
79  m_Widgets.m_TypeImage.LoadImageFromSet(0, CHAT_IMAGESET, chatTypeImageName);
80 
81  m_Widgets.m_MessageText.SetColor(textColor);
82  m_Widgets.m_MessageText.SetText(senderNameText + msg.m_sMessage);
83  }
84 
85  //------------------------------------------------------------------------------------------------
86  void SetEmptyMessage()
87  {
88  // Hide elements, leave only text so that it constraints the height of this strip
89  m_Widgets.m_Badge.SetVisible(false);
90  m_Widgets.m_BackgroundImage.SetVisible(false);
91  m_Widgets.m_TypeImage.SetVisible(false);
92  m_Widgets.m_MessageText.SetText(" ");
93  }
94 
95  //------------------------------------------------------------------------------------------------
97  void SetVisible(bool visible)
98  {
99  m_wRoot.SetVisible(visible);
100  }
101 
102  //------------------------------------------------------------------------------------------------
104  Widget GetRootWidget()
105  {
106  return m_wRoot;
107  }
108 }
SCR_ChatMessageGeneral
Definition: SCR_ChatMessage.c:19
SCR_ChatMessagePrivate
Definition: SCR_ChatMessage.c:35
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_ChatMessageLineComponent
Definition: SCR_ChatMessageLineComponent.c:1
SCR_ChatMessageRadioProtocol
Definition: SCR_ChatMessage.c:46
m_Widgets
ref SCR_VoNOverlay_ElementWidgets m_Widgets
Definition: SCR_VonDisplay.c:3
SCR_ChatMessageStyle
Definition: SCR_ChatMessageStyle.c:6
SCR_ChatMessage
Definition: SCR_ChatMessage.c:7
SCR_ChatMessageLineWidgets
Definition: SCR_ChatMessageLineWidgets.c:4