[MIRROR] Fix crayon text input (#7779)

* Fix crayon text input (#61002)

The regex expression being used missed some symbols and screwed up spacing.

* Fix crayon text input

Co-authored-by: Tim <timothymtorres@gmail.com>
This commit is contained in:
SkyratBot
2021-08-26 23:46:57 +02:00
committed by GitHub
parent fa206676e3
commit 3f9eeb55b9
+11 -5
View File
@@ -250,9 +250,14 @@
if("select_colour")
. = can_change_colour && select_colour(usr)
if("enter_text")
var/txt = stripped_input(usr,"Choose what to write.",
"Scribbles",default = text_buffer)
text_buffer = crayon_text_strip(txt)
var/txt = input(usr, "Choose what to write.", "Scribbles", text_buffer) as text|null
if(isnull(txt))
return
txt = crayon_text_strip(txt)
if(text_buffer == txt)
return // No valid changes.
text_buffer = txt
. = TRUE
paint_mode = PAINT_NORMAL
drawtype = "a"
@@ -266,8 +271,9 @@
return FALSE
/obj/item/toy/crayon/proc/crayon_text_strip(text)
var/static/regex/crayon_r = new /regex(@"[^\w!?,.=%#&+\/\-]")
return replacetext(lowertext(text), crayon_r, "")
text = copytext(text, 1, MAX_MESSAGE_LEN)
var/static/regex/crayon_regex = new /regex(@"[^\w!?,.=&%#+/\-]", "ig")
return lowertext(crayon_regex.Replace(text, ""))
/obj/item/toy/crayon/afterattack(atom/target, mob/user, proximity, params)
. = ..()