blob: 137558dc326c8311838f6d13c8e90d41916000ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "Client.hpp"
void Client::AddMessage(const char *msg, int type)
{
int len_msg = strlen(msg);
char *source = new char[len_msg+1];
strcpy(source, msg);
int lines = (len_msg / oneline_len) + 1;
for(int i = lines; i < lines_in_chat; i++) {
chat[i-lines]->value(chat[i]->value());
chat[i-lines]->textfont(chat[i]->textfont());
}
int need_print = lines;
while(need_print > 0)
{
int len = strlen(source);
int size = len > oneline_len ? oneline_len : len;
char *str = new char[oneline_len + 1];
int str_ptr = oneline_len * (lines - need_print);
memcpy(str, source + str_ptr, oneline_len);
str[size] = '\0';
int spec = 0;
if(type == system_msg) spec = FL_ITALIC;
int p = lines_in_chat-need_print;
chat[p]->textfont(STD_FONT+spec);
chat[p]->value(str);
delete[] str;
need_print--;
}
delete[] source;
}
|