Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
chat.c
Go to the documentation of this file.
1
// #include "Scripts\Classes\Gui\ChatLine.c"
2
13
14
class
Chat
15
{
16
const
int
LINE_COUNT
= 12;
17
18
protected
Widget
m_RootWidget
;
19
protected
int
m_LineHeight
;
20
protected
int
m_LastLine
;
21
protected
ref
array<ref ChatLine>
m_Lines
;
22
23
void
Chat
()
24
{
25
m_Lines
=
new
array<ref ChatLine>
;
26
}
27
28
void
~Chat
()
29
{
30
Destroy
();
31
}
32
33
void
Init
(
Widget
root_widget)
34
{
35
Destroy
();
36
37
m_RootWidget
= root_widget;
38
39
if
(
m_RootWidget
)
40
{
41
float
w;
42
float
h;
43
m_RootWidget
.GetSize(w,h);
44
m_LineHeight
= h /
LINE_COUNT
;
45
m_LastLine
= 0;
46
47
for
(
int
i = 0; i <
LINE_COUNT
; i++)
48
{
49
ChatLine
line =
new
ChatLine
(
m_RootWidget
);
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
{
64
m_Lines
.Get(i).Clear();
65
}
66
}
67
68
void
Add
(
ChatMessageEventParams
params)
69
{
70
int
max_lenght = ChatMaxUserLength;
71
int
name_lenght = params.param2.Length();
72
int
text_lenght = params.param3.Length();
73
int
total_lenght = text_lenght + name_lenght;
74
int
channel = params.param1;
75
76
if
( channel & CCSystem || channel & CCBattlEye)
//TODO separate battleye bellow
77
{
78
if
(
g_Game
.GetProfileOption(
EDayZProfilesOptions
.GAME_MESSAGES ) )
79
return
;
80
81
max_lenght = ChatMaxSystemLength;
// system messages can be longer
82
}
83
//TODO add battleye filter to options
84
/*else if( channel & CCBattlEye )
85
{
86
if( g_Game.GetProfileOption( EDayZProfilesOptions.BATTLEYE_MESSAGES ) )
87
return;
88
}*/
89
else
if
( channel & CCAdmin )
90
{
91
if
(
g_Game
.GetProfileOption(
EDayZProfilesOptions
.ADMIN_MESSAGES ) )
92
return
;
93
}
94
else
if
( channel & CCDirect || channel & CCMegaphone || channel & CCTransmitter || channel & CCPublicAddressSystem )
95
{
96
if
(
g_Game
.GetProfileOption(
EDayZProfilesOptions
.PLAYER_MESSAGES ) )
97
return
;
98
}
99
else
if
( channel != 0 )
// 0 should be local messages to self
100
{
101
Print
(
"Chat: Unknown channel "
+ channel);
102
return
;
103
}
104
105
if
(total_lenght > max_lenght)
106
{
107
int
pos = 0;
108
int
lenght =
Math
.
Clamp
(max_lenght - name_lenght, 0, text_lenght);
109
ref
ChatMessageEventParams
tmp =
new
ChatMessageEventParams
(params.param1, params.param2,
""
, params.param4);
110
111
while
(pos < text_lenght)
112
{
113
tmp.param3 = params.param3.Substring(pos, lenght);
114
AddInternal
(tmp);
115
116
tmp.param2 =
""
;
117
pos += lenght;
118
lenght =
Math
.
Clamp
(text_lenght - pos, 0, max_lenght);
119
}
120
}
121
else
122
{
123
AddInternal
(params);
124
}
125
}
126
127
void
AddInternal
(
ChatMessageEventParams
params)
128
{
129
m_LastLine
= (
m_LastLine
+ 1) %
m_Lines
.Count();
130
131
ChatLine
line =
m_Lines
.Get(
m_LastLine
);
132
line.
Set
(params);
133
134
for
(
int
i = 0; i <
m_Lines
.Count(); i++)
135
{
136
line =
m_Lines
.Get((
m_LastLine
+ 1 + i) %
LINE_COUNT
);
137
line.
m_RootWidget
.SetPos(0, i *
m_LineHeight
);
138
139
float
x
= 0;
140
float
y
= 0;
141
142
line.
m_RootWidget
.GetPos(
x
,
y
);
143
}
144
}
145
}
Chat::LINE_COUNT
const int LINE_COUNT
Definition
chat.c:16
Chat::AddInternal
void AddInternal(ChatMessageEventParams params)
Definition
chat.c:127
Chat::Init
void Init(Widget root_widget)
Definition
chat.c:33
Chat::m_LineHeight
int m_LineHeight
Definition
chat.c:19
Chat::Chat
void Chat()
Definition
chat.c:23
Chat::Clear
void Clear()
Definition
chat.c:60
Chat::Add
void Add(ChatMessageEventParams params)
Definition
chat.c:68
Chat::~Chat
void ~Chat()
Definition
chat.c:28
Chat::m_Lines
ref array< ref ChatLine > m_Lines
Definition
chat.c:21
Chat::Destroy
void Destroy()
Definition
chat.c:55
Chat::m_LastLine
int m_LastLine
Definition
chat.c:20
Chat::m_RootWidget
Widget m_RootWidget
Definition
chat.c:18
ChatLine
Definition
chatline.c:2
ChatLine::Set
void Set(ChatMessageEventParams params)
Definition
chatline.c:39
ChatLine::m_RootWidget
Widget m_RootWidget
Definition
chatline.c:16
Math
Definition
enmath.c:7
Widget
Definition
enwidgets.c:190
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
EDayZProfilesOptions
EDayZProfilesOptions
Definition
edayzprofilesoptions.c:2
ChatMessageEventParams
Param4< int, string, string, string > ChatMessageEventParams
channel, from, text, color config class
Definition
gameplay.c:407
Print
proto void Print(void var)
Prints content of variable to console/log.
Math::Clamp
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'.
x
Icon x
y
Icon y
Games
Dayz
scripts
5_mission
gui
chat
chat.c
Generated by
1.17.0