summaryrefslogtreecommitdiffstats
path: root/src/client/gui/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/gui/Client.cpp')
-rw-r--r--src/client/gui/Client.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/client/gui/Client.cpp b/src/client/gui/Client.cpp
index 2465ab7..137558d 100644
--- a/src/client/gui/Client.cpp
+++ b/src/client/gui/Client.cpp
@@ -1,6 +1,39 @@
#include "Client.hpp"
-void Client::ShowMessage(const char *msg)
+void Client::AddMessage(const char *msg, int type)
{
- chat->value(msg);
+ 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;
} \ No newline at end of file