Allows shakers to pour drinks with custom names and descriptions (#81234)

<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## 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


<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## 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.
<!-- Argue for the merits of your changes and how they benefit the game,
especially if they are controversial and/or far reaching. If you can't
actually explain WHY what you are doing will improve the game, then it
probably isn't good for the game in the first place. -->

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and it's effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

🆑
add: Shakers can now pour drinks with custom names and descriptions!
Alt-click the shaker to enable this.
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
Nick
2024-02-11 01:47:59 +00:00
committed by GitHub
co-authored by MrMelbert Ghom
parent 111247d76f
commit ae7fa73bef
5 changed files with 99 additions and 0 deletions
@@ -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"
+3
View File
@@ -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"
@@ -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()
@@ -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. //
@@ -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."