mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Merge pull request #5591 from CHOMPStation2/upstream-merge-14359
[MIRROR] adds the ability to use mind-based character directories
This commit is contained in:
@@ -30,12 +30,20 @@ GLOBAL_DATUM(character_directory, /datum/character_directory)
|
||||
/datum/character_directory/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
|
||||
var/list/data = ..()
|
||||
|
||||
data["personalVisibility"] = user?.client?.prefs?.show_in_directory
|
||||
data["personalTag"] = user?.client?.prefs?.directory_tag || "Unset"
|
||||
data["personalGenderTag"] = user?.client?.prefs?.directory_gendertag || "Unset" // CHOMPStation Edit: Character Directory Update
|
||||
data["personalSexualityTag"] = user?.client?.prefs?.directory_sexualitytag || "Unset" // CHOMPStation Edit: Character Directory Update
|
||||
data["personalErpTag"] = user?.client?.prefs?.directory_erptag || "Unset"
|
||||
data["personalEventTag"] = vantag_choices_list[user?.client?.prefs?.vantag_preference] //CHOMPEdit
|
||||
if (user?.mind)
|
||||
data["personalVisibility"] = user.mind.show_in_directory
|
||||
data["personalTag"] = user.mind.directory_tag || "Unset"
|
||||
data["personalErpTag"] = user.mind.directory_erptag || "Unset"
|
||||
data["personalEventTag"] = vantag_choices_list[user.client.prefs.vantag_preference] //CHOMPEdit
|
||||
data["personalGenderTag"] = user.client.prefs.directory_gendertag || "Unset" // CHOMPStation Edit: Character Directory Update
|
||||
data["personalSexualityTag"] = user.client.prefs.directory_sexualitytag || "Unset" // CHOMPStation Edit: Character Directory Update
|
||||
else if (user?.client?.prefs)
|
||||
data["personalVisibility"] = user.client.prefs.show_in_directory
|
||||
data["personalTag"] = user.client.prefs.directory_tag || "Unset"
|
||||
data["personalErpTag"] = user.client.prefs.directory_erptag || "Unset"
|
||||
data["personalEventTag"] = vantag_choices_list[user.client.prefs.vantag_preference] //CHOMPEdit
|
||||
data["personalGenderTag"] = user.client.prefs.directory_gendertag || "Unset" // CHOMPStation Edit: Character Directory Update
|
||||
data["personalSexualityTag"] = user.client.prefs.directory_sexualitytag || "Unset" // CHOMPStation Edit: Character Directory Update
|
||||
|
||||
return data
|
||||
|
||||
@@ -45,7 +53,7 @@ GLOBAL_DATUM(character_directory, /datum/character_directory)
|
||||
var/list/directory_mobs = list()
|
||||
for(var/client/C in GLOB.clients)
|
||||
// Allow opt-out.
|
||||
if(!C?.prefs?.show_in_directory)
|
||||
if(C?.mob?.mind ? !C.mob.mind.show_in_directory : !C?.prefs?.show_in_directory)
|
||||
continue
|
||||
|
||||
// These are the three vars we're trying to find
|
||||
@@ -54,12 +62,20 @@ GLOBAL_DATUM(character_directory, /datum/character_directory)
|
||||
var/species = null
|
||||
var/ooc_notes = null
|
||||
var/flavor_text = null
|
||||
var/tag = C.prefs.directory_tag || "Unset"
|
||||
var/gendertag = C.prefs.directory_gendertag || "Unset" // CHOMPStation Edit: Character Directory Update
|
||||
var/sexualitytag = C.prefs.directory_sexualitytag || "Unset" // CHOMPStation Edit: Character Directory Update
|
||||
var/erptag = C.prefs.directory_erptag || "Unset"
|
||||
var/eventtag = vantag_choices_list[C.prefs.vantag_preference] //CHOMPEdit
|
||||
var/character_ad = C.prefs.directory_ad
|
||||
var/tag
|
||||
var/erptag
|
||||
var/character_ad
|
||||
if (C.mob?.mind) //could use ternary for all three but this is more efficient
|
||||
tag = C.mob.mind.directory_tag || "Unset"
|
||||
erptag = C.mob.mind.directory_erptag || "Unset"
|
||||
character_ad = C.mob.mind.directory_ad
|
||||
else
|
||||
tag = C.prefs.directory_tag || "Unset"
|
||||
erptag = C.prefs.directory_erptag || "Unset"
|
||||
character_ad = C.prefs.directory_ad
|
||||
|
||||
//CHOMPEdit Start
|
||||
if(ishuman(C.mob))
|
||||
@@ -134,21 +150,32 @@ GLOBAL_DATUM(character_directory, /datum/character_directory)
|
||||
if(.)
|
||||
return
|
||||
|
||||
if(action == "refresh")
|
||||
// This is primarily to stop malicious users from trying to lag the server by spamming this verb
|
||||
if(!usr.checkMoveCooldown())
|
||||
to_chat(usr, "<span class='warning'>Don't spam character directory refresh.</span>")
|
||||
return
|
||||
usr.setMoveCooldown(10)
|
||||
update_tgui_static_data(usr, ui)
|
||||
return TRUE
|
||||
else
|
||||
return check_for_mind_or_prefs(usr, action, params["overwrite_prefs"])
|
||||
|
||||
/datum/character_directory/proc/check_for_mind_or_prefs(mob/user, action, overwrite_prefs)
|
||||
if (!user.client)
|
||||
return
|
||||
var/can_set_prefs = overwrite_prefs && !!user.client.prefs
|
||||
var/can_set_mind = !!user.mind
|
||||
if (!can_set_prefs && !can_set_mind)
|
||||
if (!overwrite_prefs && !!user.client.prefs)
|
||||
to_chat(user, "<span class='warning'>You cannot change these settings if you don't have a mind to save them to. Enable overwriting prefs and switch to a slot you're fine with overwriting.</span>")
|
||||
return
|
||||
switch(action)
|
||||
if("refresh")
|
||||
// This is primarily to stop malicious users from trying to lag the server by spamming this verb
|
||||
if(!usr.checkMoveCooldown())
|
||||
to_chat(usr, "<span class='warning'>Don't spam character directory refresh.</span>")
|
||||
return
|
||||
usr.setMoveCooldown(10)
|
||||
update_tgui_static_data(usr, ui)
|
||||
return TRUE
|
||||
if("setTag")
|
||||
if ("setTag")
|
||||
var/list/new_tag = tgui_input_list(usr, "Pick a new Vore tag for the character directory", "Character Tag", GLOB.char_directory_tags)
|
||||
if(!new_tag)
|
||||
return
|
||||
usr?.client?.prefs?.directory_tag = new_tag
|
||||
return TRUE
|
||||
return set_for_mind_or_prefs(user, action, new_tag, can_set_prefs, can_set_mind)
|
||||
// CHOMPStation Edit Start: Directory Update
|
||||
if("setGenderTag")
|
||||
var/list/new_gendertag = tgui_input_list(usr, "Pick a new Gender tag for the character directory. This is YOUR gender, not what you prefer.", "Character Gender Tag", GLOB.char_directory_gendertags)
|
||||
@@ -167,9 +194,23 @@ GLOBAL_DATUM(character_directory, /datum/character_directory)
|
||||
var/list/new_erptag = tgui_input_list(usr, "Pick a new ERP tag for the character directory", "Character ERP Tag", GLOB.char_directory_erptags)
|
||||
if(!new_erptag)
|
||||
return
|
||||
usr?.client?.prefs?.directory_erptag = new_erptag
|
||||
return TRUE
|
||||
//CHOMPEdit start
|
||||
return set_for_mind_or_prefs(user, action, new_erptag, can_set_prefs, can_set_mind)
|
||||
if ("setVisible")
|
||||
var/visible = TRUE
|
||||
if (can_set_mind)
|
||||
visible = user.mind.show_in_directory
|
||||
else if (can_set_prefs)
|
||||
visible = user.client.prefs.show_in_directory
|
||||
to_chat(usr, "<span class='notice'>You are now [!visible ? "shown" : "not shown"] in the directory.</span>")
|
||||
return set_for_mind_or_prefs(user, action, !visible, can_set_prefs, can_set_mind)
|
||||
if ("editAd")
|
||||
var/current_ad = (can_set_mind ? usr.mind.directory_ad : null) || (can_set_prefs ? usr.client.prefs.directory_ad : null)
|
||||
var/new_ad = sanitize(tgui_input_text(usr, "Change your character ad", "Character Ad", current_ad, multiline = TRUE, prevent_enter = TRUE), extra = 0)
|
||||
if(isnull(new_ad))
|
||||
return
|
||||
return set_for_mind_or_prefs(user, action, new_ad, can_set_prefs, can_set_mind)
|
||||
//CHOMPEdit start
|
||||
//CHOMPEdit begin
|
||||
if("setEventTag")
|
||||
var/list/names_list = list()
|
||||
for(var/C in vantag_choices_list)
|
||||
@@ -179,18 +220,36 @@ GLOBAL_DATUM(character_directory, /datum/character_directory)
|
||||
return
|
||||
usr?.client?.prefs?.vantag_preference = names_list[new_eventtag]
|
||||
return TRUE
|
||||
//CHOMPEdit end
|
||||
if("setVisible")
|
||||
usr?.client?.prefs?.show_in_directory = !usr?.client?.prefs?.show_in_directory
|
||||
to_chat(usr, "<span class='notice'>You are now [usr.client.prefs.show_in_directory ? "shown" : "not shown"] in the directory.</span>")
|
||||
return TRUE
|
||||
if("editAd")
|
||||
if(!usr?.client?.prefs)
|
||||
return
|
||||
//CHOMPEdit end
|
||||
|
||||
var/current_ad = usr.client.prefs.directory_ad
|
||||
var/new_ad = sanitize(tgui_input_text(usr, "Change your character ad", "Character Ad", current_ad, multiline = TRUE, prevent_enter = TRUE), extra = 0)
|
||||
if(isnull(new_ad))
|
||||
return
|
||||
usr.client.prefs.directory_ad = new_ad
|
||||
/datum/character_directory/proc/set_for_mind_or_prefs(mob/user, action, new_value, can_set_prefs, can_set_mind)
|
||||
can_set_prefs &&= !!user.client.prefs
|
||||
can_set_mind &&= !!user.mind
|
||||
if (!can_set_prefs && !can_set_mind)
|
||||
to_chat(user, "<span class='warning'>You seem to have lost either your mind, or your current preferences, while changing the values.[action == "editAd" ? " Here is your ad that you wrote. [new_value]" : null]</span>")
|
||||
return
|
||||
switch(action)
|
||||
if ("setTag")
|
||||
if (can_set_prefs)
|
||||
user.client.prefs.directory_tag = new_value
|
||||
if (can_set_mind)
|
||||
user.mind.directory_tag = new_value
|
||||
return TRUE
|
||||
if ("setErpTag")
|
||||
if (can_set_prefs)
|
||||
user.client.prefs.directory_erptag = new_value
|
||||
if (can_set_mind)
|
||||
user.mind.directory_erptag = new_value
|
||||
return TRUE
|
||||
if ("setVisible")
|
||||
if (can_set_prefs)
|
||||
user.client.prefs.show_in_directory = new_value
|
||||
if (can_set_mind)
|
||||
user.mind.show_in_directory = new_value
|
||||
return TRUE
|
||||
if ("editAd")
|
||||
if (can_set_prefs)
|
||||
user.client.prefs.directory_ad = new_value
|
||||
if (can_set_mind)
|
||||
user.mind.directory_ad = new_value
|
||||
return TRUE
|
||||
|
||||
Reference in New Issue
Block a user