Skip to content

Commit

Permalink
Adds Flavor Text (Monkestation#48)
Browse files Browse the repository at this point in the history
* lgtm

* aaaAAAA

* might be better idk

* flavor-examine

* info

* haaa fuck you github
  • Loading branch information
Zonespace27 authored Jan 16, 2022
1 parent dd2a007 commit 040b7ff
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3470,6 +3470,7 @@
#include "interface\interface.dm"
#include "interface\stylesheet.dm"
#include "interface\skin.dmf"
#include "monkestation\code\_HELPERS\html_emphasis.dm"
#include "monkestation\code\_HELPERS\unsorted.dm"
#include "monkestation\code\_onclick\hud\new_player.dm"
#include "monkestation\code\datums\diseases\advance\symptoms\fermentation.dm"
Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
#define MAX_NAME_LEN 42
#define MAX_BROADCAST_LEN 512
#define MAX_CHARTER_LEN 80
#define MAX_EXAMINE_LEN 256 //MONKESTATION EDIT - EXAMINE TEXT

// Is something in the IC chat filter? This is config dependent.
#define CHAT_FILTER_CHECK(T) (CONFIG_GET(flag/ic_filter_enabled) && config.ic_filter_regex && findtext(T, config.ic_filter_regex))
Expand Down
24 changes: 23 additions & 1 deletion code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
"body_markings" = "None", "legs" = "Normal Legs", "moth_wings" = "Plain",
"ipc_screen" = "Blue", "ipc_antenna" = "None", "ipc_chassis" = "Morpheus Cyberkinetics(Greyscale)",
"insect_type" = "Common Fly")
var/examine_text //MONKESTATION EDIT - EXAMINE TEXT

var/list/custom_names = list()
var/preferred_ai_core_display = "Blue"
Expand Down Expand Up @@ -223,6 +224,11 @@ GLOBAL_LIST_EMPTY(preferences_datums)
dat += "<b>Name:</b> "
dat += "<a href='?_src_=prefs;preference=name;task=input'>[real_name]</a><BR>"

//MONKESTATION EDIT START - EXAMINE TEXT
dat += "<b>Examine Text:</b> "
dat += "<a href='?_src_=prefs;preference=examine_text;task=input'>[examine_text ? examine_text : "(none)"]</a><BR>"
//MONKESTATION EDIT END

if(!(AGENDER in pref_species.species_traits))
dat += "<b>Gender:</b> <a href='?_src_=prefs;preference=gender'>[gender == MALE ? "Male" : "Female"]</a><BR>"
dat += "<b>Age:</b> <a href='?_src_=prefs;preference=age;task=input'>[age]</a><BR>"
Expand Down Expand Up @@ -1288,6 +1294,10 @@ GLOBAL_LIST_EMPTY(preferences_datums)
switch(href_list["preference"])
if("name")
real_name = pref_species.random_name(gender,1)
//MONKESTATION EDIT START - EXAMINE TEXT
if("examine_text")
examine_text = null
//MONKESTATION EDIT END
if("age")
age = rand(AGE_MIN, AGE_MAX)
if("hair")
Expand Down Expand Up @@ -1363,7 +1373,17 @@ GLOBAL_LIST_EMPTY(preferences_datums)
real_name = new_name
else
to_chat(user, "<font color='red'>Invalid name. Your name should be at least 2 and at most [MAX_NAME_LEN] characters long. It may only contain the characters A-Z, a-z, -, ' and .</font>")

//MONKESTATION EDIT START - EXAMINE TEXT
if("examine_text")
var/new_text = input(user, "Please enter new examine text: (You can +bold+, |italicize|, and _underline_ things too!)", "Character Preference") as text|null
if(!new_text)
return
if(length(new_text) > MAX_EXAMINE_LEN)
alert("Your examine text is too long. It must be no more than [MAX_EXAMINE_LEN] characters long. The current text will be trimmed down to meet the limit.")
new_text = copytext(new_text, 1, MAX_EXAMINE_LEN+1)
new_text = html_encode(new_text)
examine_text = say_emphasis(new_text)
//MONKESTATION EDIT END
if("age")
var/new_age = input(user, "Choose your character's age:\n([AGE_MIN]-[AGE_MAX])", "Character Preference") as num|null
if(new_age)
Expand Down Expand Up @@ -1964,6 +1984,8 @@ GLOBAL_LIST_EMPTY(preferences_datums)
character.real_name = real_name
character.name = character.real_name

character.examine_text = examine_text //MONKESTATION EDIT - EXAMINE TEXT

character.gender = gender
character.age = age

Expand Down
2 changes: 2 additions & 0 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car

//Character
READ_FILE(S["real_name"], real_name)
READ_FILE(S["examine_text"], examine_text) //MONKESTATION EDIT - EXAMINE TEXT
READ_FILE(S["name_is_always_random"], be_random_name)
READ_FILE(S["body_is_always_random"], be_random_body)
READ_FILE(S["gender"], gender)
Expand Down Expand Up @@ -515,6 +516,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
WRITE_FILE(S["feature_ipc_screen"], features["ipc_screen"])
WRITE_FILE(S["feature_ipc_antenna"], features["ipc_antenna"])
WRITE_FILE(S["real_name"] , real_name)
WRITE_FILE(S["examine_text"] , examine_text) //MONKESTATION EDIT - EXAMINE TEXT
WRITE_FILE(S["name_is_always_random"] , be_random_name)
WRITE_FILE(S["body_is_always_random"] , be_random_body)
WRITE_FILE(S["gender"] , gender)
Expand Down
7 changes: 7 additions & 0 deletions code/modules/mob/living/carbon/human/examine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

. = list("<span class='info'>*---------*\nThis is <EM>[!obscure_name ? name : "Unknown"]</EM>!")

//MONKESTATION EDIT START - EXAMINE TEXT
if(examine_text && !obscure_name && (real_name == name))
. += "[examine_text]\n*---------*"
else
. += "<span class='notice'>*---------*</span>"
//MONKESTATION EDIT END

var/list/obscured = check_obscured_slots()
var/skipface = (wear_mask && (wear_mask.flags_inv & HIDEFACE)) || (head && (head.flags_inv & HIDEFACE))

Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/living_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@
//is mob player controllable
var/playable = FALSE
var/flavor_text = FLAVOR_TEXT_NONE

/// Text visible on-examine
var/examine_text = null
20 changes: 20 additions & 0 deletions monkestation/code/_HELPERS/html_emphasis.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#define ENCODE_HTML_EMPHASIS(input, char, html, varname) \
var/static/regex/##varname = regex("(?<!\\\\)[char](.+?)(?<!\\\\)[char]", "g");\
input = varname.Replace_char(input, "<[html]>$1</[html]>")



/**
* Allows you to bold, underline, and italicize things using HTML encoding
*
* Takes one argument, input, which is the text you wish to emphasize
*
* Returns the emphasized input
*/
/proc/say_emphasis(input)
ENCODE_HTML_EMPHASIS(input, "\\|", "i", italics)
ENCODE_HTML_EMPHASIS(input, "\\+", "b", bold)
ENCODE_HTML_EMPHASIS(input, "_", "u", underline)
var/static/regex/remove_escape_backlashes = regex("\\\\(_|\\+|\\|)", "g") // Removes backslashes used to escape text modification.
input = remove_escape_backlashes.Replace_char(input, "$1")
return input

0 comments on commit 040b7ff

Please sign in to comment.