From ae7fa73befef0c88db90de9317840d3a59d51d29 Mon Sep 17 00:00:00 2001 From: Nick <42454181+Momo8289@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:47:59 -0500 Subject: [PATCH] Allows shakers to pour drinks with custom names and descriptions (#81234) ## About The Pull Request This adds the ability for shakers to pour drinks with custom names and descriptions. You can alt-click on a shaker and it will prompt you to set the name and desc for the drink, and they will be given to description of whatever drinking glass you pour into. Washing the glass will remove these customization (it will also now remove any changes made using a pen). https://github.com/tgstation/tgstation/assets/42454181/6cf336f0-0621-49f3-baf1-91038f454c24 ## Why It's Good For The Game While this already kind of exists by using a pen to change the name and desc, this is pretty annoying to do for every single glass of a beverage you serve. It also is overwritten whenever the kind of drink in the glass is changed. This PR will let bartenders serve plenty of their own special concoctions without having to rename every single glass they serve. ## Changelog :cl: add: Shakers can now pour drinks with custom names and descriptions! Alt-click the shaker to enable this. /:cl: --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/__DEFINES/dcs/signals/signals_reagent.dm | 4 + code/__DEFINES/traits/sources.dm | 3 + .../reagents/reagent_containers/cups/_cup.dm | 2 + .../reagent_containers/cups/drinkingglass.dm | 17 +++++ .../reagent_containers/cups/drinks.dm | 73 +++++++++++++++++++ 5 files changed, 99 insertions(+) diff --git a/code/__DEFINES/dcs/signals/signals_reagent.dm b/code/__DEFINES/dcs/signals/signals_reagent.dm index a73d59a234c..38d2ae92d9d 100644 --- a/code/__DEFINES/dcs/signals/signals_reagent.dm +++ b/code/__DEFINES/dcs/signals/signals_reagent.dm @@ -55,3 +55,7 @@ #define COMSIG_REAGENTS_EXPOSE_TURF "reagents_expose_turf" ///from base of [/datum/component/personal_crafting/proc/del_reqs]: () #define COMSIG_REAGENTS_CRAFTING_PING "reagents_crafting_ping" +/// sent when reagents are transfered from a cup, to something refillable (atom/transfer_to) +#define COMSIG_REAGENTS_CUP_TRANSFER_TO "reagents_cup_transfer_to" +/// sent when reagents are transfered from some reagent container, to a cup (atom/transfer_from) +#define COMSIG_REAGENTS_CUP_TRANSFER_FROM "reagents_cup_transfer_from" diff --git a/code/__DEFINES/traits/sources.dm b/code/__DEFINES/traits/sources.dm index f9cdbe4326d..f009b6ccf0f 100644 --- a/code/__DEFINES/traits/sources.dm +++ b/code/__DEFINES/traits/sources.dm @@ -279,3 +279,6 @@ #define ORGAN_INSIDE_BODY_TRAIT "organ_inside_body" /// Trait when something was labelled by a pen. #define PEN_LABEL_TRAIT "pen_label" + +/// Trait when a drink was renamed by a shaker +#define SHAKER_LABEL_TRAIT "shaker_trait" diff --git a/code/modules/reagents/reagent_containers/cups/_cup.dm b/code/modules/reagents/reagent_containers/cups/_cup.dm index ed334adeac0..bdb104a1cfe 100644 --- a/code/modules/reagents/reagent_containers/cups/_cup.dm +++ b/code/modules/reagents/reagent_containers/cups/_cup.dm @@ -125,6 +125,7 @@ var/trans = reagents.trans_to(target, amount_per_transfer_from_this, transferred_by = user) to_chat(user, span_notice("You transfer [trans] unit\s of the solution to [target].")) + SEND_SIGNAL(src, COMSIG_REAGENTS_CUP_TRANSFER_TO, target) else if(target.is_drainable()) //A dispenser. Transfer FROM it TO us. if(!target.reagents.total_volume) @@ -137,6 +138,7 @@ var/trans = target.reagents.trans_to(src, amount_per_transfer_from_this, transferred_by = user) to_chat(user, span_notice("You fill [src] with [trans] unit\s of the contents of [target].")) + SEND_SIGNAL(src, COMSIG_REAGENTS_CUP_TRANSFER_FROM, target) target.update_appearance() diff --git a/code/modules/reagents/reagent_containers/cups/drinkingglass.dm b/code/modules/reagents/reagent_containers/cups/drinkingglass.dm index 8745e61cd92..adcd2ff79fa 100644 --- a/code/modules/reagents/reagent_containers/cups/drinkingglass.dm +++ b/code/modules/reagents/reagent_containers/cups/drinkingglass.dm @@ -30,6 +30,7 @@ CALLBACK(src, PROC_REF(on_cup_reset)), \ base_container_type = base_container_type, \ ) + RegisterSignal(src, COMSIG_COMPONENT_CLEAN_ACT, PROC_REF(on_cleaned)) /obj/item/reagent_containers/cup/glass/drinkingglass/on_reagent_change(datum/reagents/holder, ...) . = ..() @@ -46,6 +47,22 @@ . = ..() fill_icon_thresholds ||= list(0) +/obj/item/reagent_containers/cup/glass/drinkingglass/examine(mob/user) + . = ..() + if(HAS_TRAIT(src, TRAIT_WAS_RENAMED)) + . += span_notice("This glass has been given a custom name. It can be removed by washing it.") + +/obj/item/reagent_containers/cup/glass/drinkingglass/proc/on_cleaned(obj/source_component, obj/source) + SIGNAL_HANDLER + if(!HAS_TRAIT(src, TRAIT_WAS_RENAMED)) + return + + REMOVE_TRAIT(src, TRAIT_WAS_RENAMED, SHAKER_LABEL_TRAIT) + REMOVE_TRAIT(src, TRAIT_WAS_RENAMED, PEN_LABEL_TRAIT) + name = initial(name) + desc = initial(desc) + update_appearance(UPDATE_NAME | UPDATE_DESC) + //Shot glasses!// // This lets us add shots in here instead of lumping them in with drinks because >logic // // The format for shots is the exact same as iconstates for the drinking glass, except you use a shot glass instead. // diff --git a/code/modules/reagents/reagent_containers/cups/drinks.dm b/code/modules/reagents/reagent_containers/cups/drinks.dm index 12a3d023c72..cba2f937da4 100644 --- a/code/modules/reagents/reagent_containers/cups/drinks.dm +++ b/code/modules/reagents/reagent_containers/cups/drinks.dm @@ -426,6 +426,7 @@ // itself), in Chemistry-Recipes.dm (for the reaction that changes the components into the drink), and here (for the drinking glass // icon states. + /obj/item/reagent_containers/cup/glass/shaker name = "shaker" desc = "A metal shaker to mix drinks in." @@ -435,14 +436,86 @@ amount_per_transfer_from_this = 10 volume = 100 isGlass = FALSE + /// Whether or not poured drinks should use custom names and descriptions + var/using_custom_drinks = FALSE + /// Name custom drinks will have + var/custom_drink_name = "Custom drink" + /// Description custom drinks will have + var/custom_drink_desc = "Mixed by your favourite bartender!" /obj/item/reagent_containers/cup/glass/shaker/Initialize(mapload) . = ..() + register_context() if(prob(10)) name = "\improper Nanotrasen 20th Anniversary Shaker" desc += " It has an emblazoned Nanotrasen logo on it." icon_state = "shaker_n" +/obj/item/reagent_containers/cup/glass/shaker/add_context(atom/source, list/context, obj/item/held_item, mob/user) + . = ..() + context[SCREENTIP_CONTEXT_ALT_LMB] = "[using_custom_drinks ? "Disable" : "Enable"] custom drinks" + return CONTEXTUAL_SCREENTIP_SET + +/obj/item/reagent_containers/cup/glass/shaker/examine(mob/user) + . = ..() + . += span_notice("Alt-click to [using_custom_drinks ? "disable" : "enable"] custom drink naming") + if(using_custom_drinks) + . += span_notice("Drinks poured from this shaker will have the following name: [custom_drink_name]") + . += span_notice("Drinks poured from this shaker will have the following description: [custom_drink_desc]") + +/obj/item/reagent_containers/cup/glass/shaker/AltClick(mob/user) + . = ..() + if(!user.can_perform_action(src, NEED_HANDS|FORBID_TELEKINESIS_REACH)) + return + + if(using_custom_drinks) + using_custom_drinks = FALSE + disable_custom_drinks() + balloon_alert(user, "custom drinks disabled") + return + + var/new_name = reject_bad_text(tgui_input_text(user, "Drink name", "Set drink name", custom_drink_name, 45, FALSE), 64) + if(!new_name) + balloon_alert(user, "invalid drink name!") + using_custom_drinks = FALSE + return + + if(!user.can_perform_action(src, NEED_HANDS|FORBID_TELEKINESIS_REACH)) + return + + var/new_desc = reject_bad_text(tgui_input_text(user, "Drink description", "Set drink description", custom_drink_desc, 64, TRUE), 128) + if(!new_desc) + balloon_alert(user, "invalid drink description!") + using_custom_drinks = FALSE + return + + if(!user.can_perform_action(src, NEED_HANDS|FORBID_TELEKINESIS_REACH)) + return + + using_custom_drinks = TRUE + custom_drink_name = new_name + custom_drink_desc = new_desc + + enable_custom_drinks() + balloon_alert(user, "now pouring custom drinks") + +/obj/item/reagent_containers/cup/glass/shaker/proc/enable_custom_drinks() + RegisterSignal(src, COMSIG_REAGENTS_CUP_TRANSFER_TO, PROC_REF(handle_transfer)) + +/obj/item/reagent_containers/cup/glass/shaker/proc/disable_custom_drinks() + UnregisterSignal(src, COMSIG_REAGENTS_CUP_TRANSFER_TO) + +/obj/item/reagent_containers/cup/glass/shaker/proc/handle_transfer(atom/origin, atom/target) + SIGNAL_HANDLER + // Should only work on drinking/shot glasses + if(!istype(target, /obj/item/reagent_containers/cup/glass/drinkingglass)) + return + + var/obj/item/reagent_containers/cup/glass/drinkingglass/target_glass = target + target_glass.name = custom_drink_name + target_glass.desc = custom_drink_desc + ADD_TRAIT(target_glass, TRAIT_WAS_RENAMED, SHAKER_LABEL_TRAIT) + /obj/item/reagent_containers/cup/glass/flask name = "flask" desc = "Every good spaceman knows it's a good idea to bring along a couple of pints of whiskey wherever they go."