From: terencehill Date: Tue, 5 Jan 2021 21:49:54 +0000 (+0100) Subject: Color picker: delete color codes in a cleaner way X-Git-Tag: xonotic-v0.8.5~608^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c24bbb8a3da46a90e8be085ec8fa4dfab58cba2a;p=xonotic%2Fxonotic-data.pk3dir.git Color picker: delete color codes in a cleaner way --- diff --git a/qcsrc/menu/xonotic/colorpicker.qc b/qcsrc/menu/xonotic/colorpicker.qc index 16b71e04e..46e698c2e 100644 --- a/qcsrc/menu/xonotic/colorpicker.qc +++ b/qcsrc/menu/xonotic/colorpicker.qc @@ -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) == "^")