Files
Bubberstation/code/modules/loadout/loadout_menu.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

121 lines
4.8 KiB
Plaintext

/datum/preference_middleware/loadout
action_delegations = list(
"clear_all_items" = PROC_REF(action_clear_all),
"pass_to_loadout_item" = PROC_REF(action_pass_to_loadout_item),
"rotate_dummy" = PROC_REF(action_rotate_model_dir),
"select_item" = PROC_REF(action_select_item),
"toggle_job_clothes" = PROC_REF(action_toggle_job_outfit),
"close_greyscale_menu" = PROC_REF(force_close_greyscale_menu),
)
/// Our currently open greyscaling menu.
VAR_FINAL/datum/greyscale_modify_menu/menu
/datum/preference_middleware/loadout/Destroy(force, ...)
QDEL_NULL(menu)
return ..()
/datum/preference_middleware/loadout/on_new_character(mob/user)
preferences.character_preview_view?.update_body()
/datum/preference_middleware/loadout/proc/action_select_item(list/params, mob/user)
PRIVATE_PROC(TRUE)
var/path_to_use = text2path(params["path"])
var/datum/loadout_item/interacted_item = GLOB.all_loadout_datums[path_to_use]
if(!istype(interacted_item))
stack_trace("Failed to locate desired loadout item (path: [params["path"]]) in the global list of loadout datums!")
return TRUE // update
if(params["deselect"])
deselect_item(interacted_item)
else
select_item(interacted_item)
return TRUE
/datum/preference_middleware/loadout/proc/action_clear_all(list/params, mob/user)
PRIVATE_PROC(TRUE)
preferences.update_preference(GLOB.preference_entries[/datum/preference/loadout], null)
return TRUE
/datum/preference_middleware/loadout/proc/action_toggle_job_outfit(list/params, mob/user)
PRIVATE_PROC(TRUE)
preferences.character_preview_view.show_job_clothes = !preferences.character_preview_view.show_job_clothes
preferences.character_preview_view.update_body()
return TRUE
/datum/preference_middleware/loadout/proc/action_rotate_model_dir(list/params, mob/user)
PRIVATE_PROC(TRUE)
switch(params["dir"])
if("left")
preferences.character_preview_view.setDir(turn(preferences.character_preview_view.dir, -90))
if("right")
preferences.character_preview_view.setDir(turn(preferences.character_preview_view.dir, 90))
/datum/preference_middleware/loadout/proc/action_pass_to_loadout_item(list/params, mob/user)
PRIVATE_PROC(TRUE)
var/path_to_use = text2path(params["path"])
var/datum/loadout_item/interacted_item = GLOB.all_loadout_datums[path_to_use]
if(!istype(interacted_item)) // no you cannot href exploit to spawn with a pulse rifle
stack_trace("Failed to locate desired loadout item (path: [params["path"]]) in the global list of loadout datums!")
return TRUE // update
if(interacted_item.handle_loadout_action(src, user, params["subaction"], params))
preferences.character_preview_view.update_body()
return TRUE
return FALSE
/// Select [path] item to [category_slot] slot.
/datum/preference_middleware/loadout/proc/select_item(datum/loadout_item/selected_item)
var/list/loadout = preferences.read_preference(/datum/preference/loadout)
var/list/datum/loadout_item/loadout_datums = loadout_list_to_datums(loadout)
for(var/datum/loadout_item/item as anything in loadout_datums)
if(item.category != selected_item.category)
continue
if(!item.category.handle_duplicate_entires(src, item, selected_item, loadout_datums))
return
LAZYSET(loadout, selected_item.item_path, list())
preferences.update_preference(GLOB.preference_entries[/datum/preference/loadout], loadout)
/// Deselect [deselected_item].
/datum/preference_middleware/loadout/proc/deselect_item(datum/loadout_item/deselected_item)
var/list/loadout = preferences.read_preference(/datum/preference/loadout)
LAZYREMOVE(loadout, deselected_item.item_path)
preferences.update_preference(GLOB.preference_entries[/datum/preference/loadout], loadout)
/datum/preference_middleware/loadout/proc/register_greyscale_menu(datum/greyscale_modify_menu/open_menu)
src.menu = open_menu
RegisterSignal(menu, COMSIG_QDELETING, PROC_REF(cleanup_greyscale_menu))
/datum/preference_middleware/loadout/proc/cleanup_greyscale_menu()
SIGNAL_HANDLER
menu = null
/datum/preference_middleware/loadout/proc/force_close_greyscale_menu()
menu?.ui_close()
/datum/preference_middleware/loadout/get_ui_data(mob/user)
var/list/data = list()
data["job_clothes"] = preferences.character_preview_view.show_job_clothes
return data
/datum/preference_middleware/loadout/get_ui_static_data(mob/user)
var/list/data = list()
data["loadout_preview_view"] = preferences.character_preview_view.assigned_map
return data
/datum/preference_middleware/loadout/get_constant_data()
var/list/data = list()
var/list/loadout_tabs = list()
for(var/datum/loadout_category/category as anything in GLOB.all_loadout_categories)
var/list/cat_data = list(
"name" = category.category_name,
"category_icon" = category.category_ui_icon,
"category_info" = category.category_info,
"contents" = category.items_to_ui_data(),
)
UNTYPED_LIST_ADD(loadout_tabs, cat_data)
data["loadout_tabs"] = loadout_tabs
return data