From 0ef3779196274358fa07a13a7852f8e8879d0c9a Mon Sep 17 00:00:00 2001 From: psq95 Date: Fri, 7 Jul 2023 23:34:48 +0100 Subject: [PATCH 1/3] Fix Silicon Examine Text Move registration of human prefs signal to flavor_text/carbon subtype. Remove human specific constraint from update_prefs_flavor_text. Add flavor_text/silicon subtype. --- code/__DEFINES/dcs/signals.dm | 18 ++++++++++++----- code/datums/elements/flavor_text.dm | 23 +++++++++++++++++----- code/modules/mob/living/silicon/silicon.dm | 3 ++- code/modules/mob/transform_procs.dm | 3 +++ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 10aa54ee..a5d77983 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -570,12 +570,21 @@ #define COMSIG_HUMAN_MELEE_UNARMED_ATTACKBY "human_melee_unarmed_attackby" ///Hit by successful disarm attack (mob/living/carbon/human/attacker,zone_targeted) #define COMSIG_HUMAN_DISARM_HIT "human_disarm_hit" -#define COMSIG_HUMAN_PREFS_COPIED_TO "human_prefs_copied_to" //from datum/preferences/copy_to(): (datum/preferences, icon_updates, roundstart_checks) -#define COMSIG_HUMAN_HARDSET_DNA "human_hardset_dna" //from mob/living/carbon/human/hardset_dna(): (ui, se, newreal_name, newblood_type, datum/species, newfeatures) -#define COMSIG_HUMAN_ON_RANDOMIZE "humman_on_randomize" //from base of proc/randomize_human() +///from datum/preferences/copy_to(): (datum/preferences, icon_updates, roundstart_checks) +#define COMSIG_HUMAN_PREFS_COPIED_TO "human_prefs_copied_to" +///from mob/living/carbon/human/hardset_dna(): (ui, se, newreal_name, newblood_type, datum/species, newfeatures) +#define COMSIG_HUMAN_HARDSET_DNA "human_hardset_dna" +///from base of proc/randomize_human() +#define COMSIG_HUMAN_ON_RANDOMIZE "humman_on_randomize" ///Whenever EquipRanked is called, called after job is set #define COMSIG_JOB_RECEIVED "job_received" +// GS13: Silicon Examine Text +// /mob/living/silicon signals + +//from datum/preferences/copy_to(): (datum/preferences, icon_updates, roundstart_checks) +#define COMSIG_SILICON_PREFS_COPIED_TO "silicon_prefs_copied_to" + // /datum/species signals ///from datum/species/on_species_gain(): (datum/species/new_species, datum/species/old_species) @@ -732,10 +741,9 @@ ///from datum/action/cyborg_small_sprite and sends when a cyborg changes modules #define COMSIG_CYBORG_MODULE_CHANGE "cyborg_module_change" - /* Attack signals. They should share the returned flags, to standardize the attack chain. */ /// tool_act -> pre_attack -> target.attackby (item.attack) -> afterattack ///Ends the attack chain. If sent early might cause posterior attacks not to happen. #define COMPONENT_CANCEL_ATTACK_CHAIN (1<<0) ///Skips the specific attack step, continuing for the next one to happen. - #define COMPONENT_SKIP_ATTACK (1<<1) \ No newline at end of file + #define COMPONENT_SKIP_ATTACK (1<<1) diff --git a/code/datums/elements/flavor_text.dm b/code/datums/elements/flavor_text.dm index 87dd0427..9cfd91e8 100644 --- a/code/datums/elements/flavor_text.dm +++ b/code/datums/elements/flavor_text.dm @@ -40,9 +40,6 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code LAZYOR(GLOB.mobs_with_editable_flavor_text[M], src) M.verbs |= /mob/proc/manage_flavor_tests - if(save_key && ishuman(target)) - RegisterSignal(target, COMSIG_HUMAN_PREFS_COPIED_TO, .proc/update_prefs_flavor_text) - /datum/element/flavor_text/Detach(atom/A) . = ..() UnregisterSignal(A, list(COMSIG_PARENT_EXAMINE, COMSIG_HUMAN_PREFS_COPIED_TO)) @@ -150,9 +147,9 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code return TRUE return FALSE -/datum/element/flavor_text/proc/update_prefs_flavor_text(mob/living/carbon/human/H, datum/preferences/P, icon_updates = TRUE, roundstart_checks = TRUE) +/datum/element/flavor_text/proc/update_prefs_flavor_text(mob/M, datum/preferences/P, icon_updates = TRUE, roundstart_checks = TRUE) if(P.features.Find(save_key)) - texts_by_atom[H] = P.features[save_key] + texts_by_atom[M] = P.features[save_key] //subtypes with additional hooks for DNA and preferences. /datum/element/flavor_text/carbon @@ -169,6 +166,7 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code RegisterSignal(target, COMSIG_CARBON_IDENTITY_TRANSFERRED_TO, .proc/update_dna_flavor_text) RegisterSignal(target, COMSIG_MOB_ANTAG_ON_GAIN, .proc/on_antag_gain) if(ishuman(target)) + RegisterSignal(target, COMSIG_HUMAN_PREFS_COPIED_TO, .proc/update_prefs_flavor_text) RegisterSignal(target, COMSIG_HUMAN_HARDSET_DNA, .proc/update_dna_flavor_text) RegisterSignal(target, COMSIG_HUMAN_ON_RANDOMIZE, .proc/unset_flavor) @@ -193,3 +191,18 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code texts_by_atom[user] = "" if(user.dna) user.dna.features[save_key] = "" + +// GS13: Silicon Examine Text +/datum/element/flavor_text/silicon + +/datum/element/flavor_text/silicon/Attach(datum/target, text = "", _name = "Flavor Text", _addendum, _max_len = MAX_FLAVOR_LEN, _always_show = FALSE, _edit = TRUE, _save_key = "flavor_text", _examine_no_preview = FALSE) + if(!issilicon(target)) + return ELEMENT_INCOMPATIBLE + . = ..() + if(. == ELEMENT_INCOMPATIBLE) + return + RegisterSignal(target, COMSIG_SILICON_PREFS_COPIED_TO, .proc/update_prefs_flavor_text) + +/datum/element/flavor_text/silicon/Detach(mob/living/carbon/C) + . = ..() + UnregisterSignal(C, list(COMSIG_SILICON_PREFS_COPIED_TO)) diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index 9e519a53..4212d263 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -57,7 +57,8 @@ /mob/living/silicon/ComponentInitialize() . = ..() - AddElement(/datum/element/flavor_text, "", "Silicon Flavor Text", "", MAX_FLAVOR_LEN, FALSE, TRUE, "silicon_flavor_text") + // GS13: Silicon Examine Text + AddElement(/datum/element/flavor_text/silicon, "", "Silicon Flavor Text", "", MAX_FLAVOR_LEN, FALSE, TRUE, "silicon_flavor_text") AddElement(/datum/element/flavor_text, "", "Temporary Flavor Text", "This should be used only for things pertaining to the current round!") /mob/living/silicon/med_hud_set_health() diff --git a/code/modules/mob/transform_procs.dm b/code/modules/mob/transform_procs.dm index 590b8058..49ade8ff 100644 --- a/code/modules/mob/transform_procs.dm +++ b/code/modules/mob/transform_procs.dm @@ -372,6 +372,9 @@ var/mob/living/silicon/robot/R = new /mob/living/silicon/robot(loc) + // GS13: Silicon Examine Text + SEND_SIGNAL(R, COMSIG_SILICON_PREFS_COPIED_TO, src) + R.gender = gender R.invisibility = 0 From d3240dec8a3758a25bb2b97c63961071cd446b1a Mon Sep 17 00:00:00 2001 From: psq95 Date: Sun, 9 Jul 2023 11:36:11 +0100 Subject: [PATCH 2/3] Fix Silicon Examine Text Update silicon flavor text in after_spawn instead of on_equip to access client prefs. --- code/modules/client/preferences.dm | 3 +++ code/modules/jobs/job_types/silicon.dm | 2 ++ code/modules/mob/transform_procs.dm | 3 --- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 5cd171cc..8e305af2 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -3000,6 +3000,9 @@ GLOBAL_LIST_EMPTY(preferences_datums) character.update_hair() character.update_body_parts() +// GS13: Silicon Examine Text +/datum/preferences/proc/copy_to_robot(mob/living/silicon/robot/cyborg, icon_updates = 1, roundstart_checks = TRUE) + SEND_SIGNAL(cyborg, COMSIG_SILICON_PREFS_COPIED_TO, src, icon_updates, roundstart_checks) /datum/preferences/proc/get_default_name(name_id) switch(name_id) diff --git a/code/modules/jobs/job_types/silicon.dm b/code/modules/jobs/job_types/silicon.dm index 42136f1f..c21268ac 100644 --- a/code/modules/jobs/job_types/silicon.dm +++ b/code/modules/jobs/job_types/silicon.dm @@ -88,3 +88,5 @@ Cyborg /datum/job/cyborg/after_spawn(mob/living/silicon/robot/R, mob/M) R.updatename(M.client) R.gender = NEUTER + // GS13: Silicon Examine Text + M.client?.prefs?.copy_to_robot(R) diff --git a/code/modules/mob/transform_procs.dm b/code/modules/mob/transform_procs.dm index 49ade8ff..590b8058 100644 --- a/code/modules/mob/transform_procs.dm +++ b/code/modules/mob/transform_procs.dm @@ -372,9 +372,6 @@ var/mob/living/silicon/robot/R = new /mob/living/silicon/robot(loc) - // GS13: Silicon Examine Text - SEND_SIGNAL(R, COMSIG_SILICON_PREFS_COPIED_TO, src) - R.gender = gender R.invisibility = 0 From 6a234681c2e2dda99971f743b0bdafc2092534c2 Mon Sep 17 00:00:00 2001 From: psq95 Date: Sun, 9 Jul 2023 13:22:14 +0100 Subject: [PATCH 3/3] Fix Silicon Examine Text Preserve newlines in flavor text. Include name and designation of cyborgs. Include OOC text. Display flavor text in chat within examine text span instead of after. --- code/datums/elements/flavor_text.dm | 14 ++++++++++++-- code/modules/client/preferences.dm | 1 + code/modules/mob/living/silicon/examine.dm | 10 +++++++--- code/modules/mob/living/silicon/robot/examine.dm | 4 ++++ modular_citadel/code/modules/client/preferences.dm | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/code/datums/elements/flavor_text.dm b/code/datums/elements/flavor_text.dm index 9cfd91e8..245f61a7 100644 --- a/code/datums/elements/flavor_text.dm +++ b/code/datums/elements/flavor_text.dm @@ -68,7 +68,7 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code if(examine_no_preview) examine_list += "\[[flavor_name]\]" return - var/msg = replacetext(text, "\n", " ") + var/msg = replacetext(text, "\n", "
") // preserve newlines if(length_char(msg) <= 40) examine_list += "[msg]" else @@ -76,14 +76,22 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code //Examine Tab stuff - Hyperstation examineTabOutput = "
" + if(ishuman(target)) //user just returned, y'know, the user's own species. dumb. var/mob/living/carbon/human/L = target if(L.gender) examineTabOutput += "[icon2html('hyperstation/icons/chat/gender.dmi', world, L.gender)]" - examineTabOutput += "[L.name] " examineTabOutput += "([L.dna.custom_species ? L.dna.custom_species : L.dna.species.name])" + // GS13: Silicon Examine Text + if(iscyborg(target)) + var/mob/living/silicon/robot/R = target + if (R.gender) + examineTabOutput += "[icon2html('hyperstation/icons/chat/gender.dmi', world, R.gender)]" + examineTabOutput += "[R.name] " + examineTabOutput += "([R.get_standard_name()])" + /* if(L.client?.prefs?.pins) //character has pins var/P = "" for(P in L.client?.prefs?.pins) @@ -91,11 +99,13 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code */ examineTabOutput += "
" examineTabOutput += "
[url_encode(msg)]" + if(ismob(target)) var/mob/M = target if(M.ooc_text) examineTabOutput += "

