]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/colorpicker.qc
Use checkColorCode in textLengthUpToWidth and get rid of skipIncompleteTag
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / colorpicker.qc
index c4dfa2b6b3b8fb4fad24ccb6d4786866f6060f68..16b71e04e900a7bdb43de661f1a85ca1f893ee73 100644 (file)
@@ -62,20 +62,17 @@ float XonoticColorpicker_mouseDrag(entity me, vector coords)
        for (;;)
        {
                i = me.controlledTextbox.cursorPos;
-
-               int res = checkColorCode(me.controlledTextbox.text, i);
-               if (res)
-               {
-                       int tag_length = floor(res / 10);
-                       int ofs = res % 10;
-                       for (int j = tag_length - ofs; j > 0; j--)
-                               me.controlledTextbox.keyDown(me.controlledTextbox, K_RIGHTARROW, 8, 0);
-                       for (int j = tag_length; j > 0; j--)
-                               me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
-                       continue;
-               }
-
-               break;
+               string theText = me.controlledTextbox.text;
+               vector res = checkColorCode(theText, strlen(theText), i, true);
+               if (!res.x)
+                       break;
+
+               int cc_len = res.x;
+               int ofs = res.y;
+               for (int j = cc_len - ofs; j > 0; j--)
+                       me.controlledTextbox.keyDown(me.controlledTextbox, K_RIGHTARROW, 8, 0);
+               for (int j = cc_len; j > 0; j--)
+                       me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
        }
 
        if(substring(me.controlledTextbox.text, i-1, 1) == "^")