mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 12:35:33 +01:00
[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:
@@ -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)
|
||||
. = ..()
|
||||
|
||||
Reference in New Issue
Block a user