From 222e4cdbdc0a9ea2aa4a2792e08031ed9bdbbf2a Mon Sep 17 00:00:00 2001 From: Aura Dusklight <46622484+NovaDusklight@users.noreply.github.com> Date: Mon, 4 May 2026 00:08:15 +0200 Subject: [PATCH] Convert background prefs, and records to TG (#19417) * attempt to migrate all background prefs.. * compiles * separate background and record prefs * move some things for clarity.. --------- Co-authored-by: Cameron Lennox --- code/game/gamemodes/game_mode.dm | 5 +- code/game/jobs/job/job.dm | 2 +- .../preference_setup/general/05_background.dm | 175 -------------- code/modules/client/preferences.dm | 10 - .../preferences/types/character/background.dm | 213 ++++++++++++++++++ .../preferences/types/character/records.dm | 105 +++++++++ code/modules/client/record_updater.dm | 6 +- vorestation.dme | 3 +- 8 files changed, 327 insertions(+), 192 deletions(-) delete mode 100644 code/modules/client/preference_setup/general/05_background.dm create mode 100644 code/modules/client/preferences/types/character/background.dm create mode 100644 code/modules/client/preferences/types/character/records.dm diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm index 8d1f274f72..adeaa847b5 100644 --- a/code/game/gamemodes/game_mode.dm +++ b/code/game/gamemodes/game_mode.dm @@ -516,9 +516,10 @@ GLOBAL_LIST_EMPTY(additional_antag_types) var/list/dudes = list() for(var/mob/living/carbon/human/man in GLOB.player_list) if(man.client) - if((man.client.prefs.economic_status == CLASS_LOWER) || (man.client.prefs.economic_status == CLASS_BROKE)) + var/econ_status = man.client.prefs.read_preference(/datum/preference/choiced/human/economic_status) + if((econ_status == CLASS_LOWER) || (econ_status == CLASS_BROKE)) dudes += man - else if(man.client.prefs.economic_status == CLASS_LOWMID && prob(50)) + else if(econ_status == CLASS_LOWMID && prob(50)) dudes += man if(dudes.len == 0) return null return pick(dudes) diff --git a/code/game/jobs/job/job.dm b/code/game/jobs/job/job.dm index b4da026d6e..cff224477d 100644 --- a/code/game/jobs/job/job.dm +++ b/code/game/jobs/job/job.dm @@ -93,7 +93,7 @@ var/income = 1 if(H.client) - switch(H.client.prefs.economic_status) + switch(H.client.prefs.read_preference(/datum/preference/choiced/human/economic_status)) if(CLASS_UPPER) income = 1.30 if(CLASS_UPMID) income = 1.15 if(CLASS_MIDDLE) income = 1 diff --git a/code/modules/client/preference_setup/general/05_background.dm b/code/modules/client/preference_setup/general/05_background.dm deleted file mode 100644 index f2f0e43413..0000000000 --- a/code/modules/client/preference_setup/general/05_background.dm +++ /dev/null @@ -1,175 +0,0 @@ -/datum/category_item/player_setup_item/general/background - name = "Background" - sort_order = 5 -/datum/category_item/player_setup_item/general/background/load_character(list/save_data) - pref.med_record = save_data["med_record"] - pref.sec_record = save_data["sec_record"] - pref.gen_record = save_data["gen_record"] - pref.home_system = save_data["home_system"] - pref.birthplace = save_data["birthplace"] - pref.citizenship = save_data["citizenship"] - pref.faction = save_data["faction"] - pref.religion = save_data["religion"] - pref.economic_status = save_data["economic_status"] - -/datum/category_item/player_setup_item/general/background/save_character(list/save_data) - save_data["med_record"] = pref.med_record - save_data["sec_record"] = pref.sec_record - save_data["gen_record"] = pref.gen_record - save_data["home_system"] = pref.home_system - save_data["birthplace"] = pref.birthplace - save_data["citizenship"] = pref.citizenship - save_data["faction"] = pref.faction - save_data["religion"] = pref.religion - save_data["economic_status"] = pref.economic_status - -/datum/category_item/player_setup_item/general/background/sanitize_character() - if(!pref.home_system) pref.home_system = "Unset" - if(!pref.birthplace) pref.birthplace = "Unset" - if(!pref.citizenship) pref.citizenship = "None" - if(!pref.faction) pref.faction = "None" - if(!pref.religion) pref.religion = "None" - - pref.economic_status = sanitize_inlist(pref.economic_status, ECONOMIC_CLASS, initial(pref.economic_status)) - -// Moved from /datum/preferences/proc/copy_to() -/datum/category_item/player_setup_item/general/background/copy_to_mob(var/mob/living/carbon/human/character) - character.med_record = pref.med_record - character.sec_record = pref.sec_record - character.gen_record = pref.gen_record - character.home_system = pref.home_system - character.birthplace = pref.birthplace - character.citizenship = pref.citizenship - character.personal_faction = pref.faction - character.religion = pref.religion - -/datum/category_item/player_setup_item/general/background/tgui_data(mob/user) - var/list/data = ..() - - data["economic_status"] = pref.economic_status - data["home_system"] = pref.home_system - data["birthplace"] = pref.birthplace - data["citizenship"] = pref.citizenship - data["faction"] = pref.faction - data["religion"] = pref.religion - data["ooc_note_style"] = pref.read_preference(/datum/preference/toggle/living/ooc_notes_style) - - if(jobban_isbanned(user, "Records")) - data["records_banned"] = TRUE - else - data["records_banned"] = FALSE - - data["med_record"] = TextPreview(pref.med_record,40) - data["gen_record"] = TextPreview(pref.gen_record,40) - data["sec_record"] = TextPreview(pref.sec_record,40) - - return data - -/datum/category_item/player_setup_item/general/background/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state) - . = ..() - if(.) - return - - var/mob/user = ui.user - switch(action) - if("econ_status") - var/new_class = tgui_input_list(user, "Choose your economic status. This will affect the amount of money you will start with.", "Character Preference", ECONOMIC_CLASS, pref.economic_status) - if(new_class) - pref.economic_status = new_class - return TOPIC_REFRESH - - if("home_system") - var/choice = tgui_input_list(user, "Please choose your home planet and/or system. This should be your current primary residence. Select \"Other\" to specify manually.", "Character Preference", GLOB.home_system_choices + list("Unset","Other"), pref.home_system) - if(!choice || !CanUseTopic(user)) - return TOPIC_NOACTION - if(choice == "Other") - var/raw_choice = strip_html_simple(tgui_input_text(user, "Please enter a home system.", "Character Preference", null, MAX_NAME_LEN), MAX_NAME_LEN) - if(raw_choice) - pref.home_system = raw_choice - else - pref.home_system = choice - return TOPIC_REFRESH - - if("birthplace") - var/choice = tgui_input_list(user, "Please choose the planet and/or system or other appropriate location that you were born/created. Select \"Other\" to specify manually.", "Character Preference", GLOB.home_system_choices + list("Unset","Other"), pref.birthplace) - if(!choice || !CanUseTopic(user)) - return TOPIC_NOACTION - if(choice == "Other") - var/raw_choice = strip_html_simple(tgui_input_text(user, "Please enter a birthplace.", "Character Preference", null, MAX_NAME_LEN), MAX_NAME_LEN) - if(raw_choice) - pref.birthplace = raw_choice - else - pref.birthplace = choice - return TOPIC_REFRESH - - if("citizenship") - var/choice = tgui_input_list(user, "Please select the faction or political entity with which you currently hold citizenship. Select \"Other\" to specify manually.", "Character Preference", GLOB.citizenship_choices + list("None","Other"), pref.citizenship) - if(!choice || !CanUseTopic(user)) - return TOPIC_NOACTION - if(choice == "Other") - var/raw_choice = strip_html_simple(tgui_input_text(user, "Please enter your current citizenship.", "Character Preference", null, MAX_NAME_LEN), MAX_NAME_LEN) - if(raw_choice) - pref.citizenship = raw_choice - else - pref.citizenship = choice - return TOPIC_REFRESH - - if("faction") - var/choice = tgui_input_list(user, "Please choose the faction you primarily work for, if you are not under the direct employ of NanoTrasen. Select \"Other\" to specify manually.", "Character Preference", GLOB.faction_choices + list("None","Other"), pref.faction) - if(!choice || !CanUseTopic(user)) - return TOPIC_NOACTION - if(choice == "Other") - var/raw_choice = strip_html_simple(tgui_input_text(user, "Please enter a faction.", "Character Preference", null, MAX_NAME_LEN), MAX_NAME_LEN) - if(raw_choice) - pref.faction = raw_choice - else - pref.faction = choice - return TOPIC_REFRESH - - if("religion") - var/choice = tgui_input_list(user, "Please choose a religion. Select \"Other\" to specify manually.", "Character Preference", GLOB.religion_choices + list("None","Other"), pref.religion) - if(!choice || !CanUseTopic(user)) - return TOPIC_NOACTION - if(choice == "Other") - var/raw_choice = strip_html_simple(tgui_input_text(user, "Please enter a religon.", "Character Preference", null, MAX_NAME_LEN), MAX_NAME_LEN) - if(raw_choice) - pref.religion = sanitize(raw_choice) - else - pref.religion = choice - return TOPIC_REFRESH - - if("set_medical_records") - var/new_medical = strip_html_simple(tgui_input_text(user,"Enter medical information here.","Character Preference", html_decode(pref.med_record), MAX_RECORD_LENGTH, TRUE, prevent_enter = TRUE), MAX_RECORD_LENGTH) - if(new_medical && !jobban_isbanned(user, JOB_RECORDS)) - pref.med_record = new_medical - return TOPIC_REFRESH - - if("set_general_records") - var/new_general = strip_html_simple(tgui_input_text(user,"Enter employment information here.","Character Preference", html_decode(pref.gen_record), MAX_RECORD_LENGTH, TRUE, prevent_enter = TRUE), MAX_RECORD_LENGTH) - if(new_general && !jobban_isbanned(user, JOB_RECORDS)) - pref.gen_record = new_general - return TOPIC_REFRESH - - if("set_security_records") - var/sec_medical = strip_html_simple(tgui_input_text(user,"Enter security information here.","Character Preference", html_decode(pref.sec_record), MAX_RECORD_LENGTH, TRUE, prevent_enter = TRUE), MAX_RECORD_LENGTH) - if(sec_medical && !jobban_isbanned(user, JOB_RECORDS)) - pref.sec_record = sec_medical - return TOPIC_REFRESH - - if("reset_medrecord") - var/resetmed_choice = tgui_alert(user, "Wipe your Medical Records? This cannot be reverted if you have not saved your character recently! You may wish to make a backup first.","Reset Records",list("Yes","No")) - if(resetmed_choice == "Yes") - pref.med_record = null - return TOPIC_REFRESH - - if("reset_emprecord") - var/resetemp_choice = tgui_alert(user, "Wipe your Employment Records? This cannot be reverted if you have not saved your character recently! You may wish to make a backup first.","Reset Records",list("Yes","No")) - if(resetemp_choice == "Yes") - pref.gen_record = null - return TOPIC_REFRESH - - if("reset_secrecord") - var/resetsec_choice = tgui_alert(user, "Wipe your Security Records? This cannot be reverted if you have not saved your character recently! You may wish to make a backup first.","Reset Records",list("Yes","No")) - if(resetsec_choice == "Yes") - pref.sec_record = null - return TOPIC_REFRESH diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 920ca0f315..ac976eb254 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -42,11 +42,6 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/digitigrade = 0 //Some faction information. - var/home_system = "Unset" //Current home or residence. - var/birthplace = "Unset" //Location of birth. - var/citizenship = "None" //Government or similar entity with which you hold citizenship. - var/faction = "None" //General associated faction. - var/religion = "None" //Religious association. var/antag_faction = "None" //Antag associated faction. var/antag_vis = "Hidden" //How visible antag association is to others. @@ -93,13 +88,8 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/list/flavour_texts_robot = list() var/custom_link = null - var/med_record = "" - var/sec_record = "" - var/gen_record = "" var/exploit_record = "" - var/economic_status = "Average" - var/client/client = null var/client_ckey = null diff --git a/code/modules/client/preferences/types/character/background.dm b/code/modules/client/preferences/types/character/background.dm new file mode 100644 index 0000000000..2d80c36aee --- /dev/null +++ b/code/modules/client/preferences/types/character/background.dm @@ -0,0 +1,213 @@ +// Character background preferences +// Handles "Background Information" pref section + +/datum/preference/text/human/home_system + savefile_key = "home_system" + savefile_identifier = PREFERENCE_CHARACTER + category = PREFERENCE_CATEGORY_NON_CONTEXTUAL + can_randomize = FALSE + maximum_value_length = MAX_NAME_LEN + +/datum/preference/text/human/home_system/create_default_value() + return "Unset" + +/datum/preference/text/human/home_system/pref_deserialize(input, datum/preferences/preferences) + if(!input || !istext(input)) + return create_default_value() + return STRIP_HTML_SIMPLE(input, maximum_value_length) + +/datum/preference/text/human/home_system/apply_to_human(mob/living/carbon/human/target, value) + target.home_system = value + +/datum/preference/text/human/birthplace + savefile_key = "birthplace" + savefile_identifier = PREFERENCE_CHARACTER + category = PREFERENCE_CATEGORY_NON_CONTEXTUAL + can_randomize = FALSE + maximum_value_length = MAX_NAME_LEN + +/datum/preference/text/human/birthplace/create_default_value() + return "Unset" + +/datum/preference/text/human/birthplace/pref_deserialize(input, datum/preferences/preferences) + if(!input || !istext(input)) + return create_default_value() + return STRIP_HTML_SIMPLE(input, maximum_value_length) + +/datum/preference/text/human/birthplace/apply_to_human(mob/living/carbon/human/target, value) + target.birthplace = value + +/datum/preference/text/human/citizenship + savefile_key = "citizenship" + savefile_identifier = PREFERENCE_CHARACTER + category = PREFERENCE_CATEGORY_NON_CONTEXTUAL + can_randomize = FALSE + maximum_value_length = MAX_NAME_LEN + +/datum/preference/text/human/citizenship/create_default_value() + return "None" + +/datum/preference/text/human/citizenship/pref_deserialize(input, datum/preferences/preferences) + if(!input || !istext(input)) + return create_default_value() + return STRIP_HTML_SIMPLE(input, maximum_value_length) + +/datum/preference/text/human/citizenship/apply_to_human(mob/living/carbon/human/target, value) + target.citizenship = value + +/datum/preference/text/human/faction + savefile_key = "faction" + savefile_identifier = PREFERENCE_CHARACTER + category = PREFERENCE_CATEGORY_NON_CONTEXTUAL + can_randomize = FALSE + maximum_value_length = MAX_NAME_LEN + +/datum/preference/text/human/faction/create_default_value() + return "None" + +/datum/preference/text/human/faction/pref_deserialize(input, datum/preferences/preferences) + if(!input || !istext(input)) + return create_default_value() + return STRIP_HTML_SIMPLE(input, maximum_value_length) + +/datum/preference/text/human/faction/apply_to_human(mob/living/carbon/human/target, value) + target.personal_faction = value + +/datum/preference/text/human/religion + savefile_key = "religion" + savefile_identifier = PREFERENCE_CHARACTER + category = PREFERENCE_CATEGORY_NON_CONTEXTUAL + can_randomize = FALSE + maximum_value_length = MAX_NAME_LEN + +/datum/preference/text/human/religion/create_default_value() + return "None" + +/datum/preference/text/human/religion/pref_deserialize(input, datum/preferences/preferences) + if(!input || !istext(input)) + return create_default_value() + return STRIP_HTML_SIMPLE(input, maximum_value_length) + +/datum/preference/text/human/religion/apply_to_human(mob/living/carbon/human/target, value) + target.religion = value + +// Economic Status + +/datum/preference/choiced/human/economic_status + savefile_key = "economic_status" + savefile_identifier = PREFERENCE_CHARACTER + category = PREFERENCE_CATEGORY_NON_CONTEXTUAL + can_randomize = FALSE + +/datum/preference/choiced/human/economic_status/init_possible_values() + return ECONOMIC_CLASS + +/datum/preference/choiced/human/economic_status/create_default_value() + return "Average" + +/datum/preference/choiced/human/economic_status/apply_to_human(mob/living/carbon/human/target, value) + return // Economic status is read directly from prefs when needed, not stored on the mob. + +// Bay UI Bridge + +/datum/category_item/player_setup_item/general/background + name = "Background" + sort_order = 5 + +/datum/category_item/player_setup_item/general/background/load_character(list/save_data) + return + +/datum/category_item/player_setup_item/general/background/save_character(list/save_data) + return + +/datum/category_item/player_setup_item/general/background/sanitize_character() + return + +/datum/category_item/player_setup_item/general/background/copy_to_mob(var/mob/living/carbon/human/character) + return + +/datum/category_item/player_setup_item/general/background/tgui_data(mob/user) + var/list/data = ..() + + data["economic_status"] = pref.read_preference(/datum/preference/choiced/human/economic_status) + data["home_system"] = pref.read_preference(/datum/preference/text/human/home_system) + data["birthplace"] = pref.read_preference(/datum/preference/text/human/birthplace) + data["citizenship"] = pref.read_preference(/datum/preference/text/human/citizenship) + data["faction"] = pref.read_preference(/datum/preference/text/human/faction) + data["religion"] = pref.read_preference(/datum/preference/text/human/religion) + data["ooc_note_style"] = pref.read_preference(/datum/preference/toggle/living/ooc_notes_style) + + return data + +/datum/category_item/player_setup_item/general/background/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state) + . = ..() + if(.) + return + + var/mob/user = ui.user + switch(action) + if("econ_status") + var/new_class = tgui_input_list(user, "Choose your economic status. This will affect the amount of money you will start with.", "Character Preference", ECONOMIC_CLASS, pref.read_preference(/datum/preference/choiced/human/economic_status)) + if(new_class) + pref.write_preference_by_type(/datum/preference/choiced/human/economic_status, new_class) + return TOPIC_REFRESH + + if("home_system") + var/choice = tgui_input_list(user, "Please choose your home planet and/or system. This should be your current primary residence. Select \"Other\" to specify manually.", "Character Preference", GLOB.home_system_choices + list("Unset","Other"), pref.read_preference(/datum/preference/text/human/home_system)) + if(!choice || !CanUseTopic(user)) + return TOPIC_NOACTION + if(choice == "Other") + var/raw_choice = strip_html_simple(tgui_input_text(user, "Please enter a home system.", "Character Preference", null, MAX_NAME_LEN), MAX_NAME_LEN) + if(raw_choice) + pref.write_preference_by_type(/datum/preference/text/human/home_system, raw_choice) + else + pref.write_preference_by_type(/datum/preference/text/human/home_system, choice) + return TOPIC_REFRESH + + if("birthplace") + var/choice = tgui_input_list(user, "Please choose the planet and/or system or other appropriate location that you were born/created. Select \"Other\" to specify manually.", "Character Preference", GLOB.home_system_choices + list("Unset","Other"), pref.read_preference(/datum/preference/text/human/birthplace)) + if(!choice || !CanUseTopic(user)) + return TOPIC_NOACTION + if(choice == "Other") + var/raw_choice = strip_html_simple(tgui_input_text(user, "Please enter a birthplace.", "Character Preference", null, MAX_NAME_LEN), MAX_NAME_LEN) + if(raw_choice) + pref.write_preference_by_type(/datum/preference/text/human/birthplace, raw_choice) + else + pref.write_preference_by_type(/datum/preference/text/human/birthplace, choice) + return TOPIC_REFRESH + + if("citizenship") + var/choice = tgui_input_list(user, "Please select the faction or political entity with which you currently hold citizenship. Select \"Other\" to specify manually.", "Character Preference", GLOB.citizenship_choices + list("None","Other"), pref.read_preference(/datum/preference/text/human/citizenship)) + if(!choice || !CanUseTopic(user)) + return TOPIC_NOACTION + if(choice == "Other") + var/raw_choice = strip_html_simple(tgui_input_text(user, "Please enter your current citizenship.", "Character Preference", null, MAX_NAME_LEN), MAX_NAME_LEN) + if(raw_choice) + pref.write_preference_by_type(/datum/preference/text/human/citizenship, raw_choice) + else + pref.write_preference_by_type(/datum/preference/text/human/citizenship, choice) + return TOPIC_REFRESH + + if("faction") + var/choice = tgui_input_list(user, "Please choose the faction you primarily work for, if you are not under the direct employ of NanoTrasen. Select \"Other\" to specify manually.", "Character Preference", GLOB.faction_choices + list("None","Other"), pref.read_preference(/datum/preference/text/human/faction)) + if(!choice || !CanUseTopic(user)) + return TOPIC_NOACTION + if(choice == "Other") + var/raw_choice = strip_html_simple(tgui_input_text(user, "Please enter a faction.", "Character Preference", null, MAX_NAME_LEN), MAX_NAME_LEN) + if(raw_choice) + pref.write_preference_by_type(/datum/preference/text/human/faction, raw_choice) + else + pref.write_preference_by_type(/datum/preference/text/human/faction, choice) + return TOPIC_REFRESH + + if("religion") + var/choice = tgui_input_list(user, "Please choose a religion. Select \"Other\" to specify manually.", "Character Preference", GLOB.religion_choices + list("None","Other"), pref.read_preference(/datum/preference/text/human/religion)) + if(!choice || !CanUseTopic(user)) + return TOPIC_NOACTION + if(choice == "Other") + var/raw_choice = strip_html_simple(tgui_input_text(user, "Please enter a religon.", "Character Preference", null, MAX_NAME_LEN), MAX_NAME_LEN) + if(raw_choice) + pref.write_preference_by_type(/datum/preference/text/human/religion, sanitize(raw_choice)) + else + pref.write_preference_by_type(/datum/preference/text/human/religion, choice) + return TOPIC_REFRESH diff --git a/code/modules/client/preferences/types/character/records.dm b/code/modules/client/preferences/types/character/records.dm new file mode 100644 index 0000000000..65e2d87434 --- /dev/null +++ b/code/modules/client/preferences/types/character/records.dm @@ -0,0 +1,105 @@ +// Character employment, medical, and security records. +// Separated from background preferences where it was handled. + +/datum/preference/text/human/med_record + savefile_key = "med_record" + savefile_identifier = PREFERENCE_CHARACTER + category = PREFERENCE_CATEGORY_NON_CONTEXTUAL + can_randomize = FALSE + maximum_value_length = MAX_RECORD_LENGTH + +/datum/preference/text/human/med_record/apply_to_human(mob/living/carbon/human/target, value) + target.med_record = value + +/datum/preference/text/human/sec_record + savefile_key = "sec_record" + savefile_identifier = PREFERENCE_CHARACTER + category = PREFERENCE_CATEGORY_NON_CONTEXTUAL + can_randomize = FALSE + maximum_value_length = MAX_RECORD_LENGTH + +/datum/preference/text/human/sec_record/apply_to_human(mob/living/carbon/human/target, value) + target.sec_record = value + +/datum/preference/text/human/gen_record + savefile_key = "gen_record" + savefile_identifier = PREFERENCE_CHARACTER + category = PREFERENCE_CATEGORY_NON_CONTEXTUAL + can_randomize = FALSE + maximum_value_length = MAX_RECORD_LENGTH + +/datum/preference/text/human/gen_record/apply_to_human(mob/living/carbon/human/target, value) + target.gen_record = value + +/datum/category_item/player_setup_item/general/records + name = "Records" + sort_order = 6 + +/datum/category_item/player_setup_item/general/records/load_character(list/save_data) + return + +/datum/category_item/player_setup_item/general/records/save_character(list/save_data) + return + +/datum/category_item/player_setup_item/general/records/sanitize_character() + return + +/datum/category_item/player_setup_item/general/records/copy_to_mob(var/mob/living/carbon/human/character) + return + +/datum/category_item/player_setup_item/general/records/tgui_data(mob/user) + var/list/data = ..() + + if(jobban_isbanned(user, "Records")) + data["records_banned"] = TRUE + else + data["records_banned"] = FALSE + + data["med_record"] = TextPreview(pref.read_preference(/datum/preference/text/human/med_record), 40) + data["gen_record"] = TextPreview(pref.read_preference(/datum/preference/text/human/gen_record), 40) + data["sec_record"] = TextPreview(pref.read_preference(/datum/preference/text/human/sec_record), 40) + + return data + +/datum/category_item/player_setup_item/general/records/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state) + . = ..() + if(.) + return + + var/mob/user = ui.user + switch(action) + if("set_medical_records") + var/new_medical = strip_html_simple(tgui_input_text(user,"Enter medical information here.","Character Preference", html_decode(pref.read_preference(/datum/preference/text/human/med_record)), MAX_RECORD_LENGTH, TRUE, prevent_enter = TRUE), MAX_RECORD_LENGTH) + if(new_medical && !jobban_isbanned(user, JOB_RECORDS)) + pref.write_preference_by_type(/datum/preference/text/human/med_record, new_medical) + return TOPIC_REFRESH + + if("set_general_records") + var/new_general = strip_html_simple(tgui_input_text(user,"Enter employment information here.","Character Preference", html_decode(pref.read_preference(/datum/preference/text/human/gen_record)), MAX_RECORD_LENGTH, TRUE, prevent_enter = TRUE), MAX_RECORD_LENGTH) + if(new_general && !jobban_isbanned(user, JOB_RECORDS)) + pref.write_preference_by_type(/datum/preference/text/human/gen_record, new_general) + return TOPIC_REFRESH + + if("set_security_records") + var/sec_medical = strip_html_simple(tgui_input_text(user,"Enter security information here.","Character Preference", html_decode(pref.read_preference(/datum/preference/text/human/sec_record)), MAX_RECORD_LENGTH, TRUE, prevent_enter = TRUE), MAX_RECORD_LENGTH) + if(sec_medical && !jobban_isbanned(user, JOB_RECORDS)) + pref.write_preference_by_type(/datum/preference/text/human/sec_record, sec_medical) + return TOPIC_REFRESH + + if("reset_medrecord") + var/resetmed_choice = tgui_alert(user, "Wipe your Medical Records? This cannot be reverted if you have not saved your character recently! You may wish to make a backup first.","Reset Records",list("Yes","No")) + if(resetmed_choice == "Yes") + pref.write_preference_by_type(/datum/preference/text/human/med_record, "") + return TOPIC_REFRESH + + if("reset_emprecord") + var/resetemp_choice = tgui_alert(user, "Wipe your Employment Records? This cannot be reverted if you have not saved your character recently! You may wish to make a backup first.","Reset Records",list("Yes","No")) + if(resetemp_choice == "Yes") + pref.write_preference_by_type(/datum/preference/text/human/gen_record, "") + return TOPIC_REFRESH + + if("reset_secrecord") + var/resetsec_choice = tgui_alert(user, "Wipe your Security Records? This cannot be reverted if you have not saved your character recently! You may wish to make a backup first.","Reset Records",list("Yes","No")) + if(resetsec_choice == "Yes") + pref.write_preference_by_type(/datum/preference/text/human/sec_record, "") + return TOPIC_REFRESH diff --git a/code/modules/client/record_updater.dm b/code/modules/client/record_updater.dm index 06ac53f6ec..ce5b1895d5 100644 --- a/code/modules/client/record_updater.dm +++ b/code/modules/client/record_updater.dm @@ -109,15 +109,15 @@ GLOBAL_VAR_INIT(client_record_update_lock, FALSE) // Update records in the consoles, remember this can happen a while after a record is closed on the console... Use cached data. switch(console_path) if(/obj/machinery/computer/med_data) - P.med_record = new_data + P.write_preference_by_type(/datum/preference/text/human/med_record, new_data) if(active) active.fields["notes"] = new_data if(/obj/machinery/computer/skills) - P.gen_record = new_data + P.write_preference_by_type(/datum/preference/text/human/gen_record, new_data) if(active) active.fields["notes"] = new_data if(/obj/machinery/computer/secure_data) - P.sec_record = new_data + P.write_preference_by_type(/datum/preference/text/human/sec_record, new_data) if(active) active.fields["notes"] = new_data diff --git a/vorestation.dme b/vorestation.dme index d463db989c..827d3550ac 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -2472,7 +2472,6 @@ #include "code\modules\client\preference_setup\general\01_basic.dm" #include "code\modules\client\preference_setup\general\02_language.dm" #include "code\modules\client\preference_setup\general\03_body.dm" -#include "code\modules\client\preference_setup\general\05_background.dm" #include "code\modules\client\preference_setup\general\06_flavor.dm" #include "code\modules\client\preference_setup\general\07_antagonism.dm" #include "code\modules\client\preference_setup\general\08_candidacy.dm" @@ -2515,9 +2514,11 @@ #include "code\modules\client\preferences\migrations\17_tails.dm" #include "code\modules\client\preferences\migrations\18_jukebox.dm" #include "code\modules\client\preferences\migrations\19_paifile.dm" +#include "code\modules\client\preferences\types\character\background.dm" #include "code\modules\client\preferences\types\character\gender.dm" #include "code\modules\client\preferences\types\character\names.dm" #include "code\modules\client\preferences\types\character\organ_data.dm" +#include "code\modules\client\preferences\types\character\records.dm" #include "code\modules\client\preferences\types\character\rlimb_data.dm" #include "code\modules\client\preferences\types\character\species.dm" #include "code\modules\client\preferences\types\character\antagonism\01_basic.dm"