DayZ 1.24
Loading...
Searching...
No Matches
ChatLine.c
Go to the documentation of this file.
2{
3 // Consts
4 const float FADE_TIMEOUT = 30;
5 const float FADE_OUT_DURATION = 3;
6 const float FADE_IN_DURATION = 0.5;
7
8 private const string RADIO_PREFIX = "(" + "#str_radio" + ") ";
9 private const string GAME_PREFIX = "(" + "#layout_chat_game" + ") ";
10 private const string ADMIN_PREFIX = "(" + "#STR_MP_MASTER" + ") ";
11 private const int DEFAULT_COLOUR = ARGB(255, 255, 255, 255);
12 private const int GAME_TEXT_COLOUR = ARGB(255, 255, 0, 0);
13 private const int ADMIN_TEXT_COLOUR = ARGB(255, 255, 255, 0);
14
15 // Widgets
19
20 private ref WidgetFadeTimer m_FadeTimer;
22
24 {
25 m_RootWidget = GetGame().GetWorkspace().CreateWidgets("gui/layouts/day_z_chat_item.layout", root_widget);
26
27 m_NameWidget = TextWidget.Cast(m_RootWidget.FindAnyWidget("ChatItemSenderWidget"));
28 m_TextWidget = TextWidget.Cast(m_RootWidget.FindAnyWidget("ChatItemTextWidget"));
29
30 m_FadeTimer = new WidgetFadeTimer;
32 }
33
34 void ~ChatLine()
35 {
36 delete m_TextWidget;
37 }
38
39 void Set(ChatMessageEventParams params) // Param 1 --> Channel, Param 2 --> sender name, Param 3 --> message, Param 4 ??
40 {
41 int channel;
42
43 m_NameWidget.SetText("");
44 m_TextWidget.SetText("");
45
47 m_RootWidget.Show(true);
48
49 channel = params.param1; // 0 = Survior 1 = Game/System 2 = Admin
50
51 /*
52 if (params.param2 != "")
53 {
54 m_NameWidget.SetText( params.param2 + " : ");
55 }
56
57 if( channel & CCSystem )
58 {
59 if(params.param2 != "")
60 {
61 m_NameWidget.SetText(GAME_PREFIX + ": " );
62 }
63 SetColour(GAME_TEXT_COLOUR);
64 }
65 else if( channel & CCAdmin )
66 {
67 m_NameWidget.SetText(ADMIN_PREFIX + ": ");
68 SetColour(ADMIN_TEXT_COLOUR);
69 }
70 else if( channel & CCTransmitter )
71 {
72 m_NameWidget.SetText(RADIO_PREFIX + params.param2 + " : ");
73 }
74 */
75
76 if (channel & CCSystem)
77 {
78 // Game
79 if (params.param2 != "")
80 m_NameWidget.SetText(GAME_PREFIX + ": ");
81
83 }
84 else if (channel & CCAdmin)
85 {
86 // Admin
87 m_NameWidget.SetText(ADMIN_PREFIX + ": ");
89 }
90 else if (channel & CCTransmitter)
91 {
92 // Radio - Trasnmitter
93 m_NameWidget.SetText(RADIO_PREFIX + params.param2 + " : ");
94 }
95 else if (channel == 0 || channel & CCDirect)
96 {
97 // Player
98 if (params.param2 != "")
99 m_NameWidget.SetText(params.param2 + " : ");
100 }
101
102
103 m_TextWidget.SetText(params.param3);
104
107 }
108
109 private void SetColour(int colour)
110 {
111 m_NameWidget.SetColor(colour);
112 m_TextWidget.SetColor(colour);
113 }
114
115 protected void SetColorByParam(string pParamValue, int pFallback)
116 {
117 if (pParamValue != "")
118 {
120 return;
121 }
122
124 }
125
126 void Clear()
127 {
128 m_RootWidget.Show(false);
129 m_TimeoutTimer.Stop();
130 m_FadeTimer.Stop();
131 }
132
133 protected int ColorNameToColor(string pColorName)
134 {
135 int color = 0xFFFFFFFF;
136 switch (pColorName)
137 {
138 case "colorStatusChannel":
140 break;
141 case "colorAction":
143 break;
144 case "colorFriendly":
146 break;
147 case "colorImportant":
149 break;
150 }
151
152 return color;
153 }
154}
const int ADMIN_TEXT_COLOUR
Definition ChatLine.c:13
const string RADIO_PREFIX
Definition ChatLine.c:8
Widget m_RootWidget
Definition ChatLine.c:16
const int GAME_TEXT_COLOUR
Definition ChatLine.c:12
ref Timer m_TimeoutTimer
Definition ChatLine.c:21
const float FADE_OUT_DURATION
Definition ChatLine.c:5
const float FADE_TIMEOUT
Definition ChatLine.c:4
void Set(ChatMessageEventParams params)
Definition ChatLine.c:39
TextWidget m_TextWidget
Definition ChatLine.c:18
void SetColour(int colour)
Definition ChatLine.c:109
ref WidgetFadeTimer m_FadeTimer
Definition ChatLine.c:20
void ChatLine(Widget root_widget)
Definition ChatLine.c:23
const string GAME_PREFIX
Definition ChatLine.c:9
TextWidget m_NameWidget
Definition ChatLine.c:17
const int DEFAULT_COLOUR
Definition ChatLine.c:11
void Clear()
Definition ChatLine.c:126
const float FADE_IN_DURATION
Definition ChatLine.c:6
const string ADMIN_PREFIX
Definition ChatLine.c:10
int ColorNameToColor(string pColorName)
Definition ChatLine.c:133
void ~ChatLine()
Definition ChatLine.c:34
void SetColorByParam(string pParamValue, int pFallback)
Definition ChatLine.c:115
proto native CGame GetGame()
const int COLOR_BLUE
Definition constants.c:66
const int COLOR_RED
Definition constants.c:64
const int COLOR_GREEN
Definition constants.c:65
const int COLOR_YELLOW
Definition constants.c:67
const int CALL_CATEGORY_GUI
Definition tools.c:9
int ARGB(int a, int r, int g, int b)
Definition proto.c:322