From 243275c17152bcf66f6d69b04991c60db7fe9af6 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 25 May 2021 22:33:19 +0200 Subject: [PATCH] [MIRROR] Makes washing machines support GAGS recoloration (#5950) * Makes washing machines support GAGS recoloration (#59292) * Makes washing machines support GAGS recoloration Co-authored-by: Emmett Gaines --- code/game/atoms.dm | 33 ++++++------- code/game/machinery/PDApainter.dm | 3 +- code/game/machinery/washing_machine.dm | 49 ++++++++++++------- code/game/objects/items.dm | 11 ++++- .../items/circuitboards/circuitboard.dm | 5 +- code/game/objects/items/tools/screwdriver.dm | 2 +- code/game/objects/items/tools/wirecutters.dm | 6 ++- code/modules/admin/greyscale_modify_menu.dm | 4 +- .../machinery/portable/canister.dm | 3 +- .../mob/living/simple_animal/hostile/carp.dm | 6 +-- code/modules/vending/_vending.dm | 2 +- 11 files changed, 68 insertions(+), 56 deletions(-) diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 08983c26765..cc8e9c5642e 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -728,31 +728,26 @@ . = list() SEND_SIGNAL(src, COMSIG_ATOM_UPDATE_OVERLAYS, .) -/// Checks if the colors given are different and if so causes a greyscale icon update -/// The colors argument can be either a list or the full color string -/atom/proc/set_greyscale_colors(list/colors, update=TRUE) +/// Handles updates to greyscale value updates. +/// The colors argument can be either a list or the full color string. +/// Child procs should call parent last so the update happens after all changes. +/atom/proc/set_greyscale(list/colors, new_config) SHOULD_CALL_PARENT(TRUE) if(istype(colors)) colors = colors.Join("") - if(greyscale_colors == colors) - return - greyscale_colors = colors - if(!greyscale_config) - return - if(update && greyscale_config && greyscale_colors) - update_greyscale() + if(!isnull(colors) && greyscale_colors != colors) // If you want to disable greyscale stuff then give a blank string + greyscale_colors = colors -/// Checks if the greyscale config given is different and if so causes a greyscale icon update -/atom/proc/set_greyscale_config(new_config, update=TRUE) - if(greyscale_config == new_config) - return - greyscale_config = new_config - if(update && greyscale_config && greyscale_colors) - update_greyscale() + if(!isnull(new_config) && greyscale_config != new_config) + greyscale_config = new_config -/// Checks if this atom uses the GAS system and if so updates the icon + update_greyscale() + +/// Checks if this atom uses the GAGS system and if so updates the icon /atom/proc/update_greyscale() - icon = SSgreyscale.GetColoredIconByType(greyscale_config, greyscale_colors) + SHOULD_CALL_PARENT(TRUE) + if(greyscale_colors && greyscale_config) + icon = SSgreyscale.GetColoredIconByType(greyscale_config, greyscale_colors) /** * An atom we are buckled or is contained within us has tried to move diff --git a/code/game/machinery/PDApainter.dm b/code/game/machinery/PDApainter.dm index 904b124c1ab..f8a3faa6e81 100644 --- a/code/game/machinery/PDApainter.dm +++ b/code/game/machinery/PDApainter.dm @@ -322,8 +322,7 @@ break if(initial(pda_path.greyscale_config) && initial(pda_path.greyscale_colors)) - stored_pda.set_greyscale_config(initial(pda_path.greyscale_config), update=FALSE) - stored_pda.set_greyscale_colors(initial(pda_path.greyscale_colors)) + stored_pda.set_greyscale(initial(pda_path.greyscale_colors), initial(pda_path.greyscale_config)) else stored_pda.icon = initial(pda_path.icon) stored_pda.icon_state = initial(pda_path.icon_state) diff --git a/code/game/machinery/washing_machine.dm b/code/game/machinery/washing_machine.dm index 052a36fb3da..4217a5226a1 100644 --- a/code/game/machinery/washing_machine.dm +++ b/code/game/machinery/washing_machine.dm @@ -190,25 +190,36 @@ GLOBAL_LIST_INIT(dye_registry, list( var/dye_key_selector = dye_key_override ? dye_key_override : dying_key if(undyeable) return FALSE - if(dye_key_selector) - if(!GLOB.dye_registry[dye_key_selector]) - log_runtime("Item just tried to be dyed with an invalid registry key: [dye_key_selector]") - return FALSE - var/obj/item/target_type = GLOB.dye_registry[dye_key_selector][dye_color] - if(target_type) - icon = initial(target_type.icon) - icon_state = initial(target_type.icon_state) - lefthand_file = initial(target_type.lefthand_file) - righthand_file = initial(target_type.righthand_file) - inhand_icon_state = initial(target_type.inhand_icon_state) - worn_icon = initial(target_type.worn_icon) - worn_icon_state = initial(target_type.worn_icon_state) - inhand_x_dimension = initial(target_type.inhand_x_dimension) - inhand_y_dimension = initial(target_type.inhand_y_dimension) - name = initial(target_type.name) - desc = "[initial(target_type.desc)] The colors look a little dodgy." - return target_type //successfully "appearance copy" dyed something; returns the target type as a hacky way of extending - return FALSE + if(!dye_key_selector) + return FALSE + if(!GLOB.dye_registry[dye_key_selector]) + log_runtime("Item just tried to be dyed with an invalid registry key: [dye_key_selector]") + return FALSE + var/obj/item/target_type = GLOB.dye_registry[dye_key_selector][dye_color] + if(!target_type) + return FALSE + if(initial(target_type.greyscale_config) && initial(target_type.greyscale_colors)) + set_greyscale( + colors=initial(target_type.greyscale_colors), + new_config=initial(target_type.greyscale_config), + new_worn_config=initial(target_type.greyscale_config_worn), + new_inhand_left=initial(target_type.greyscale_config_inhand_left), + new_inhand_right=initial(target_type.greyscale_config_inhand_right) + ) + else + icon = initial(target_type.icon) + lefthand_file = initial(target_type.lefthand_file) + righthand_file = initial(target_type.righthand_file) + worn_icon = initial(target_type.worn_icon) + + icon_state = initial(target_type.icon_state) + inhand_icon_state = initial(target_type.inhand_icon_state) + worn_icon_state = initial(target_type.worn_icon_state) + inhand_x_dimension = initial(target_type.inhand_x_dimension) + inhand_y_dimension = initial(target_type.inhand_y_dimension) + name = initial(target_type.name) + desc = "[initial(target_type.desc)] The colors look a little dodgy." + return target_type //successfully "appearance copy" dyed something; returns the target type as a hacky way of extending //what happens to this object when washed inside a washing machine /atom/movable/proc/machine_wash(obj/machinery/washing_machine/WM) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 56b73c7e0b5..90de94a72a6 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -267,7 +267,16 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/e /obj/item/proc/suicide_act(mob/user) return -/// Checks if this atom uses the GAS system and if so updates the worn and inhand icons +/obj/item/set_greyscale(list/colors, new_config, new_worn_config, new_inhand_left, new_inhand_right) + if(new_worn_config) + greyscale_config_worn = new_worn_config + if(new_inhand_left) + greyscale_config_inhand_left = new_inhand_left + if(new_inhand_right) + greyscale_config_inhand_right = new_inhand_right + return ..() + +/// Checks if this atom uses the GAGS system and if so updates the worn and inhand icons /obj/item/update_greyscale() . = ..() if(!greyscale_colors) diff --git a/code/game/objects/items/circuitboards/circuitboard.dm b/code/game/objects/items/circuitboards/circuitboard.dm index 12fa7c8150d..e6083b7911f 100644 --- a/code/game/objects/items/circuitboards/circuitboard.dm +++ b/code/game/objects/items/circuitboards/circuitboard.dm @@ -19,9 +19,8 @@ var/onstation = TRUE /obj/item/circuitboard/Initialize() - set_greyscale_config(/datum/greyscale_config/circuit) - set_greyscale_colors(greyscale_colors) - . = ..() + set_greyscale(new_config=/datum/greyscale_config/circuit) + return ..() /obj/item/circuitboard/proc/apply_default_parts(obj/machinery/M) if(LAZYLEN(M.component_parts)) diff --git a/code/game/objects/items/tools/screwdriver.dm b/code/game/objects/items/tools/screwdriver.dm index b1af262f6b6..dca411d9412 100644 --- a/code/game/objects/items/tools/screwdriver.dm +++ b/code/game/objects/items/tools/screwdriver.dm @@ -50,7 +50,7 @@ /obj/item/screwdriver/Initialize() if(random_color) var/our_color = pick(screwdriver_colors) - set_greyscale_colors(list(screwdriver_colors[our_color])) + set_greyscale(colors=list(screwdriver_colors[our_color])) inhand_icon_state = null colored_belt_appearance = mutable_appearance(SSgreyscale.GetColoredIconByType(/datum/greyscale_config/screwdriver_belt, greyscale_colors)) . = ..() diff --git a/code/game/objects/items/tools/wirecutters.dm b/code/game/objects/items/tools/wirecutters.dm index 2b0e18c25bd..f8b00f3640b 100644 --- a/code/game/objects/items/tools/wirecutters.dm +++ b/code/game/objects/items/tools/wirecutters.dm @@ -6,6 +6,9 @@ inhand_icon_state = "cutters" lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi' righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi' + + greyscale_config = /datum/greyscale_config/wirecutters + flags_1 = CONDUCT_1 slot_flags = ITEM_SLOT_BELT force = 6 @@ -37,9 +40,8 @@ /obj/item/wirecutters/Initialize() if(random_color) - set_greyscale_config(/datum/greyscale_config/wirecutters) var/our_color = pick(wirecutter_colors) - set_greyscale_colors(list(wirecutter_colors[our_color])) + set_greyscale(colors=list(wirecutter_colors[our_color])) return ..() /obj/item/wirecutters/attack(mob/living/carbon/C, mob/user) diff --git a/code/modules/admin/greyscale_modify_menu.dm b/code/modules/admin/greyscale_modify_menu.dm index 9be6b121b24..e9c80821408 100644 --- a/code/modules/admin/greyscale_modify_menu.dm +++ b/code/modules/admin/greyscale_modify_menu.dm @@ -231,6 +231,4 @@ This is highly likely to cause a lag spike for a few seconds."}, unlocked = TRUE /datum/greyscale_modify_menu/proc/DefaultApply() - target.set_greyscale_config(config.type, update=FALSE) - target.greyscale_colors = "" // We do this to force an update, in some cases it will think nothing changed when it should be refreshing - target.set_greyscale_colors(split_colors) + target.set_greyscale(split_colors, config.type) diff --git a/code/modules/atmospherics/machinery/portable/canister.dm b/code/modules/atmospherics/machinery/portable/canister.dm index c2c5b85004b..2b64edef211 100644 --- a/code/modules/atmospherics/machinery/portable/canister.dm +++ b/code/modules/atmospherics/machinery/portable/canister.dm @@ -662,8 +662,7 @@ GLOBAL_LIST_INIT(gas_id_to_canister, init_gas_id_to_canister()) desc = initial(replacement.desc) icon_state = initial(replacement.icon_state) base_icon_state = icon_state - set_greyscale_config(initial(replacement.greyscale_config), update=FALSE) - set_greyscale_colors(initial(replacement.greyscale_colors)) + set_greyscale(initial(replacement.greyscale_colors), initial(replacement.greyscale_config)) if("restricted") restricted = !restricted if(restricted) diff --git a/code/modules/mob/living/simple_animal/hostile/carp.dm b/code/modules/mob/living/simple_animal/hostile/carp.dm index 87614c61897..c88c2a6b243 100644 --- a/code/modules/mob/living/simple_animal/hostile/carp.dm +++ b/code/modules/mob/living/simple_animal/hostile/carp.dm @@ -68,7 +68,7 @@ /mob/living/simple_animal/hostile/carp/Initialize(mapload) AddElement(/datum/element/simple_flying) if(random_color) - set_greyscale_config(/datum/greyscale_config/carp) + set_greyscale(new_config=/datum/greyscale_config/carp) carp_randomify(rarechance) . = ..() ADD_TRAIT(src, TRAIT_SPACEWALK, INNATE_TRAIT) @@ -92,10 +92,10 @@ var/our_color if(prob(rarechance)) our_color = pick(carp_colors_rare) - set_greyscale_colors(list(carp_colors_rare[our_color])) + set_greyscale(colors=list(carp_colors_rare[our_color])) else our_color = pick(carp_colors) - set_greyscale_colors(list(carp_colors[our_color])) + set_greyscale(colors=list(carp_colors[our_color])) /mob/living/simple_animal/hostile/carp/revive(full_heal = FALSE, admin_revive = FALSE) . = ..() diff --git a/code/modules/vending/_vending.dm b/code/modules/vending/_vending.dm index 418883c2af6..9c7c9106ea8 100644 --- a/code/modules/vending/_vending.dm +++ b/code/modules/vending/_vending.dm @@ -939,7 +939,7 @@ GLOBAL_LIST_EMPTY(vending_products) playsound(src, 'sound/machines/machine_vend.ogg', 50, TRUE, extrarange = -3) var/obj/item/vended_item = new R.product_path(get_turf(src)) if(greyscale_colors) - vended_item.set_greyscale_colors(greyscale_colors) + vended_item.set_greyscale(colors=greyscale_colors) R.amount-- if(usr.CanReach(src) && usr.put_in_hands(vended_item)) to_chat(usr, "You take [R.name] out of the slot.")