]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Color picker: delete color codes in a cleaner way
authorterencehill <piuntn@gmail.com>
Tue, 5 Jan 2021 21:49:54 +0000 (22:49 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 5 Jan 2021 21:49:54 +0000 (22:49 +0100)
qcsrc/menu/xonotic/colorpicker.qc

index 16b71e04e900a7bdb43de661f1a85ca1f893ee73..46e698c2e2a1d6a9497ab6c25ffc350b776948ad 100644 (file)
@@ -68,11 +68,10 @@ float XonoticColorpicker_mouseDrag(entity me, vector coords)
                        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);
+               int new_pos = i - res.y;
+               theText = strcat(substring(theText, 0, new_pos), substring(theText, new_pos + cc_len, -1));
+               me.controlledTextbox.setText(me.controlledTextbox, theText);
+               me.controlledTextbox.cursorPos = new_pos;
        }
 
        if(substring(me.controlledTextbox.text, i-1, 1) == "^")