16 const int LINE_COUNT = 12;
18 protected Widget m_RootWidget;
19 protected int m_LineHeight;
20 protected int m_LastLine;
33 void Init(
Widget root_widget)
44 m_LineHeight = h / LINE_COUNT;
47 for (
int i = 0; i < LINE_COUNT; i++)
62 for (
int i = 0; i < LINE_COUNT; i++)
64 m_Lines.Get(i).Clear();
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;
76 if( channel & CCSystem || channel & CCBattlEye)
81 max_lenght = ChatMaxSystemLength;
89 else if( channel & CCAdmin )
94 else if( channel & CCDirect || channel & CCMegaphone || channel & CCTransmitter || channel & CCPublicAddressSystem )
99 else if( channel != 0 )
101 Print(
"Chat: Unknown channel " + channel);
105 if (total_lenght > max_lenght)
108 int lenght =
Math.Clamp(max_lenght - name_lenght, 0, text_lenght);
111 while (pos < text_lenght)
113 tmp.param3 = params.param3.Substring(pos, lenght);
118 lenght =
Math.Clamp(text_lenght - pos, 0, max_lenght);
129 m_LastLine = (m_LastLine + 1) % m_Lines.Count();
131 ChatLine line = m_Lines.Get(m_LastLine);
134 for (
int i = 0; i < m_Lines.Count(); i++)
136 line = m_Lines.Get((m_LastLine + 1 + i) % LINE_COUNT);
137 line.m_RootWidget.SetPos(0, i * m_LineHeight);
142 line.m_RootWidget.GetPos(
x,
y);