From: terencehill Date: Thu, 22 Aug 2013 10:17:58 +0000 (+0200) Subject: Wrap long lines in the MOTD textlistbox. Also make safe directmenu command call X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4096aef4590ab4f5f1cd6b602c5c3142054d7ad4;p=xonotic%2Fxonotic-data.pk3dir.git Wrap long lines in the MOTD textlistbox. Also make safe directmenu command call --- diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index c36543bab..c44e1acf2 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -1191,7 +1191,7 @@ void Net_ReadServerInfo() { localcmd("\nmenu_cmd directmenu Welcome serverinfo_name \"", ReadString(), "\" serverinfo_ip \"", ReadString(), - "\" serverinfo_MOTD \"", strreplace("\n", "\\n", ReadString()), + "\" serverinfo_MOTD \"", MakeConsoleSafe(strreplace("\n", "\\n", ReadString())), "\"\n"); } diff --git a/qcsrc/menu/xonotic/textlistbox.c b/qcsrc/menu/xonotic/textlistbox.c index 45bbc986c..c42754d3b 100644 --- a/qcsrc/menu/xonotic/textlistbox.c +++ b/qcsrc/menu/xonotic/textlistbox.c @@ -52,15 +52,32 @@ void XonoticTextListBox_resizeNotify(entity me, vector relOrigin, vector relSize void XonoticTextListBox_setText(entity me, string theText) { float i, k; + string ts; if(me.textbuf >= 0) buf_del(me.textbuf); me.textbuf = buf_create(); string s = strzone(theText); + me.nItems = 0; k = tokenizebyseparator(s, "\\n"); for(i = 0; i < k; ++i) - bufstr_add(me.textbuf, argv(i), 1); + { + getWrappedLine_remaining = argv(i); + if(!getWrappedLine_remaining) + { + bufstr_add(me.textbuf, "", 1); + ++me.nItems; + } + else while(getWrappedLine_remaining) + { + ts = getWrappedLine(1 - me.controlWidth, me.realFontSize, draw_TextWidth_WithColors); + if (ts != "") + { + bufstr_add(me.textbuf, ts, 1); + ++me.nItems; + } + } + } strunzone(s); - me.nItems = k; } void XonoticTextListBox_destroy(entity me) {