]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Wrap long lines in the MOTD textlistbox. Also make safe directmenu command call
authorterencehill <piuntn@gmail.com>
Thu, 22 Aug 2013 10:17:58 +0000 (12:17 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 22 Aug 2013 12:57:02 +0000 (14:57 +0200)
qcsrc/client/Main.qc
qcsrc/menu/xonotic/textlistbox.c

index c36543bab9d15a57922031775b2bc293fb7b037c..c44e1acf213612ce83fe33c4050c2e1acc9135a2 100644 (file)
@@ -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");
 }
 
index 45bbc986c5ab3216f1299641fbd87fa1d6d88e11..c42754d3ba703b356c358caec605deae3f8fc9cc 100644 (file)
@@ -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)
 {