diff --git a/code/controllers/subsystem/greyscale.dm b/code/controllers/subsystem/greyscale.dm index 440053421de..eac8f661b93 100644 --- a/code/controllers/subsystem/greyscale.dm +++ b/code/controllers/subsystem/greyscale.dm @@ -14,6 +14,12 @@ SUBSYSTEM_DEF(greyscale) var/datum/greyscale_config/config = new greyscale_type() configurations["[greyscale_type]"] = config + // We do this after all the types have been loaded into the listing so reference layers don't care about init order + for(var/greyscale_type in configurations) + CHECK_TICK + var/datum/greyscale_config/config = configurations[greyscale_type] + config.Refresh() + return ..() /datum/controller/subsystem/greyscale/proc/RefreshConfigsFromFile() diff --git a/code/datums/greyscale/README.md b/code/datums/greyscale/README.md index c28909eec72..4f3d8ea427c 100644 --- a/code/datums/greyscale/README.md +++ b/code/datums/greyscale/README.md @@ -7,6 +7,10 @@ If you're wanting to add easy recolors for your sprite then this is the system f - Blend modes; Instead of just putting layers of sprites on top of eachother you can use the more advanced blend modes. - Reusable configurations; You can reference greyscale sprites from within the configuration of another, allowing you to have a bunch of styles with minimal additional configuration. +## Other Documents + +- [Basic follow along guide on hackmd](https://hackmd.io/@tgstation/GAGS-Walkthrough) + ## Broad overview There are three main parts to GAGS that you'll need to be aware of when adding a new greyscale sprite: diff --git a/code/datums/greyscale/_greyscale_config.dm b/code/datums/greyscale/_greyscale_config.dm index 1ae6ba6c0df..71bd56fbcb1 100644 --- a/code/datums/greyscale/_greyscale_config.dm +++ b/code/datums/greyscale/_greyscale_config.dm @@ -39,8 +39,6 @@ CRASH("Greyscale config object [DebugName()] is missing an icon file, make sure `icon_file` has been assigned a value.") string_icon_file = "[icon_file]" - Refresh() - /datum/greyscale_config/proc/Refresh(loadFromDisk=FALSE) if(loadFromDisk) json_config = file(string_json_config) @@ -127,13 +125,20 @@ var/list/colors = ParseColorString(color_string) if(length(colors) != expected_colors) CRASH("[DebugName()] expected [expected_colors] color arguments but only received [length(colors)]") - var/icon/icon_bundle = new + + // We could do this all in one loop but it's easier to debug this way + var/list/generated_icons = list() for(var/icon_state in icon_states) var/icon/generated_icon = GenerateLayerGroup(colors, icon_states[icon_state], render_steps) // We read a pixel to force the icon to be fully generated before we let it loose into the world // I hate this generated_icon.GetPixel(1, 1) - icon_bundle.Insert(generated_icon, icon_state) + generated_icons[icon_state] = generated_icon + + var/icon/icon_bundle = new + for(var/icon_state in generated_icons) + icon_bundle.Insert(generated_icons[icon_state], icon_state) + icon_bundle = fcopy_rsc(icon_bundle) icon_cache[key] = icon_bundle var/icon/output = icon(icon_bundle) diff --git a/code/datums/greyscale/greyscale_configs.dm b/code/datums/greyscale/greyscale_configs.dm index 5ec45703e79..940d5facf7e 100644 --- a/code/datums/greyscale/greyscale_configs.dm +++ b/code/datums/greyscale/greyscale_configs.dm @@ -128,3 +128,28 @@ /datum/greyscale_config/circuit icon_file = 'icons/obj/module.dmi' json_config = 'code/datums/greyscale/json_configs/circuit.json' + +/datum/greyscale_config/sombrero + icon_file = 'icons/obj/clothing/head/sombrero.dmi' + json_config = 'code/datums/greyscale/json_configs/sombrero.json' + +/datum/greyscale_config/sombrero/base + json_config = 'code/datums/greyscale/json_configs/sombrero_base.json' + +/datum/greyscale_config/sombrero/lefthand + json_config = 'code/datums/greyscale/json_configs/sombrero_lefthand.json' + +/datum/greyscale_config/sombrero/base_lefthand + json_config = 'code/datums/greyscale/json_configs/sombrero_base_lefthand.json' + +/datum/greyscale_config/sombrero/righthand + json_config = 'code/datums/greyscale/json_configs/sombrero_righthand.json' + +/datum/greyscale_config/sombrero/base_righthand + json_config = 'code/datums/greyscale/json_configs/sombrero_base_righthand.json' + +/datum/greyscale_config/sombrero/worn + json_config = 'code/datums/greyscale/json_configs/sombrero_worn.json' + +/datum/greyscale_config/sombrero/base_worn + json_config = 'code/datums/greyscale/json_configs/sombrero_base_worn.json' diff --git a/code/datums/greyscale/json_configs/sombrero.json b/code/datums/greyscale/json_configs/sombrero.json new file mode 100644 index 00000000000..8a183c55def --- /dev/null +++ b/code/datums/greyscale/json_configs/sombrero.json @@ -0,0 +1,23 @@ +{ + "sombrero": [ + { + "type": "reference", + "reference_type": "/datum/greyscale_config/sombrero/base", + "blend_mode": "overlay", + "color_ids": [ 1, 2 ] + } + ], + "shamebrero": [ + { + "type": "reference", + "reference_type": "/datum/greyscale_config/sombrero/base", + "blend_mode": "overlay", + "color_ids": [ 1, 2 ] + }, + { + "type": "icon_state", + "icon_state": "dongles", + "blend_mode": "overlay" + } + ] +} diff --git a/code/datums/greyscale/json_configs/sombrero_base.json b/code/datums/greyscale/json_configs/sombrero_base.json new file mode 100644 index 00000000000..9f2097ac2e8 --- /dev/null +++ b/code/datums/greyscale/json_configs/sombrero_base.json @@ -0,0 +1,21 @@ +{ + "": [ + { + "type": "icon_state", + "icon_state": "cloth", + "blend_mode": "overlay", + "color_ids": [ 1 ] + }, + { + "type": "icon_state", + "icon_state": "ornamentation", + "blend_mode": "overlay", + "color_ids": [ 2 ] + }, + { + "type": "icon_state", + "icon_state": "plate", + "blend_mode": "overlay" + } + ] +} diff --git a/code/datums/greyscale/json_configs/sombrero_base_lefthand.json b/code/datums/greyscale/json_configs/sombrero_base_lefthand.json new file mode 100644 index 00000000000..d9d26e0b9c2 --- /dev/null +++ b/code/datums/greyscale/json_configs/sombrero_base_lefthand.json @@ -0,0 +1,16 @@ +{ + "": [ + { + "type": "icon_state", + "icon_state": "cloth_lefthand", + "blend_mode": "overlay", + "color_ids": [ 1 ] + }, + { + "type": "icon_state", + "icon_state": "ornamentation_lefthand", + "blend_mode": "overlay", + "color_ids": [ 2 ] + } + ] +} diff --git a/code/datums/greyscale/json_configs/sombrero_base_righthand.json b/code/datums/greyscale/json_configs/sombrero_base_righthand.json new file mode 100644 index 00000000000..32769cb21be --- /dev/null +++ b/code/datums/greyscale/json_configs/sombrero_base_righthand.json @@ -0,0 +1,16 @@ +{ + "": [ + { + "type": "icon_state", + "icon_state": "cloth_righthand", + "blend_mode": "overlay", + "color_ids": [ 1 ] + }, + { + "type": "icon_state", + "icon_state": "ornamentation_righthand", + "blend_mode": "overlay", + "color_ids": [ 2 ] + } + ] +} diff --git a/code/datums/greyscale/json_configs/sombrero_base_worn.json b/code/datums/greyscale/json_configs/sombrero_base_worn.json new file mode 100644 index 00000000000..e97c1875df4 --- /dev/null +++ b/code/datums/greyscale/json_configs/sombrero_base_worn.json @@ -0,0 +1,21 @@ +{ + "": [ + { + "type": "icon_state", + "icon_state": "cloth_worn", + "blend_mode": "overlay", + "color_ids": [ 1 ] + }, + { + "type": "icon_state", + "icon_state": "ornamentation_worn", + "blend_mode": "overlay", + "color_ids": [ 2 ] + }, + { + "type": "icon_state", + "icon_state": "plate_worn", + "blend_mode": "overlay" + } + ] +} diff --git a/code/datums/greyscale/json_configs/sombrero_lefthand.json b/code/datums/greyscale/json_configs/sombrero_lefthand.json new file mode 100644 index 00000000000..5ba8a89ed28 --- /dev/null +++ b/code/datums/greyscale/json_configs/sombrero_lefthand.json @@ -0,0 +1,23 @@ +{ + "sombrero": [ + { + "type": "reference", + "reference_type": "/datum/greyscale_config/sombrero/base_lefthand", + "blend_mode": "overlay", + "color_ids": [ 1, 2 ] + } + ], + "shamebrero": [ + { + "type": "reference", + "reference_type": "/datum/greyscale_config/sombrero/base_lefthand", + "blend_mode": "overlay", + "color_ids": [ 1, 2 ] + }, + { + "type": "icon_state", + "icon_state": "dongles_lefthand", + "blend_mode": "overlay" + } + ] +} diff --git a/code/datums/greyscale/json_configs/sombrero_righthand.json b/code/datums/greyscale/json_configs/sombrero_righthand.json new file mode 100644 index 00000000000..07737ad2532 --- /dev/null +++ b/code/datums/greyscale/json_configs/sombrero_righthand.json @@ -0,0 +1,23 @@ +{ + "sombrero": [ + { + "type": "reference", + "reference_type": "/datum/greyscale_config/sombrero/base_righthand", + "blend_mode": "overlay", + "color_ids": [ 1, 2 ] + } + ], + "shamebrero": [ + { + "type": "reference", + "reference_type": "/datum/greyscale_config/sombrero/base_righthand", + "blend_mode": "overlay", + "color_ids": [ 1, 2 ] + }, + { + "type": "icon_state", + "icon_state": "dongles_righthand", + "blend_mode": "overlay" + } + ] +} diff --git a/code/datums/greyscale/json_configs/sombrero_worn.json b/code/datums/greyscale/json_configs/sombrero_worn.json new file mode 100644 index 00000000000..a70cd5ce9c7 --- /dev/null +++ b/code/datums/greyscale/json_configs/sombrero_worn.json @@ -0,0 +1,23 @@ +{ + "sombrero": [ + { + "type": "reference", + "reference_type": "/datum/greyscale_config/sombrero/base_worn", + "blend_mode": "overlay", + "color_ids": [ 1, 2 ] + } + ], + "shamebrero": [ + { + "type": "reference", + "reference_type": "/datum/greyscale_config/sombrero/base_worn", + "blend_mode": "overlay", + "color_ids": [ 1, 2 ] + }, + { + "type": "icon_state", + "icon_state": "dongles_worn", + "blend_mode": "overlay" + } + ] +} diff --git a/code/modules/clothing/head/misc.dm b/code/modules/clothing/head/misc.dm index db70ca02bf3..9d8542e635a 100644 --- a/code/modules/clothing/head/misc.dm +++ b/code/modules/clothing/head/misc.dm @@ -289,13 +289,17 @@ dog_fashion = /datum/dog_fashion/head/sombrero + greyscale_config = /datum/greyscale_config/sombrero + greyscale_config_worn = /datum/greyscale_config/sombrero/worn + greyscale_config_inhand_left = /datum/greyscale_config/sombrero/lefthand + greyscale_config_inhand_right = /datum/greyscale_config/sombrero/righthand + /obj/item/clothing/head/sombrero/green name = "green sombrero" - icon_state = "greensombrero" - inhand_icon_state = "greensombrero" desc = "As elegant as a dancing cactus." flags_inv = HIDEHAIR|HIDEFACE|HIDEEARS dog_fashion = null + greyscale_colors = "#13d968#ffffff" /obj/item/clothing/head/sombrero/shamebrero name = "shamebrero" @@ -303,6 +307,7 @@ inhand_icon_state = "shamebrero" desc = "Once it's on, it never comes off." dog_fashion = null + greyscale_colors = "#d565d3#f8db18" /obj/item/clothing/head/sombrero/shamebrero/Initialize() . = ..() diff --git a/icons/mob/clothing/head.dmi b/icons/mob/clothing/head.dmi index e0bc491e321..07ad2429e5e 100644 Binary files a/icons/mob/clothing/head.dmi and b/icons/mob/clothing/head.dmi differ diff --git a/icons/obj/clothing/head/sombrero.dmi b/icons/obj/clothing/head/sombrero.dmi new file mode 100644 index 00000000000..abc29a501a9 Binary files /dev/null and b/icons/obj/clothing/head/sombrero.dmi differ