diff --git a/code/__HELPERS/colour_helpers.dm b/code/__HELPERS/colour_helpers.dm index 2c8668fd400..fd053bfab1b 100644 --- a/code/__HELPERS/colour_helpers.dm +++ b/code/__HELPERS/colour_helpers.dm @@ -44,4 +44,25 @@ RGB[1] = clamp(RGB[1]+value,0,255) RGB[2] = clamp(RGB[2]+value,0,255) RGB[3] = clamp(RGB[3]+value,0,255) - return rgb(RGB[1],RGB[2],RGB[3]) + return rgb(RGB[1], RGB[2], RGB[3]) + +// Change one RGB color to match the hue of another RGB color (but not saturation or lightness) +/proc/match_hue(color, color_to_match) + var/list/RGB = rgb2num(color, COLORSPACE_HSL) + var/list/TARGET = rgb2num(color_to_match, COLORSPACE_HSL) + RGB[1] = TARGET[1] //change hue to target hue + return rgb(RGB[1], RGB[2], RGB[3], space = COLORSPACE_HSL) + +// Change one RGB color to match the saturation of another RGB color (but not hue or lightness) +/proc/match_saturation(color, color_to_match) + var/list/RGB = rgb2num(color, COLORSPACE_HSL) + var/list/TARGET = rgb2num(color_to_match, COLORSPACE_HSL) + RGB[2] = TARGET[2] //change saturation to target saturation + return rgb(RGB[1], RGB[2], RGB[3], space = COLORSPACE_HSL) + +// Change one RGB color to match the lightness of another RGB color (but not saturation or hue) +/proc/match_lightness(color, color_to_match) + var/list/RGB = rgb2num(color, COLORSPACE_HSL) + var/list/TARGET = rgb2num(color_to_match, COLORSPACE_HSL) + RGB[3] = TARGET[3] //change lightness to target lightness + return rgb(RGB[1], RGB[2], RGB[3], space = COLORSPACE_HSL) diff --git a/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm b/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm index fb9b77c7113..6e15d33fac1 100644 --- a/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm +++ b/code/modules/food_and_drinks/drinks/drinks/drinkingglass.dm @@ -51,30 +51,58 @@ /obj/item/reagent_containers/drinks/drinkingglass/on_reagent_change() overlays.Cut() - if(length(reagents.reagent_list)) - var/datum/reagent/R = reagents.get_master_reagent() - name = R.drink_name - desc = R.drink_desc - force = (istype(R, /datum/reagent/consumable/drink/salt_and_battery) && reagents.total_volume) ? 10 : initial(force) - attack_verb = (istype(R, /datum/reagent/consumable/drink/salt_and_battery) && reagents.total_volume) ? list("assaulted", "battered") : initial(attack_verb) - if(R.drink_icon) - icon_state = R.drink_icon - else - var/image/I = image(icon, "glassoverlay") - I.color = mix_color_from_reagents(reagents.reagent_list) - overlays += I - else + if(!length(reagents.reagent_list)) force = initial(force) attack_verb = initial(attack_verb) icon_state = "glass_empty" name = initial(name) desc = initial(desc) + return + + var/datum/reagent/main_reagent = reagents.get_master_reagent() + name = main_reagent.drink_name + desc = main_reagent.drink_desc + force = (istype(main_reagent, /datum/reagent/consumable/drink/salt_and_battery) && reagents.total_volume) ? 10 : initial(force) + attack_verb = (istype(main_reagent, /datum/reagent/consumable/drink/salt_and_battery) && reagents.total_volume) ? list("assaulted", "battered") : initial(attack_verb) + if(main_reagent.drink_icon) + icon_state = main_reagent.drink_icon + if((main_reagent.id == "bubbletea" || main_reagent.id == "bubblemilktea") && length(reagents.reagent_list) > 1) + customize_bubble_tea() + else + var/image/drink_image = image(icon, "glassoverlay") + drink_image.color = mix_color_from_reagents(reagents.reagent_list) + overlays += drink_image + +/obj/item/reagent_containers/drinks/drinkingglass/proc/customize_bubble_tea() + if(length(reagents.reagent_list) < 2) + return + var/datum/reagent/main_reagent = reagents.get_master_reagent() + if(!(main_reagent.id == "bubbletea" || main_reagent.id == "bubblemilktea")) + return + + var/datum/reagent/coloring_reagent //sub-master reagent, second by volume + var/max_volume = 0 + for(var/datum/reagent/one_reagent in reagents.reagent_list) + if(one_reagent.volume > max_volume && one_reagent != main_reagent) + max_volume = one_reagent.volume + coloring_reagent = one_reagent + + var/image/drink_overlay = image(icon, (main_reagent.id == "bubbletea" ? "bubbletea_overlay" : "bubblemilktea_overlay")) + if(main_reagent.id == "bubblemilktea") + var/milky_color = match_hue("#F7E0C5", coloring_reagent.color) + if(rgb2num(milky_color, COLORSPACE_HSL)[2] > rgb2num(coloring_reagent.color, COLORSPACE_HSL)[2]) //if the color is less saturated, use that color's saturation. So we don't end up with pink milk and sugar. + milky_color = match_saturation(milky_color, coloring_reagent.color) + drink_overlay.color = milky_color + else + drink_overlay.color = coloring_reagent.color + + overlays += drink_overlay + name = istype(coloring_reagent, /datum/reagent/consumable) ? "Glass of [coloring_reagent.name] [main_reagent.name]" : "Glass of Surprise [main_reagent.name]" // for /obj/machinery/economy/vending/sovietsoda /obj/item/reagent_containers/drinks/drinkingglass/soda list_reagents = list("sodawater" = 50) - /obj/item/reagent_containers/drinks/drinkingglass/cola list_reagents = list("cola" = 50) diff --git a/code/modules/reagents/chemistry/reagents/drinks_reagents.dm b/code/modules/reagents/chemistry/reagents/drinks_reagents.dm index 6cc2e3ba95e..b9580b60315 100644 --- a/code/modules/reagents/chemistry/reagents/drinks_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drinks_reagents.dm @@ -852,18 +852,17 @@ drink_desc = "This would go great with sugar, milk, and tea." taste_description = "chewy starch" -/datum/reagent/consumable/drink/bubbletea +/datum/reagent/consumable/drink/tea/bubbletea name = "Bubble Tea" description = "A tea-based drink made with tapioca pearls. Known by some as boba tea." id = "bubbletea" - color = "#5d2409" drink_icon = "bubbletea" drink_name = "Bubble Tea" drink_desc = "You feel trendy for drinking this." taste_description = "sweet tea with chewy pearls" goal_difficulty = REAGENT_GOAL_NORMAL -/datum/reagent/consumable/drink/milktea +/datum/reagent/consumable/drink/tea/milktea name = "Milk Tea" description = "Tea and milk mixed together. Both sweet and creamy." id = "milktea" @@ -874,7 +873,7 @@ taste_description = "sweet milky tea" goal_difficulty = REAGENT_GOAL_EASY -/datum/reagent/consumable/drink/bubblemilktea +/datum/reagent/consumable/drink/tea/bubblemilktea name = "Bubble Milk Tea" description = "A tea-based drink made with milk and tapioca pearls. Known by some as boba milk tea." id = "bubblemilktea" diff --git a/icons/obj/drinks.dmi b/icons/obj/drinks.dmi index 270ba5d6527..310d4da3c09 100644 Binary files a/icons/obj/drinks.dmi and b/icons/obj/drinks.dmi differ