Cleanup + TGUI Fix for Hair Dye [NOVA PORT] (#5896)

## About The Pull Request
ORIGINAL PR: https://github.com/NovaSector/NovaSector/pull/6818
Cleans up the code for hair dye and fixes the TGUI NtOS bluescreen.
## Why It's Good For The Game
Bugs are bad and maintenance for unmaintained code is good.
## Proof Of Testing
See below.
<details>
<summary>Screenshots/Videos</summary>
<img width="451" height="172" alt="image"
src="https://github.com/user-attachments/assets/36c89512-e375-47f7-9d49-942158acabde"
/>

<img width="767" height="526" alt="image"
src="https://github.com/user-attachments/assets/bb0c5053-437f-4d93-8956-f8164ad9be4d"
/>

</details>

## Changelog
🆑 xPokee, Hardly
fix: Fixes hair dye's gradient dyeing not working
/🆑
This commit is contained in:
Alexis
2026-07-04 11:44:27 -07:00
committed by GitHub
parent 33ff8655c4
commit fb67ef6a5d
2 changed files with 26 additions and 25 deletions
+5 -11
View File
@@ -1,12 +1,10 @@
/obj/item/dyespray
name = "hair dye spray"
desc = "A spray to dye your hair any colors and gradients you'd like." // SKYRAT EDIT - Making the dyespray change hair color
desc = "A spray to dye your hair any gradients you'd like."
w_class = WEIGHT_CLASS_TINY
icon = 'icons/obj/cosmetic.dmi'
icon_state = "dyespray"
var/uses = 40 //SKYRAT EDIT ADDITION
/obj/item/dyespray/attack_self(mob/user)
dye(user, user)
@@ -20,14 +18,11 @@
* Arguments:
* * target - The mob who we will apply the gradient and gradient color to.
*/
/* SKYRAT EDIT REMOVAL - MOVED TO MODULAR (modular_skyrat\master_files\code\game\objects\items\dyekit.dm)
/* BUBBER EDIT - REMOVAL - MOVED TO MODULAR (modular_skyrat\master_files\code\game\objects\items\dyekit.dm)
/obj/item/dyespray/proc/dye(mob/target, mob/user)
if(!ishuman(target))
return
if(!uses) //SKYRAT EDIT ADDITION
return //SKYRAT EDIT ADDITION
var/mob/living/carbon/human/human_target = target
var/list/dyables = list("Hair", "Facial Hair")
for(var/obj/item/organ/organ as anything in human_target.organs)
@@ -63,8 +58,7 @@
if(!user.can_perform_action(src, NEED_DEXTERITY))
return
var/hair_key = what_to_dye == "Hair" ? GRADIENT_HAIR_KEY : GRADIENT_FACIAL_HAIR_KEY
var/new_grad_color = tgui_color_picker(user, "Choose a secondary hair color:", "Character Preference", human_target.get_hair_gradient_color(hair_key))
var/new_grad_color = tgui_color_picker(user, "Choose a secondary hair color:", "Character Preference", human_target.get_hair_gradient_color())
if(!new_grad_color || !user.can_perform_action(src, NEED_DEXTERITY) || !target.IsReachableBy(user))
return
@@ -78,6 +72,7 @@
human_target.set_facial_hair_gradient_style(new_grad_style, update = FALSE)
human_target.set_facial_hair_gradient_color(new_grad_color, update = TRUE)
playsound(src, 'sound/effects/spray.ogg', 10, vary = TRUE)
*/
/obj/item/dyespray/proc/dye_organ(mob/living/carbon/human/target, mob/user)
var/list/dyables = list()
@@ -122,4 +117,3 @@
if(QDELETED(selected) || !(selected in target.organs))
return
overlay.set_dye_color(new_color, selected)
*/
@@ -8,6 +8,11 @@
* * target - The mob who we will apply the hair color / gradient and gradient color to.
* * user - The mob that is applying the hair color / gradient and gradient color.
*/
/obj/item/dyespray
desc = "A spray to dye hair, as well as giving it any gradient you'd like."
var/uses = 40
/obj/item/dyespray/proc/dye(mob/target, mob/user)
if(!ishuman(target))
return
@@ -22,40 +27,40 @@
if(!gradient_or_hair || !user.can_perform_action(src, NEED_DEXTERITY))
return
var/dying_themselves = target == user
var/dyeing_themselves = target == user
if(gradient_or_hair == DYE_OPTION_HAIR_COLOR)
var/new_color = tgui_color_picker(usr, "Choose a hair color:", "Character Preference", "#" + human_target.hair_color) // BUBBERSTATION EDIT: TGUI COLOR PICKER
var/new_color = tgui_color_picker(user, "Choose a hair color:", "Character Preference", "#" + human_target.hair_color)
if(!new_color || !user.can_perform_action(src, NEED_DEXTERITY))
return
human_target.visible_message(span_notice("[user] starts applying hair dye to [dying_themselves ? "their own" : "[human_target]'s"] hair..."), span_notice("[dying_themselves ? "You start" : "[user] starts"] applying hair dye to [dying_themselves ? "your own" : "your"] hair..."), ignored_mobs = user)
if(!dying_themselves)
human_target.visible_message(span_notice("[user] starts applying hair dye to [dyeing_themselves ? "their own" : "[human_target]'s"] hair..."), span_notice("[dyeing_themselves ? "You start" : "[user] starts"] applying hair dye to [dyeing_themselves ? "your own" : "your"] hair..."), ignored_mobs = user)
if(!dyeing_themselves)
balloon_alert(user, "dyeing...")
if(!do_after(usr, 3 SECONDS, target))
if(!do_after(user, 3 SECONDS, target))
return
human_target.set_haircolor(sanitize_hexcolor(new_color), update = TRUE)
else
var/beard_or_hair = input(user, "What do you want to dye?", "Character Preference") as null|anything in list("Hair", "Facial Hair")
var/beard_or_hair = tgui_input_list(user, "What do you want to dye?", "Character Preference", list("Hair", "Facial Hair"))
if(!beard_or_hair || !user.can_perform_action(src, NEED_DEXTERITY))
return
var/list/choices = beard_or_hair == "Hair" ? SSaccessories.hair_gradients_list : SSaccessories.facial_hair_gradients_list
var/new_grad_style = tgui_input_list(usr, "Choose a color pattern:", "Dye Spray", choices)
var/new_grad_style = tgui_input_list(user, "Choose a color pattern:", "Dye Spray", choices)
if(!new_grad_style || !user.can_perform_action(src, NEED_DEXTERITY))
return
var/new_grad_color = tgui_color_picker(usr, "Choose a secondary hair color:", "Dye Spray", human_target.grad_color) // BUBBERSTATION EDIT: TGUI COLOR PICKER
var/hair_key = beard_or_hair == "Hair" ? GRADIENT_HAIR_KEY : GRADIENT_FACIAL_HAIR_KEY
var/new_grad_color = tgui_color_picker(user, "Choose a secondary hair color:", "Dye Spray", human_target.get_hair_gradient_color(hair_key))
if(!new_grad_color || !user.can_perform_action(src, NEED_DEXTERITY))
return
human_target.visible_message(span_notice("[user] starts applying hair dye to [dying_themselves ? "their own" : "[human_target]'s"] hair..."), span_notice("[dying_themselves ? "You start" : "[user] starts"] applying hair dye to [dying_themselves ? "your own" : "your"] hair..."), ignored_mobs = user)
if(!dying_themselves)
human_target.visible_message(span_notice("[user] starts applying hair dye to [dyeing_themselves ? "their own" : "[human_target]'s"] hair..."), span_notice("[dyeing_themselves ? "You start" : "[user] starts"] applying hair dye to [dyeing_themselves ? "your own" : "your"] hair..."), ignored_mobs = user)
if(!dyeing_themselves)
balloon_alert(user, "dyeing...")
if(!do_after(usr, 3 SECONDS, target))
if(!do_after(user, 3 SECONDS, target))
return
if(beard_or_hair == "Hair")
@@ -67,8 +72,10 @@
playsound(src, 'sound/effects/spray.ogg', 10, vary = TRUE)
human_target.visible_message(span_notice("[user] finishes applying hair dye to [dying_themselves ? "their own" : "[human_target]'s"] hair, changing its color!"), span_notice("[dying_themselves ? "You finish" : "[user] finishes"] applying hair dye to [dying_themselves ? "your own" : "your"] hair, changing its color!"), ignored_mobs = user)
if(!dying_themselves)
human_target.visible_message(
span_notice("[user] finishes applying hair dye to [dyeing_themselves ? "their own" : "[human_target]'s"] hair, changing its color!"),
span_notice("[dyeing_themselves ? "You finish" : "[user] finishes"] applying hair dye to [dyeing_themselves ? "your own" : "your"] hair, changing its color!"), ignored_mobs = user)
if(!dyeing_themselves)
balloon_alert(user, "dyeing complete!")
uses--