From 9e9327d128867eec5ea892b66105342dceeb94bb Mon Sep 17 00:00:00 2001 From: Emmett Gaines Date: Fri, 28 May 2021 10:06:37 -0400 Subject: [PATCH] Adds a unit test for icon states on GAGS items and fixes some inhand sprites (#59330) This adds a unit test which goes through all items and makes sure all the icon states needed are in the greyscale configurations, if it has one. --- .../greyscale/json_configs/screwdriver.json | 2 +- .../json_configs/screwdriver_worn.json | 2 +- code/game/objects/items/theft_tools.dm | 2 ++ code/game/objects/items/tools/screwdriver.dm | 5 ++++- code/modules/clothing/shoes/colour.dm | 4 ++++ code/modules/clothing/under/color.dm | 1 + .../clothing/under/jobs/civilian/curator.dm | 1 + code/modules/clothing/under/jobs/security.dm | 1 + code/modules/unit_tests/_unit_tests.dm | 1 + code/modules/unit_tests/greyscale_config.dm | 19 +++++++++++++++++++ 10 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 code/modules/unit_tests/greyscale_config.dm diff --git a/code/datums/greyscale/json_configs/screwdriver.json b/code/datums/greyscale/json_configs/screwdriver.json index 79ea5d833e9..7604eb07465 100644 --- a/code/datums/greyscale/json_configs/screwdriver.json +++ b/code/datums/greyscale/json_configs/screwdriver.json @@ -1,5 +1,5 @@ { - "": [ + "screwdriver_map": [ { "type": "icon_state", "icon_state": "screwdriver", diff --git a/code/datums/greyscale/json_configs/screwdriver_worn.json b/code/datums/greyscale/json_configs/screwdriver_worn.json index ed750b3231d..9e63bb6b883 100644 --- a/code/datums/greyscale/json_configs/screwdriver_worn.json +++ b/code/datums/greyscale/json_configs/screwdriver_worn.json @@ -1,5 +1,5 @@ { - "": [ + "screwdriver": [ { "type": "icon_state", "icon_state": "screwdriver", diff --git a/code/game/objects/items/theft_tools.dm b/code/game/objects/items/theft_tools.dm index 31b67bf3b14..5a88d94e77c 100644 --- a/code/game/objects/items/theft_tools.dm +++ b/code/game/objects/items/theft_tools.dm @@ -91,6 +91,8 @@ inhand_icon_state = "screwdriver_nuke" toolspeed = 0.5 random_color = FALSE + greyscale_config_inhand_left = null + greyscale_config_inhand_right = null /obj/item/paper/guides/antag/nuke_instructions info = "How to break into a Nanotrasen self-destruct terminal and remove its plutonium core:
\ diff --git a/code/game/objects/items/tools/screwdriver.dm b/code/game/objects/items/tools/screwdriver.dm index 71826aabe92..4c20a46e7fe 100644 --- a/code/game/objects/items/tools/screwdriver.dm +++ b/code/game/objects/items/tools/screwdriver.dm @@ -51,7 +51,6 @@ if(random_color) var/our_color = pick(screwdriver_colors) 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)) . = ..() AddElement(/datum/element/eyestab) @@ -71,6 +70,8 @@ usesound = 'sound/items/pshoom.ogg' toolspeed = 0.1 random_color = FALSE + greyscale_config_inhand_left = null + greyscale_config_inhand_right = null /obj/item/screwdriver/abductor/get_belt_overlay() return mutable_appearance('icons/obj/clothing/belt_overlays.dmi', "screwdriver_nuke") @@ -95,6 +96,8 @@ usesound = 'sound/items/drill_use.ogg' toolspeed = 0.7 random_color = FALSE + greyscale_config_inhand_left = null + greyscale_config_inhand_right = null /obj/item/screwdriver/power/examine() . = ..() diff --git a/code/modules/clothing/shoes/colour.dm b/code/modules/clothing/shoes/colour.dm index 08087c4e666..9b7e87257fc 100644 --- a/code/modules/clothing/shoes/colour.dm +++ b/code/modules/clothing/shoes/colour.dm @@ -51,8 +51,12 @@ name = "rainbow shoes" desc = "Very gay shoes." icon_state = "rain_bow" + greyscale_colors = null greyscale_config = null + greyscale_config_inhand_left = null + greyscale_config_inhand_right = null + greyscale_config_worn = null /obj/item/clothing/shoes/sneakers/orange name = "orange shoes" diff --git a/code/modules/clothing/under/color.dm b/code/modules/clothing/under/color.dm index bb8c596e659..717c8c02f82 100644 --- a/code/modules/clothing/under/color.dm +++ b/code/modules/clothing/under/color.dm @@ -9,6 +9,7 @@ icon = 'icons/obj/clothing/under/color.dmi' icon_state = "jumpsuit" inhand_icon_state = "jumpsuit" + worn_icon_state = "jumpsuit" worn_icon = 'icons/mob/clothing/under/color.dmi' /obj/item/clothing/under/color/jumpskirt diff --git a/code/modules/clothing/under/jobs/civilian/curator.dm b/code/modules/clothing/under/jobs/civilian/curator.dm index 936c574e157..08e3842d8b2 100644 --- a/code/modules/clothing/under/jobs/civilian/curator.dm +++ b/code/modules/clothing/under/jobs/civilian/curator.dm @@ -31,6 +31,7 @@ name = "\improper NASA jumpsuit" desc = "It has a NASA logo on it and is made of space-proofed materials." icon_state = "jumpsuit" + inhand_icon_state = "jumpsuit" greyscale_colors = "#3f3f3f" greyscale_config = /datum/greyscale_config/jumpsuit greyscale_config_inhand_left = /datum/greyscale_config/jumpsuit_inhand_left diff --git a/code/modules/clothing/under/jobs/security.dm b/code/modules/clothing/under/jobs/security.dm index 7a1c5b1a92b..fbf0cd24076 100644 --- a/code/modules/clothing/under/jobs/security.dm +++ b/code/modules/clothing/under/jobs/security.dm @@ -197,6 +197,7 @@ name = "prison jumpsuit" desc = "It's standardised Nanotrasen prisoner-wear. Its suit sensors are stuck in the \"Fully On\" position." icon_state = "jumpsuit" + inhand_icon_state = "jumpsuit" greyscale_colors = "#ff8300" greyscale_config = /datum/greyscale_config/jumpsuit_prison greyscale_config_inhand_left = /datum/greyscale_config/jumpsuit_prison_inhand_left diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 346df69e921..98b9353a74a 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -57,6 +57,7 @@ #include "egg_glands.dm" #include "emoting.dm" #include "food_edibility_check.dm" +#include "greyscale_config.dm" #include "heretic_knowledge.dm" #include "holidays.dm" #include "hydroponics_harvest.dm" diff --git a/code/modules/unit_tests/greyscale_config.dm b/code/modules/unit_tests/greyscale_config.dm new file mode 100644 index 00000000000..d35b53fcda4 --- /dev/null +++ b/code/modules/unit_tests/greyscale_config.dm @@ -0,0 +1,19 @@ +/// Makes sure items using GAGS have all the icon states needed to work +/datum/unit_test/greyscale_item_icon_states + +/datum/unit_test/greyscale_item_icon_states/Run() + for(var/obj/item/item_path as anything in subtypesof(/obj/item)) + var/held_icon_state = initial(item_path.inhand_icon_state) || initial(item_path.icon_state) + + var/datum/greyscale_config/lefthand = SSgreyscale.configurations["[initial(item_path.greyscale_config_inhand_left)]"] + if(lefthand && !lefthand.icon_states[held_icon_state]) + Fail("[lefthand.DebugName()] is missing a sprite for the held lefthand for [item_path]. Expected icon state: '[held_icon_state]'") + + var/datum/greyscale_config/righthand = SSgreyscale.configurations["[initial(item_path.greyscale_config_inhand_right)]"] + if(righthand && !righthand.icon_states[held_icon_state]) + Fail("[righthand.DebugName()] is missing a sprite for the held righthand for [item_path]. Expected icon state: '[held_icon_state]'") + + var/datum/greyscale_config/worn = SSgreyscale.configurations["[initial(item_path.greyscale_config_worn)]"] + var/worn_icon_state = initial(item_path.worn_icon_state) || initial(item_path.icon_state) + if(worn && !worn.icon_states[worn_icon_state]) + Fail("[worn.DebugName()] is missing a sprite for the worn overlay for [item_path]. Expected icon state: '[worn_icon_state]'")