From ecc7cf390f3ee4d42d3b155f062b9843c569dc01 Mon Sep 17 00:00:00 2001 From: Waterpig <49160555+Majkl-J@users.noreply.github.com> Date: Sun, 17 Nov 2024 18:00:44 +0100 Subject: [PATCH] Minor pref changes before I go utterly insane doing something else (#2447) ## About The Pull Request Makes some pref code correctly use apply_to_human and dna. This means that if you switch mind around the prefs stay the same... I wonder why I'm adding that Removes deprecated headshot var from preferences. This used to be the universal one on skyrat but since we have one for humans one for silicons it was never really used in any place that couldn't be replaced by dna on here. ## Why It's Good For The Game Makes the code more consistent. And more ready for certain *fun* activities ## Proof Of Testing
Screenshots/Videos ![image](https://github.com/user-attachments/assets/3e48def9-03e0-4556-a43b-f4d95626cfaa)
## Changelog :cl: code: Makes headshot and nsfw preference code handling more consistent with the rest. Savefiles are untouched by this /:cl: --- .../code/modules/client/preferences.dm | 3 - .../modules/client/preferences/headshot.dm | 6 +- .../modules/client/preferences_savefile.dm | 3 - .../code/modules/mob/living/examine_tgui.dm | 55 +++++++++---------- .../code/modules/client/examine_tgui.dm | 30 +++++----- .../modules/client/flavor_text/flavor_text.dm | 7 ++- 6 files changed, 49 insertions(+), 55 deletions(-) diff --git a/modular_skyrat/master_files/code/modules/client/preferences.dm b/modular_skyrat/master_files/code/modules/client/preferences.dm index aee78a01604..58d8ad82e35 100644 --- a/modular_skyrat/master_files/code/modules/client/preferences.dm +++ b/modular_skyrat/master_files/code/modules/client/preferences.dm @@ -48,9 +48,6 @@ // Determines if the player has undergone TGUI preferences migration, if so, this will prevent constant loading. var/tgui_prefs_migration = TRUE - /// A photo of the character, visible on close examine - var/headshot = "" - /// An assoc list of food types to liked or dislike values. If null or empty, default species tastes are used instead on application. /// If a food doesn't exist in this list, it uses the default value. var/list/food_preferences = list() diff --git a/modular_skyrat/master_files/code/modules/client/preferences/headshot.dm b/modular_skyrat/master_files/code/modules/client/preferences/headshot.dm index a0d396694eb..7bca4e7552b 100644 --- a/modular_skyrat/master_files/code/modules/client/preferences/headshot.dm +++ b/modular_skyrat/master_files/code/modules/client/preferences/headshot.dm @@ -11,11 +11,10 @@ var/static/list/valid_extensions = list("jpg", "png", "jpeg") // Regex works fine, if you know how it works /datum/preference/text/headshot/apply_to_human(mob/living/carbon/human/target, value, datum/preferences/preferences) - target?.dna.features["headshot"] = preferences?.headshot + target.dna.features["headshot"] = value /datum/preference/text/headshot/is_valid(value) if(!length(value)) // Just to get blank ones out of the way - usr?.client?.prefs?.headshot = null return TRUE var/find_index = findtext(value, "https://") @@ -48,6 +47,5 @@ to_chat(usr, span_notice("If the photo doesn't show up properly in-game, ensure that it's a direct image link that opens properly in a browser.")) to_chat(usr, span_notice("Keep in mind that the photo will be downsized to 250x250 pixels, so the more square the photo, the better it will look.")) log_game("[usr] has set their Headshot image to '[value]'.") - stored_link[usr?.ckey] = value - usr?.client?.prefs.headshot = value + stored_link[usr.ckey] = value return TRUE diff --git a/modular_skyrat/master_files/code/modules/client/preferences_savefile.dm b/modular_skyrat/master_files/code/modules/client/preferences_savefile.dm index bb54ae3a8c5..a09fb8e4a58 100644 --- a/modular_skyrat/master_files/code/modules/client/preferences_savefile.dm +++ b/modular_skyrat/master_files/code/modules/client/preferences_savefile.dm @@ -86,8 +86,6 @@ migrate_skyrat(save_data) addtimer(CALLBACK(src, PROC_REF(check_migration)), 10 SECONDS) - headshot = save_data["headshot"] - food_preferences = SANITIZE_LIST(save_data["food_preferences"]) var/skyrat_update = savefile_needs_update_skyrat(save_data) if(skyrat_update >= 0) @@ -278,7 +276,6 @@ save_data["allow_advanced_colors"] = allow_advanced_colors save_data["alt_job_titles"] = alt_job_titles save_data["languages"] = languages - save_data["headshot"] = headshot save_data["food_preferences"] = food_preferences if(updated) save_data["modular_version"] = MODULAR_SAVEFILE_VERSION_MAX diff --git a/modular_skyrat/master_files/code/modules/mob/living/examine_tgui.dm b/modular_skyrat/master_files/code/modules/mob/living/examine_tgui.dm index 2b5540e1b8c..275f186c113 100644 --- a/modular_skyrat/master_files/code/modules/mob/living/examine_tgui.dm +++ b/modular_skyrat/master_files/code/modules/mob/living/examine_tgui.dm @@ -59,39 +59,36 @@ var/headshot = "" // Handle OOC notes first - if(preferences && preferences.read_preference(/datum/preference/toggle/master_erp_preferences)) - var/e_prefs = preferences.read_preference(/datum/preference/choiced/erp_status) - var/e_prefs_hypno = preferences.read_preference(/datum/preference/choiced/erp_status_hypno) - var/e_prefs_v = preferences.read_preference(/datum/preference/choiced/erp_status_v) - var/e_prefs_nc = preferences.read_preference(/datum/preference/choiced/erp_status_nc) - var/e_prefs_mechanical = preferences.read_preference(/datum/preference/choiced/erp_status_mechanics) - ooc_notes += "ERP: [e_prefs]\n" - ooc_notes += "Hypnosis: [e_prefs_hypno]\n" - ooc_notes += "Vore: [e_prefs_v]\n" - ooc_notes += "Non-Con: [e_prefs_nc]\n" - ooc_notes += "ERP Mechanics: [e_prefs_mechanical]\n" - ooc_notes += "\n" + if(preferences) + if(preferences.read_preference(/datum/preference/toggle/master_erp_preferences)) + var/e_prefs = preferences.read_preference(/datum/preference/choiced/erp_status) + var/e_prefs_hypno = preferences.read_preference(/datum/preference/choiced/erp_status_hypno) + var/e_prefs_v = preferences.read_preference(/datum/preference/choiced/erp_status_v) + var/e_prefs_nc = preferences.read_preference(/datum/preference/choiced/erp_status_nc) + var/e_prefs_mechanical = preferences.read_preference(/datum/preference/choiced/erp_status_mechanics) + ooc_notes += "ERP: [e_prefs]\n" + ooc_notes += "Hypnosis: [e_prefs_hypno]\n" + ooc_notes += "Vore: [e_prefs_v]\n" + ooc_notes += "Non-Con: [e_prefs_nc]\n" + ooc_notes += "ERP Mechanics: [e_prefs_mechanical]\n" + ooc_notes += "\n" - // Now we handle silicon and/or human, order doesn't really matter - // If other variants of mob/living need to be handled at some point, put them here - if(preferences && issilicon(holder)) - flavor_text = preferences?.read_preference(/datum/preference/text/silicon_flavor_text) - // Silicon prefs and headshot - custom_species = preferences?.read_preference(/datum/preference/text/custom_species/silicon) - custom_species_lore = preferences?.read_preference(/datum/preference/text/custom_species_lore/silicon) - ooc_notes += preferences?.read_preference(/datum/preference/text/ooc_notes/silicon) - headshot += preferences?.read_preference(/datum/preference/text/headshot/silicon) - name = holder.name + // Now we handle silicon and/or human, order doesn't really matter + // If other variants of mob/living need to be handled at some point, put them here + if(issilicon(holder)) + flavor_text = preferences.read_preference(/datum/preference/text/silicon_flavor_text) + // Silicon prefs and headshot + custom_species = preferences.read_preference(/datum/preference/text/custom_species/silicon) + custom_species_lore = preferences.read_preference(/datum/preference/text/custom_species_lore/silicon) + ooc_notes += preferences.read_preference(/datum/preference/text/ooc_notes/silicon) + headshot += preferences.read_preference(/datum/preference/text/headshot/silicon) + name = holder.name if(ishuman(holder)) var/mob/living/carbon/human/holder_human = holder - obscured = ( \ - holder_human.wear_mask && \ - (holder_human.wear_mask.flags_inv & HIDEFACE)) && \ + obscured = (holder_human.wear_mask && (holder_human.wear_mask.flags_inv & HIDEFACE)) && \ obscurity_examine_pref || \ - (holder_human.head && (holder_human.head.flags_inv & HIDEFACE) && \ - obscurity_examine_pref \ - ) + (holder_human.head && (holder_human.head.flags_inv & HIDEFACE) && obscurity_examine_pref) //Check if the mob is obscured, then continue to headshot and species lore ooc_notes += holder_human.dna?.features["ooc_notes"] @@ -101,7 +98,7 @@ flavor_text = "Obscured" name = "Unknown" else - headshot += preferences?.read_preference(/datum/preference/text/headshot) + headshot = holder_human.dna.features["headshot"] flavor_text = holder_human.dna.features["flavor_text"] name = holder.name //Custom species handling. Reports the normal custom species if there is not one set. diff --git a/modular_zubbers/code/modules/client/examine_tgui.dm b/modular_zubbers/code/modules/client/examine_tgui.dm index c87148833c0..2d42d4f8cff 100644 --- a/modular_zubbers/code/modules/client/examine_tgui.dm +++ b/modular_zubbers/code/modules/client/examine_tgui.dm @@ -1,31 +1,33 @@ /datum/examine_panel/ui_data(mob/user) var/list/data = ..() var/datum/preferences/preferences = holder.client?.prefs + if(isnull(preferences)) + return ..() var/flavor_text_nsfw = "" var/headshot_nsfw = "" var/character_ad = "" - var/emote_length = preferences?.read_preference(/datum/preference/choiced/emote_length) - var/approach = preferences?.read_preference(/datum/preference/choiced/approach_pref) - var/furries = preferences?.read_preference(/datum/preference/choiced/directory_character_prefs/furry_pref) - var/scalies = preferences?.read_preference(/datum/preference/choiced/directory_character_prefs/scalie_pref) - var/others = preferences?.read_preference(/datum/preference/choiced/directory_character_prefs/other_pref) - var/demihumans = preferences?.read_preference(/datum/preference/choiced/directory_character_prefs/demihuman_pref) - var/humans = preferences?.read_preference(/datum/preference/choiced/directory_character_prefs/human_pref) - var/show_nsfw_flavor_text = preferences?.read_preference(/datum/preference/choiced/show_nsfw_flavor_text) + var/emote_length = preferences.read_preference(/datum/preference/choiced/emote_length) + var/approach = preferences.read_preference(/datum/preference/choiced/approach_pref) + var/furries = preferences.read_preference(/datum/preference/choiced/directory_character_prefs/furry_pref) + var/scalies = preferences.read_preference(/datum/preference/choiced/directory_character_prefs/scalie_pref) + var/others = preferences.read_preference(/datum/preference/choiced/directory_character_prefs/other_pref) + var/demihumans = preferences.read_preference(/datum/preference/choiced/directory_character_prefs/demihuman_pref) + var/humans = preferences.read_preference(/datum/preference/choiced/directory_character_prefs/human_pref) + var/show_nsfw_flavor_text = preferences.read_preference(/datum/preference/choiced/show_nsfw_flavor_text) if(issilicon(holder) && !(show_nsfw_flavor_text == "Never")) - flavor_text_nsfw = preferences?.read_preference(/datum/preference/text/flavor_text_nsfw/silicon) - headshot_nsfw += preferences?.read_preference(/datum/preference/text/headshot/silicon/nsfw) - if(ishuman(holder)) + flavor_text_nsfw = preferences.read_preference(/datum/preference/text/flavor_text_nsfw/silicon) + headshot_nsfw = preferences.read_preference(/datum/preference/text/headshot/silicon/nsfw) + else if(ishuman(holder)) var/mob/living/carbon/human/holder_human = holder if((show_nsfw_flavor_text == "Always On") || (show_nsfw_flavor_text == "Nude Only" && !(holder_human.w_uniform))) - flavor_text_nsfw = preferences?.read_preference(/datum/preference/text/flavor_text_nsfw) - headshot_nsfw += preferences?.read_preference(/datum/preference/text/headshot/nsfw) + flavor_text_nsfw = holder_human.dna.features["flavor_text_nsfw"] + headshot_nsfw = holder_human.dna.features["headshot_nsfw"] character_ad += "Preferred Emote Length: [emote_length]\n" character_ad += "How to Approach: [approach]\n" character_ad += "Furries: [furries] | Scalies: [scalies] | Other: [others]\n" character_ad += "Demis: [demihumans] | Humans: [humans]\n" character_ad += "\n" - character_ad += preferences?.read_preference(/datum/preference/text/character_ad) + character_ad += preferences.read_preference(/datum/preference/text/character_ad) data["character_ad"] = character_ad data["flavor_text_nsfw"] = flavor_text_nsfw diff --git a/modular_zubbers/code/modules/client/flavor_text/flavor_text.dm b/modular_zubbers/code/modules/client/flavor_text/flavor_text.dm index 247effc329c..f53deb57077 100644 --- a/modular_zubbers/code/modules/client/flavor_text/flavor_text.dm +++ b/modular_zubbers/code/modules/client/flavor_text/flavor_text.dm @@ -21,12 +21,15 @@ return "" /datum/preference/text/flavor_text_nsfw/apply_to_human(mob/living/carbon/human/target, value, datum/preferences/preferences) - return FALSE + target.dna.features["flavor_text_nsfw"] = value //This is just a silicon variant of the NSFW flavor text. /datum/preference/text/flavor_text_nsfw/silicon savefile_key = "silicon_flavor_text_nsfw" +/datum/preference/text/flavor_text_nsfw/silicon/apply_to_human(mob/living/carbon/human/target, value, datum/preferences/preferences) + return FALSE + //Lets the client choose when their NSFW flavor text is visible on a per-character basis. /datum/preference/choiced/show_nsfw_flavor_text category = PREFERENCE_CATEGORY_NON_CONTEXTUAL @@ -50,7 +53,7 @@ savefile_key = "headshot_nsfw" /datum/preference/text/headshot/nsfw/apply_to_human(mob/living/carbon/human/target, value, datum/preferences/preferences) - return FALSE + target.dna.features["headshot_nsfw"] = value /datum/preference/text/headshot/nsfw/apply_headshot(value) if(stored_link[usr.ckey] != value)