OOC" examineTabOutput += "
[url_encode(M.ooc_text)]" + user.client << output(examineTabOutput, "statbrowser:update_examine") //open the examine window user.client << output(null, "statbrowser:create_mobexamine") //open the examine window diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 8e305af2..675ef7be 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -3003,6 +3003,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) // GS13: Silicon Examine Text /datum/preferences/proc/copy_to_robot(mob/living/silicon/robot/cyborg, icon_updates = 1, roundstart_checks = TRUE) SEND_SIGNAL(cyborg, COMSIG_SILICON_PREFS_COPIED_TO, src, icon_updates, roundstart_checks) + cyborg.ooc_text = features["ooc_text"] /datum/preferences/proc/get_default_name(name_id) switch(name_id) diff --git a/code/modules/mob/living/silicon/examine.dm b/code/modules/mob/living/silicon/examine.dm index 37107f2d..b0cae459 100644 --- a/code/modules/mob/living/silicon/examine.dm +++ b/code/modules/mob/living/silicon/examine.dm @@ -1,6 +1,10 @@ -/mob/living/silicon/examine(mob/user) //Displays a silicon's laws to ghosts - . = ..() +/mob/living/silicon/examine(mob/user) + // GS13: Silicon Examine Text + // COMSIG_PARENT_EXAMINE is called in /mob/living/silicon/robot/examine instead of /atom/proc/examine + // to display flavour_text in the examine text span similar to /mob/living/carbon/human/examine + + //Display a silicon's laws to ghosts if(laws && isobserver(user)) . += "[src] has the following laws:" for(var/law in laws.get_law_list(include_zeroth = TRUE)) - . += law \ No newline at end of file + . += law diff --git a/code/modules/mob/living/silicon/robot/examine.dm b/code/modules/mob/living/silicon/robot/examine.dm index c49ee6cc..67616460 100644 --- a/code/modules/mob/living/silicon/robot/examine.dm +++ b/code/modules/mob/living/silicon/robot/examine.dm @@ -48,5 +48,9 @@ . += "It doesn't seem to be responding." if(DEAD) . += "It looks like its system is corrupted and requires a reset." + + // GS13: Silicon Examine Text + SEND_SIGNAL(src, COMSIG_PARENT_EXAMINE, user, .) + . += "*---------*" . += ..() diff --git a/modular_citadel/code/modules/client/preferences.dm b/modular_citadel/code/modules/client/preferences.dm index 6b8c846b..68ca7640 100644 --- a/modular_citadel/code/modules/client/preferences.dm +++ b/modular_citadel/code/modules/client/preferences.dm @@ -57,7 +57,7 @@ if(L[slot_to_string(slot)] < DEFAULT_SLOT_AMT) return TRUE -datum/preferences/copy_to(mob/living/carbon/human/character, icon_updates = 1) +/datum/preferences/copy_to(mob/living/carbon/human/character, icon_updates = 1) ..() character.give_genitals(TRUE) character.ooc_text = features["ooc_text"] //Let's update their flavor_text at least initially