Skip to content

Commit

Permalink
Minor fixes and improvement to Flavor Text (#2952)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

Improves and fixes issues where flavor text would sanitize certain
characters and refuse new lines while also giving new looks to the
flavor text page. Bits of codes for the popup was taken from
MapleStation but I can't find the specific PR for it.

Flavor text's length was also chopped from a whooping 4096 to 1024 for
the sake of keeping it lag free, it should still allow you to make a
pretty robust flavor text and it shouldn't really impact anyone as the
average flavor text length I've seen on a round was around 362
characters, with the highest being 645 characters.


![dreamseeker_RBS1nF48VM](https://github.com/shiptest-ss13/Shiptest/assets/66234359/8b541cf1-c51f-4893-b388-fe01b6f413fc)

Additionally changes the text a bit on the flavor text's edit popup so
it leads to less confusion.

I'm intending to do a full refactor for flavor text itself and hopefully
make use of TGUI but this might take quite a bit and I can't really make
any guarantees, so hopefully this helps for now.

## Why It's Good For The Game

<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

Flavor text has been buggy and limiting for quite a while, while this PR
doesn't solve many code shenanigans it should at least help people
describe how their characters a lot better and with less wall of texts.

As for the text changes; I believe this might make more sense and
hopefully lead to less confusion that I'd see some have when it comes to
flavor text.

## Changelog

:cl: Hardly
add: Added some style to the flavor text popup
fix: Fixed flavor text not accepting certain characters or new lines
tweak: Changed up Flavor Text editing text a bit
tweak: Flavor text's max length has been chopped from 4096 to 1024
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Co-authored-by: FalloutFalcon <[email protected]>
  • Loading branch information
Hardly3D and FalloutFalcon authored May 31, 2024
1 parent 8fa9d08 commit ebc45af
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion check_regex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ standards:

- exactly:
[
269,
268,
"non-bitwise << uses",
'(?<!\d)(?<!\d\s)(?<!<)<<(?!=|\s\d|\d|<|\/)',
]
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@

//Don't set this very much higher then 1024 unless you like inviting people in to dos your server with message spam
#define MAX_MESSAGE_LEN 1024
#define MAX_FLAVOR_LEN 1024
#define MAX_SHORTFLAVOR_LEN 100
#define MAX_NAME_LEN 42
#define MAX_BROADCAST_LEN 512
#define MAX_CHARTER_LEN 80
Expand Down
4 changes: 2 additions & 2 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1670,9 +1670,9 @@ GLOBAL_LIST_EMPTY(preferences_datums)
age = clamp(round(text2num(new_age)), pref_species.species_age_min, pref_species.species_age_max)

if("flavor_text")
var/msg = sanitize(stripped_multiline_input(usr, "Set the flavor text in your 'examine' verb. This can also be used for OOC notes and preferences!", "Flavor Text", features["flavor_text"], 4096, TRUE))
var/msg = stripped_multiline_input(usr, "A snippet of text shown when others examine you, describing what you may look like. This can also be used for OOC notes.", "Flavor Text", html_decode(features["flavor_text"]), MAX_FLAVOR_LEN, TRUE)
if(msg) //WS edit - "Cancel" does not clear flavor text
features["flavor_text"] = html_decode(msg)
features["flavor_text"] = msg

if("hair")
var/new_hair = input(user, "Choose your character's hair colour:", "Character Preference","#"+hair_color) as color|null
Expand Down
6 changes: 4 additions & 2 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,10 @@
src << browse(null, t1)

if(href_list["flavor_more"])
usr << browse(text("<HTML><HEAD><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", name, replacetext(flavor_text, "\n", "<BR>")), text("window=[];size=500x200", name))
onclose(usr, "[name]")
var/datum/browser/popup = new(usr, "[name]'s flavor text", "[name]'s Flavor Text (expanded)", 500, 200)
popup.set_content(text("<HTML><HEAD><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", "[name]'s flavor text (expanded)", replacetext(flavor_text, "\n", "<BR>")))
popup.open()
return

if(user != src)
if(href_list["item"] && user.canUseTopic(src, BE_CLOSE, NO_DEXTERITY))
Expand Down
6 changes: 3 additions & 3 deletions code/modules/mob/say_vr.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

if(usr != src)
to_chat(usr, span_warning("You can't set someone else's flavour text!"))
var/msg = sanitize(input(usr,"Set the flavor text in your 'examine' verb. Can also be used for OOC notes about your character.","Flavor Text",html_decode(flavor_text)) as message|null)
var/msg = input(usr, "A snippet of text shown when others examine you, describing what you may look like. This can also be used for OOC notes.", "Flavor Text", html_decode("flavor_text")) as message|null

if(msg)
msg = copytext(msg, 1, MAX_MESSAGE_LEN)
Expand All @@ -22,10 +22,10 @@
/mob/proc/print_flavor_text()
if(flavor_text && flavor_text != "")
var/msg = replacetext(flavor_text, "\n", " ")
if(length(msg) <= 100)
if(length(msg) <= MAX_SHORTFLAVOR_LEN)
return "<span class='notice'>[msg]</span>"
else
return "<span class='notice'>[copytext(msg, 1, 97)]... <a href=\"byond://?src=[text_ref(src)];flavor_more=1\">More...</span></a>"
return "<span class='notice'>[copytext(msg, 1, MAX_SHORTFLAVOR_LEN)]... <a href=\"byond://?src=[text_ref(src)];flavor_more=1\">More...</span></a>"

/mob/proc/get_top_level_mob()
if(istype(src.loc,/mob)&&src.loc!=src)
Expand Down

0 comments on commit ebc45af

Please sign in to comment.