Files
Bubberstation/code/modules/loadout/loadout_preference.dm
MrMelbert d244c86ce6 Adds Character Loadout Tab to preferences (with just a small handful of items to start) (#83521)
## About The Pull Request

Adds a Character Loadout Tab to the preference menu

This tab lets you pick items to start the round with


![image](https://private-user-images.githubusercontent.com/51863163/336254447-c5f7eefa-c44c-418d-b48e-0409bb5bb982.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgwNDAxMjMsIm5iZiI6MTcxODAzOTgyMywicGF0aCI6Ii81MTg2MzE2My8zMzYyNTQ0NDctYzVmN2VlZmEtYzQ0Yy00MThkLWI0OGUtMDQwOWJiNWJiOTgyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjEwVDE3MTcwM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYxYWFmYjI2NDU0YjUyODg3NjBmM2VjZDg4YWQ1YjlhMThmODU3MDYyMzYwOGVmYTcxYmY2MDhjZWVmYjQ5ZTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Y0_19Gisfp4yyUmLgW2atfKyneL7POWFRKNVgNWTbEs)

This also has some additional mechanics, such as being able to recolor
colorable items, rename certain items (such as plushies), set item skins
(such as the pride pin)


![image](https://github.com/tgstation/tgstation/assets/51863163/8a085d6c-a294-4538-95d2-ada902ab69b4)

## Why It's Good For The Game

This has been headcoder sanctioned for some time, just no one did it. So
here we are.

Allows players to add some additional customization to their characters.
Keeps us from cluttering the quirks list with quirks that do nothing but
grants items.

## Changelog

🆑 Melbert
add: Character Loadouts
del: Pride Pin quirk (it's in the Loadout menu now)
/🆑
2024-06-11 17:50:12 -07:00

60 lines
2.3 KiB
Plaintext

/datum/preference/loadout
savefile_key = "loadout_list"
savefile_identifier = PREFERENCE_CHARACTER
priority = PREFERENCE_PRIORITY_LOADOUT
can_randomize = FALSE
// Loadout preference is an assoc list [item_path] = [loadout item information list]
//
// it may look something like
// - list(/obj/item/glasses = list())
// or
// - list(/obj/item/plush/lizard = list("name" = "Tests-The-Loadout", "color" = "#FF0000"))
// Loadouts are applied with job equip code.
/datum/preference/loadout/apply_to_human(mob/living/carbon/human/target, value)
return
// Sanitize on load to ensure no invalid paths from older saves get in
/datum/preference/loadout/deserialize(input, datum/preferences/preferences)
return sanitize_loadout_list(input, preferences.parent?.mob)
// Default value is null - the loadout list is a lazylist
/datum/preference/loadout/create_default_value(datum/preferences/preferences)
return null
/datum/preference/loadout/is_valid(value)
return isnull(value) || islist(value)
/**
* Removes all invalid paths from loadout lists.
* This is a general sanitization for preference loading.
*
* Returns a list, or null if empty
*/
/datum/preference/loadout/proc/sanitize_loadout_list(list/passed_list, mob/optional_loadout_owner) as /list
var/list/sanitized_list
for(var/path in passed_list)
// Loading from json has each path in the list as a string that we need to convert back to typepath
var/obj/item/real_path = istext(path) ? text2path(path) : path
if(!ispath(real_path, /obj/item))
if(optional_loadout_owner)
to_chat(optional_loadout_owner, span_boldnotice("The following invalid item path was found \
in your character loadout: [real_path || "null"]. \
It has been removed, renamed, or is otherwise missing - \
You may want to check your loadout settings."))
continue
else if(!istype(GLOB.all_loadout_datums[real_path], /datum/loadout_item))
if(optional_loadout_owner)
to_chat(optional_loadout_owner, span_boldnotice("The following invalid loadout item was found \
in your character loadout: [real_path || "null"]. \
It has been removed, renamed, or is otherwise missing - \
You may want to check your loadout settings."))
continue
// Set into sanitize list using converted path key
var/list/data = passed_list[path]
LAZYSET(sanitized_list, real_path, LAZYLISTDUPLICATE(data))
return sanitized_list