DayZ 1.24
Loading...
Searching...
No Matches
Chat.c
Go to the documentation of this file.
1// #include "Scripts\Classes\Gui\ChatLine.c"
2
14class Chat
15{
16 const int LINE_COUNT = 12;
17
19 protected int m_LineHeight;
20 protected int m_LastLine;
22
23 void Chat()
24 {
26 }
27
28 void ~Chat()
29 {
30 Destroy();
31 }
32
34 {
35 Destroy();
36
38
39 if (m_RootWidget)
40 {
41 float w;
42 float h;
43 m_RootWidget.GetSize(w, h);
45 m_LastLine = 0;
46
47 for (int i = 0; i < LINE_COUNT; i++)
48 {
50 m_Lines.Insert(line);
51 }
52 }
53 }
54
55 void Destroy()
56 {
57 m_Lines.Clear();
58 }
59
60 void Clear()
61 {
62 for (int i = 0; i < LINE_COUNT; i++)
63 m_Lines.Get(i).Clear();
64 }
65
67 {
69 int name_lenght = params.param2.Length();
70 int text_lenght = params.param3.Length();
72 int channel = params.param1;
73
74 if (channel & CCSystem || channel & CCBattlEye) //TODO separate battleye bellow
75 {
76 if (g_Game.GetProfileOption(EDayZProfilesOptions.GAME_MESSAGES))
77 return;
78
79 max_lenght = ChatMaxSystemLength; // system messages can be longer
80 }
81 //TODO add battleye filter to options
82 /*else if( channel & CCBattlEye )
83 {
84 if( g_Game.GetProfileOption( EDayZProfilesOptions.BATTLEYE_MESSAGES ) )
85 return;
86 }*/
87 else if (channel & CCAdmin)
88 {
89 if (g_Game.GetProfileOption(EDayZProfilesOptions.ADMIN_MESSAGES))
90 return;
91 }
93 {
94 if (g_Game.GetProfileOption(EDayZProfilesOptions.PLAYER_MESSAGES))
95 return;
96 }
97 else if (channel != 0) // 0 should be local messages to self
98 {
99 Print("Chat: Unknown channel " + channel);
100 return;
101 }
102
104 {
105 int pos = 0;
107 ref ChatMessageEventParams tmp = new ChatMessageEventParams(params.param1, params.param2, "", params.param4);
108
109 while (pos < text_lenght)
110 {
111 tmp.param3 = params.param3.Substring(pos, lenght);
113
114 tmp.param2 = "";
115 pos += lenght;
117 }
118 }
119 else
121 }
122
124 {
125 m_LastLine = (m_LastLine + 1) % m_Lines.Count();
126
128 line.Set(params);
129
130 for (int i = 0; i < m_Lines.Count(); i++)
131 {
132 line = m_Lines.Get((m_LastLine + 1 + i) % LINE_COUNT);
133 line.m_RootWidget.SetPos(0, i * m_LineHeight);
134
135 float x = 0;
136 float y = 0;
137
138 line.m_RootWidget.GetPos(x, y);
139 }
140 }
141}
DayZGame g_Game
Definition DayZGame.c:3528
EDayZProfilesOptions
Icon x
Icon y
Definition Chat.c:15
void Clear()
Definition Chat.c:60
void Destroy()
Definition Chat.c:55
Widget m_RootWidget
Definition Chat.c:18
int m_LastLine
Definition Chat.c:20
void Init(Widget root_widget)
Definition Chat.c:33
void Chat()
Definition Chat.c:23
void Add(ChatMessageEventParams params)
Definition Chat.c:66
void AddInternal(ChatMessageEventParams params)
Definition Chat.c:123
ref array< ref ChatLine > m_Lines
Definition Chat.c:21
void ~Chat()
Definition Chat.c:28
const int LINE_COUNT
Definition Chat.c:16
int m_LineHeight
Definition Chat.c:19
Definition EnMath.c:7
Param4< int, string, string, string > ChatMessageEventParams
channel, from, text, color config class
Definition gameplay.c:394
proto void Print(void var)
Prints content of variable to console/log.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.