diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index 2b840e6759c..3d4cfae622c 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -339,4 +339,19 @@ proc/checkhtml(var/t) /proc/trim_strip_html_properly(var/input, var/max_length = MAX_MESSAGE_LEN) return trim(strip_html_properly(input, max_length)) + +//Used in preferences' SetFlavorText and human's set_flavor verb +//Previews a string of len or less length +/proc/TextPreview(var/string,var/len=40) + if(lentext(string) <= len) + if(!lentext(string)) + return "\[...\]" + else + return string + else + return "[copytext_preserve_html(string, 1, 37)]..." + +//alternative copytext() for encoded text, doesn't break html entities (" and other) +/proc/copytext_preserve_html(var/text, var/first, var/last) + return html_encode(copytext(html_decode(text), first, last)) \ No newline at end of file diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 6c985f2a002..80b622bd20a 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -337,7 +337,7 @@ datum/preferences else dat += "[flavor_text]" else - dat += "[copytext(flavor_text, 1, 37)]...
" + dat += "[TextPreview(flavor_text, 1, 37)]...
" dat += "
" var/hairname = "Hair" diff --git a/code/modules/mob/living/carbon/human/emote.dm b/code/modules/mob/living/carbon/human/emote.dm index da2f516375b..4b50ba8c2e9 100644 --- a/code/modules/mob/living/carbon/human/emote.dm +++ b/code/modules/mob/living/carbon/human/emote.dm @@ -848,4 +848,4 @@ set desc = "Sets an extended description of your character's features." set category = "IC" - flavor_text = sanitize(copytext(input(usr, "Please enter your new flavour text.", "Flavour text", null) as text, 1)) + flavor_text = TextPreview((input(usr, "Please enter your new flavour text.", "Flavour text", null) as text, 1)) diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index 8f032a3147f..775bef4859c 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -241,7 +241,7 @@ set desc = "Sets an extended description of your character's features." set category = "IC" - flavor_text = sanitize(copytext(input(usr, "Please enter your new flavour text.", "Flavour text", null) as text, 1)) + flavor_text = sanitize(input(usr, "Please enter your new flavour text.", "Flavour text", null) as text) /mob/living/silicon/binarycheck() return 1 diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 2b94fdae71c..9cd4cb9b25f 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -605,7 +605,7 @@ var/list/slot_equipment_priority = list( \ if(lentext(msg) <= 40) return "\blue [msg]" else - return "\blue [copytext(msg, 1, 37)]... More..." + return "\blue [copytext_preserve_html(msg, 1, 37)]... More..." /mob/proc/is_dead() return stat == DEAD