mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +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:
@@ -1,2 +1,14 @@
|
||||
/datum/mind
|
||||
var/vore_death = FALSE // Was our last gasp a gurgle?
|
||||
var/show_in_directory
|
||||
var/directory_tag
|
||||
var/directory_erptag
|
||||
var/directory_ad
|
||||
|
||||
/mob/living/mind_initialize()
|
||||
. = ..()
|
||||
if (client?.prefs)
|
||||
mind.show_in_directory = client.prefs.show_in_directory
|
||||
mind.directory_tag = client.prefs.directory_tag
|
||||
mind.directory_erptag = client.prefs.directory_erptag
|
||||
mind.directory_ad = client.prefs.directory_ad
|
||||
|
||||
@@ -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,8 +150,7 @@ GLOBAL_DATUM(character_directory, /datum/character_directory)
|
||||
if(.)
|
||||
return
|
||||
|
||||
switch(action)
|
||||
if("refresh")
|
||||
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>")
|
||||
@@ -143,12 +158,24 @@ GLOBAL_DATUM(character_directory, /datum/character_directory)
|
||||
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 ("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
|
||||
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)
|
||||
@@ -180,17 +221,35 @@ GLOBAL_DATUM(character_directory, /datum/character_directory)
|
||||
usr?.client?.prefs?.vantag_preference = names_list[new_eventtag]
|
||||
return TRUE
|
||||
//CHOMPEdit end
|
||||
|
||||
/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")
|
||||
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>")
|
||||
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(!usr?.client?.prefs)
|
||||
return
|
||||
|
||||
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
|
||||
if (can_set_prefs)
|
||||
user.client.prefs.directory_ad = new_value
|
||||
if (can_set_mind)
|
||||
user.mind.directory_ad = new_value
|
||||
return TRUE
|
||||
|
||||
@@ -30,22 +30,43 @@ export const CharacterDirectory = (props, context) => {
|
||||
|
||||
const [overlay, setOverlay] = useLocalState(context, 'overlay', null);
|
||||
|
||||
const [overwritePrefs, setOverwritePrefs] = useLocalState(context, 'overwritePrefs', false);
|
||||
|
||||
return (
|
||||
<Window width={816} height={722} resizeable>
|
||||
<Window.Content scrollable>
|
||||
{(overlay && <ViewCharacter />) || (
|
||||
<Fragment>
|
||||
<Section
|
||||
title="Controls"
|
||||
buttons={
|
||||
<Fragment>
|
||||
<Box color="label" inline>
|
||||
Save to current preferences slot:
|
||||
</Box>
|
||||
<Button
|
||||
icon={overwritePrefs ? 'toggle-on' : 'toggle-off'}
|
||||
selected={overwritePrefs}
|
||||
content={overwritePrefs ? 'On' : 'Off'}
|
||||
onClick={() => setOverwritePrefs(!overwritePrefs)}
|
||||
/>
|
||||
</Fragment>
|
||||
}>
|
||||
<Section title="Settings and Preferences">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Visibility">
|
||||
<Button
|
||||
fluid
|
||||
content={personalVisibility ? 'Shown' : 'Not Shown'}
|
||||
onClick={() => act('setVisible')}
|
||||
onClick={() => act('setVisible', { overwrite_prefs: overwritePrefs })}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Vore Tag">
|
||||
<Button fluid content={personalTag} onClick={() => act('setTag')} />
|
||||
<Button
|
||||
fluid
|
||||
content={personalTag}
|
||||
onClick={() => act('setTag', { overwrite_prefs: overwritePrefs })}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Gender">
|
||||
<Button fluid content={personalGenderTag} onClick={() => act('setGenderTag')} />
|
||||
@@ -54,13 +75,17 @@ export const CharacterDirectory = (props, context) => {
|
||||
<Button fluid content={personalSexualityTag} onClick={() => act('setSexualityTag')} />
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="ERP Tag">
|
||||
<Button fluid content={personalErpTag} onClick={() => act('setErpTag')} />
|
||||
<Button
|
||||
fluid
|
||||
content={personalErpTag}
|
||||
onClick={() => act('setErpTag', { overwrite_prefs: overwritePrefs })}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Event Pref">
|
||||
<Button fluid content={personalEventTag} onClick={() => act('setEventTag')} />
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Advertisement">
|
||||
<Button fluid content="Edit Ad" onClick={() => act('editAd')} />
|
||||
<Button fluid content="Edit Ad" onClick={() => act('editAd', { overwrite_prefs: overwritePrefs })} />
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
|
||||
Reference in New Issue
Block a user