DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Chat.c
См. документацию.
1// #include "Scripts\Classes\Gui\ChatLine.c"
2
13
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
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);
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
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
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}
DayZGame g_Game
Определения DayZGame.c:3868
EDayZProfilesOptions
Определения EDayZProfilesOptions.c:2
Icon x
Icon y
void Clear()
Определения Chat.c:60
void Destroy()
Определения Chat.c:55
Widget m_RootWidget
Определения Chat.c:18
int m_LastLine
Определения Chat.c:20
void Init(Widget root_widget)
Определения Chat.c:33
void Chat()
Определения Chat.c:23
void Add(ChatMessageEventParams params)
Определения Chat.c:68
void AddInternal(ChatMessageEventParams params)
Определения Chat.c:127
ref array< ref ChatLine > m_Lines
Определения Chat.c:21
void ~Chat()
Определения Chat.c:28
const int LINE_COUNT
Определения Chat.c:16
int m_LineHeight
Определения Chat.c:19
Widget m_RootWidget
Определения ChatLine.c:16
void Set(ChatMessageEventParams params)
Определения ChatLine.c:39
Определения ChatLine.c:2
Определения EnMath.c:7
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Param4< int, string, string, string > ChatMessageEventParams
channel, from, text, color config class
Определения gameplay.c:407
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'.